Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vxlan: Fix regression when dropping packets due to invalid src addresses

Commit f58f45c1e5b9 ("vxlan: drop packets from invalid src-address")
has recently been added to vxlan mainly in the context of source
address snooping/learning so that when it is enabled, an entry in the
FDB is not being created for an invalid address for the corresponding
tunnel endpoint.

Before commit f58f45c1e5b9 vxlan was similarly behaving as geneve in
that it passed through whichever macs were set in the L2 header. It
turns out that this change in behavior breaks setups, for example,
Cilium with netkit in L3 mode for Pods as well as tunnel mode has been
passing before the change in f58f45c1e5b9 for both vxlan and geneve.
After mentioned change it is only passing for geneve as in case of
vxlan packets are dropped due to vxlan_set_mac() returning false as
source and destination macs are zero which for E/W traffic via tunnel
is totally fine.

Fix it by only opting into the is_valid_ether_addr() check in
vxlan_set_mac() when in fact source address snooping/learning is
actually enabled in vxlan. This is done by moving the check into
vxlan_snoop(). With this change, the Cilium connectivity test suite
passes again for both tunnel flavors.

Fixes: f58f45c1e5b9 ("vxlan: drop packets from invalid src-address")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Bauer <mail@david-bauer.net>
Cc: Ido Schimmel <idosch@nvidia.com>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: David Bauer <mail@david-bauer.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Borkmann and committed by
David S. Miller
1cd4bc98 affc18fd

+4 -4
+4 -4
drivers/net/vxlan/vxlan_core.c
··· 1446 1446 struct vxlan_fdb *f; 1447 1447 u32 ifindex = 0; 1448 1448 1449 + /* Ignore packets from invalid src-address */ 1450 + if (!is_valid_ether_addr(src_mac)) 1451 + return true; 1452 + 1449 1453 #if IS_ENABLED(CONFIG_IPV6) 1450 1454 if (src_ip->sa.sa_family == AF_INET6 && 1451 1455 (ipv6_addr_type(&src_ip->sin6.sin6_addr) & IPV6_ADDR_LINKLOCAL)) ··· 1618 1614 1619 1615 /* Ignore packet loops (and multicast echo) */ 1620 1616 if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr)) 1621 - return false; 1622 - 1623 - /* Ignore packets from invalid src-address */ 1624 - if (!is_valid_ether_addr(eth_hdr(skb)->h_source)) 1625 1617 return false; 1626 1618 1627 1619 /* Get address from the outer IP header */