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>
This commit is contained in:
Родитель
dcd79aebe7
Коммит
7e80c12448
|
@ -1039,22 +1039,25 @@ static int br_ip6_multicast_mld2_report(struct net_bridge *br,
|
||||||
}
|
}
|
||||||
#endif
|
#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,
|
static void br_multicast_add_router(struct net_bridge *br,
|
||||||
struct net_bridge_port *port)
|
struct net_bridge_port *port)
|
||||||
{
|
{
|
||||||
struct net_bridge_port *p;
|
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) {
|
hlist_for_each_entry(p, n, &br->router_list, rlist) {
|
||||||
if ((unsigned long) port >= (unsigned long) p) {
|
if ((unsigned long) port >= (unsigned long) p)
|
||||||
hlist_add_before_rcu(n, &port->rlist);
|
break;
|
||||||
return;
|
slot = n;
|
||||||
}
|
|
||||||
last = n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last)
|
if (slot)
|
||||||
hlist_add_after_rcu(last, &port->rlist);
|
hlist_add_after_rcu(slot, &port->rlist);
|
||||||
else
|
else
|
||||||
hlist_add_head_rcu(&port->rlist, &br->router_list);
|
hlist_add_head_rcu(&port->rlist, &br->router_list);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче