[NETNS]: Add netns to nl_info structure.
authorDenis V. Lunev <den@openvz.org>
Thu, 10 Jan 2008 11:26:13 +0000 (03:26 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:01:29 +0000 (15:01 -0800)
nl_info is used to track the end-user destination of routing change
notification. This is a natural object to hold a namespace on. Place
it there and utilize the context in the appropriate places.

Acked-by: Benjamin Thery <benjamin.thery@bull.net>
Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netlink.h
net/ipv4/fib_frontend.c
net/ipv4/fib_semantics.c
net/ipv6/ip6_fib.c
net/ipv6/route.c

index a52d036017545cd2ca2a2a160218b0ae0aef64fd..a5e6d0ef51ddd52c425d05897887e35554bc55b0 100644 (file)
@@ -217,6 +217,7 @@ struct nla_policy {
  */
 struct nl_info {
        struct nlmsghdr         *nlh;
+       struct net              *nl_net;
        u32                     pid;
 };
 
index d1a45cb6f6b0cb997ed772219e79adb1df6ade9e..90aa05f47f8e3e9f84ba5f14b48907521607ee13 100644 (file)
@@ -310,6 +310,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
        int plen;
 
        memset(cfg, 0, sizeof(*cfg));
+       cfg->fc_nlinfo.nl_net = &init_net;
 
        if (rt->rt_dst.sa_family != AF_INET)
                return -EAFNOSUPPORT;
@@ -516,6 +517,7 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
 
        cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid;
        cfg->fc_nlinfo.nlh = nlh;
+       cfg->fc_nlinfo.nl_net = &init_net;
 
        if (cfg->fc_type > RTN_MAX) {
                err = -EINVAL;
@@ -670,6 +672,9 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad
                .fc_prefsrc = ifa->ifa_local,
                .fc_oif = ifa->ifa_dev->dev->ifindex,
                .fc_nlflags = NLM_F_CREATE | NLM_F_APPEND,
+               .fc_nlinfo = {
+                       .nl_net = &init_net,
+               },
        };
 
        if (type == RTN_UNICAST)
index c1263e23876be91c573e94fa25242cb206dafb00..0de6102020e23668a4c7c3fa35cd6df581f99361 100644 (file)
@@ -320,11 +320,11 @@ void rtmsg_fib(int event, __be32 key, struct fib_alias *fa,
                kfree_skb(skb);
                goto errout;
        }
-       err = rtnl_notify(skb, &init_net, info->pid, RTNLGRP_IPV4_ROUTE,
+       err = rtnl_notify(skb, info->nl_net, info->pid, RTNLGRP_IPV4_ROUTE,
                          info->nlh, GFP_KERNEL);
 errout:
        if (err < 0)
-               rtnl_set_sk_err(&init_net, RTNLGRP_IPV4_ROUTE, err);
+               rtnl_set_sk_err(info->nl_net, RTNLGRP_IPV4_ROUTE, err);
 }
 
 /* Return the first fib alias matching TOS with
@@ -531,9 +531,11 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
 
                        if (cfg->fc_scope >= RT_SCOPE_LINK)
                                return -EINVAL;
-                       if (inet_addr_type(&init_net, nh->nh_gw) != RTN_UNICAST)
+                       if (inet_addr_type(cfg->fc_nlinfo.nl_net,
+                                          nh->nh_gw) != RTN_UNICAST)
                                return -EINVAL;
-                       if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL)
+                       if ((dev = __dev_get_by_index(cfg->fc_nlinfo.nl_net,
+                                                     nh->nh_oif)) == NULL)
                                return -ENODEV;
                        if (!(dev->flags&IFF_UP))
                                return -ENETDOWN;
@@ -795,7 +797,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
                if (nhs != 1 || nh->nh_gw)
                        goto err_inval;
                nh->nh_scope = RT_SCOPE_NOWHERE;
-               nh->nh_dev = dev_get_by_index(&init_net, fi->fib_nh->nh_oif);
+               nh->nh_dev = dev_get_by_index(cfg->fc_nlinfo.nl_net,
+                                             fi->fib_nh->nh_oif);
                err = -ENODEV;
                if (nh->nh_dev == NULL)
                        goto failure;
@@ -809,7 +812,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
        if (fi->fib_prefsrc) {
                if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||
                    fi->fib_prefsrc != cfg->fc_dst)
-                       if (inet_addr_type(&init_net, fi->fib_prefsrc) != RTN_LOCAL)
+                       if (inet_addr_type(cfg->fc_nlinfo.nl_net,
+                                          fi->fib_prefsrc) != RTN_LOCAL)
                                goto err_inval;
        }
 
index 0e83164aa3e671b85b28aeee89aa93edaed45947..f93407cf651511ea9d4fa22b9c3f0f9ce94085fe 100644 (file)
@@ -1314,7 +1314,9 @@ static int fib6_walk(struct fib6_walker_t *w)
 
 static int fib6_clean_node(struct fib6_walker_t *w)
 {
-       struct nl_info info = {};
+       struct nl_info info = {
+               .nl_net = &init_net,
+       };
        int res;
        struct rt6_info *rt;
        struct fib6_cleaner_t *c = container_of(w, struct fib6_cleaner_t, w);
index d2b3cf695affeb96db1a54e3b10334ca8aa57306..48c8d7cb9020ba74c158b86398a2b5372e551188 100644 (file)
@@ -601,7 +601,9 @@ static int __ip6_ins_rt(struct rt6_info *rt, struct nl_info *info)
 
 int ip6_ins_rt(struct rt6_info *rt)
 {
-       struct nl_info info = {};
+       struct nl_info info = {
+               .nl_net = &init_net,
+       };
        return __ip6_ins_rt(rt, &info);
 }
 
@@ -1259,7 +1261,9 @@ static int __ip6_del_rt(struct rt6_info *rt, struct nl_info *info)
 
 int ip6_del_rt(struct rt6_info *rt)
 {
-       struct nl_info info = {};
+       struct nl_info info = {
+               .nl_net = &init_net,
+       };
        return __ip6_del_rt(rt, &info);
 }