mlxsw: Add VXLAN to the same hardware domain as physical bridge ports
Subsystems (5)
Petr Machata
maintainercover mlxsw: Add VXLAN to the same hardware domain as physical bridge ports
Amit Cohen writes:
Packets which are trapped to CPU for forwarding in software data path are handled according to driver marking of skb->offload_{,l3}_fwd_mark. Packets which are marked as L2-forwarded in hardware, will not be flooded by the bridge to bridge ports which are in the same hardware domain as the ingress port.
Currently, mlxsw does not add VXLAN bridge ports to the same hardware domain as physical bridge ports despite the fact that the device is able to forward packets to and from VXLAN tunnels in hardware. In some scenarios this can result in remote VTEPs receiving duplicate packets.
To solve such packets duplication, add VXLAN bridge ports to the same hardware domain as other bridge ports.
One complication is ARP suppression which requires the local VTEP to avoid flooding ARP packets to remote VTEPs if the local VTEP is able to reply on behalf of remote hosts. This is currently implemented by having the device flood ARP packets in hardware and trapping them during VXLAN encapsulation, but marking them with skb->offload_fwd_mark=1 so that the bridge will not re-flood them to physical bridge ports.
The above scheme will break when VXLAN bridge ports are added to the same hardware domain as physical bridge ports as ARP packets that cannot be suppressed by the bridge will not be able to egress the VXLAN bridge ports due to hardware domain filtering. This is solved by trapping ARP packets when they enter the device and not marking them as being forwarded in hardware.
Patch set overview:
Patch #1 sets hardware to trap ARP packets at layer 2 Patches #2-#4 are preparations for setting hardwarwe domain of VXLAN Patch #5 sets hardware domain of VXLAN
Patch #6 extends VXLAN flood test to verify that this set solves the packets duplication
Amit Cohen (6):
mlxsw: Trap ARP packets at layer 2 instead of layer 3
mlxsw: spectrum: Call mlxsw_sp_bridge_vxlan_{join, leave}() for
VLAN-aware bridge
mlxsw: spectrum_switchdev: Add an internal API for VXLAN leave
mlxsw: spectrum_switchdev: Move mlxsw_sp_bridge_vxlan_join()
mlxsw: Add VXLAN bridge ports to same hardware domain as physical
bridge ports
selftests: vxlan_bridge: Test flood with unresolved FDB entry
.../net/ethernet/mellanox/mlxsw/spectrum.c | 22 ++----- .../net/ethernet/mellanox/mlxsw/spectrum.h | 4 +- .../mellanox/mlxsw/spectrum_switchdev.c | 66 +++++++++++++------ .../ethernet/mellanox/mlxsw/spectrum_trap.c | 12 ++-- drivers/net/ethernet/mellanox/mlxsw/trap.h | 5 +- .../net/forwarding/vxlan_bridge_1d.sh | 8 +++ .../net/forwarding/vxlan_bridge_1q.sh | 15 +++++ 7 files changed, 83 insertions(+), 49 deletions(-)
Signature · 1 line
2.47.0
Petr Machata
maintainerPATCH 1/6 mlxsw: Trap ARP packets at layer 2 instead of layer 3
From: Amit Cohen <[email protected]>
Next patch will set the same hardware domain for all bridge ports, including VXLAN, to prevent packets from being forwarded by software when they were already forwarded by hardware.
ARP packets are not flooded by hardware to VXLAN, so software should handle such flooding. When hardware domain of VXLAN device will be changed, ARP packets which are trapped and marked with offload_fwd_mark will not be flooded to VXLAN also in software, which will break VXLAN traffic.
To prevent such breaking, trap ARP packets at layer 2 and don't mark them as L2-forwarded in hardware, then flooding ARP packets will be done only in software, and VXLAN will send ARP packets.
Remove NVE_ENCAP_ARP which is no longer needed, as now ARP packets are trapped when they enter the device.
--- drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 2 -- drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c | 12 ++++++------ drivers/net/ethernet/mellanox/mlxsw/trap.h | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +0 -2
@@ -2409,8 +2409,6 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {/* Multicast Router Traps */ MLXSW_SP_RXL_MARK (ACL1 ,TRAP_TO_CPU ,MULTICAST , false), MLXSW_SP_RXL_L3_MARK(ACL2, TRAP_TO_CPU, MULTICAST, false), -/* NVE traps */ - MLXSW_SP_RXL_MARK(NVE_ENCAP_ARP, TRAP_TO_CPU, NEIGH_DISCOVERY, false), }; static const struct mlxsw_listener mlxsw_sp1_listener[] = {
drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c +6 -6
@@ -959,18 +959,18 @@ static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = { }, { .trap = MLXSW_SP_TRAP_CONTROL(ARP_REQUEST, NEIGH_DISCOVERY, - MIRROR), + TRAP), .listeners_arr = { -MLXSW_SP_RXL_MARK (ROUTER_ARPBC ,NEIGH_DISCOVERY , - TRAP_TO_CPU, false), +MLXSW_SP_RXL_NO_MARK (ARPBC ,NEIGH_DISCOVERY , + TRAP_TO_CPU, false), }, }, { .trap =MLXSW_SP_TRAP_CONTROL (ARP_RESPONSE ,NEIGH_DISCOVERY , - MIRROR), + TRAP), .listeners_arr = { -MLXSW_SP_RXL_MARK (ROUTER_ARPUC ,NEIGH_DISCOVERY , - TRAP_TO_CPU, false), +MLXSW_SP_RXL_NO_MARK (ARPUC ,NEIGH_DISCOVERY , + TRAP_TO_CPU, false), }, }, {
drivers/net/ethernet/mellanox/mlxsw/trap.h +2 -3
@@ -29,6 +29,8 @@ enum {MLXSW_TRAP_ID_FDB_MISMATCH =0x3B ,MLXSW_TRAP_ID_FID_MISS =0x3D ,MLXSW_TRAP_ID_DECAP_ECN0 =0x40 , +MLXSW_TRAP_ID_ARPBC =0x50 , +MLXSW_TRAP_ID_ARPUC =0x51 ,MLXSW_TRAP_ID_MTUERROR =0x52 ,MLXSW_TRAP_ID_TTLERROR =0x53 , MLXSW_TRAP_ID_LBERROR = 0x54,
@@ -66,13 +68,10 @@ enum {MLXSW_TRAP_ID_HOST_MISS_IPV6 =0x92 ,MLXSW_TRAP_ID_IPIP_DECAP_ERROR =0xB1 ,MLXSW_TRAP_ID_NVE_DECAP_ARP =0xB8 , -MLXSW_TRAP_ID_NVE_ENCAP_ARP =0xBD ,MLXSW_TRAP_ID_IPV4_BFD =0xD0 ,MLXSW_TRAP_ID_IPV6_BFD =0xD1 ,MLXSW_TRAP_ID_ROUTER_ALERT_IPV4 =0xD6 ,MLXSW_TRAP_ID_ROUTER_ALERT_IPV6 =0xD7 , -MLXSW_TRAP_ID_ROUTER_ARPBC =0xE0 , -MLXSW_TRAP_ID_ROUTER_ARPUC =0xE1 ,MLXSW_TRAP_ID_DISCARD_NON_ROUTABLE =0x11A ,MLXSW_TRAP_ID_DISCARD_ROUTER2 =0x130 , MLXSW_TRAP_ID_DISCARD_ROUTER3 = 0x131,
Signature · 1 line
2.47.0
Re: [PATCH net-next 1/6] mlxsw: Trap ARP packets at layer 2 instead of layer 3
Quoted 15 lines · Petr Machata
From: Amit Cohen <[email protected]>
Next patch will set the same hardware domain for all bridge ports, including VXLAN, to prevent packets from being forwarded by software when they were already forwarded by hardware.
ARP packets are not flooded by hardware to VXLAN, so software should handle such flooding. When hardware domain of VXLAN device will be changed, ARP packets which are trapped and marked with
offload_fwd_markwill not be flooded to VXLAN also in software, which will break VXLAN traffic.To prevent such breaking, trap ARP packets at layer 2 and don't mark them as L2-forwarded in hardware, then flooding ARP packets will be done only in software, and VXLAN will send ARP packets.
Quoted 7 lines
Remove
NVE_ENCAP_ARPwhich is no longer needed, as now ARP packets are trapped when they enter the device.Signed-off-by Amit Cohen <[email protected]>Reviewed-by Petr Machata <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Petr Machata <[email protected]>
Petr Machata
maintainerPATCH 2/6 mlxsw: spectrum: Call mlxsw_sp_bridge_vxlan_{join, leave}() for VLAN-aware bridge
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
mlxsw_sp_bridge_vxlan_{join,leave}() are not called when a VXLAN device joins or leaves a VLAN-aware bridge. As mentioned in the comment - when the bridge is VLAN-aware, the VNI of the VXLAN device needs to be mapped to a VLAN, but at this point no VLANs are configured on the VxLAN device. This means that we can call the APIs, but there is no point to do that, as they do not configure anything in such cases.
Next patch will extend mlxsw_sp_bridge_vxlan_{join,leave}() to set hardware domain for VXLAN, this should be done also when a VXLAN device joins or leaves a VLAN-aware bridge. Call the APIs, which for now do not do anything in these flows.
Align the call to mlxsw_sp_bridge_vxlan_leave() to be called like mlxsw_sp_bridge_vxlan_join(), only in case that the VXLAN device is up, so move the check to be done before calling mlxsw_sp_bridge_vxlan_{join,leave}(). This does not change the existing behavior, as there is a similar check inside mlxsw_sp_bridge_vxlan_leave().
--- .../net/ethernet/mellanox/mlxsw/spectrum.c | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +4 -16
@@ -5230,25 +5230,13 @@ static int mlxsw_sp_netdevice_vxlan_event(struct mlxsw_sp *mlxsw_sp,return 0 ;if (!mlxsw_sp_bridge_vxlan_is_valid (upper_dev, extack))return -EOPNOTSUPP ; -if (cu_info->linking) { -if (!netif_running (dev)) -return 0 ; -/* When the bridge is VLAN-aware, the VNI of the VxLAN -* device needs to be mapped to a VLAN, but at this -* point no VLANs are configured on the VxLAN device -*/ -if (br_vlan_enabled (upper_dev)) -return 0 ; +if (!netif_running (dev)) +return 0 ; +if (cu_info->linking)return mlxsw_sp_bridge_vxlan_join (mlxsw_sp, upper_dev, dev,0 , extack); - }else { -/* VLANs were already flushed, which triggered the -* necessary cleanup -*/ -if (br_vlan_enabled (upper_dev)) -return 0 ; +else mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, dev); - }break ;case NETDEV_PRE_UP : upper_dev =netdev_master_upper_dev_get (dev);
Signature · 1 line
2.47.0
Re: [PATCH net-next 2/6] mlxsw: spectrum: Call mlxsw_sp_bridge_vxlan_{join, leave}() for VLAN-aware bridge
Quoted 20 lines · Petr Machata
From: Amit Cohen <[email protected]>
mlxsw_sp_bridge_vxlan_{join,leave}() are not called when a VXLAN device joins or leaves a VLAN-aware bridge. As mentioned in the comment - when the bridge is VLAN-aware, the VNI of the VXLAN device needs to be mapped to a VLAN, but at this point no VLANs are configured on the VxLAN device. This means that we can call the APIs, but there is no point to do that, as they do not configure anything in such cases.
Next patch will extend mlxsw_sp_bridge_vxlan_{join,leave}() to set hardware domain for VXLAN, this should be done also when a VXLAN device joins or leaves a VLAN-aware bridge. Call the APIs, which for now do not do anything in these flows.
Align the call to
mlxsw_sp_bridge_vxlan_leave()to be called likemlxsw_sp_bridge_vxlan_join(), only in case that the VXLAN device is up, so move the check to be done before calling mlxsw_sp_bridge_vxlan_{join,leave}(). This does not change the existing behavior, as there is a similar check insidemlxsw_sp_bridge_vxlan_leave().
Quoted 4 lines
Signed-off-by Amit Cohen <[email protected]>Reviewed-by Petr Machata <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Petr Machata <[email protected]>
Petr Machata
maintainerPATCH 3/6 mlxsw: spectrum_switchdev: Add an internal API for VXLAN leave
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
There is asymmetry in how the VXLAN join and leave functions are used. The join function (mlxsw_sp_bridge_vxlan_join()) is only called in response to netdev events (e.g., VXLAN device joining a bridge), but the leave function is also called in response to switchdev events (e.g., VLAN configuration on top of the VXLAN device) in order to invalidate VNI to FID mappings.
This asymmetry will cause problems when the functions will be later extended to mark VXLAN bridge ports as offloaded or not.
Therefore, create an internal function (__mlxsw_sp_bridge_vxlan_leave()) that is used to invalidate VNI to FID mappings and call it from mlxsw_sp_bridge_vxlan_leave() which will only be invoked in response to netdev events, like mlxsw_sp_bridge_vxlan_join().
No functional changes intended.
--- .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +11 -5
@@ -2944,8 +2944,8 @@ int mlxsw_sp_bridge_vxlan_join(struct mlxsw_sp *mlxsw_sp, extack); } -void mlxsw_sp_bridge_vxlan_leave (struct mlxsw_sp *mlxsw_sp, -const struct net_device *vxlan_dev) +static void __mlxsw_sp_bridge_vxlan_leave (struct mlxsw_sp *mlxsw_sp, +const struct net_device *vxlan_dev) {struct vxlan_dev *vxlan =netdev_priv (vxlan_dev);struct mlxsw_sp_fid *fid;
@@ -2963,6 +2963,12 @@ void mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,mlxsw_sp_fid_put (fid); } +void mlxsw_sp_bridge_vxlan_leave (struct mlxsw_sp *mlxsw_sp, +const struct net_device *vxlan_dev) +{ +__mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev); +} + static void mlxsw_sp_switchdev_vxlan_addr_convert(const union vxlan_addr *vxlan_addr, enum mlxsw_sp_l3proto *proto,
@@ -3867,7 +3873,7 @@ mlxsw_sp_switchdev_vxlan_vlan_add(struct mlxsw_sp *mlxsw_sp,mlxsw_sp_fid_put (fid);return -EINVAL ; } -mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev); +__mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev);mlxsw_sp_fid_put (fid);return 0 ; }
@@ -3883,7 +3889,7 @@ mlxsw_sp_switchdev_vxlan_vlan_add(struct mlxsw_sp *mlxsw_sp,/* Fourth case: Thew new VLAN is PVID, which means the VLAN currently * mapped to the VNI should be unmapped */ -mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev); +__mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev);mlxsw_sp_fid_put (fid);/* Fifth case: The new VLAN is also egress untagged, which means the
@@ -3923,7 +3929,7 @@ mlxsw_sp_switchdev_vxlan_vlan_del(struct mlxsw_sp *mlxsw_sp,if (mlxsw_sp_fid_8021q_vid (fid) != vid) goto out; -mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev); +__mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev); out:mlxsw_sp_fid_put (fid);
Signature · 1 line
2.47.0
Re: [PATCH net-next 3/6] mlxsw: spectrum_switchdev: Add an internal API for VXLAN leave
Quoted 17 lines · Petr Machata
From: Amit Cohen <[email protected]>
There is asymmetry in how the VXLAN join and leave functions are used. The join function (
mlxsw_sp_bridge_vxlan_join()) is only called in response to netdev events (e.g., VXLAN device joining a bridge), but the leave function is also called in response to switchdev events (e.g., VLAN configuration on top of the VXLAN device) in order to invalidate VNI to FID mappings.This asymmetry will cause problems when the functions will be later extended to mark VXLAN bridge ports as offloaded or not.
Therefore, create an internal function (
__mlxsw_sp_bridge_vxlan_leave()) that is used to invalidate VNI to FID mappings and call it frommlxsw_sp_bridge_vxlan_leave()which will only be invoked in response to netdev events, likemlxsw_sp_bridge_vxlan_join().
Quoted 6 lines
No functional changes intended.
Signed-off-by Amit Cohen <[email protected]>Reviewed-by Petr Machata <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Petr Machata <[email protected]>
Petr Machata
maintainerPATCH 4/6 mlxsw: spectrum_switchdev: Move mlxsw_sp_bridge_vxlan_join()
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
Next patch will call __mlxsw_sp_bridge_vxlan_leave() from mlxsw_sp_bridge_vxlan_join() as part of error flow, move the function to be able to call the second one.
--- .../mellanox/mlxsw/spectrum_switchdev.c | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +15 -15
@@ -2929,21 +2929,6 @@ void mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,mlxsw_sp_bridge_port_put (mlxsw_sp->bridge, bridge_port); } -int mlxsw_sp_bridge_vxlan_join (struct mlxsw_sp *mlxsw_sp, -const struct net_device *br_dev, -const struct net_device *vxlan_dev,u16 vid, -struct netlink_ext_ack *extack) -{ -struct mlxsw_sp_bridge_device *bridge_device; - - bridge_device =mlxsw_sp_bridge_device_find (mlxsw_sp->bridge, br_dev); -if (WARN_ON (!bridge_device)) -return -EINVAL ; - -return bridge_device->ops->vxlan_join (bridge_device, vxlan_dev, vid, - extack); -} -static void __mlxsw_sp_bridge_vxlan_leave (struct mlxsw_sp *mlxsw_sp,const struct net_device *vxlan_dev) {
@@ -2963,6 +2948,21 @@ static void __mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,mlxsw_sp_fid_put (fid); } +int mlxsw_sp_bridge_vxlan_join (struct mlxsw_sp *mlxsw_sp, +const struct net_device *br_dev, +const struct net_device *vxlan_dev,u16 vid, +struct netlink_ext_ack *extack) +{ +struct mlxsw_sp_bridge_device *bridge_device; + + bridge_device =mlxsw_sp_bridge_device_find (mlxsw_sp->bridge, br_dev); +if (WARN_ON (!bridge_device)) +return -EINVAL ; + +return bridge_device->ops->vxlan_join (bridge_device, vxlan_dev, vid, + extack); +} +void mlxsw_sp_bridge_vxlan_leave (struct mlxsw_sp *mlxsw_sp,const struct net_device *vxlan_dev) {
Signature · 1 line
2.47.0
Re: [PATCH net-next 4/6] mlxsw: spectrum_switchdev: Move mlxsw_sp_bridge_vxlan_join()
Quoted 10 lines · Petr Machata
From: Amit Cohen <[email protected]>
Next patch will call
__mlxsw_sp_bridge_vxlan_leave()frommlxsw_sp_bridge_vxlan_join()as part of error flow, move the function to be able to call the second one.Signed-off-by Amit Cohen <[email protected]>Reviewed-by Petr Machata <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Petr Machata <[email protected]>
Petr Machata
maintainerPATCH 5/6 mlxsw: Add VXLAN bridge ports to same hardware domain as physical bridge ports
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
When hardware floods packets to bridge ports, but flooding to VXLAN bridge port fails during encapsulation to one of the remote VTEPs, the packets are trapped to CPU. In such case, the packets are marked with skb->offload_fwd_mark, which means that packet was L2-forwarded in hardware. Software data path repeats flooding, but packets which are marked with skb->offload_fwd_mark will not be flooded by the bridge to bridge ports which are in the same hardware domain as the ingress port.
Currently, mlxsw does not add VXLAN bridge ports to the same hardware domain as physical bridge ports despite the fact that the device is able to forward packets to and from VXLAN tunnels in hardware. In some scenarios (as mentioned above) this can result in remote VTEPs receiving duplicate packets. The packets are first flooded by hardware and after an encapsulation failure, they are flooded again to all remote VTEPs by software.
Solve this by adding VXLAN bridge ports to the same hardware domain as physical bridge ports, so then nbp_switchdev_allowed_egress() will return false also for VXLAN, and packets will not be sent twice from VXLAN device.
switchdev_bridge_port_offload() should get vxlan_dev not as const, so some changes are required. Call switchdev API from mlxsw_sp_bridge_vxlan_{join,leave}() which handle offload configurations.
--- .../net/ethernet/mellanox/mlxsw/spectrum.h | 4 +-- .../mellanox/mlxsw/spectrum_switchdev.c | 28 ++++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +2 -2
@@ -661,10 +661,10 @@ bool mlxsw_sp_bridge_device_is_offloaded(const struct mlxsw_sp *mlxsw_sp, const struct net_device *br_dev);int mlxsw_sp_bridge_vxlan_join (struct mlxsw_sp *mlxsw_sp,const struct net_device *br_dev, -const struct net_device *vxlan_dev,u16 vid, +struct net_device *vxlan_dev,u16 vid,struct netlink_ext_ack *extack);void mlxsw_sp_bridge_vxlan_leave (struct mlxsw_sp *mlxsw_sp, -const struct net_device *vxlan_dev); +struct net_device *vxlan_dev);extern struct notifier_block mlxsw_sp_switchdev_notifier;/* spectrum.c */
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +24 -4
@@ -2950,22 +2950,42 @@ static void __mlxsw_sp_bridge_vxlan_leave(struct mlxsw_sp *mlxsw_sp,int mlxsw_sp_bridge_vxlan_join (struct mlxsw_sp *mlxsw_sp,const struct net_device *br_dev, -const struct net_device *vxlan_dev,u16 vid, +struct net_device *vxlan_dev,u16 vid,struct netlink_ext_ack *extack) {struct mlxsw_sp_bridge_device *bridge_device; +struct mlxsw_sp_port *mlxsw_sp_port; +int err; bridge_device =mlxsw_sp_bridge_device_find (mlxsw_sp->bridge, br_dev);if (WARN_ON (!bridge_device))return -EINVAL ; -return bridge_device->ops->vxlan_join (bridge_device, vxlan_dev, vid, - extack); + mlxsw_sp_port =mlxsw_sp_port_dev_lower_find (bridge_device->dev); +if (!mlxsw_sp_port) +return -EINVAL ; + + err = bridge_device->ops->vxlan_join (bridge_device, vxlan_dev, vid, + extack); +if (err) +return err; + + err =switchdev_bridge_port_offload (vxlan_dev, mlxsw_sp_port->dev, +NULL ,NULL ,NULL , false, extack); +if (err) + goto err_bridge_port_offload; + +return 0 ; + +err_bridge_port_offload: +__mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev); +return err; }void mlxsw_sp_bridge_vxlan_leave (struct mlxsw_sp *mlxsw_sp, -const struct net_device *vxlan_dev) +struct net_device *vxlan_dev) { +switchdev_bridge_port_unoffload (vxlan_dev,NULL ,NULL ,NULL );__mlxsw_sp_bridge_vxlan_leave (mlxsw_sp, vxlan_dev); }
Signature · 1 line
2.47.0
Re: [PATCH net-next 5/6] mlxsw: Add VXLAN bridge ports to same hardware domain as physical bridge ports
Quoted 26 lines · Petr Machata
From: Amit Cohen <[email protected]>
When hardware floods packets to bridge ports, but flooding to VXLAN bridge port fails during encapsulation to one of the remote VTEPs, the packets are trapped to CPU. In such case, the packets are marked with
skb->offload_fwd_mark, which means that packet was L2-forwarded in hardware. Software data path repeats flooding, but packets which are marked withskb->offload_fwd_markwill not be flooded by the bridge to bridge ports which are in the same hardware domain as the ingress port.Currently, mlxsw does not add VXLAN bridge ports to the same hardware domain as physical bridge ports despite the fact that the device is able to forward packets to and from VXLAN tunnels in hardware. In some scenarios (as mentioned above) this can result in remote VTEPs receiving duplicate packets. The packets are first flooded by hardware and after an encapsulation failure, they are flooded again to all remote VTEPs by software.
Solve this by adding VXLAN bridge ports to the same hardware domain as physical bridge ports, so then
nbp_switchdev_allowed_egress()will return false also for VXLAN, and packets will not be sent twice from VXLAN device.
switchdev_bridge_port_offload()should getvxlan_devnot as const, so some changes are required. Call switchdev API from mlxsw_sp_bridge_vxlan_{join,leave}() which handle offload configurations.
Quoted 7 lines
Reported-by Vladimir Oltean <[email protected]>Reported-by Vladyslav Mykhaliuk <[email protected]>Signed-off-by Amit Cohen <[email protected]>Reviewed-by Petr Machata <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Petr Machata <[email protected]>
Petr Machata
maintainerPATCH 6/6 selftests: vxlan_bridge: Test flood with unresolved FDB entry
In reply to Petr MachataFrom: Amit Cohen <[email protected]>
Extend flood test to configure FDB entry with unresolved destination IP, check that packets are not sent twice.
Without the previous patch which handles such scenario in mlxsw, the tests fail:
$ TESTS='test_flood' ./vxlan_bridge_1d.sh
Running tests with UDP port 4789
TEST: VXLAN: flood [ OK ]
TEST: VXLAN: flood, unresolved FDB entry [FAIL]
vx2 ns2: Expected to capture 10 packets, got 20.$ TESTS='test_flood' ./vxlan_bridge_1q.sh
INFO: Running tests with UDP port 4789
TEST: VXLAN: flood vlan 10 [ OK ]
TEST: VXLAN: flood vlan 20 [ OK ]
TEST: VXLAN: flood vlan 10, unresolved FDB entry [FAIL]
vx10 ns2: Expected to capture 10 packets, got 20.
TEST: VXLAN: flood vlan 20, unresolved FDB entry [FAIL]
vx20 ns2: Expected to capture 10 packets, got 20.With the previous patch, the tests pass.
--- .../selftests/net/forwarding/vxlan_bridge_1d.sh | 8 ++++++++ .../selftests/net/forwarding/vxlan_bridge_1q.sh | 15 +++++++++++++++ 2 files changed, 23 insertions(+)
tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh +8 -0
@@ -428,6 +428,14 @@ __test_flood() test_flood() { __test_flood de:ad:be:ef:13:37 192.0.2.100 "flood" + + # Add an entry with arbitrary destination IP. Verify that packets are + # not duplicated (this can happen if hardware floods the packets, and + # then traps them due to misconfiguration, so software data path repeats + # flooding and resends packets). + bridge fdb append dev vx1 00:00:00:00:00:00 dst 198.51.100.1 self + __test_flood de:ad:be:ef:13:37 192.0.2.100 "flood, unresolved FDB entry" + bridge fdb del dev vx1 00:00:00:00:00:00 dst 198.51.100.1 self } vxlan_fdb_add_del()
tools/testing/selftests/net/forwarding/vxlan_bridge_1q.sh +15 -0
@@ -539,6 +539,21 @@ test_flood() 10 10 0 10 0 __test_flood ca:fe:be:ef:13:37 198.51.100.100 20 "flood vlan 20" \ 10 0 10 0 10 + + # Add entries with arbitrary destination IP. Verify that packets are + # not duplicated (this can happen if hardware floods the packets, and + # then traps them due to misconfiguration, so software data path repeats + # flooding and resends packets). + bridge fdb append dev vx10 00:00:00:00:00:00 dst 203.0.113.1 self + bridge fdb append dev vx20 00:00:00:00:00:00 dst 203.0.113.2 self + + __test_flood de:ad:be:ef:13:37 192.0.2.100 10 \ + "flood vlan 10, unresolved FDB entry" 10 10 0 10 0 + __test_flood ca:fe:be:ef:13:37 198.51.100.100 20 \ + "flood vlan 20, unresolved FDB entry" 10 0 10 0 10 + + bridge fdb del dev vx20 00:00:00:00:00:00 dst 203.0.113.2 self + bridge fdb del dev vx10 00:00:00:00:00:00 dst 203.0.113.1 self } vxlan_fdb_add_del()
Signature · 1 line
2.47.0
Re: [PATCH net-next 6/6] selftests: vxlan_bridge: Test flood with unresolved FDB entry
Quoted 23 lines · Petr Machata
From: Amit Cohen <[email protected]>
Extend flood test to configure FDB entry with unresolved destination IP, check that packets are not sent twice.
Without the previous patch which handles such scenario in mlxsw, the tests fail:
$ TESTS='test_flood' ./vxlan_bridge_1d.sh Running tests with UDP port 4789 TEST: VXLAN: flood [ OK ] TEST: VXLAN: flood, unresolved FDB entry [FAIL] vx2 ns2: Expected to capture 10 packets, got 20.$ TESTS='test_flood' ./vxlan_bridge_1q.sh INFO: Running tests with UDP port 4789 TEST: VXLAN: flood vlan 10 [ OK ] TEST: VXLAN: flood vlan 20 [ OK ] TEST: VXLAN: flood vlan 10, unresolved FDB entry [FAIL] vx10 ns2: Expected to capture 10 packets, got 20. TEST: VXLAN: flood vlan 20, unresolved FDB entry [FAIL] vx20 ns2: Expected to capture 10 packets, got 20.
Quoted 6 lines
With the previous patch, the tests pass.
Signed-off-by Amit Cohen <[email protected]>Reviewed-by Petr Machata <[email protected]>Reviewed-by Ido Schimmel <[email protected]>Signed-off-by Petr Machata <[email protected]>
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 17 Mar 2025 18:37:25 +0100 you wrote:
Amit Cohen writes:
Packets which are trapped to CPU for forwarding in software data path are handled according to driver marking of skb->offload_{,l3}_fwd_mark. Packets which are marked as L2-forwarded in hardware, will not be flooded by the bridge to bridge ports which are in the same hardware domain as the ingress port.
[...]
Here is the summary with links:
- [net-next,1/6] mlxsw: Trap ARP packets at layer 2 instead of layer 3
https://git.kernel.org/netdev/net-next/c/6d627a29aab8 - [net-next,2/6] mlxsw: spectrum: Call mlxsw_sp_bridge_vxlan_{join, leave}() for VLAN-aware bridge https://git.kernel.org/netdev/net-next/c/a13fc7ebd994 - [net-next,3/6] mlxsw: spectrum_switchdev: Add an internal API for VXLAN leave https://git.kernel.org/netdev/net-next/c/413e2c069969 - [net-next,4/6] mlxsw: spectrum_switchdev: Move mlxsw_sp_bridge_vxlan_join() https://git.kernel.org/netdev/net-next/c/630e7e20d35f - [net-next,5/6] mlxsw: Add VXLAN bridge ports to same hardware domain as physical bridge ports https://git.kernel.org/netdev/net-next/c/139ae87714eb - [net-next,6/6] selftests: vxlan_bridge: Test flood with unresolved FDB entry https://git.kernel.org/netdev/net-next/c/36ed81bcade9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html