Bug 203533 - VxLAN: Cannot create multiple vxlan devices for a given VNI and different source addresses.
Summary: VxLAN: Cannot create multiple vxlan devices for a given VNI and different sou...
Status: NEW
Alias: None
Product: Networking
Classification: Unclassified
Component: IPV4 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-06 21:18 UTC by Hasan Naqvi
Modified: 2019-05-06 23:10 UTC (History)
2 users (show)

See Also:
Kernel Version: 4.9.110
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Hasan Naqvi 2019-05-06 21:18:30 UTC
When trying to create two vxlan terminations with different source VTEPs, only one termination is allowed and second netdevice creation fails with EEXIST error.

root@:~# ip link add vxlan-10 type vxlan id 10 local 10.1.1.1 dstport 4789
root@:~# ip link add vxlan2-10 type vxlan id 10 local 20.1.1.1 dstport 4789
RTNETLINK answers: File exists
root@:~#

It is a valid use-case scenario where a router is terminating multiple VxLAN endpoints. But this doesn't seem to be allowed in the kernel.

The EEXIST error is coming from here:
vxlan_dev_configure():
...
    list_for_each_entry(tmp, &vn->vxlan_list, next) {
        if (tmp->cfg.vni == conf->vni &&
          | (tmp->default_dst.remote_ip.sa.sa_family == AF_INET6 ||
          |  tmp->cfg.saddr.sa.sa_family == AF_INET6) == use_ipv6 &&
          | tmp->cfg.dst_port == vxlan->cfg.dst_port &&
          | (tmp->flags & VXLAN_F_RCV_FLAGS) ==
          | (vxlan->flags & VXLAN_F_RCV_FLAGS)) {
            pr_info("duplicate VNI %u\n", be32_to_cpu(conf->vni));
            return -EEXIST;
        }
    }

The uniqueness of vxlan device should be checked with <local-endpoint, vni, dstport> instead of just <vni, dstport>. Similarly, vxlan_vs_find_vni() should lookup vxlan device using <src-addr, vni> instead of just <vni>:
static struct vxlan_dev *vxlan_vs_find_vni(struct vxlan_sock *vs, __be32 vni)

As per the code, I can see this issue exists in v5.1 as well.

Note You need to log in before you can comment on or make changes to this bug.