bridge: vlan: use rcu list for the ordered vlan list

When I did the conversion to rhashtable I missed the required locking of
one important user of the vlan list - br_get_link_af_size_filtered()
which is called:
br_ifinfo_notify() -> br_nlmsg_size() -> br_get_link_af_size_filtered()
and the notifications can be sent without holding rtnl. Before this
conversion the function relied on using rcu and since we already use rcu to
destroy the vlans, we can simply migrate the list to use the rcu helpers.

Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Nikolay Aleksandrov 2015-10-02 15:05:10 +02:00 коммит произвёл David S. Miller
Родитель e96f78ab27
Коммит 586c2b573e
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -34,7 +34,7 @@ static int __get_num_vlan_infos(struct net_bridge_vlan_group *vg,
pvid = br_get_pvid(vg); pvid = br_get_pvid(vg);
/* Count number of vlan infos */ /* Count number of vlan infos */
list_for_each_entry(v, &vg->vlan_list, vlist) { list_for_each_entry_rcu(v, &vg->vlan_list, vlist) {
flags = 0; flags = 0;
/* only a context, bridge vlan not activated */ /* only a context, bridge vlan not activated */
if (!br_vlan_should_use(v)) if (!br_vlan_should_use(v))
@ -76,13 +76,19 @@ initvars:
static int br_get_num_vlan_infos(struct net_bridge_vlan_group *vg, static int br_get_num_vlan_infos(struct net_bridge_vlan_group *vg,
u32 filter_mask) u32 filter_mask)
{ {
int num_vlans;
if (!vg) if (!vg)
return 0; return 0;
if (filter_mask & RTEXT_FILTER_BRVLAN) if (filter_mask & RTEXT_FILTER_BRVLAN)
return vg->num_vlans; return vg->num_vlans;
return __get_num_vlan_infos(vg, filter_mask); rcu_read_lock();
num_vlans = __get_num_vlan_infos(vg, filter_mask);
rcu_read_unlock();
return num_vlans;
} }
static size_t br_get_link_af_size_filtered(const struct net_device *dev, static size_t br_get_link_af_size_filtered(const struct net_device *dev,

Просмотреть файл

@ -111,12 +111,12 @@ static void __vlan_add_list(struct net_bridge_vlan *v)
else else
break; break;
} }
list_add(&v->vlist, hpos); list_add_rcu(&v->vlist, hpos);
} }
static void __vlan_del_list(struct net_bridge_vlan *v) static void __vlan_del_list(struct net_bridge_vlan *v)
{ {
list_del(&v->vlist); list_del_rcu(&v->vlist);
} }
static int __vlan_vid_del(struct net_device *dev, struct net_bridge *br, static int __vlan_vid_del(struct net_device *dev, struct net_bridge *br,