Skip to content

Commit 7e80c12

Browse files
stephen hemmingerdavem330
authored andcommitted
bridge: simplify multicast_add_router
By coding slightly differently, there are only two cases to deal with: add at head and add after previous entry. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent dcd79ae commit 7e80c12

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

‎net/bridge/br_multicast.c‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,22 +1039,25 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,
10391039
}
10401040
#endif
10411041

1042+
/*
1043+
* Add port to rotuer_list
1044+
* list is maintained ordered by pointer value
1045+
* and locked by br->multicast_lock and RCU
1046+
*/
10421047
static void br_multicast_add_router(struct net_bridge *br,
10431048
struct net_bridge_port *port)
10441049
{
10451050
struct net_bridge_port *p;
1046-
struct hlist_node *n, *last = NULL;
1051+
struct hlist_node *n, *slot = NULL;
10471052

10481053
hlist_for_each_entry(p, n, &br->router_list, rlist) {
1049-
if ((unsigned long) port >= (unsigned long) p) {
1050-
hlist_add_before_rcu(n, &port->rlist);
1051-
return;
1052-
}
1053-
last = n;
1054+
if ((unsigned long) port >= (unsigned long) p)
1055+
break;
1056+
slot = n;
10541057
}
10551058

1056-
if (last)
1057-
hlist_add_after_rcu(last, &port->rlist);
1059+
if (slot)
1060+
hlist_add_after_rcu(slot, &port->rlist);
10581061
else
10591062
hlist_add_head_rcu(&port->rlist, &br->router_list);
10601063
}

0 commit comments

Comments
 (0)