aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/netlink.h1
-rw-r--r--net/ipv4/fib_frontend.c5
-rw-r--r--net/ipv4/fib_semantics.c16
-rw-r--r--net/ipv6/ip6_fib.c4
-rw-r--r--net/ipv6/route.c8
5 files changed, 25 insertions, 9 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h
index a52d03601754..a5e6d0ef51dd 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -217,6 +217,7 @@ struct nla_policy {
217 */ 217 */
218struct nl_info { 218struct nl_info {
219 struct nlmsghdr *nlh; 219 struct nlmsghdr *nlh;
220 struct net *nl_net;
220 u32 pid; 221 u32 pid;
221}; 222};
222 223
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index d1a45cb6f6b0..90aa05f47f8e 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -310,6 +310,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt,
310 int plen; 310 int plen;
311 311
312 memset(cfg, 0, sizeof(*cfg)); 312 memset(cfg, 0, sizeof(*cfg));
313 cfg->fc_nlinfo.nl_net = &init_net;
313 314
314 if (rt->rt_dst.sa_family != AF_INET) 315 if (rt->rt_dst.sa_family != AF_INET)
315 return -EAFNOSUPPORT; 316 return -EAFNOSUPPORT;
@@ -516,6 +517,7 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh,
516 517
517 cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; 518 cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid;
518 cfg->fc_nlinfo.nlh = nlh; 519 cfg->fc_nlinfo.nlh = nlh;
520 cfg->fc_nlinfo.nl_net = &init_net;
519 521
520 if (cfg->fc_type > RTN_MAX) { 522 if (cfg->fc_type > RTN_MAX) {
521 err = -EINVAL; 523 err = -EINVAL;
@@ -670,6 +672,9 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad
670 .fc_prefsrc = ifa->ifa_local, 672 .fc_prefsrc = ifa->ifa_local,
671 .fc_oif = ifa->ifa_dev->dev->ifindex, 673 .fc_oif = ifa->ifa_dev->dev->ifindex,
672 .fc_nlflags = NLM_F_CREATE | NLM_F_APPEND, 674 .fc_nlflags = NLM_F_CREATE | NLM_F_APPEND,
675 .fc_nlinfo = {
676 .nl_net = &init_net,
677 },
673 }; 678 };
674 679
675 if (type == RTN_UNICAST) 680 if (type == RTN_UNICAST)
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index c1263e23876b..0de6102020e2 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -320,11 +320,11 @@ void rtmsg_fib(int event, __be32 key, struct fib_alias *fa,
320 kfree_skb(skb); 320 kfree_skb(skb);
321 goto errout; 321 goto errout;
322 } 322 }
323 err = rtnl_notify(skb, &init_net, info->pid, RTNLGRP_IPV4_ROUTE, 323 err = rtnl_notify(skb, info->nl_net, info->pid, RTNLGRP_IPV4_ROUTE,
324 info->nlh, GFP_KERNEL); 324 info->nlh, GFP_KERNEL);
325errout: 325errout:
326 if (err < 0) 326 if (err < 0)
327 rtnl_set_sk_err(&init_net, RTNLGRP_IPV4_ROUTE, err); 327 rtnl_set_sk_err(info->nl_net, RTNLGRP_IPV4_ROUTE, err);
328} 328}
329 329
330/* Return the first fib alias matching TOS with 330/* 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,
531 531
532 if (cfg->fc_scope >= RT_SCOPE_LINK) 532 if (cfg->fc_scope >= RT_SCOPE_LINK)
533 return -EINVAL; 533 return -EINVAL;
534 if (inet_addr_type(&init_net, nh->nh_gw) != RTN_UNICAST) 534 if (inet_addr_type(cfg->fc_nlinfo.nl_net,
535 nh->nh_gw) != RTN_UNICAST)
535 return -EINVAL; 536 return -EINVAL;
536 if ((dev = __dev_get_by_index(&init_net, nh->nh_oif)) == NULL) 537 if ((dev = __dev_get_by_index(cfg->fc_nlinfo.nl_net,
538 nh->nh_oif)) == NULL)
537 return -ENODEV; 539 return -ENODEV;
538 if (!(dev->flags&IFF_UP)) 540 if (!(dev->flags&IFF_UP))
539 return -ENETDOWN; 541 return -ENETDOWN;
@@ -795,7 +797,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
795 if (nhs != 1 || nh->nh_gw) 797 if (nhs != 1 || nh->nh_gw)
796 goto err_inval; 798 goto err_inval;
797 nh->nh_scope = RT_SCOPE_NOWHERE; 799 nh->nh_scope = RT_SCOPE_NOWHERE;
798 nh->nh_dev = dev_get_by_index(&init_net, fi->fib_nh->nh_oif); 800 nh->nh_dev = dev_get_by_index(cfg->fc_nlinfo.nl_net,
801 fi->fib_nh->nh_oif);
799 err = -ENODEV; 802 err = -ENODEV;
800 if (nh->nh_dev == NULL) 803 if (nh->nh_dev == NULL)
801 goto failure; 804 goto failure;
@@ -809,7 +812,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
809 if (fi->fib_prefsrc) { 812 if (fi->fib_prefsrc) {
810 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst || 813 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||
811 fi->fib_prefsrc != cfg->fc_dst) 814 fi->fib_prefsrc != cfg->fc_dst)
812 if (inet_addr_type(&init_net, fi->fib_prefsrc) != RTN_LOCAL) 815 if (inet_addr_type(cfg->fc_nlinfo.nl_net,
816 fi->fib_prefsrc) != RTN_LOCAL)
813 goto err_inval; 817 goto err_inval;
814 } 818 }
815 819
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 0e83164aa3e6..f93407cf6515 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1314,7 +1314,9 @@ static int fib6_walk(struct fib6_walker_t *w)
1314 1314
1315static int fib6_clean_node(struct fib6_walker_t *w) 1315static int fib6_clean_node(struct fib6_walker_t *w)
1316{ 1316{
1317 struct nl_info info = {}; 1317 struct nl_info info = {
1318 .nl_net = &init_net,
1319 };
1318 int res; 1320 int res;
1319 struct rt6_info *rt; 1321 struct rt6_info *rt;
1320 struct fib6_cleaner_t *c = container_of(w, struct fib6_cleaner_t, w); 1322 struct fib6_cleaner_t *c = container_of(w, struct fib6_cleaner_t, w);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index d2b3cf695aff..48c8d7cb9020 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -601,7 +601,9 @@ static int __ip6_ins_rt(struct rt6_info *rt, struct nl_info *info)
601 601
602int ip6_ins_rt(struct rt6_info *rt) 602int ip6_ins_rt(struct rt6_info *rt)
603{ 603{
604 struct nl_info info = {}; 604 struct nl_info info = {
605 .nl_net = &init_net,
606 };
605 return __ip6_ins_rt(rt, &info); 607 return __ip6_ins_rt(rt, &info);
606} 608}
607 609
@@ -1259,7 +1261,9 @@ static int __ip6_del_rt(struct rt6_info *rt, struct nl_info *info)
1259 1261
1260int ip6_del_rt(struct rt6_info *rt) 1262int ip6_del_rt(struct rt6_info *rt)
1261{ 1263{
1262 struct nl_info info = {}; 1264 struct nl_info info = {
1265 .nl_net = &init_net,
1266 };
1263 return __ip6_del_rt(rt, &info); 1267 return __ip6_del_rt(rt, &info);
1264} 1268}
1265 1269