vxlan: Fix regression when dropping packets due to invalid src addresses
Subsystems (3)
Daniel Borkmann
maintainerPATCH v2 1/1 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.
---
v1 -> v2:
- Moved is_valid_ether_addr into vxlan_snoop, thanks Ido!
drivers/net/vxlan/vxlan_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/vxlan/vxlan_core.c +4 -4
@@ -1446,6 +1446,10 @@ static bool vxlan_snoop(struct net_device *dev,struct vxlan_fdb *f;u32 ifindex =0 ; +/* Ignore packets from invalid src-address */ +if (!is_valid_ether_addr (src_mac)) +return true; +#if IS_ENABLED (CONFIG_IPV6 )if (src_ip->sa.sa_family ==AF_INET6 && (ipv6_addr_type (&src_ip->sin6.sin6_addr) &IPV6_ADDR_LINKLOCAL ))
@@ -1616,10 +1620,6 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,if (ether_addr_equal (eth_hdr (skb)->h_source, vxlan->dev->dev_addr))return false; -/* Ignore packets from invalid src-address */ -if (!is_valid_ether_addr (eth_hdr (skb)->h_source)) -return false; -/* Get address from the outer IP header */ if (vxlan_get_sk_family (vs) ==AF_INET ) { saddr.sin.sin_addr.s_addr =ip_hdr (skb)->saddr;
Signature · 1 line
2.34.1
Quoted 22 lines · Daniel Borkmann
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
f58f45c1e5b9vxlan 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 inf58f45c1e5b9for both vxlan and geneve. After mentioned change it is only passing for geneve as in case of vxlan packets are dropped due tovxlan_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 invxlan_set_mac()when in fact source address snooping/learning is actually enabled in vxlan. This is done by moving the check intovxlan_snoop(). With this change, the Cilium connectivity test suite passes again for both tunnel flavors.
Quoted 6 lines
Fixes f58f45c1e5b9 ("vxlan: drop packets from invalid src-address")Signed-off-by Daniel Borkmann <[email protected]>Cc David Bauer <[email protected]>Cc Ido Schimmel <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Cc Martin KaFai Lau <[email protected]>
Thanks!
Quoted 28 lines · Daniel Borkmann
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
f58f45c1e5b9vxlan 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 inf58f45c1e5b9for both vxlan and geneve. After mentioned change it is only passing for geneve as in case of vxlan packets are dropped due tovxlan_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 invxlan_set_mac()when in fact source address snooping/learning is actually enabled in vxlan. This is done by moving the check intovxlan_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 <[email protected]>Cc David Bauer <[email protected]>Cc Ido Schimmel <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Cc Martin KaFai Lau <[email protected]>
Quoted 7 lines
---
v1 -> v2:
- Movedis_valid_ether_addrintovxlan_snoop, thanks Ido!drivers/net/vxlan/vxlan_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
LGTM
Quoted 22 lines · Daniel Borkmann
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
f58f45c1e5b9vxlan 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 inf58f45c1e5b9for both vxlan and geneve. After mentioned change it is only passing for geneve as in case of vxlan packets are dropped due tovxlan_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 invxlan_set_mac()when in fact source address snooping/learning is actually enabled in vxlan. This is done by moving the check intovxlan_snoop(). With this change, the Cilium connectivity test suite passes again for both tunnel flavors.
Quoted 6 lines
Fixes f58f45c1e5b9 ("vxlan: drop packets from invalid src-address")Signed-off-by Daniel Borkmann <[email protected]>Cc David Bauer <[email protected]>Cc Ido Schimmel <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Cc Martin KaFai Lau <[email protected]>
Best
David
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 16 lines · On Mon, 3 Jun 2024 10:59:26 +0200 you wrote:
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
f58f45c1e5b9vxlan 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 inf58f45c1e5b9for both vxlan and geneve. After mentioned change it is only passing for geneve as in case of vxlan packets are dropped due tovxlan_set_mac()returning false as source and destination macs are zero which for E/W traffic via tunnel is totally fine.
Quoted 1 line
[...]
Here is the summary with links:
- [v2,net] vxlan: Fix regression when dropping packets due to invalid src addresses
https://git.kernel.org/netdev/net/c/1cd4bc987abb
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html