bridge: ability to disable forwarding on a port
Subsystems (3)
RFC PATCH 1/1 bridge: ability to disable forwarding on a port
From: Roopa Prabhu <[email protected]>
On a Linux bridge with bridge forwarding offloaded to a switch ASIC, there is a need to not re-forward the frames that come up to the kernel in software.
Typically these are broadcast or multicast packets forwarded by the hardware to multiple destination ports including sending a copy of the packet to the kernel (e.g. an arp broadcast).
The bridge driver will try to forward the packet again, resulting in two copies of the same packet.
These packets can also come up to the kernel for logging when they hit a LOG acl in hardware.
This patch makes forwarding a flag on the port similar to
learn and flood and drops the packet just before forwarding. (The forwarding disable on a bridge is tested to work on our boxes. The bridge port flag addition is only compile tested.
This will need to be further refined to cover cases where a non-switch port is bridged to a switch port etc. We will submit more patches to cover all cases if we agree on this approach).
Other ways to solve the same problem could be to:
- use the offload feature flag on these switch ports to avoid the re-forward:
https://www.marc.info/?l=linux-netdev&m=141820235010603&w=2
- Or the switch driver can mark or set a flag in the skb, which the bridge driver can use to avoid a re-forward.
--- include/linux/if_bridge.h | 3 ++- include/uapi/linux/if_link.h | 1 + net/bridge/br_forward.c | 13 +++++++++++++ net/bridge/br_if.c | 2 +- net/bridge/br_netlink.c | 4 +++- net/bridge/br_sysfs_if.c | 1 + net/core/rtnetlink.c | 4 +++- 7 files changed, 24 insertions(+), 4 deletions(-)
include/linux/if_bridge.h +2 -1
@@ -40,10 +40,11 @@ struct br_ip_list {#define BR_ADMIN_COST BIT(4)#define BR_LEARNING BIT(5)#define BR_FLOOD BIT(6) -#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)#define BR_PROMISC BIT(7)#define BR_PROXYARP BIT(8)#define BR_LEARNING_SYNC BIT(9) +#define BR_FORWARD BIT(10) +#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING | BR_FORWARD)extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *));
include/uapi/linux/if_link.h +1 -0
@@ -246,6 +246,7 @@ enum {IFLA_BRPORT_UNICAST_FLOOD ,/* flood unicast traffic */ IFLA_BRPORT_PROXYARP ,/* proxy ARP */ IFLA_BRPORT_LEARNING_SYNC ,/* mac learning sync from device */ +IFLA_BRPORT_FORWARD ,/* enable forwarding on a device */ __IFLA_BRPORT_MAX };#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
net/bridge/br_forward.c +13 -0
@@ -81,10 +81,23 @@ static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) br_forward_finish); } +int br_hw_forward_finish (struct sk_buff *skb) +{ +kfree_skb (skb); + +return 0 ; +} +static void __br_forward (const struct net_bridge_port *to,struct sk_buff *skb) {struct net_device *indev; +if (!(to->flags &BR_FORWARD )) { +NF_HOOK (NFPROTO_BRIDGE ,NF_BR_FORWARD , skb, skb->dev, to->dev, + br_hw_forward_finish); +return ; + } +if (skb_warn_if_lro (skb)) {kfree_skb (skb);return ;
net/bridge/br_if.c +1 -1
@@ -330,7 +330,7 @@ static struct net_bridge_port *new_nbp(struct net_bridge *br, p->path_cost =port_cost (dev); p->priority =0x8000 >>BR_PORT_BITS ; p->port_no = index; - p->flags =BR_LEARNING |BR_FLOOD ; + p->flags =BR_LEARNING |BR_FLOOD |BR_FORWARD ;br_init_port (p);br_set_state (p,BR_STATE_DISABLED );br_stp_port_timer_init (p);
net/bridge/br_netlink.c +3 -1
@@ -61,7 +61,8 @@ static int br_port_fill_attrs(struct sk_buff *skb,nla_put_u8 (skb,IFLA_BRPORT_FAST_LEAVE , !!(p->flags &BR_MULTICAST_FAST_LEAVE )) ||nla_put_u8 (skb,IFLA_BRPORT_LEARNING , !!(p->flags &BR_LEARNING )) ||nla_put_u8 (skb,IFLA_BRPORT_UNICAST_FLOOD , !!(p->flags &BR_FLOOD )) || - nla_put_u8(skb, IFLA_BRPORT_PROXYARP, !!(p->flags & BR_PROXYARP))) +nla_put_u8 (skb,IFLA_BRPORT_PROXYARP , !!(p->flags &BR_PROXYARP )) || + nla_put_u8(skb, IFLA_BRPORT_FORWARD, !!(p->flags & BR_FORWARD))) return -EMSGSIZE;return 0 ;
@@ -335,6 +336,7 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])br_set_port_flag (p, tb,IFLA_BRPORT_LEARNING ,BR_LEARNING );br_set_port_flag (p, tb,IFLA_BRPORT_UNICAST_FLOOD ,BR_FLOOD );br_set_port_flag (p, tb,IFLA_BRPORT_PROXYARP ,BR_PROXYARP ); +br_set_port_flag (p, tb,IFLA_BRPORT_FORWARD ,BR_FORWARD );if (tb[IFLA_BRPORT_COST ]) { err =br_stp_set_path_cost (p,nla_get_u32 (tb[IFLA_BRPORT_COST ]));
net/bridge/br_sysfs_if.c +1 -0
@@ -171,6 +171,7 @@ BRPORT_ATTR_FLAG(root_block, BR_ROOT_BLOCK);BRPORT_ATTR_FLAG (learning,BR_LEARNING );BRPORT_ATTR_FLAG (unicast_flood,BR_FLOOD );BRPORT_ATTR_FLAG (proxyarp,BR_PROXYARP ); +BRPORT_ATTR_FLAG (forward,BR_FORWARD );#ifdef CONFIG_BRIDGE_IGMP_SNOOPING static ssize_t show_multicast_router (struct net_bridge_port *p,char *buf)
net/core/rtnetlink.c +3 -1
@@ -2785,7 +2785,9 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, brport_nla_put_flag(skb, flags, mask, IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD) || brport_nla_put_flag(skb, flags, mask, - IFLA_BRPORT_PROXYARP, BR_PROXYARP)) { + IFLA_BRPORT_PROXYARP, BR_PROXYARP) || + brport_nla_put_flag(skb, flags, mask, + IFLA_BRPORT_FORWARD, BR_FORWARD)) {nla_nest_cancel (skb, protinfo); goto nla_put_failure; }
Signature · 1 line
1.7.10.4
Quoted 35 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, January 16, 2015 11:33 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Arad, Ronen; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [RFC PATCH net-next] bridge: ability to disable forwarding on a portFrom: Roopa Prabhu <[email protected]>
On a Linux bridge with bridge forwarding offloaded to a switch ASIC, there is a need to not re-forward the frames that come up to the kernel in software.
Typically these are broadcast or multicast packets forwarded by the hardware to multiple destination ports including sending a copy of the packet to the kernel (e.g. an arp broadcast).
The bridge driver will try to forward the packet again, resulting in two copies of the same packet.These packets can also come up to the kernel for logging when they hit a LOG acl in hardware.
This patch makes forwarding a flag on the port similar to
learn and flood and drops the packet just before forwarding. (The forwarding disable on a bridge is tested to work on our boxes. The bridge port flag addition is only compile tested.
This will need to be further refined to cover cases where a non-switch port is bridged to a switch port etc. We will submit more patches to cover all cases if we agree on this approach).
Quoted 8 lines
Other ways to solve the same problem could be to:
- use the offload feature flag on these switch ports to avoid the re-forward:
https://www.marc.info/?l=linux-netdev&m=141820235010603&w=2- Or the switch driver can mark or set a flag in the skb, which the bridge driver can use to avoid a re-forward.
The proposed patch does not go along with the offload feature flag. The premise of the offload feature flag is that offloading is driven by the switch port driver without user intervention. This patch requires different setting for BR_FLOOD in the software bridge port and the switch port driver. The alternatives suggested (offload flag or skb flag) are better.
The proposed patch avoids re-forward but not without cost. For example in the case of unicast flood with local destination, the skb is cloned for each port before the forward avoidance in __br_forward. Is it acceptable overhead?
[...]
Quoted 39 lines · Ronen
Quoted 39 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Friday, January 16, 2015 11:33 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Arad, Ronen; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: [RFC PATCH net-next] bridge: ability to disable forwarding on a portFrom: Roopa Prabhu <[email protected]>
On a Linux bridge with bridge forwarding offloaded to a switch ASIC, there is a need to not re-forward the frames that come up to the kernel in software.
Typically these are broadcast or multicast packets forwarded by the hardware to multiple destination ports including sending a copy of the packet to the kernel (e.g. an arp broadcast).
The bridge driver will try to forward the packet again, resulting in two copies of the same packet.These packets can also come up to the kernel for logging when they hit a LOG acl in hardware.
This patch makes forwarding a flag on the port similar to
learn and flood and drops the packet just before forwarding. (The forwarding disable on a bridge is tested to work on our boxes. The bridge port flag addition is only compile tested.
This will need to be further refined to cover cases where a non-switch port is bridged to a switch port etc. We will submit more patches to cover all cases if we agree on this approach).Other ways to solve the same problem could be to:
- use the offload feature flag on these switch ports to avoid the re-forward:
https://www.marc.info/?l=linux-netdev&m=141820235010603&w=2
Quoted 7 lines
Quoted 3 lines
- Or the switch driver can mark or set a flag in the skb, which the bridge driver can use to avoid a re-forward.
The proposed patch does not go along with the offload feature flag. The premise of the offload feature flag is that offloading is driven by the switch port driver without user intervention. This patch requires different setting for
BR_FLOODin the software bridge port and the switch port driver.
Even with the offload feature flag, there are a few bridge port attributes that can be set from userspace which can be different for sw and hw. So, with this patch I was trying to see if making it similar to the other existing flags would be better.
Quoted 1 line
The alternatives suggested (offload flag or skb flag) are better.
Glad to know your opinion.
Quoted 4 lines
The proposed patch avoids re-forward but not without cost. For example in the case of unicast flood with local destination, the skb is cloned for each port before the forward avoidance in
__br_forward. Is it acceptable overhead?
This patch places it in __br_forward to just make sure all the paths including the netfilter hook is traversed for these packets. And plus it was written with minimal changes in mind. We have not measured it but the extra overhead for these pkts that hit
the kernel has been negligible. But, I will look at the code to see if it can be avoided.
Thanks,
Roopa
Quoted 15 lines · On Fri, Jan 16, 2015 at 11:32 PM, <[email protected]> wrote:
From: Roopa Prabhu <[email protected]>
On a Linux bridge with bridge forwarding offloaded to a switch ASIC, there is a need to not re-forward the frames that come up to the kernel in software.
Typically these are broadcast or multicast packets forwarded by the hardware to multiple destination ports including sending a copy of the packet to the kernel (e.g. an arp broadcast).
The bridge driver will try to forward the packet again, resulting in two copies of the same packet.These packets can also come up to the kernel for logging when they hit a LOG acl in hardware.
Quoted 7 lines
This patch makes forwarding a flag on the port similar to
learn and flood and drops the packet just before forwarding. (The forwarding disable on a bridge is tested to work on our boxes. The bridge port flag addition is only compile tested.
This will need to be further refined to cover cases where a non-switch port is bridged to a switch port etc. We will submit more patches to cover all cases if we agree on this approach).
Good topic to bring up, thanks for proposing a patch. There is indeed duplicate pkts sent out in the case where both the bridge and the offloaded device are flooding these non-unicast pkts, such as ARP requests. We do have per-port control today over unicast flooding using BR_FLOOD (IFLA_BRPORT_UNICAST_FLOOD).
As you point out, this doesn't solve the case for non-offloaded ports bridged with switch ports. If this port setting is enabled on an offloaded switch port, for example, the non-offloaded port can't get an ARP request resolved, if the MAC is behind the offloaded switch port. But do we care? Is there a use-case for this one, mixing offloaded and non-offloaded ports in a bridge?
Quoted 26 lines
Other ways to solve the same problem could be to:
- use the offload feature flag on these switch ports to avoid the re-forward:
https://www.marc.info/?l=linux-netdev&m=141820235010603&w=2- Or the switch driver can mark or set a flag in the skb, which the bridge driver can use to avoid a re-forward.
Signed-off-by Wilson Kok <[email protected]>Signed-off-by Roopa Prabhu <[email protected]>--- include/linux/if_bridge.h | 3 ++- include/uapi/linux/if_link.h | 1 + net/bridge/br_forward.c | 13 +++++++++++++ net/bridge/br_if.c | 2 +- net/bridge/br_netlink.c | 4 +++- net/bridge/br_sysfs_if.c | 1 + net/core/rtnetlink.c | 4 +++- 7 files changed, 24 insertions(+), 4 deletions(-)include/linux/if_bridge.h +0
-0
include/linux/if_bridge.h struct br_ip_list { · line 46
Quoted 8 lines
include/linux/if_bridge.h +1
-1@@ -40,10 +40,11 @@ struct br_ip_list {#define BR_ADMIN_COST BIT(4)#define BR_LEARNING BIT(5)#define BR_FLOOD BIT(6) -#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)#define BR_PROMISC BIT(7)#define BR_PROXYARP BIT(8)#define BR_LEARNING_SYNC BIT(9) +#define BR_FORWARD BIT(10)
The name BR_FORWARD might confuse people thinking this is related to STP FORWARDING state. We have BR_FLOOD for unknown unicast flooding. How about renaming BR_FLOOD to BR_FLOOD_UNICAST and add BR_FLOOD_BROADCAST? So you would have:
IFLA_BRPORT_UNICAST_FLOOD BR_FLOOD_UNICAST /* flood
unknown unicast traffic to port */
IFLA_BRPORT_BROADCAST_FLOOD BR_FLOOD_BROADCAST /* flood
bcast/mcast traffic to port */
Quoted 31 lines
include/linux/if_bridge.h +1
-0+#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING | BR_FORWARD)extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *));include/uapi/linux/if_link.h +1
-0@@ -246,6 +246,7 @@ enum {IFLA_BRPORT_UNICAST_FLOOD ,/* flood unicast traffic */ IFLA_BRPORT_PROXYARP ,/* proxy ARP */ IFLA_BRPORT_LEARNING_SYNC ,/* mac learning sync from device */ +IFLA_BRPORT_FORWARD ,/* enable forwarding on a device */ __IFLA_BRPORT_MAX };#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)net/bridge/br_forward.c +7
-0@@ -81,10 +81,23 @@ static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) br_forward_finish); } +int br_hw_forward_finish (struct sk_buff *skb) +{ +kfree_skb (skb); + +return 0 ; +} +
net/bridge/br_forward.c static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) · line 100
Quoted 10 lines
net/bridge/br_forward.c +6
-0static void __br_forward (const struct net_bridge_port *to,struct sk_buff *skb) {struct net_device *indev; +if (!(to->flags &BR_FORWARD )) { +NF_HOOK (NFPROTO_BRIDGE ,NF_BR_FORWARD , skb, skb->dev, to->dev, + br_hw_forward_finish); +return ; + } +
Seems you should make the (flags & BR_FORWARD) check earlier, before skb cloning, in br_flood(), alongside the (flags & BR_FLOOD) check.
Also, the above code is skipping some vlan checks (br_handle_vlan).
-scott
Quoted 29 lines · Scott Feldman
Quoted 15 lines · On Fri, Jan 16, 2015 at 11:32 PM, <[email protected]> wrote:
From: Roopa Prabhu <[email protected]>
On a Linux bridge with bridge forwarding offloaded to a switch ASIC, there is a need to not re-forward the frames that come up to the kernel in software.
Typically these are broadcast or multicast packets forwarded by the hardware to multiple destination ports including sending a copy of the packet to the kernel (e.g. an arp broadcast).
The bridge driver will try to forward the packet again, resulting in two copies of the same packet.These packets can also come up to the kernel for logging when they hit a LOG acl in hardware.
Quoted 7 lines
This patch makes forwarding a flag on the port similar to
learn and flood and drops the packet just before forwarding. (The forwarding disable on a bridge is tested to work on our boxes. The bridge port flag addition is only compile tested.
This will need to be further refined to cover cases where a non-switch port is bridged to a switch port etc. We will submit more patches to cover all cases if we agree on this approach).Good topic to bring up, thanks for proposing a patch. There is indeed duplicate pkts sent out in the case where both the bridge and the offloaded device are flooding these non-unicast pkts, such as ARP requests. We do have per-port control today over unicast flooding using
BR_FLOOD(IFLA_BRPORT_UNICAST_FLOOD).
Quoted 6 lines
As you point out, this doesn't solve the case for non-offloaded ports bridged with switch ports. If this port setting is enabled on an offloaded switch port, for example, the non-offloaded port can't get an ARP request resolved, if the MAC is behind the offloaded switch port. But do we care? Is there a use-case for this one, mixing offloaded and non-offloaded ports in a bridge?
Not sure. I don't know the use case, but I think I might have heard that there could be a case
where a switch port could be bridged with a vm's port running on the
switch. (?)
Quoted 21 lines
Quoted 21 lines
Other ways to solve the same problem could be to:
- use the offload feature flag on these switch ports to avoid the re-forward:
https://www.marc.info/?l=linux-netdev&m=141820235010603&w=2- Or the switch driver can mark or set a flag in the skb, which the bridge driver can use to avoid a re-forward.
Signed-off-by Wilson Kok <[email protected]>Signed-off-by Roopa Prabhu <[email protected]>--- include/linux/if_bridge.h | 3 ++- include/uapi/linux/if_link.h | 1 + net/bridge/br_forward.c | 13 +++++++++++++ net/bridge/br_if.c | 2 +- net/bridge/br_netlink.c | 4 +++- net/bridge/br_sysfs_if.c | 1 + net/core/rtnetlink.c | 4 +++- 7 files changed, 24 insertions(+), 4 deletions(-)
Quoted 15 lines
include/linux/if_bridge.h struct br_ip_list { · line 46
Quoted 13 lines
include/linux/if_bridge.h +1
-1@@ -40,10 +40,11 @@ struct br_ip_list {#define BR_ADMIN_COST BIT(4)#define BR_LEARNING BIT(5)#define BR_FLOOD BIT(6) -#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING)#define BR_PROMISC BIT(7)#define BR_PROXYARP BIT(8)#define BR_LEARNING_SYNC BIT(9) +#define BR_FORWARD BIT(10)The name
BR_FORWARDmight confuse people thinking this is related to STP FORWARDING state.
yes, that thought crossed my mind too. I had BR_FORWARDING initially and to make it sound less like STP changed it to BR_FORWARD. :)
Quoted 8 lines
We have
BR_FLOODfor unknown unicast flooding. How about renamingBR_FLOODtoBR_FLOOD_UNICASTand addBR_FLOOD_BROADCAST? So you would have:
IFLA_BRPORT_UNICAST_FLOODBR_FLOOD_UNICAST/* flood
unknown unicast traffic to port */
IFLA_BRPORT_BROADCAST_FLOODBR_FLOOD_BROADCAST/* flood
bcast/mcast traffic to port */
That's a good idea. So, unknown unicast and broadcast will be covered with that. Am afraid there might be other packets, like the acl LOG packet hitting the CPU/kernel (?) I will check if there are others.
Quoted 36 lines
Quoted 36 lines
include/linux/if_bridge.h +1
-0+#define BR_AUTO_MASK (BR_FLOOD | BR_LEARNING | BR_FORWARD)extern void brioctl_set (int (*ioctl_hook)(struct net *,unsigned int ,void __user *));include/uapi/linux/if_link.h +1
-0@@ -246,6 +246,7 @@ enum {IFLA_BRPORT_UNICAST_FLOOD ,/* flood unicast traffic */ IFLA_BRPORT_PROXYARP ,/* proxy ARP */ IFLA_BRPORT_LEARNING_SYNC ,/* mac learning sync from device */ +IFLA_BRPORT_FORWARD ,/* enable forwarding on a device */ __IFLA_BRPORT_MAX };#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)net/bridge/br_forward.c +7
-0@@ -81,10 +81,23 @@ static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) br_forward_finish); } +int br_hw_forward_finish (struct sk_buff *skb) +{ +kfree_skb (skb); + +return 0 ; +} +static void __br_forward (const struct net_bridge_port *to,struct sk_buff *skb) {struct net_device *indev;
Quoted 8 lines
net/bridge/br_forward.c static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) · line 100
Quoted 6 lines
net/bridge/br_forward.c +6
-0+if (!(to->flags &BR_FORWARD )) { +NF_HOOK (NFPROTO_BRIDGE ,NF_BR_FORWARD , skb, skb->dev, to->dev, + br_hw_forward_finish); +return ; + } +Seems you should make the (flags &
BR_FORWARD) check earlier, before skb cloning, inbr_flood(), alongside the (flags &BR_FLOOD) check.
This patch strategically places it in __br_forward to catch all forwards (due to floods or no floods ..with direct call to br_foward) with minimal code changes in mind. Will see if the clone can be avoided.
Quoted 2 lines
Also, the above code is skipping some vlan checks (
br_handle_vlan).
The br_handle_vlan checks seemed not necessary for a packet getting dropped.
But, will check and fix if its needed while the packet traverses the netfilter hook and before it gets dropped.
Thanks,
Roopa
Quoted 37 lines · roopa
Quoted 29 lines · Scott Feldman
Quoted 15 lines · On Fri, Jan 16, 2015 at 11:32 PM, <[email protected]> wrote:
From: Roopa Prabhu <[email protected]>
On a Linux bridge with bridge forwarding offloaded to a switch ASIC, there is a need to not re-forward the frames that come up to the kernel in software.
Typically these are broadcast or multicast packets forwarded by the hardware to multiple destination ports including sending a copy of the packet to the kernel (e.g. an arp broadcast).
The bridge driver will try to forward the packet again, resulting in two copies of the same packet.These packets can also come up to the kernel for logging when they hit a LOG acl in hardware.
Quoted 7 lines
This patch makes forwarding a flag on the port similar to
learn and flood and drops the packet just before forwarding. (The forwarding disable on a bridge is tested to work on our boxes. The bridge port flag addition is only compile tested.
This will need to be further refined to cover cases where a non-switch port is bridged to a switch port etc. We will submit more patches to cover all cases if we agree on this approach).Good topic to bring up, thanks for proposing a patch. There is indeed duplicate pkts sent out in the case where both the bridge and the offloaded device are flooding these non-unicast pkts, such as ARP requests. We do have per-port control today over unicast flooding using
BR_FLOOD(IFLA_BRPORT_UNICAST_FLOOD).Quoted 6 lines
As you point out, this doesn't solve the case for non-offloaded ports bridged with switch ports. If this port setting is enabled on an offloaded switch port, for example, the non-offloaded port can't get an ARP request resolved, if the MAC is behind the offloaded switch port. But do we care? Is there a use-case for this one, mixing offloaded and non-offloaded ports in a bridge?
Quoted 3 lines
Not sure. I don't know the use case, but I think I might have heard that there could be a case
where a switch port could be bridged with a vm's port running on the
switch. (?)
Ignoring the above usecase for a bit. And thinking through this again, It appears that this check should be only on the ingress port, no ?
If the ingress bridge port is an offloaded port, don't flood or forward because hardware has already done it. And this is best done with the offload feature flag on the bridge port.
But, If we bring in the usecase, where a bridge has offloaded and non-offloaded ports mixed, there should be an option to disable this check and to achieve that its better for this to be a flag on the port maintained by the bridge driver like the one proposed by this patch (BR_FORWARD).
Thanks,
Roopa
Quoted 50 lines · roopa
Quoted 43 lines · roopa
Quoted 33 lines · Scott Feldman
Quoted 16 lines · On Fri, Jan 16, 2015 at 11:32 PM, <[email protected]> wrote:
From: Roopa Prabhu <[email protected]>
On a Linux bridge with bridge forwarding offloaded to a switch ASIC, there is a need to not re-forward the frames that come up to the kernel in software.
Typically these are broadcast or multicast packets forwarded by the hardware to multiple destination ports including sending a copy of the packet to the kernel (e.g. an arp broadcast).
The bridge driver will try to forward the packet again, resulting in two copies of the same packet.These packets can also come up to the kernel for logging when they hit a LOG acl in hardware.
Quoted 8 lines
This patch makes forwarding a flag on the port similar to learn and flood and drops the packet just before forwarding. (The forwarding disable on a bridge is tested to work on our boxes. The bridge port flag addition is only compile tested.
This will need to be further refined to cover cases where a non-switch port
is bridged to a switch port etc. We will submit more patches to cover all cases if we agree on this approach).Good topic to bring up, thanks for proposing a patch. There is indeed duplicate pkts sent out in the case where both the bridge and the offloaded device are flooding these non-unicast pkts, such as ARP requests. We do have per-port control today over unicast flooding using
BR_FLOOD(IFLA_BRPORT_UNICAST_FLOOD).Quoted 6 lines
As you point out, this doesn't solve the case for non-offloaded ports bridged with switch ports. If this port setting is enabled on an offloaded switch port, for example, the non-offloaded port can't get an ARP request resolved, if the MAC is behind the offloaded switch port. But do we care? Is there a use-case for this one, mixing offloaded and non-offloaded ports in a bridge?
Quoted 4 lines
Not sure. I don't know the use case, but I think I might have heard that there could be a case
where a switch port could be bridged with a vm's port running on the
switch. (?)
Quoted 7 lines
Ignoring the above usecase for a bit. And thinking through this again, It appears that this check should
be only on the ingress port, no ?If the ingress bridge port is an offloaded port, don't flood or forward because hardware has already done it.
And this is best done with the offload feature flag on the bridge port.
That's assuming hardware did the flood. Maybe your other option to mark the skb if already flooded by hw is best. That's enough info for the bridge driver to make a decision to flood or not to the other ports, and it's an implementation decision for the driver/device to do the flood offload, if desired, and mark the skb if it did.
Btw, you're still saying flood or forward, but in my mind we're talking about flood only: flood of unknown unicast or flood of bcast/mcast pkts. Forwarding would be for known-unicast pkts, which should even involve the bridge driver since that forwarding is offloaded to the device.
Quoted 11 lines
But, If we bring in the usecase, where a bridge has offloaded and non-offloaded ports mixed,
there should be an option to disable this check and to achieve that its better for this to be a
flag on the port maintained by the bridge driver like the one proposed by this patch (BR_FORWARD).Thanks,
Roopa
On 1/18/15, 11:37 PM, Scott Feldman wrote:
<snip..>
Quoted 10 lines
Not sure. I don't know the use case, but I think I might have heard that there could be a case
where a switch port could be bridged with a vm's port running on the
switch. (?)Quoted 5 lines
Ignoring the above usecase for a bit. And thinking through this again, It appears that this check should
be only on the ingress port, no ?
Quoted 8 lines
Quoted 3 lines
If the ingress bridge port is an offloaded port, don't flood or forward because hardware has already done it.
And this is best done with the offload feature flag on the bridge port.That's assuming hardware did the flood. Maybe your other option to mark the skb if already flooded by hw is best. That's enough info for the bridge driver to make a decision to flood or not to the other ports, and it's an implementation decision for the driver/device to do the flood offload, if desired, and mark the skb if it did.
Still thinking we can just use the offload feature flag here. How about avoid forwarding only if both src and dst ports have forwarding offloaded/accelerated by a switch asic ?. That should cover all cases.
Quoted 6 lines
Btw, you're still saying flood or forward, but in my mind we're talking about flood only: flood of unknown unicast or flood of bcast/mcast pkts. Forwarding would be for known-unicast pkts, which should even involve the bridge driver since that forwarding is offloaded to the device.
I was also taking into account pkts copied to the CPU due to an acl rule such as log. These unicast pkts can come to cpu even if it is already forwarded in hw.
Thanks,
Roopa
Quoted 25 lines · roopa
On 1/18/15, 11:37 PM, Scott Feldman wrote:
<snip..>
Quoted 10 lines
Not sure. I don't know the use case, but I think I might have heard that there could be a case
where a switch port could be bridged with a vm's port running on the
switch. (?)Quoted 5 lines
Ignoring the above usecase for a bit. And thinking through this again, It appears that this check should
be only on the ingress port, no ?Quoted 8 lines
Quoted 3 lines
If the ingress bridge port is an offloaded port, don't flood or forward because hardware has already done it.
And this is best done with the offload feature flag on the bridge port.That's assuming hardware did the flood. Maybe your other option to mark the skb if already flooded by hw is best. That's enough info for the bridge driver to make a decision to flood or not to the other ports, and it's an implementation decision for the driver/device to do the flood offload, if desired, and mark the skb if it did.
Still thinking we can just use the offload feature flag here. How about avoid forwarding only if both src and dst ports have forwarding offloaded/accelerated by a switch asic ?. That should cover all cases.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Btw, you're still saying flood or forward, but in my mind we're talking about flood only: flood of unknown unicast or flood of bcast/mcast pkts. Forwarding would be for known-unicast pkts, which should even involve the bridge driver since that forwarding is offloaded to the device.
I was also taking into account pkts copied to the CPU due to an acl rule such as log. These unicast pkts can come to cpu even if it is already forwarded in hw.
Do you have a switch port netdev that corresponds to CPU port? Or are they seen on the bridge device?
Thanks
Sridhar
Quoted 33 lines · Sridhar
Quoted 31 lines · roopa
On 1/18/15, 11:37 PM, Scott Feldman wrote:
<snip..>
Quoted 10 lines
Not sure. I don't know the use case, but I think I might have heard that there could be a case
where a switch port could be bridged with a vm's port running on the
switch. (?)Quoted 5 lines
Ignoring the above usecase for a bit. And thinking through this again, It appears that this check should
be only on the ingress port, no ?Quoted 8 lines
Quoted 3 lines
If the ingress bridge port is an offloaded port, don't flood or forward because hardware has already done it.
And this is best done with the offload feature flag on the bridge port.That's assuming hardware did the flood. Maybe your other option to mark the skb if already flooded by hw is best. That's enough info for the bridge driver to make a decision to flood or not to the other ports, and it's an implementation decision for the driver/device to do the flood offload, if desired, and mark the skb if it did.
Still thinking we can just use the offload feature flag here. How about avoid forwarding only if both src and dst ports have forwarding offloaded/accelerated by a switch asic ?. That should cover all cases.
Quoted 6 lines
Btw, you're still saying flood or forward, but in my mind we're talking about flood only: flood of unknown unicast or flood of bcast/mcast pkts. Forwarding would be for known-unicast pkts, which should even involve the bridge driver since that forwarding is offloaded to the device.
Quoted 4 lines
Quoted 2 lines
I was also taking into account pkts copied to the CPU due to an acl rule such as log. These unicast pkts can come to cpu even if it is already forwarded in hw.
Do you have a switch port netdev that corresponds to CPU port? Or are they seen on the bridge device?
No we dont have a netdev for the CPU port. These show up on the netdev corresponding to the ingress front panel port.