diff options
author | stephen hemminger <shemminger@vyatta.com> | 2010-04-27 15:01:04 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-27 18:13:53 -0700 |
commit | 7e80c124485b73146deadce14fd4da2054581806 (patch) | |
tree | da7349b9a75f669bd317729543a51406c778727c | |
parent | dcd79aebe736e88d62aeb4a7712ac0ba7cc2aa96 (diff) | |
download | op-kernel-dev-7e80c124485b73146deadce14fd4da2054581806.zip op-kernel-dev-7e80c124485b73146deadce14fd4da2054581806.tar.gz |
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>
-rw-r--r-- | net/bridge/br_multicast.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index fcba313..d63868c 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -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); } |