Skip to content

Commit

Permalink
net: bridge: mcast: add wrappers for router node retrieval
Browse files Browse the repository at this point in the history
In preparation for the upcoming split of multicast router state into
their IPv4 and IPv6 variants and to avoid IPv6 #ifdef clutter later add
two wrapper functions for router node retrieval in the payload
forwarding code.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Linus Lüssing authored and David S. Miller committed May 13, 2021
1 parent ce6f709 commit 44ebb08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/bridge/br_forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
bool allow_mode_include = true;
struct hlist_node *rp;

rp = rcu_dereference(hlist_first_rcu(&br->ip4_mc_router_list));
rp = br_multicast_get_first_rport_node(br, skb);

if (mdst) {
p = rcu_dereference(mdst->ports);
if (br_multicast_should_handle_mode(br, mdst->addr.proto) &&
Expand All @@ -290,7 +291,7 @@ void br_multicast_flood(struct net_bridge_mdb_entry *mdst,
struct net_bridge_port *port, *lport, *rport;

lport = p ? p->key.port : NULL;
rport = hlist_entry_safe(rp, struct net_bridge_port, ip4_rlist);
rport = br_multicast_rport_from_node_skb(rp, skb);

if ((unsigned long)lport > (unsigned long)rport) {
port = lport;
Expand Down
10 changes: 10 additions & 0 deletions net/bridge/br_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,16 @@ static inline bool br_group_is_l2(const struct br_ip *group)
#define mlock_dereference(X, br) \
rcu_dereference_protected(X, lockdep_is_held(&br->multicast_lock))

static inline struct hlist_node *
br_multicast_get_first_rport_node(struct net_bridge *b, struct sk_buff *skb) {
return rcu_dereference(hlist_first_rcu(&b->ip4_mc_router_list));
}

static inline struct net_bridge_port *
br_multicast_rport_from_node_skb(struct hlist_node *rp, struct sk_buff *skb) {
return hlist_entry_safe(rp, struct net_bridge_port, ip4_rlist);
}

static inline bool br_multicast_is_router(struct net_bridge *br)
{
return br->multicast_router == 2 ||
Expand Down

0 comments on commit 44ebb08

Please sign in to comment.