Skip to content

Commit 6536993

Browse files
HoratiuVulturdavem330
authored andcommitted
bridge: mrp: Integrate MRP into the bridge
To integrate MRP into the bridge, the bridge needs to do the following: - detect if the MRP frame was received on MRP ring port in that case it would be processed otherwise just forward it as usual. - enable parsing of MRP - before whenever the bridge was set up, it would set all the ports in forwarding state. Add an extra check to not set ports in forwarding state if the port is an MRP ring port. The reason of this change is that if the MRP instance initially sets the port in blocked state by setting the bridge up it would overwrite this setting. Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4d02b8f commit 6536993

5 files changed

Lines changed: 44 additions & 0 deletions

File tree

‎net/bridge/br_device.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ void br_dev_setup(struct net_device *dev)
463463
spin_lock_init(&br->lock);
464464
INIT_LIST_HEAD(&br->port_list);
465465
INIT_HLIST_HEAD(&br->fdb_list);
466+
#if IS_ENABLED(CONFIG_BRIDGE_MRP)
467+
INIT_LIST_HEAD(&br->mrp_list);
468+
#endif
466469
spin_lock_init(&br->hash_lock);
467470

468471
br->bridge_id.prio[0] = 0x80;

‎net/bridge/br_if.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ static void del_nbp(struct net_bridge_port *p)
333333
br_stp_disable_port(p);
334334
spin_unlock_bh(&br->lock);
335335

336+
br_mrp_port_del(br, p);
337+
336338
br_ifinfo_notify(RTM_DELLINK, NULL, p);
337339

338340
list_del_rcu(&p->list);

‎net/bridge/br_input.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
342342
}
343343
}
344344

345+
if (unlikely(br_mrp_process(p, skb)))
346+
return RX_HANDLER_PASS;
347+
345348
forward:
346349
switch (p->state) {
347350
case BR_STATE_FORWARDING:

‎net/bridge/br_netlink.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,11 @@ static int br_afspec(struct net_bridge *br,
672672
if (err)
673673
return err;
674674
break;
675+
case IFLA_BRIDGE_MRP:
676+
err = br_mrp_parse(br, p, attr, cmd, extack);
677+
if (err)
678+
return err;
679+
break;
675680
}
676681
}
677682

‎net/bridge/br_private.h‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,37 @@ unsigned long br_timer_value(const struct timer_list *timer);
13081308
extern int (*br_fdb_test_addr_hook)(struct net_device *dev, unsigned char *addr);
13091309
#endif
13101310

1311+
/* br_mrp.c */
1312+
#if IS_ENABLED(CONFIG_BRIDGE_MRP)
1313+
int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
1314+
struct nlattr *attr, int cmd, struct netlink_ext_ack *extack);
1315+
int br_mrp_process(struct net_bridge_port *p, struct sk_buff *skb);
1316+
bool br_mrp_enabled(struct net_bridge *br);
1317+
void br_mrp_port_del(struct net_bridge *br, struct net_bridge_port *p);
1318+
#else
1319+
static inline int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
1320+
struct nlattr *attr, int cmd,
1321+
struct netlink_ext_ack *extack)
1322+
{
1323+
return -EOPNOTSUPP;
1324+
}
1325+
1326+
static inline int br_mrp_process(struct net_bridge_port *p, struct sk_buff *skb)
1327+
{
1328+
return 0;
1329+
}
1330+
1331+
static inline bool br_mrp_enabled(struct net_bridge *br)
1332+
{
1333+
return 0;
1334+
}
1335+
1336+
static inline void br_mrp_port_del(struct net_bridge *br,
1337+
struct net_bridge_port *p)
1338+
{
1339+
}
1340+
#endif
1341+
13111342
/* br_netlink.c */
13121343
extern struct rtnl_link_ops br_link_ops;
13131344
int br_netlink_init(void);

0 commit comments

Comments
 (0)