Skip to content

Commit ed78530

Browse files
congwangdavem330
authored andcommitted
ipv4: take rtnl_lock and mark mrt table as freed on namespace cleanup
This is the IPv4 part for commit 905a6f9 (ipv6: take rtnl_lock and mark mrt6 table as freed on namespace cleanup). Cc: Hannes Frederic Sowa <[email protected]> Acked-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 666b805 commit ed78530

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/ipv4/ipmr.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ static void __net_exit ipmr_rules_exit(struct net *net)
278278
{
279279
struct mr_table *mrt, *next;
280280

281+
rtnl_lock();
281282
list_for_each_entry_safe(mrt, next, &net->ipv4.mr_tables, list) {
282283
list_del(&mrt->list);
283284
ipmr_free_table(mrt);
284285
}
286+
rtnl_unlock();
285287
fib_rules_unregister(net->ipv4.mr_rules_ops);
286288
}
287289
#else
@@ -308,7 +310,10 @@ static int __net_init ipmr_rules_init(struct net *net)
308310

309311
static void __net_exit ipmr_rules_exit(struct net *net)
310312
{
313+
rtnl_lock();
311314
ipmr_free_table(net->ipv4.mrt);
315+
net->ipv4.mrt = NULL;
316+
rtnl_unlock();
312317
}
313318
#endif
314319

0 commit comments

Comments
 (0)