aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2010-04-27 11:01:04 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-27 21:13:53 -0400
commit7e80c124485b73146deadce14fd4da2054581806 (patch)
treeda7349b9a75f669bd317729543a51406c778727c
parentdcd79aebe736e88d62aeb4a7712ac0ba7cc2aa96 (diff)
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.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index fcba313f1894..d63868c9b2c0 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,
1039} 1039}
1040#endif 1040#endif
1041 1041
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 */
1042static void br_multicast_add_router(struct net_bridge *br, 1047static void br_multicast_add_router(struct net_bridge *br,
1043 struct net_bridge_port *port) 1048 struct net_bridge_port *port)
1044{ 1049{
1045 struct net_bridge_port *p; 1050 struct net_bridge_port *p;
1046 struct hlist_node *n, *last = NULL; 1051 struct hlist_node *n, *slot = NULL;
1047 1052
1048 hlist_for_each_entry(p, n, &br->router_list, rlist) { 1053 hlist_for_each_entry(p, n, &br->router_list, rlist) {
1049 if ((unsigned long) port >= (unsigned long) p) { 1054 if ((unsigned long) port >= (unsigned long) p)
1050 hlist_add_before_rcu(n, &port->rlist); 1055 break;
1051 return; 1056 slot = n;
1052 }
1053 last = n;
1054 } 1057 }
1055 1058
1056 if (last) 1059 if (slot)
1057 hlist_add_after_rcu(last, &port->rlist); 1060 hlist_add_after_rcu(slot, &port->rlist);
1058 else 1061 else
1059 hlist_add_head_rcu(&port->rlist, &br->router_list); 1062 hlist_add_head_rcu(&port->rlist, &br->router_list);
1060} 1063}