]> Pileus Git - ~andy/linux/blobdiff - net/ipv4/devinet.c
netconf: advertise mc_forwarding status
[~andy/linux] / net / ipv4 / devinet.c
index 259622a5e690a1012443a3739ae4a457f6a1368b..cc06a47f12163ad8b93cae060a8c211bb13fcc73 100644 (file)
@@ -539,9 +539,6 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
 
        ASSERT_RTNL();
 
-       if (!capable(CAP_NET_ADMIN))
-               return -EPERM;
-
        err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv4_policy);
        if (err < 0)
                goto errout;
@@ -649,9 +646,6 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
 
        ASSERT_RTNL();
 
-       if (!capable(CAP_NET_ADMIN))
-               return -EPERM;
-
        ifa = rtm_to_ifaddr(net, nlh);
        if (IS_ERR(ifa))
                return PTR_ERR(ifa);
@@ -1459,6 +1453,8 @@ static int inet_netconf_msgsize_devconf(int type)
                size += nla_total_size(4);
        if (type == -1 || type == NETCONFA_RP_FILTER)
                size += nla_total_size(4);
+       if (type == -1 || type == NETCONFA_MC_FORWARDING)
+               size += nla_total_size(4);
 
        return size;
 }
@@ -1491,6 +1487,10 @@ static int inet_netconf_fill_devconf(struct sk_buff *skb, int ifindex,
            nla_put_s32(skb, NETCONFA_RP_FILTER,
                        IPV4_DEVCONF(*devconf, RP_FILTER)) < 0)
                goto nla_put_failure;
+       if ((type == -1 || type == NETCONFA_MC_FORWARDING) &&
+           nla_put_s32(skb, NETCONFA_MC_FORWARDING,
+                       IPV4_DEVCONF(*devconf, MC_FORWARDING)) < 0)
+               goto nla_put_failure;
 
        return nlmsg_end(skb, nlh);
 
@@ -1499,8 +1499,8 @@ nla_put_failure:
        return -EMSGSIZE;
 }
 
-static void inet_netconf_notify_devconf(struct net *net, int type, int ifindex,
-                                       struct ipv4_devconf *devconf)
+void inet_netconf_notify_devconf(struct net *net, int type, int ifindex,
+                                struct ipv4_devconf *devconf)
 {
        struct sk_buff *skb;
        int err = -ENOBUFS;
@@ -1821,10 +1821,6 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name,
                t->devinet_vars[i].extra2 = net;
        }
 
-       /* Don't export sysctls to unprivileged users */
-       if (net->user_ns != &init_user_ns)
-               t->devinet_vars[0].procname = NULL;
-
        snprintf(path, sizeof(path), "net/ipv4/conf/%s", dev_name);
 
        t->sysctl_header = register_net_sysctl(net, path, t->devinet_vars);
@@ -1910,10 +1906,6 @@ static __net_init int devinet_init_net(struct net *net)
                tbl[0].data = &all->data[IPV4_DEVCONF_FORWARDING - 1];
                tbl[0].extra1 = all;
                tbl[0].extra2 = net;
-
-               /* Don't export sysctls to unprivileged users */
-               if (net->user_ns != &init_user_ns)
-                       tbl[0].procname = NULL;
 #endif
        }