vxlan: reject IPv6 addresses if IPv6 is not configured
authorJiri Benc <jbenc@redhat.com>
Thu, 17 Sep 2015 14:11:11 +0000 (16:11 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Sep 2015 05:32:15 +0000 (22:32 -0700)
When IPv6 address is set without IPv6 configured, the vxlan socket is mostly
treated as an IPv4 one but various lookus in fdb etc. still take the
AF_INET6 into account. This creates incosistencies with weird consequences.

Just reject IPv6 addresses in such case.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/vxlan.c

index 6ebe562af04ecc4f0dbc9b2d2eaff5fb2f9708e2..bbac1d35ed4e37450a3282b4b7f9dc41dabcd4e8 100644 (file)
@@ -2636,8 +2636,11 @@ static int vxlan_dev_configure(struct net *src_net, struct net_device *dev,
                dst->remote_ip.sa.sa_family = AF_INET;
 
        if (dst->remote_ip.sa.sa_family == AF_INET6 ||
-           vxlan->cfg.saddr.sa.sa_family == AF_INET6)
+           vxlan->cfg.saddr.sa.sa_family == AF_INET6) {
+               if (!IS_ENABLED(CONFIG_IPV6))
+                       return -EPFNOSUPPORT;
                use_ipv6 = true;
+       }
 
        if (conf->remote_ifindex) {
                struct net_device *lowerdev