[NET]: Modify all rtnetlink methods to only work in the initial namespace (v2)
[deliverable/linux.git] / net / bridge / br_netlink.c
index 53ab8e0cb5189c40a880b92b9b49e9c9e0aad85e..a4ffa2b63cd56e5222c8be089f94e1a5ae33b8e9 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/kernel.h>
 #include <net/rtnetlink.h>
 #include <net/net_namespace.h>
+#include <net/sock.h>
 #include "br_private.h"
 
 static inline size_t br_nlmsg_size(void)
@@ -107,9 +108,13 @@ errout:
  */
 static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 {
+       struct net *net = skb->sk->sk_net;
        struct net_device *dev;
        int idx;
 
+       if (net != &init_net)
+               return 0;
+
        idx = 0;
        for_each_netdev(&init_net, dev) {
                /* not a bridge port */
@@ -135,12 +140,16 @@ skip:
  */
 static int br_rtm_setlink(struct sk_buff *skb,  struct nlmsghdr *nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct ifinfomsg *ifm;
        struct nlattr *protinfo;
        struct net_device *dev;
        struct net_bridge_port *p;
        u8 new_state;
 
+       if (net != &init_net)
+               return -EINVAL;
+
        if (nlmsg_len(nlh) < sizeof(*ifm))
                return -EINVAL;
 
This page took 0.028593 seconds and 5 git commands to generate.