diff options
-rw-r--r-- | net/ipv4/fib_frontend.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index a5e81677a2b5..8b44e3195242 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -305,14 +305,14 @@ static int put_rtax(struct nlattr *mx, int len, int type, u32 value) | |||
305 | return len + nla_total_size(4); | 305 | return len + nla_total_size(4); |
306 | } | 306 | } |
307 | 307 | ||
308 | static int rtentry_to_fib_config(int cmd, struct rtentry *rt, | 308 | static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt, |
309 | struct fib_config *cfg) | 309 | struct fib_config *cfg) |
310 | { | 310 | { |
311 | __be32 addr; | 311 | __be32 addr; |
312 | int plen; | 312 | int plen; |
313 | 313 | ||
314 | memset(cfg, 0, sizeof(*cfg)); | 314 | memset(cfg, 0, sizeof(*cfg)); |
315 | cfg->fc_nlinfo.nl_net = &init_net; | 315 | cfg->fc_nlinfo.nl_net = net; |
316 | 316 | ||
317 | if (rt->rt_dst.sa_family != AF_INET) | 317 | if (rt->rt_dst.sa_family != AF_INET) |
318 | return -EAFNOSUPPORT; | 318 | return -EAFNOSUPPORT; |
@@ -373,7 +373,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt, | |||
373 | colon = strchr(devname, ':'); | 373 | colon = strchr(devname, ':'); |
374 | if (colon) | 374 | if (colon) |
375 | *colon = 0; | 375 | *colon = 0; |
376 | dev = __dev_get_by_name(&init_net, devname); | 376 | dev = __dev_get_by_name(net, devname); |
377 | if (!dev) | 377 | if (!dev) |
378 | return -ENODEV; | 378 | return -ENODEV; |
379 | cfg->fc_oif = dev->ifindex; | 379 | cfg->fc_oif = dev->ifindex; |
@@ -396,7 +396,7 @@ static int rtentry_to_fib_config(int cmd, struct rtentry *rt, | |||
396 | if (rt->rt_gateway.sa_family == AF_INET && addr) { | 396 | if (rt->rt_gateway.sa_family == AF_INET && addr) { |
397 | cfg->fc_gw = addr; | 397 | cfg->fc_gw = addr; |
398 | if (rt->rt_flags & RTF_GATEWAY && | 398 | if (rt->rt_flags & RTF_GATEWAY && |
399 | inet_addr_type(&init_net, addr) == RTN_UNICAST) | 399 | inet_addr_type(net, addr) == RTN_UNICAST) |
400 | cfg->fc_scope = RT_SCOPE_UNIVERSE; | 400 | cfg->fc_scope = RT_SCOPE_UNIVERSE; |
401 | } | 401 | } |
402 | 402 | ||
@@ -453,7 +453,7 @@ int ip_rt_ioctl(unsigned int cmd, void __user *arg) | |||
453 | return -EFAULT; | 453 | return -EFAULT; |
454 | 454 | ||
455 | rtnl_lock(); | 455 | rtnl_lock(); |
456 | err = rtentry_to_fib_config(cmd, &rt, &cfg); | 456 | err = rtentry_to_fib_config(&init_net, cmd, &rt, &cfg); |
457 | if (err == 0) { | 457 | if (err == 0) { |
458 | struct fib_table *tb; | 458 | struct fib_table *tb; |
459 | 459 | ||
@@ -494,8 +494,8 @@ const struct nla_policy rtm_ipv4_policy[RTA_MAX+1] = { | |||
494 | [RTA_FLOW] = { .type = NLA_U32 }, | 494 | [RTA_FLOW] = { .type = NLA_U32 }, |
495 | }; | 495 | }; |
496 | 496 | ||
497 | static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh, | 497 | static int rtm_to_fib_config(struct net *net, struct sk_buff *skb, |
498 | struct fib_config *cfg) | 498 | struct nlmsghdr *nlh, struct fib_config *cfg) |
499 | { | 499 | { |
500 | struct nlattr *attr; | 500 | struct nlattr *attr; |
501 | int err, remaining; | 501 | int err, remaining; |
@@ -519,7 +519,7 @@ static int rtm_to_fib_config(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
519 | 519 | ||
520 | cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; | 520 | cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; |
521 | cfg->fc_nlinfo.nlh = nlh; | 521 | cfg->fc_nlinfo.nlh = nlh; |
522 | cfg->fc_nlinfo.nl_net = &init_net; | 522 | cfg->fc_nlinfo.nl_net = net; |
523 | 523 | ||
524 | if (cfg->fc_type > RTN_MAX) { | 524 | if (cfg->fc_type > RTN_MAX) { |
525 | err = -EINVAL; | 525 | err = -EINVAL; |
@@ -575,7 +575,7 @@ static int inet_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *ar | |||
575 | if (net != &init_net) | 575 | if (net != &init_net) |
576 | return -EINVAL; | 576 | return -EINVAL; |
577 | 577 | ||
578 | err = rtm_to_fib_config(skb, nlh, &cfg); | 578 | err = rtm_to_fib_config(net, skb, nlh, &cfg); |
579 | if (err < 0) | 579 | if (err < 0) |
580 | goto errout; | 580 | goto errout; |
581 | 581 | ||
@@ -600,7 +600,7 @@ static int inet_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *ar | |||
600 | if (net != &init_net) | 600 | if (net != &init_net) |
601 | return -EINVAL; | 601 | return -EINVAL; |
602 | 602 | ||
603 | err = rtm_to_fib_config(skb, nlh, &cfg); | 603 | err = rtm_to_fib_config(net, skb, nlh, &cfg); |
604 | if (err < 0) | 604 | if (err < 0) |
605 | goto errout; | 605 | goto errout; |
606 | 606 | ||
@@ -667,6 +667,7 @@ out: | |||
667 | 667 | ||
668 | static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa) | 668 | static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa) |
669 | { | 669 | { |
670 | struct net *net = ifa->ifa_dev->dev->nd_net; | ||
670 | struct fib_table *tb; | 671 | struct fib_table *tb; |
671 | struct fib_config cfg = { | 672 | struct fib_config cfg = { |
672 | .fc_protocol = RTPROT_KERNEL, | 673 | .fc_protocol = RTPROT_KERNEL, |
@@ -677,14 +678,14 @@ static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifad | |||
677 | .fc_oif = ifa->ifa_dev->dev->ifindex, | 678 | .fc_oif = ifa->ifa_dev->dev->ifindex, |
678 | .fc_nlflags = NLM_F_CREATE | NLM_F_APPEND, | 679 | .fc_nlflags = NLM_F_CREATE | NLM_F_APPEND, |
679 | .fc_nlinfo = { | 680 | .fc_nlinfo = { |
680 | .nl_net = &init_net, | 681 | .nl_net = net, |
681 | }, | 682 | }, |
682 | }; | 683 | }; |
683 | 684 | ||
684 | if (type == RTN_UNICAST) | 685 | if (type == RTN_UNICAST) |
685 | tb = fib_new_table(&init_net, RT_TABLE_MAIN); | 686 | tb = fib_new_table(net, RT_TABLE_MAIN); |
686 | else | 687 | else |
687 | tb = fib_new_table(&init_net, RT_TABLE_LOCAL); | 688 | tb = fib_new_table(net, RT_TABLE_LOCAL); |
688 | 689 | ||
689 | if (tb == NULL) | 690 | if (tb == NULL) |
690 | return; | 691 | return; |