diff options
Diffstat (limited to 'net')
-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 6203ece53606..f70fac612596 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); |