[NET]: Make the device list and device lookups per namespace.
[pandora-kernel.git] / net / core / fib_rules.c
index 8c5474e..1ba71ba 100644 (file)
@@ -11,6 +11,8 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/list.h>
+#include <net/net_namespace.h>
+#include <net/sock.h>
 #include <net/fib_rules.h>
 
 static LIST_HEAD(rules_ops);
@@ -197,6 +199,7 @@ errout:
 
 static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 {
+       struct net *net = skb->sk->sk_net;
        struct fib_rule_hdr *frh = nlmsg_data(nlh);
        struct fib_rules_ops *ops = NULL;
        struct fib_rule *rule, *r, *last = NULL;
@@ -234,7 +237,7 @@ static int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
 
                rule->ifindex = -1;
                nla_strlcpy(rule->ifname, tb[FRA_IFNAME], IFNAMSIZ);
-               dev = __dev_get_by_name(rule->ifname);
+               dev = __dev_get_by_name(net, rule->ifname);
                if (dev)
                        rule->ifindex = dev->ifindex;
        }
@@ -596,6 +599,9 @@ static int fib_rules_event(struct notifier_block *this, unsigned long event,
        struct net_device *dev = ptr;
        struct fib_rules_ops *ops;
 
+       if (dev->nd_net != &init_net)
+               return NOTIFY_DONE;
+
        ASSERT_RTNL();
        rcu_read_lock();