Commit 2430aa85 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Disable multicaststing configuration inside non-initial namespace.

Do not calls hooks from device notifiers and disallow configuration from
ioctl/netlink layer.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0c65babd
...@@ -1198,6 +1198,9 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) ...@@ -1198,6 +1198,9 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr)
ASSERT_RTNL(); ASSERT_RTNL();
if (in_dev->dev->nd_net != &init_net)
return;
for (im=in_dev->mc_list; im; im=im->next) { for (im=in_dev->mc_list; im; im=im->next) {
if (im->multiaddr == addr) { if (im->multiaddr == addr) {
im->users++; im->users++;
...@@ -1277,6 +1280,9 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr) ...@@ -1277,6 +1280,9 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr)
ASSERT_RTNL(); ASSERT_RTNL();
if (in_dev->dev->nd_net != &init_net)
return;
for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) {
if (i->multiaddr==addr) { if (i->multiaddr==addr) {
if (--i->users == 0) { if (--i->users == 0) {
...@@ -1304,6 +1310,9 @@ void ip_mc_down(struct in_device *in_dev) ...@@ -1304,6 +1310,9 @@ void ip_mc_down(struct in_device *in_dev)
ASSERT_RTNL(); ASSERT_RTNL();
if (in_dev->dev->nd_net != &init_net)
return;
for (i=in_dev->mc_list; i; i=i->next) for (i=in_dev->mc_list; i; i=i->next)
igmp_group_dropped(i); igmp_group_dropped(i);
...@@ -1324,6 +1333,9 @@ void ip_mc_init_dev(struct in_device *in_dev) ...@@ -1324,6 +1333,9 @@ void ip_mc_init_dev(struct in_device *in_dev)
{ {
ASSERT_RTNL(); ASSERT_RTNL();
if (in_dev->dev->nd_net != &init_net)
return;
in_dev->mc_tomb = NULL; in_dev->mc_tomb = NULL;
#ifdef CONFIG_IP_MULTICAST #ifdef CONFIG_IP_MULTICAST
in_dev->mr_gq_running = 0; in_dev->mr_gq_running = 0;
...@@ -1347,6 +1359,9 @@ void ip_mc_up(struct in_device *in_dev) ...@@ -1347,6 +1359,9 @@ void ip_mc_up(struct in_device *in_dev)
ASSERT_RTNL(); ASSERT_RTNL();
if (in_dev->dev->nd_net != &init_net)
return;
ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS);
for (i=in_dev->mc_list; i; i=i->next) for (i=in_dev->mc_list; i; i=i->next)
...@@ -1363,6 +1378,9 @@ void ip_mc_destroy_dev(struct in_device *in_dev) ...@@ -1363,6 +1378,9 @@ void ip_mc_destroy_dev(struct in_device *in_dev)
ASSERT_RTNL(); ASSERT_RTNL();
if (in_dev->dev->nd_net != &init_net)
return;
/* Deactivate timers */ /* Deactivate timers */
ip_mc_down(in_dev); ip_mc_down(in_dev);
...@@ -1744,6 +1762,9 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr) ...@@ -1744,6 +1762,9 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
if (!ipv4_is_multicast(addr)) if (!ipv4_is_multicast(addr))
return -EINVAL; return -EINVAL;
if (sk->sk_net != &init_net)
return -EPROTONOSUPPORT;
rtnl_lock(); rtnl_lock();
in_dev = ip_mc_find_dev(imr); in_dev = ip_mc_find_dev(imr);
...@@ -1812,6 +1833,9 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr) ...@@ -1812,6 +1833,9 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr)
u32 ifindex; u32 ifindex;
int ret = -EADDRNOTAVAIL; int ret = -EADDRNOTAVAIL;
if (sk->sk_net != &init_net)
return -EPROTONOSUPPORT;
rtnl_lock(); rtnl_lock();
in_dev = ip_mc_find_dev(imr); in_dev = ip_mc_find_dev(imr);
ifindex = imr->imr_ifindex; ifindex = imr->imr_ifindex;
...@@ -1857,6 +1881,9 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct ...@@ -1857,6 +1881,9 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
if (!ipv4_is_multicast(addr)) if (!ipv4_is_multicast(addr))
return -EINVAL; return -EINVAL;
if (sk->sk_net != &init_net)
return -EPROTONOSUPPORT;
rtnl_lock(); rtnl_lock();
imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr; imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr;
...@@ -1990,6 +2017,9 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) ...@@ -1990,6 +2017,9 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
msf->imsf_fmode != MCAST_EXCLUDE) msf->imsf_fmode != MCAST_EXCLUDE)
return -EINVAL; return -EINVAL;
if (sk->sk_net != &init_net)
return -EPROTONOSUPPORT;
rtnl_lock(); rtnl_lock();
imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
...@@ -2070,6 +2100,9 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf, ...@@ -2070,6 +2100,9 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
if (!ipv4_is_multicast(addr)) if (!ipv4_is_multicast(addr))
return -EINVAL; return -EINVAL;
if (sk->sk_net != &init_net)
return -EPROTONOSUPPORT;
rtnl_lock(); rtnl_lock();
imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
...@@ -2132,6 +2165,9 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, ...@@ -2132,6 +2165,9 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
if (!ipv4_is_multicast(addr)) if (!ipv4_is_multicast(addr))
return -EINVAL; return -EINVAL;
if (sk->sk_net != &init_net)
return -EPROTONOSUPPORT;
rtnl_lock(); rtnl_lock();
err = -EADDRNOTAVAIL; err = -EADDRNOTAVAIL;
...@@ -2216,6 +2252,9 @@ void ip_mc_drop_socket(struct sock *sk) ...@@ -2216,6 +2252,9 @@ void ip_mc_drop_socket(struct sock *sk)
if (inet->mc_list == NULL) if (inet->mc_list == NULL)
return; return;
if (sk->sk_net != &init_net)
return;
rtnl_lock(); rtnl_lock();
while ((iml = inet->mc_list) != NULL) { while ((iml = inet->mc_list) != NULL) {
struct in_device *in_dev; struct in_device *in_dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment