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

bridge: add per-port broadcast flood flag

Support for l2 multicast flood control was added in commit b6cb5ac8331b
("net: bridge: add per-port multicast flood flag"). It allows broadcast
as it was introduced specifically for unknown multicast flood control.
But as broadcast is a special case of multicast, this may also need to
be disabled. For this purpose, introduce a flag to disable the flooding
of received l2 broadcasts. This approach is backwards compatible and
provides flexibility in filtering for the desired packet types.

Cc: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: Mike Manning <mmanning@brocade.com>
Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mike Manning and committed by
David S. Miller
99f906e9 06b4fc52

+25 -8
+1
include/linux/if_bridge.h
··· 48 48 #define BR_MCAST_FLOOD BIT(11) 49 49 #define BR_MULTICAST_TO_UNICAST BIT(12) 50 50 #define BR_VLAN_TUNNEL BIT(13) 51 + #define BR_BCAST_FLOOD BIT(14) 51 52 52 53 #define BR_DEFAULT_AGEING_TIME (300 * HZ) 53 54
+1
include/uapi/linux/if_link.h
··· 323 323 IFLA_BRPORT_MCAST_FLOOD, 324 324 IFLA_BRPORT_MCAST_TO_UCAST, 325 325 IFLA_BRPORT_VLAN_TUNNEL, 326 + IFLA_BRPORT_BCAST_FLOOD, 326 327 __IFLA_BRPORT_MAX 327 328 }; 328 329 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
+17 -7
net/bridge/br_forward.c
··· 183 183 struct net_bridge_port *p; 184 184 185 185 list_for_each_entry_rcu(p, &br->port_list, list) { 186 - /* Do not flood unicast traffic to ports that turn it off */ 187 - if (pkt_type == BR_PKT_UNICAST && !(p->flags & BR_FLOOD)) 188 - continue; 189 - /* Do not flood if mc off, except for traffic we originate */ 190 - if (pkt_type == BR_PKT_MULTICAST && 191 - !(p->flags & BR_MCAST_FLOOD) && skb->dev != br->dev) 192 - continue; 186 + /* Do not flood unicast traffic to ports that turn it off, nor 187 + * other traffic if flood off, except for traffic we originate 188 + */ 189 + switch (pkt_type) { 190 + case BR_PKT_UNICAST: 191 + if (!(p->flags & BR_FLOOD)) 192 + continue; 193 + break; 194 + case BR_PKT_MULTICAST: 195 + if (!(p->flags & BR_MCAST_FLOOD) && skb->dev != br->dev) 196 + continue; 197 + break; 198 + case BR_PKT_BROADCAST: 199 + if (!(p->flags & BR_BCAST_FLOOD) && skb->dev != br->dev) 200 + continue; 201 + break; 202 + } 193 203 194 204 /* Do not flood to ports that enable proxy ARP */ 195 205 if (p->flags & BR_PROXYARP)
+1 -1
net/bridge/br_if.c
··· 361 361 p->path_cost = port_cost(dev); 362 362 p->priority = 0x8000 >> BR_PORT_BITS; 363 363 p->port_no = index; 364 - p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD; 364 + p->flags = BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD; 365 365 br_init_port(p); 366 366 br_set_state(p, BR_STATE_DISABLED); 367 367 br_stp_port_timer_init(p);
+3
net/bridge/br_netlink.c
··· 189 189 !!(p->flags & BR_FLOOD)) || 190 190 nla_put_u8(skb, IFLA_BRPORT_MCAST_FLOOD, 191 191 !!(p->flags & BR_MCAST_FLOOD)) || 192 + nla_put_u8(skb, IFLA_BRPORT_BCAST_FLOOD, 193 + !!(p->flags & BR_BCAST_FLOOD)) || 192 194 nla_put_u8(skb, IFLA_BRPORT_PROXYARP, !!(p->flags & BR_PROXYARP)) || 193 195 nla_put_u8(skb, IFLA_BRPORT_PROXYARP_WIFI, 194 196 !!(p->flags & BR_PROXYARP_WIFI)) || ··· 685 683 br_set_port_flag(p, tb, IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD); 686 684 br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD); 687 685 br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_TO_UCAST, BR_MULTICAST_TO_UNICAST); 686 + br_set_port_flag(p, tb, IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD); 688 687 br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP, BR_PROXYARP); 689 688 br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP_WIFI, BR_PROXYARP_WIFI); 690 689
+2
net/bridge/br_sysfs_if.c
··· 173 173 BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP); 174 174 BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI); 175 175 BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD); 176 + BRPORT_ATTR_FLAG(broadcast_flood, BR_BCAST_FLOOD); 176 177 177 178 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING 178 179 static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf) ··· 222 221 &brport_attr_proxyarp, 223 222 &brport_attr_proxyarp_wifi, 224 223 &brport_attr_multicast_flood, 224 + &brport_attr_broadcast_flood, 225 225 NULL 226 226 }; 227 227