Skip to content

Commit

Permalink
bridge: simplify multicast_add_router
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stephen hemminger authored and David S. Miller committed Apr 28, 2010
1 parent dcd79ae commit 7e80c12
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions net/bridge/br_multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,22 +1039,25 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,
}
#endif

/*
* Add port to rotuer_list
* list is maintained ordered by pointer value
* and locked by br->multicast_lock and RCU
*/
static void br_multicast_add_router(struct net_bridge *br,
struct net_bridge_port *port)
{
struct net_bridge_port *p;
struct hlist_node *n, *last = NULL;
struct hlist_node *n, *slot = NULL;

hlist_for_each_entry(p, n, &br->router_list, rlist) {
if ((unsigned long) port >= (unsigned long) p) {
hlist_add_before_rcu(n, &port->rlist);
return;
}
last = n;
if ((unsigned long) port >= (unsigned long) p)
break;
slot = n;
}

if (last)
hlist_add_after_rcu(last, &port->rlist);
if (slot)
hlist_add_after_rcu(slot, &port->rlist);
else
hlist_add_head_rcu(&port->rlist, &br->router_list);
}
Expand Down

0 comments on commit 7e80c12

Please sign in to comment.