net: use list_for_each_entry_safe for list iter
Commit <29e5375d7fcb5> ("add struct uncached_list->quarantine list") [tapd] https://tapd.woa.com/TS4Q/bugtrace/bugs/view/1020422414128561917 when del list entry in cycle create by list_for_each_entry shuld use list_for_each_entry_safe or a deadlock may raise fix <769ae85160> ("ipv4: add (struct uncached_list)->quarantine list") Reviewed-by: Hui Li <caelli@tencent.com> Signed-off-by: mengensun <mengensun@tencent.com> Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
This commit is contained in:
parent
fed4e5664b
commit
d5c14b99af
|
@ -1549,7 +1549,7 @@ void rt_del_uncached_list(struct rtable *rt)
|
|||
struct uncached_list *ul = rt->rt_uncached_list;
|
||||
|
||||
spin_lock_bh(&ul->lock);
|
||||
list_del(&rt->rt_uncached);
|
||||
list_del_init(&rt->rt_uncached);
|
||||
spin_unlock_bh(&ul->lock);
|
||||
}
|
||||
}
|
||||
|
@ -1564,14 +1564,16 @@ static void ipv4_dst_destroy(struct dst_entry *dst)
|
|||
|
||||
void rt_flush_dev(struct net_device *dev)
|
||||
{
|
||||
struct rtable *rt;
|
||||
struct rtable *rt, *safe;
|
||||
int cpu;
|
||||
|
||||
for_each_possible_cpu(cpu) {
|
||||
struct uncached_list *ul = &per_cpu(rt_uncached_list, cpu);
|
||||
if (list_empty(&ul->head))
|
||||
continue;
|
||||
|
||||
spin_lock_bh(&ul->lock);
|
||||
list_for_each_entry(rt, &ul->head, rt_uncached) {
|
||||
list_for_each_entry_safe(rt, safe, &ul->head, rt_uncached) {
|
||||
if (rt->dst.dev != dev)
|
||||
continue;
|
||||
rt->dst.dev = blackhole_netdev;
|
||||
|
|
Loading…
Reference in New Issue