Skip to content

Commit 1f51445

Browse files
idoschdavem330
authored andcommitted
bridge: Export VLAN filtering state
It's useful for drivers supporting bridge offload to be able to query the bridge's VLAN filtering state. Currently, upon enslavement to a bridge master, the offloading driver will only learn about the bridge's VLAN filtering state after the bridge device was already linked with its slave. Being able to query the bridge's VLAN filtering state allows such drivers to forbid enslavement in case resource couldn't be allocated for a VLAN-aware bridge and also choose the correct initialization routine for the enslaved port, which is dependent on the bridge type. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5f9e27e commit 1f51445

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

include/linux/if_bridge.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,13 @@ static inline bool br_multicast_has_querier_adjacent(struct net_device *dev,
8080
}
8181
#endif
8282

83+
#if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_VLAN_FILTERING)
84+
bool br_vlan_enabled(const struct net_device *dev);
85+
#else
86+
static inline bool br_vlan_enabled(const struct net_device *dev)
87+
{
88+
return false;
89+
}
90+
#endif
91+
8392
#endif

net/bridge/br_if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void br_manage_promisc(struct net_bridge *br)
138138
/* If vlan filtering is disabled or bridge interface is placed
139139
* into promiscuous mode, place all ports in promiscuous mode.
140140
*/
141-
if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br))
141+
if ((br->dev->flags & IFF_PROMISC) || !br_vlan_enabled(br->dev))
142142
set_all = true;
143143

144144
list_for_each_entry(p, &br->port_list, list) {

net/bridge/br_mdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ static int br_mdb_add(struct sk_buff *skb, struct nlmsghdr *nlh,
599599
return -EINVAL;
600600

601601
vg = nbp_vlan_group(p);
602-
if (br_vlan_enabled(br) && vg && entry->vid == 0) {
602+
if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) {
603603
list_for_each_entry(v, &vg->vlan_list, vlist) {
604604
entry->vid = v->vid;
605605
err = __br_mdb_add(net, br, entry);
@@ -694,7 +694,7 @@ static int br_mdb_del(struct sk_buff *skb, struct nlmsghdr *nlh,
694694
return -EINVAL;
695695

696696
vg = nbp_vlan_group(p);
697-
if (br_vlan_enabled(br) && vg && entry->vid == 0) {
697+
if (br_vlan_enabled(br->dev) && vg && entry->vid == 0) {
698698
list_for_each_entry(v, &vg->vlan_list, vlist) {
699699
entry->vid = v->vid;
700700
err = __br_mdb_del(br, entry);

net/bridge/br_netlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ static int br_fill_info(struct sk_buff *skb, const struct net_device *brdev)
12511251
u32 ageing_time = jiffies_to_clock_t(br->ageing_time);
12521252
u32 stp_enabled = br->stp_enabled;
12531253
u16 priority = (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1];
1254-
u8 vlan_enabled = br_vlan_enabled(br);
1254+
u8 vlan_enabled = br_vlan_enabled(br->dev);
12551255
u64 clockval;
12561256

12571257
clockval = br_timer_value(&br->hello_timer);

net/bridge/br_private.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,6 @@ static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
854854
return vg->pvid;
855855
}
856856

857-
static inline int br_vlan_enabled(struct net_bridge *br)
858-
{
859-
return br->vlan_enabled;
860-
}
861857
#else
862858
static inline bool br_allowed_ingress(const struct net_bridge *br,
863859
struct net_bridge_vlan_group *vg,
@@ -945,11 +941,6 @@ static inline u16 br_get_pvid(const struct net_bridge_vlan_group *vg)
945941
return 0;
946942
}
947943

948-
static inline int br_vlan_enabled(struct net_bridge *br)
949-
{
950-
return 0;
951-
}
952-
953944
static inline int __br_vlan_filter_toggle(struct net_bridge *br,
954945
unsigned long val)
955946
{

net/bridge/br_vlan.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,14 @@ int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val)
706706
return __br_vlan_filter_toggle(br, val);
707707
}
708708

709+
bool br_vlan_enabled(const struct net_device *dev)
710+
{
711+
struct net_bridge *br = netdev_priv(dev);
712+
713+
return !!br->vlan_enabled;
714+
}
715+
EXPORT_SYMBOL_GPL(br_vlan_enabled);
716+
709717
int __br_vlan_set_proto(struct net_bridge *br, __be16 proto)
710718
{
711719
int err = 0;

0 commit comments

Comments
 (0)