diff options
author | Daniel Lezcano <dlezcano@fr.ibm.com> | 2008-08-13 19:15:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-08-13 19:15:57 -0400 |
commit | 877acedc0d3ea07f7b36573ed2f1f479c2c1eefd (patch) | |
tree | 572dfad981cfd3f32e4661cb89cfc88def25bdf8 /net/ipv4 | |
parent | 1bb5bd2c713cdf19794996fafd7b48da4c4b0113 (diff) |
netns: Fix crash by making igmp per namespace
This patch makes the multicast socket to be per namespace.
When a network namespace is created, other than the init_net and a
multicast packet is received, the kernel goes to a hang or a kernel panic.
How to reproduce ?
* create a child network namespace
* create a pair virtual device veth
* ip link add type veth
* move one side to the pair network device to the child namespace
* ip link set netns <childpid> dev veth1
* ping -I veth0 224.0.0.1
The bug appears because the function ip_mc_init_dev does not initialize
the different multicast fields as it exits because it is not the init_net.
BUG: soft lockup - CPU#0 stuck for 61s! [avahi-daemon:2695]
Modules linked in:
irq event stamp: 50350
hardirqs last enabled at (50349): [<c03ee949>] _spin_unlock_irqrestore+0x34/0x39
hardirqs last disabled at (50350): [<c03ec639>] schedule+0x9f/0x5ff
softirqs last enabled at (45712): [<c0374d4b>] ip_setsockopt+0x8e7/0x909
softirqs last disabled at (45710): [<c03ee682>] _spin_lock_bh+0x8/0x27
Pid: 2695, comm: avahi-daemon Not tainted (2.6.27-rc2-00029-g0872073 #3)
EIP: 0060:[<c03ee47c>] EFLAGS: 00000297 CPU: 0
EIP is at __read_lock_failed+0x8/0x10
EAX: c4f38810 EBX: c4f38810 ECX: 00000000 EDX: c04cc22e
ESI: fb0000e0 EDI: 00000011 EBP: 0f02000a ESP: c4e3faa0
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
CR0: 8005003b CR2: 44618a40 CR3: 04e37000 CR4: 000006d0
DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
DR6: ffff0ff0 DR7: 00000400
[<c02311f8>] ? _raw_read_lock+0x23/0x25
[<c0390666>] ? ip_check_mc+0x1c/0x83
[<c036d478>] ? ip_route_input+0x229/0xe92
[<c022e2e4>] ? trace_hardirqs_on_thunk+0xc/0x10
[<c0104c9c>] ? do_IRQ+0x69/0x7d
[<c0102e64>] ? restore_nocheck_notrace+0x0/0xe
[<c036fdba>] ? ip_rcv+0x227/0x505
[<c0358764>] ? netif_receive_skb+0xfe/0x2b3
[<c03588d2>] ? netif_receive_skb+0x26c/0x2b3
[<c035af31>] ? process_backlog+0x73/0xbd
[<c035a8cd>] ? net_rx_action+0xc1/0x1ae
[<c01218a8>] ? __do_softirq+0x7b/0xef
[<c0121953>] ? do_softirq+0x37/0x4d
[<c035b50d>] ? dev_queue_xmit+0x3d4/0x40b
[<c0122037>] ? local_bh_enable+0x96/0xab
[<c035b50d>] ? dev_queue_xmit+0x3d4/0x40b
[<c012181e>] ? _local_bh_enable+0x79/0x88
[<c035fcb8>] ? neigh_resolve_output+0x20f/0x239
[<c0373118>] ? ip_finish_output+0x1df/0x209
[<c0373364>] ? ip_dev_loopback_xmit+0x62/0x66
[<c0371db5>] ? ip_local_out+0x15/0x17
[<c0372013>] ? ip_push_pending_frames+0x25c/0x2bb
[<c03891b8>] ? udp_push_pending_frames+0x2bb/0x30e
[<c038a189>] ? udp_sendmsg+0x413/0x51d
[<c038a1a9>] ? udp_sendmsg+0x433/0x51d
[<c038f927>] ? inet_sendmsg+0x35/0x3f
[<c034f092>] ? sock_sendmsg+0xb8/0xd1
[<c012d554>] ? autoremove_wake_function+0x0/0x2b
[<c022e6de>] ? copy_from_user+0x32/0x5e
[<c022e6de>] ? copy_from_user+0x32/0x5e
[<c034f238>] ? sys_sendmsg+0x18d/0x1f0
[<c0175e90>] ? pipe_write+0x3cb/0x3d7
[<c0170347>] ? do_sync_write+0xbe/0x105
[<c012d554>] ? autoremove_wake_function+0x0/0x2b
[<c03503b2>] ? sys_socketcall+0x176/0x1b0
[<c01085ea>] ? syscall_trace_enter+0x6c/0x7b
[<c0102e1a>] ? syscall_call+0x7/0xb
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/igmp.c | 71 |
1 files changed, 20 insertions, 51 deletions
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 6203ece5360..f70fac61259 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -289,6 +289,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) | |||
289 | struct rtable *rt; | 289 | struct rtable *rt; |
290 | struct iphdr *pip; | 290 | struct iphdr *pip; |
291 | struct igmpv3_report *pig; | 291 | struct igmpv3_report *pig; |
292 | struct net *net = dev_net(dev); | ||
292 | 293 | ||
293 | skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); | 294 | skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
294 | if (skb == NULL) | 295 | if (skb == NULL) |
@@ -299,7 +300,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) | |||
299 | .nl_u = { .ip4_u = { | 300 | .nl_u = { .ip4_u = { |
300 | .daddr = IGMPV3_ALL_MCR } }, | 301 | .daddr = IGMPV3_ALL_MCR } }, |
301 | .proto = IPPROTO_IGMP }; | 302 | .proto = IPPROTO_IGMP }; |
302 | if (ip_route_output_key(&init_net, &rt, &fl)) { | 303 | if (ip_route_output_key(net, &rt, &fl)) { |
303 | kfree_skb(skb); | 304 | kfree_skb(skb); |
304 | return NULL; | 305 | return NULL; |
305 | } | 306 | } |
@@ -629,6 +630,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, | |||
629 | struct igmphdr *ih; | 630 | struct igmphdr *ih; |
630 | struct rtable *rt; | 631 | struct rtable *rt; |
631 | struct net_device *dev = in_dev->dev; | 632 | struct net_device *dev = in_dev->dev; |
633 | struct net *net = dev_net(dev); | ||
632 | __be32 group = pmc ? pmc->multiaddr : 0; | 634 | __be32 group = pmc ? pmc->multiaddr : 0; |
633 | __be32 dst; | 635 | __be32 dst; |
634 | 636 | ||
@@ -643,7 +645,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, | |||
643 | struct flowi fl = { .oif = dev->ifindex, | 645 | struct flowi fl = { .oif = dev->ifindex, |
644 | .nl_u = { .ip4_u = { .daddr = dst } }, | 646 | .nl_u = { .ip4_u = { .daddr = dst } }, |
645 | .proto = IPPROTO_IGMP }; | 647 | .proto = IPPROTO_IGMP }; |
646 | if (ip_route_output_key(&init_net, &rt, &fl)) | 648 | if (ip_route_output_key(net, &rt, &fl)) |
647 | return -1; | 649 | return -1; |
648 | } | 650 | } |
649 | if (rt->rt_src == 0) { | 651 | if (rt->rt_src == 0) { |
@@ -1196,9 +1198,6 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) | |||
1196 | 1198 | ||
1197 | ASSERT_RTNL(); | 1199 | ASSERT_RTNL(); |
1198 | 1200 | ||
1199 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1200 | return; | ||
1201 | |||
1202 | for (im=in_dev->mc_list; im; im=im->next) { | 1201 | for (im=in_dev->mc_list; im; im=im->next) { |
1203 | if (im->multiaddr == addr) { | 1202 | if (im->multiaddr == addr) { |
1204 | im->users++; | 1203 | im->users++; |
@@ -1278,9 +1277,6 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr) | |||
1278 | 1277 | ||
1279 | ASSERT_RTNL(); | 1278 | ASSERT_RTNL(); |
1280 | 1279 | ||
1281 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1282 | return; | ||
1283 | |||
1284 | for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { | 1280 | for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { |
1285 | if (i->multiaddr==addr) { | 1281 | if (i->multiaddr==addr) { |
1286 | if (--i->users == 0) { | 1282 | if (--i->users == 0) { |
@@ -1308,9 +1304,6 @@ void ip_mc_down(struct in_device *in_dev) | |||
1308 | 1304 | ||
1309 | ASSERT_RTNL(); | 1305 | ASSERT_RTNL(); |
1310 | 1306 | ||
1311 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1312 | return; | ||
1313 | |||
1314 | for (i=in_dev->mc_list; i; i=i->next) | 1307 | for (i=in_dev->mc_list; i; i=i->next) |
1315 | igmp_group_dropped(i); | 1308 | igmp_group_dropped(i); |
1316 | 1309 | ||
@@ -1331,9 +1324,6 @@ void ip_mc_init_dev(struct in_device *in_dev) | |||
1331 | { | 1324 | { |
1332 | ASSERT_RTNL(); | 1325 | ASSERT_RTNL(); |
1333 | 1326 | ||
1334 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1335 | return; | ||
1336 | |||
1337 | in_dev->mc_tomb = NULL; | 1327 | in_dev->mc_tomb = NULL; |
1338 | #ifdef CONFIG_IP_MULTICAST | 1328 | #ifdef CONFIG_IP_MULTICAST |
1339 | in_dev->mr_gq_running = 0; | 1329 | in_dev->mr_gq_running = 0; |
@@ -1357,9 +1347,6 @@ void ip_mc_up(struct in_device *in_dev) | |||
1357 | 1347 | ||
1358 | ASSERT_RTNL(); | 1348 | ASSERT_RTNL(); |
1359 | 1349 | ||
1360 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1361 | return; | ||
1362 | |||
1363 | ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); | 1350 | ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); |
1364 | 1351 | ||
1365 | for (i=in_dev->mc_list; i; i=i->next) | 1352 | for (i=in_dev->mc_list; i; i=i->next) |
@@ -1376,9 +1363,6 @@ void ip_mc_destroy_dev(struct in_device *in_dev) | |||
1376 | 1363 | ||
1377 | ASSERT_RTNL(); | 1364 | ASSERT_RTNL(); |
1378 | 1365 | ||
1379 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1380 | return; | ||
1381 | |||
1382 | /* Deactivate timers */ | 1366 | /* Deactivate timers */ |
1383 | ip_mc_down(in_dev); | 1367 | ip_mc_down(in_dev); |
1384 | 1368 | ||
@@ -1395,7 +1379,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) | |||
1395 | write_unlock_bh(&in_dev->mc_list_lock); | 1379 | write_unlock_bh(&in_dev->mc_list_lock); |
1396 | } | 1380 | } |
1397 | 1381 | ||
1398 | static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) | 1382 | static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) |
1399 | { | 1383 | { |
1400 | struct flowi fl = { .nl_u = { .ip4_u = | 1384 | struct flowi fl = { .nl_u = { .ip4_u = |
1401 | { .daddr = imr->imr_multiaddr.s_addr } } }; | 1385 | { .daddr = imr->imr_multiaddr.s_addr } } }; |
@@ -1404,19 +1388,19 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) | |||
1404 | struct in_device *idev = NULL; | 1388 | struct in_device *idev = NULL; |
1405 | 1389 | ||
1406 | if (imr->imr_ifindex) { | 1390 | if (imr->imr_ifindex) { |
1407 | idev = inetdev_by_index(&init_net, imr->imr_ifindex); | 1391 | idev = inetdev_by_index(net, imr->imr_ifindex); |
1408 | if (idev) | 1392 | if (idev) |
1409 | __in_dev_put(idev); | 1393 | __in_dev_put(idev); |
1410 | return idev; | 1394 | return idev; |
1411 | } | 1395 | } |
1412 | if (imr->imr_address.s_addr) { | 1396 | if (imr->imr_address.s_addr) { |
1413 | dev = ip_dev_find(&init_net, imr->imr_address.s_addr); | 1397 | dev = ip_dev_find(net, imr->imr_address.s_addr); |
1414 | if (!dev) | 1398 | if (!dev) |
1415 | return NULL; | 1399 | return NULL; |
1416 | dev_put(dev); | 1400 | dev_put(dev); |
1417 | } | 1401 | } |
1418 | 1402 | ||
1419 | if (!dev && !ip_route_output_key(&init_net, &rt, &fl)) { | 1403 | if (!dev && !ip_route_output_key(net, &rt, &fl)) { |
1420 | dev = rt->u.dst.dev; | 1404 | dev = rt->u.dst.dev; |
1421 | ip_rt_put(rt); | 1405 | ip_rt_put(rt); |
1422 | } | 1406 | } |
@@ -1754,18 +1738,16 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr) | |||
1754 | struct ip_mc_socklist *iml=NULL, *i; | 1738 | struct ip_mc_socklist *iml=NULL, *i; |
1755 | struct in_device *in_dev; | 1739 | struct in_device *in_dev; |
1756 | struct inet_sock *inet = inet_sk(sk); | 1740 | struct inet_sock *inet = inet_sk(sk); |
1741 | struct net *net = sock_net(sk); | ||
1757 | int ifindex; | 1742 | int ifindex; |
1758 | int count = 0; | 1743 | int count = 0; |
1759 | 1744 | ||
1760 | if (!ipv4_is_multicast(addr)) | 1745 | if (!ipv4_is_multicast(addr)) |
1761 | return -EINVAL; | 1746 | return -EINVAL; |
1762 | 1747 | ||
1763 | if (!net_eq(sock_net(sk), &init_net)) | ||
1764 | return -EPROTONOSUPPORT; | ||
1765 | |||
1766 | rtnl_lock(); | 1748 | rtnl_lock(); |
1767 | 1749 | ||
1768 | in_dev = ip_mc_find_dev(imr); | 1750 | in_dev = ip_mc_find_dev(net, imr); |
1769 | 1751 | ||
1770 | if (!in_dev) { | 1752 | if (!in_dev) { |
1771 | iml = NULL; | 1753 | iml = NULL; |
@@ -1827,15 +1809,13 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr) | |||
1827 | struct inet_sock *inet = inet_sk(sk); | 1809 | struct inet_sock *inet = inet_sk(sk); |
1828 | struct ip_mc_socklist *iml, **imlp; | 1810 | struct ip_mc_socklist *iml, **imlp; |
1829 | struct in_device *in_dev; | 1811 | struct in_device *in_dev; |
1812 | struct net *net = sock_net(sk); | ||
1830 | __be32 group = imr->imr_multiaddr.s_addr; | 1813 | __be32 group = imr->imr_multiaddr.s_addr; |
1831 | u32 ifindex; | 1814 | u32 ifindex; |
1832 | int ret = -EADDRNOTAVAIL; | 1815 | int ret = -EADDRNOTAVAIL; |
1833 | 1816 | ||
1834 | if (!net_eq(sock_net(sk), &init_net)) | ||
1835 | return -EPROTONOSUPPORT; | ||
1836 | |||
1837 | rtnl_lock(); | 1817 | rtnl_lock(); |
1838 | in_dev = ip_mc_find_dev(imr); | 1818 | in_dev = ip_mc_find_dev(net, imr); |
1839 | ifindex = imr->imr_ifindex; | 1819 | ifindex = imr->imr_ifindex; |
1840 | for (imlp = &inet->mc_list; (iml = *imlp) != NULL; imlp = &iml->next) { | 1820 | for (imlp = &inet->mc_list; (iml = *imlp) != NULL; imlp = &iml->next) { |
1841 | if (iml->multi.imr_multiaddr.s_addr != group) | 1821 | if (iml->multi.imr_multiaddr.s_addr != group) |
@@ -1873,21 +1853,19 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct | |||
1873 | struct in_device *in_dev = NULL; | 1853 | struct in_device *in_dev = NULL; |
1874 | struct inet_sock *inet = inet_sk(sk); | 1854 | struct inet_sock *inet = inet_sk(sk); |
1875 | struct ip_sf_socklist *psl; | 1855 | struct ip_sf_socklist *psl; |
1856 | struct net *net = sock_net(sk); | ||
1876 | int leavegroup = 0; | 1857 | int leavegroup = 0; |
1877 | int i, j, rv; | 1858 | int i, j, rv; |
1878 | 1859 | ||
1879 | if (!ipv4_is_multicast(addr)) | 1860 | if (!ipv4_is_multicast(addr)) |
1880 | return -EINVAL; | 1861 | return -EINVAL; |
1881 | 1862 | ||
1882 | if (!net_eq(sock_net(sk), &init_net)) | ||
1883 | return -EPROTONOSUPPORT; | ||
1884 | |||
1885 | rtnl_lock(); | 1863 | rtnl_lock(); |
1886 | 1864 | ||
1887 | imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr; | 1865 | imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr; |
1888 | imr.imr_address.s_addr = mreqs->imr_interface; | 1866 | imr.imr_address.s_addr = mreqs->imr_interface; |
1889 | imr.imr_ifindex = ifindex; | 1867 | imr.imr_ifindex = ifindex; |
1890 | in_dev = ip_mc_find_dev(&imr); | 1868 | in_dev = ip_mc_find_dev(net, &imr); |
1891 | 1869 | ||
1892 | if (!in_dev) { | 1870 | if (!in_dev) { |
1893 | err = -ENODEV; | 1871 | err = -ENODEV; |
@@ -2007,6 +1985,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) | |||
2007 | struct in_device *in_dev; | 1985 | struct in_device *in_dev; |
2008 | struct inet_sock *inet = inet_sk(sk); | 1986 | struct inet_sock *inet = inet_sk(sk); |
2009 | struct ip_sf_socklist *newpsl, *psl; | 1987 | struct ip_sf_socklist *newpsl, *psl; |
1988 | struct net *net = sock_net(sk); | ||
2010 | int leavegroup = 0; | 1989 | int leavegroup = 0; |
2011 | 1990 | ||
2012 | if (!ipv4_is_multicast(addr)) | 1991 | if (!ipv4_is_multicast(addr)) |
@@ -2015,15 +1994,12 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) | |||
2015 | msf->imsf_fmode != MCAST_EXCLUDE) | 1994 | msf->imsf_fmode != MCAST_EXCLUDE) |
2016 | return -EINVAL; | 1995 | return -EINVAL; |
2017 | 1996 | ||
2018 | if (!net_eq(sock_net(sk), &init_net)) | ||
2019 | return -EPROTONOSUPPORT; | ||
2020 | |||
2021 | rtnl_lock(); | 1997 | rtnl_lock(); |
2022 | 1998 | ||
2023 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; | 1999 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; |
2024 | imr.imr_address.s_addr = msf->imsf_interface; | 2000 | imr.imr_address.s_addr = msf->imsf_interface; |
2025 | imr.imr_ifindex = ifindex; | 2001 | imr.imr_ifindex = ifindex; |
2026 | in_dev = ip_mc_find_dev(&imr); | 2002 | in_dev = ip_mc_find_dev(net, &imr); |
2027 | 2003 | ||
2028 | if (!in_dev) { | 2004 | if (!in_dev) { |
2029 | err = -ENODEV; | 2005 | err = -ENODEV; |
@@ -2094,19 +2070,17 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf, | |||
2094 | struct in_device *in_dev; | 2070 | struct in_device *in_dev; |
2095 | struct inet_sock *inet = inet_sk(sk); | 2071 | struct inet_sock *inet = inet_sk(sk); |
2096 | struct ip_sf_socklist *psl; | 2072 | struct ip_sf_socklist *psl; |
2073 | struct net *net = sock_net(sk); | ||
2097 | 2074 | ||
2098 | if (!ipv4_is_multicast(addr)) | 2075 | if (!ipv4_is_multicast(addr)) |
2099 | return -EINVAL; | 2076 | return -EINVAL; |
2100 | 2077 | ||
2101 | if (!net_eq(sock_net(sk), &init_net)) | ||
2102 | return -EPROTONOSUPPORT; | ||
2103 | |||
2104 | rtnl_lock(); | 2078 | rtnl_lock(); |
2105 | 2079 | ||
2106 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; | 2080 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; |
2107 | imr.imr_address.s_addr = msf->imsf_interface; | 2081 | imr.imr_address.s_addr = msf->imsf_interface; |
2108 | imr.imr_ifindex = 0; | 2082 | imr.imr_ifindex = 0; |
2109 | in_dev = ip_mc_find_dev(&imr); | 2083 | in_dev = ip_mc_find_dev(net, &imr); |
2110 | 2084 | ||
2111 | if (!in_dev) { | 2085 | if (!in_dev) { |
2112 | err = -ENODEV; | 2086 | err = -ENODEV; |
@@ -2163,9 +2137,6 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, | |||
2163 | if (!ipv4_is_multicast(addr)) | 2137 | if (!ipv4_is_multicast(addr)) |
2164 | return -EINVAL; | 2138 | return -EINVAL; |
2165 | 2139 | ||
2166 | if (!net_eq(sock_net(sk), &init_net)) | ||
2167 | return -EPROTONOSUPPORT; | ||
2168 | |||
2169 | rtnl_lock(); | 2140 | rtnl_lock(); |
2170 | 2141 | ||
2171 | err = -EADDRNOTAVAIL; | 2142 | err = -EADDRNOTAVAIL; |
@@ -2246,19 +2217,17 @@ void ip_mc_drop_socket(struct sock *sk) | |||
2246 | { | 2217 | { |
2247 | struct inet_sock *inet = inet_sk(sk); | 2218 | struct inet_sock *inet = inet_sk(sk); |
2248 | struct ip_mc_socklist *iml; | 2219 | struct ip_mc_socklist *iml; |
2220 | struct net *net = sock_net(sk); | ||
2249 | 2221 | ||
2250 | if (inet->mc_list == NULL) | 2222 | if (inet->mc_list == NULL) |
2251 | return; | 2223 | return; |
2252 | 2224 | ||
2253 | if (!net_eq(sock_net(sk), &init_net)) | ||
2254 | return; | ||
2255 | |||
2256 | rtnl_lock(); | 2225 | rtnl_lock(); |
2257 | while ((iml = inet->mc_list) != NULL) { | 2226 | while ((iml = inet->mc_list) != NULL) { |
2258 | struct in_device *in_dev; | 2227 | struct in_device *in_dev; |
2259 | inet->mc_list = iml->next; | 2228 | inet->mc_list = iml->next; |
2260 | 2229 | ||
2261 | in_dev = inetdev_by_index(&init_net, iml->multi.imr_ifindex); | 2230 | in_dev = inetdev_by_index(net, iml->multi.imr_ifindex); |
2262 | (void) ip_mc_leave_src(sk, iml, in_dev); | 2231 | (void) ip_mc_leave_src(sk, iml, in_dev); |
2263 | if (in_dev != NULL) { | 2232 | if (in_dev != NULL) { |
2264 | ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); | 2233 | ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); |