Skip to content

Commit 5af48b5

Browse files
Nikolay Aleksandrovdavem330
authored andcommitted
net: bridge: add per-port group_fwd_mask with less restrictions
We need to be able to transparently forward most link-local frames via tunnels (e.g. vxlan, qinq). Currently the bridge's group_fwd_mask has a mask which restricts the forwarding of STP and LACP, but we need to be able to forward these over tunnels and control that forwarding on a per-port basis thus add a new per-port group_fwd_mask option which only disallows mac pause frames to be forwarded (they're always dropped anyway). The patch does not change the current default situation - all of the others are still restricted unless configured for forwarding. We have successfully tested this patch with LACP and STP forwarding over VxLAN and qinq tunnels. Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent de9c8a6 commit 5af48b5

5 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎include/uapi/linux/if_link.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ enum {
325325
IFLA_BRPORT_MCAST_TO_UCAST,
326326
IFLA_BRPORT_VLAN_TUNNEL,
327327
IFLA_BRPORT_BCAST_FLOOD,
328+
IFLA_BRPORT_GROUP_FWD_MASK,
328329
__IFLA_BRPORT_MAX
329330
};
330331
#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)

‎net/bridge/br_input.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
289289
*
290290
* Others reserved for future standardization
291291
*/
292+
fwd_mask |= p->group_fwd_mask;
292293
switch (dest[5]) {
293294
case 0x00: /* Bridge Group Address */
294295
/* If STP is turned off,

‎net/bridge/br_netlink.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ static inline size_t br_port_info_size(void)
152152
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
153153
+ nla_total_size(sizeof(u8)) /* IFLA_BRPORT_MULTICAST_ROUTER */
154154
#endif
155+
+ nla_total_size(sizeof(u16)) /* IFLA_BRPORT_GROUP_FWD_MASK */
155156
+ 0;
156157
}
157158

@@ -208,7 +209,8 @@ static int br_port_fill_attrs(struct sk_buff *skb,
208209
p->topology_change_ack) ||
209210
nla_put_u8(skb, IFLA_BRPORT_CONFIG_PENDING, p->config_pending) ||
210211
nla_put_u8(skb, IFLA_BRPORT_VLAN_TUNNEL, !!(p->flags &
211-
BR_VLAN_TUNNEL)))
212+
BR_VLAN_TUNNEL)) ||
213+
nla_put_u16(skb, IFLA_BRPORT_GROUP_FWD_MASK, p->group_fwd_mask))
212214
return -EMSGSIZE;
213215

214216
timerval = br_timer_value(&p->message_age_timer);
@@ -637,6 +639,7 @@ static const struct nla_policy br_port_policy[IFLA_BRPORT_MAX + 1] = {
637639
[IFLA_BRPORT_MCAST_TO_UCAST] = { .type = NLA_U8 },
638640
[IFLA_BRPORT_MCAST_FLOOD] = { .type = NLA_U8 },
639641
[IFLA_BRPORT_BCAST_FLOOD] = { .type = NLA_U8 },
642+
[IFLA_BRPORT_GROUP_FWD_MASK] = { .type = NLA_U16 },
640643
};
641644

642645
/* Change the state of the port and notify spanning tree */
@@ -773,6 +776,15 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[])
773776
return err;
774777
}
775778
#endif
779+
780+
if (tb[IFLA_BRPORT_GROUP_FWD_MASK]) {
781+
u16 fwd_mask = nla_get_u16(tb[IFLA_BRPORT_GROUP_FWD_MASK]);
782+
783+
if (fwd_mask & BR_GROUPFWD_MACPAUSE)
784+
return -EINVAL;
785+
p->group_fwd_mask = fwd_mask;
786+
}
787+
776788
br_port_flags_change(p, old_flags ^ p->flags);
777789
return 0;
778790
}

‎net/bridge/br_private.h‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@
3636
/* Control of forwarding link local multicast */
3737
#define BR_GROUPFWD_DEFAULT 0
3838
/* Don't allow forwarding of control protocols like STP, MAC PAUSE and LACP */
39-
#define BR_GROUPFWD_RESTRICTED 0x0007u
39+
enum {
40+
BR_GROUPFWD_STP = BIT(0),
41+
BR_GROUPFWD_MACPAUSE = BIT(1),
42+
BR_GROUPFWD_LACP = BIT(2),
43+
};
44+
45+
#define BR_GROUPFWD_RESTRICTED (BR_GROUPFWD_STP | BR_GROUPFWD_MACPAUSE | \
46+
BR_GROUPFWD_LACP)
4047
/* The Nearest Customer Bridge Group Address, 01-80-C2-00-00-[00,0B,0C,0D,0F] */
4148
#define BR_GROUPFWD_8021AD 0xB801u
4249

@@ -268,6 +275,7 @@ struct net_bridge_port {
268275
#ifdef CONFIG_NET_SWITCHDEV
269276
int offload_fwd_mark;
270277
#endif
278+
u16 group_fwd_mask;
271279
};
272280

273281
#define br_auto_port(p) ((p)->flags & BR_AUTO_MASK)

‎net/bridge/br_sysfs_if.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,23 @@ static int store_flush(struct net_bridge_port *p, unsigned long v)
165165
}
166166
static BRPORT_ATTR(flush, S_IWUSR, NULL, store_flush);
167167

168+
static ssize_t show_group_fwd_mask(struct net_bridge_port *p, char *buf)
169+
{
170+
return sprintf(buf, "%#x\n", p->group_fwd_mask);
171+
}
172+
173+
static int store_group_fwd_mask(struct net_bridge_port *p,
174+
unsigned long v)
175+
{
176+
if (v & BR_GROUPFWD_MACPAUSE)
177+
return -EINVAL;
178+
p->group_fwd_mask = v;
179+
180+
return 0;
181+
}
182+
static BRPORT_ATTR(group_fwd_mask, S_IRUGO | S_IWUSR, show_group_fwd_mask,
183+
store_group_fwd_mask);
184+
168185
BRPORT_ATTR_FLAG(hairpin_mode, BR_HAIRPIN_MODE);
169186
BRPORT_ATTR_FLAG(bpdu_guard, BR_BPDU_GUARD);
170187
BRPORT_ATTR_FLAG(root_block, BR_ROOT_BLOCK);
@@ -223,6 +240,7 @@ static const struct brport_attribute *brport_attrs[] = {
223240
&brport_attr_proxyarp_wifi,
224241
&brport_attr_multicast_flood,
225242
&brport_attr_broadcast_flood,
243+
&brport_attr_group_fwd_mask,
226244
NULL
227245
};
228246

0 commit comments

Comments
 (0)