diff options
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 606 |
1 files changed, 396 insertions, 210 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index e8b241cb60bc..cd82b6db35ff 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <linux/if_arp.h> | 40 | #include <linux/if_arp.h> |
41 | #include <linux/proc_fs.h> | 41 | #include <linux/proc_fs.h> |
42 | #include <linux/seq_file.h> | 42 | #include <linux/seq_file.h> |
43 | #include <linux/nsproxy.h> | ||
43 | #include <net/net_namespace.h> | 44 | #include <net/net_namespace.h> |
44 | #include <net/snmp.h> | 45 | #include <net/snmp.h> |
45 | #include <net/ipv6.h> | 46 | #include <net/ipv6.h> |
@@ -87,14 +88,16 @@ static void ip6_link_failure(struct sk_buff *skb); | |||
87 | static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu); | 88 | static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu); |
88 | 89 | ||
89 | #ifdef CONFIG_IPV6_ROUTE_INFO | 90 | #ifdef CONFIG_IPV6_ROUTE_INFO |
90 | static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixlen, | 91 | static struct rt6_info *rt6_add_route_info(struct net *net, |
92 | struct in6_addr *prefix, int prefixlen, | ||
91 | struct in6_addr *gwaddr, int ifindex, | 93 | struct in6_addr *gwaddr, int ifindex, |
92 | unsigned pref); | 94 | unsigned pref); |
93 | static struct rt6_info *rt6_get_route_info(struct in6_addr *prefix, int prefixlen, | 95 | static struct rt6_info *rt6_get_route_info(struct net *net, |
96 | struct in6_addr *prefix, int prefixlen, | ||
94 | struct in6_addr *gwaddr, int ifindex); | 97 | struct in6_addr *gwaddr, int ifindex); |
95 | #endif | 98 | #endif |
96 | 99 | ||
97 | static struct dst_ops ip6_dst_ops = { | 100 | static struct dst_ops ip6_dst_ops_template = { |
98 | .family = AF_INET6, | 101 | .family = AF_INET6, |
99 | .protocol = __constant_htons(ETH_P_IPV6), | 102 | .protocol = __constant_htons(ETH_P_IPV6), |
100 | .gc = ip6_dst_gc, | 103 | .gc = ip6_dst_gc, |
@@ -124,7 +127,7 @@ static struct dst_ops ip6_dst_blackhole_ops = { | |||
124 | .entries = ATOMIC_INIT(0), | 127 | .entries = ATOMIC_INIT(0), |
125 | }; | 128 | }; |
126 | 129 | ||
127 | struct rt6_info ip6_null_entry = { | 130 | static struct rt6_info ip6_null_entry_template = { |
128 | .u = { | 131 | .u = { |
129 | .dst = { | 132 | .dst = { |
130 | .__refcnt = ATOMIC_INIT(1), | 133 | .__refcnt = ATOMIC_INIT(1), |
@@ -134,8 +137,6 @@ struct rt6_info ip6_null_entry = { | |||
134 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | 137 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, |
135 | .input = ip6_pkt_discard, | 138 | .input = ip6_pkt_discard, |
136 | .output = ip6_pkt_discard_out, | 139 | .output = ip6_pkt_discard_out, |
137 | .ops = &ip6_dst_ops, | ||
138 | .path = (struct dst_entry*)&ip6_null_entry, | ||
139 | } | 140 | } |
140 | }, | 141 | }, |
141 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), | 142 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), |
@@ -148,7 +149,7 @@ struct rt6_info ip6_null_entry = { | |||
148 | static int ip6_pkt_prohibit(struct sk_buff *skb); | 149 | static int ip6_pkt_prohibit(struct sk_buff *skb); |
149 | static int ip6_pkt_prohibit_out(struct sk_buff *skb); | 150 | static int ip6_pkt_prohibit_out(struct sk_buff *skb); |
150 | 151 | ||
151 | struct rt6_info ip6_prohibit_entry = { | 152 | struct rt6_info ip6_prohibit_entry_template = { |
152 | .u = { | 153 | .u = { |
153 | .dst = { | 154 | .dst = { |
154 | .__refcnt = ATOMIC_INIT(1), | 155 | .__refcnt = ATOMIC_INIT(1), |
@@ -158,8 +159,6 @@ struct rt6_info ip6_prohibit_entry = { | |||
158 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | 159 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, |
159 | .input = ip6_pkt_prohibit, | 160 | .input = ip6_pkt_prohibit, |
160 | .output = ip6_pkt_prohibit_out, | 161 | .output = ip6_pkt_prohibit_out, |
161 | .ops = &ip6_dst_ops, | ||
162 | .path = (struct dst_entry*)&ip6_prohibit_entry, | ||
163 | } | 162 | } |
164 | }, | 163 | }, |
165 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), | 164 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), |
@@ -167,7 +166,7 @@ struct rt6_info ip6_prohibit_entry = { | |||
167 | .rt6i_ref = ATOMIC_INIT(1), | 166 | .rt6i_ref = ATOMIC_INIT(1), |
168 | }; | 167 | }; |
169 | 168 | ||
170 | struct rt6_info ip6_blk_hole_entry = { | 169 | static struct rt6_info ip6_blk_hole_entry_template = { |
171 | .u = { | 170 | .u = { |
172 | .dst = { | 171 | .dst = { |
173 | .__refcnt = ATOMIC_INIT(1), | 172 | .__refcnt = ATOMIC_INIT(1), |
@@ -177,8 +176,6 @@ struct rt6_info ip6_blk_hole_entry = { | |||
177 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | 176 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, |
178 | .input = dst_discard, | 177 | .input = dst_discard, |
179 | .output = dst_discard, | 178 | .output = dst_discard, |
180 | .ops = &ip6_dst_ops, | ||
181 | .path = (struct dst_entry*)&ip6_blk_hole_entry, | ||
182 | } | 179 | } |
183 | }, | 180 | }, |
184 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), | 181 | .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), |
@@ -189,9 +186,9 @@ struct rt6_info ip6_blk_hole_entry = { | |||
189 | #endif | 186 | #endif |
190 | 187 | ||
191 | /* allocate dst with ip6_dst_ops */ | 188 | /* allocate dst with ip6_dst_ops */ |
192 | static __inline__ struct rt6_info *ip6_dst_alloc(void) | 189 | static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops) |
193 | { | 190 | { |
194 | return (struct rt6_info *)dst_alloc(&ip6_dst_ops); | 191 | return (struct rt6_info *)dst_alloc(ops); |
195 | } | 192 | } |
196 | 193 | ||
197 | static void ip6_dst_destroy(struct dst_entry *dst) | 194 | static void ip6_dst_destroy(struct dst_entry *dst) |
@@ -211,7 +208,7 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
211 | struct rt6_info *rt = (struct rt6_info *)dst; | 208 | struct rt6_info *rt = (struct rt6_info *)dst; |
212 | struct inet6_dev *idev = rt->rt6i_idev; | 209 | struct inet6_dev *idev = rt->rt6i_idev; |
213 | struct net_device *loopback_dev = | 210 | struct net_device *loopback_dev = |
214 | dev->nd_net->loopback_dev; | 211 | dev_net(dev)->loopback_dev; |
215 | 212 | ||
216 | if (dev != loopback_dev && idev != NULL && idev->dev == dev) { | 213 | if (dev != loopback_dev && idev != NULL && idev->dev == dev) { |
217 | struct inet6_dev *loopback_idev = | 214 | struct inet6_dev *loopback_idev = |
@@ -239,7 +236,8 @@ static inline int rt6_need_strict(struct in6_addr *daddr) | |||
239 | * Route lookup. Any table->tb6_lock is implied. | 236 | * Route lookup. Any table->tb6_lock is implied. |
240 | */ | 237 | */ |
241 | 238 | ||
242 | static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt, | 239 | static inline struct rt6_info *rt6_device_match(struct net *net, |
240 | struct rt6_info *rt, | ||
243 | int oif, | 241 | int oif, |
244 | int strict) | 242 | int strict) |
245 | { | 243 | { |
@@ -268,7 +266,7 @@ static __inline__ struct rt6_info *rt6_device_match(struct rt6_info *rt, | |||
268 | return local; | 266 | return local; |
269 | 267 | ||
270 | if (strict) | 268 | if (strict) |
271 | return &ip6_null_entry; | 269 | return net->ipv6.ip6_null_entry; |
272 | } | 270 | } |
273 | return rt; | 271 | return rt; |
274 | } | 272 | } |
@@ -409,9 +407,10 @@ static struct rt6_info *find_rr_leaf(struct fib6_node *fn, | |||
409 | static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict) | 407 | static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict) |
410 | { | 408 | { |
411 | struct rt6_info *match, *rt0; | 409 | struct rt6_info *match, *rt0; |
410 | struct net *net; | ||
412 | 411 | ||
413 | RT6_TRACE("%s(fn->leaf=%p, oif=%d)\n", | 412 | RT6_TRACE("%s(fn->leaf=%p, oif=%d)\n", |
414 | __FUNCTION__, fn->leaf, oif); | 413 | __func__, fn->leaf, oif); |
415 | 414 | ||
416 | rt0 = fn->rr_ptr; | 415 | rt0 = fn->rr_ptr; |
417 | if (!rt0) | 416 | if (!rt0) |
@@ -432,15 +431,17 @@ static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict) | |||
432 | } | 431 | } |
433 | 432 | ||
434 | RT6_TRACE("%s() => %p\n", | 433 | RT6_TRACE("%s() => %p\n", |
435 | __FUNCTION__, match); | 434 | __func__, match); |
436 | 435 | ||
437 | return (match ? match : &ip6_null_entry); | 436 | net = dev_net(rt0->rt6i_dev); |
437 | return (match ? match : net->ipv6.ip6_null_entry); | ||
438 | } | 438 | } |
439 | 439 | ||
440 | #ifdef CONFIG_IPV6_ROUTE_INFO | 440 | #ifdef CONFIG_IPV6_ROUTE_INFO |
441 | int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, | 441 | int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, |
442 | struct in6_addr *gwaddr) | 442 | struct in6_addr *gwaddr) |
443 | { | 443 | { |
444 | struct net *net = dev_net(dev); | ||
444 | struct route_info *rinfo = (struct route_info *) opt; | 445 | struct route_info *rinfo = (struct route_info *) opt; |
445 | struct in6_addr prefix_buf, *prefix; | 446 | struct in6_addr prefix_buf, *prefix; |
446 | unsigned int pref; | 447 | unsigned int pref; |
@@ -488,7 +489,8 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, | |||
488 | prefix = &prefix_buf; | 489 | prefix = &prefix_buf; |
489 | } | 490 | } |
490 | 491 | ||
491 | rt = rt6_get_route_info(prefix, rinfo->prefix_len, gwaddr, dev->ifindex); | 492 | rt = rt6_get_route_info(net, prefix, rinfo->prefix_len, gwaddr, |
493 | dev->ifindex); | ||
492 | 494 | ||
493 | if (rt && !lifetime) { | 495 | if (rt && !lifetime) { |
494 | ip6_del_rt(rt); | 496 | ip6_del_rt(rt); |
@@ -496,7 +498,7 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, | |||
496 | } | 498 | } |
497 | 499 | ||
498 | if (!rt && lifetime) | 500 | if (!rt && lifetime) |
499 | rt = rt6_add_route_info(prefix, rinfo->prefix_len, gwaddr, dev->ifindex, | 501 | rt = rt6_add_route_info(net, prefix, rinfo->prefix_len, gwaddr, dev->ifindex, |
500 | pref); | 502 | pref); |
501 | else if (rt) | 503 | else if (rt) |
502 | rt->rt6i_flags = RTF_ROUTEINFO | | 504 | rt->rt6i_flags = RTF_ROUTEINFO | |
@@ -515,9 +517,9 @@ int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, | |||
515 | } | 517 | } |
516 | #endif | 518 | #endif |
517 | 519 | ||
518 | #define BACKTRACK(saddr) \ | 520 | #define BACKTRACK(__net, saddr) \ |
519 | do { \ | 521 | do { \ |
520 | if (rt == &ip6_null_entry) { \ | 522 | if (rt == __net->ipv6.ip6_null_entry) { \ |
521 | struct fib6_node *pn; \ | 523 | struct fib6_node *pn; \ |
522 | while (1) { \ | 524 | while (1) { \ |
523 | if (fn->fn_flags & RTN_TL_ROOT) \ | 525 | if (fn->fn_flags & RTN_TL_ROOT) \ |
@@ -533,7 +535,8 @@ do { \ | |||
533 | } \ | 535 | } \ |
534 | } while(0) | 536 | } while(0) |
535 | 537 | ||
536 | static struct rt6_info *ip6_pol_route_lookup(struct fib6_table *table, | 538 | static struct rt6_info *ip6_pol_route_lookup(struct net *net, |
539 | struct fib6_table *table, | ||
537 | struct flowi *fl, int flags) | 540 | struct flowi *fl, int flags) |
538 | { | 541 | { |
539 | struct fib6_node *fn; | 542 | struct fib6_node *fn; |
@@ -543,8 +546,8 @@ static struct rt6_info *ip6_pol_route_lookup(struct fib6_table *table, | |||
543 | fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); | 546 | fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); |
544 | restart: | 547 | restart: |
545 | rt = fn->leaf; | 548 | rt = fn->leaf; |
546 | rt = rt6_device_match(rt, fl->oif, flags); | 549 | rt = rt6_device_match(net, rt, fl->oif, flags); |
547 | BACKTRACK(&fl->fl6_src); | 550 | BACKTRACK(net, &fl->fl6_src); |
548 | out: | 551 | out: |
549 | dst_use(&rt->u.dst, jiffies); | 552 | dst_use(&rt->u.dst, jiffies); |
550 | read_unlock_bh(&table->tb6_lock); | 553 | read_unlock_bh(&table->tb6_lock); |
@@ -552,8 +555,8 @@ out: | |||
552 | 555 | ||
553 | } | 556 | } |
554 | 557 | ||
555 | struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr, | 558 | struct rt6_info *rt6_lookup(struct net *net, struct in6_addr *daddr, |
556 | int oif, int strict) | 559 | struct in6_addr *saddr, int oif, int strict) |
557 | { | 560 | { |
558 | struct flowi fl = { | 561 | struct flowi fl = { |
559 | .oif = oif, | 562 | .oif = oif, |
@@ -571,7 +574,7 @@ struct rt6_info *rt6_lookup(struct in6_addr *daddr, struct in6_addr *saddr, | |||
571 | flags |= RT6_LOOKUP_F_HAS_SADDR; | 574 | flags |= RT6_LOOKUP_F_HAS_SADDR; |
572 | } | 575 | } |
573 | 576 | ||
574 | dst = fib6_rule_lookup(&fl, flags, ip6_pol_route_lookup); | 577 | dst = fib6_rule_lookup(net, &fl, flags, ip6_pol_route_lookup); |
575 | if (dst->error == 0) | 578 | if (dst->error == 0) |
576 | return (struct rt6_info *) dst; | 579 | return (struct rt6_info *) dst; |
577 | 580 | ||
@@ -604,7 +607,7 @@ static int __ip6_ins_rt(struct rt6_info *rt, struct nl_info *info) | |||
604 | int ip6_ins_rt(struct rt6_info *rt) | 607 | int ip6_ins_rt(struct rt6_info *rt) |
605 | { | 608 | { |
606 | struct nl_info info = { | 609 | struct nl_info info = { |
607 | .nl_net = &init_net, | 610 | .nl_net = dev_net(rt->rt6i_dev), |
608 | }; | 611 | }; |
609 | return __ip6_ins_rt(rt, &info); | 612 | return __ip6_ins_rt(rt, &info); |
610 | } | 613 | } |
@@ -660,8 +663,8 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *d | |||
660 | return rt; | 663 | return rt; |
661 | } | 664 | } |
662 | 665 | ||
663 | static struct rt6_info *ip6_pol_route(struct fib6_table *table, int oif, | 666 | static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, int oif, |
664 | struct flowi *fl, int flags) | 667 | struct flowi *fl, int flags) |
665 | { | 668 | { |
666 | struct fib6_node *fn; | 669 | struct fib6_node *fn; |
667 | struct rt6_info *rt, *nrt; | 670 | struct rt6_info *rt, *nrt; |
@@ -680,8 +683,9 @@ restart_2: | |||
680 | 683 | ||
681 | restart: | 684 | restart: |
682 | rt = rt6_select(fn, oif, strict | reachable); | 685 | rt = rt6_select(fn, oif, strict | reachable); |
683 | BACKTRACK(&fl->fl6_src); | 686 | |
684 | if (rt == &ip6_null_entry || | 687 | BACKTRACK(net, &fl->fl6_src); |
688 | if (rt == net->ipv6.ip6_null_entry || | ||
685 | rt->rt6i_flags & RTF_CACHE) | 689 | rt->rt6i_flags & RTF_CACHE) |
686 | goto out; | 690 | goto out; |
687 | 691 | ||
@@ -699,7 +703,7 @@ restart: | |||
699 | } | 703 | } |
700 | 704 | ||
701 | dst_release(&rt->u.dst); | 705 | dst_release(&rt->u.dst); |
702 | rt = nrt ? : &ip6_null_entry; | 706 | rt = nrt ? : net->ipv6.ip6_null_entry; |
703 | 707 | ||
704 | dst_hold(&rt->u.dst); | 708 | dst_hold(&rt->u.dst); |
705 | if (nrt) { | 709 | if (nrt) { |
@@ -732,15 +736,16 @@ out2: | |||
732 | return rt; | 736 | return rt; |
733 | } | 737 | } |
734 | 738 | ||
735 | static struct rt6_info *ip6_pol_route_input(struct fib6_table *table, | 739 | static struct rt6_info *ip6_pol_route_input(struct net *net, struct fib6_table *table, |
736 | struct flowi *fl, int flags) | 740 | struct flowi *fl, int flags) |
737 | { | 741 | { |
738 | return ip6_pol_route(table, fl->iif, fl, flags); | 742 | return ip6_pol_route(net, table, fl->iif, fl, flags); |
739 | } | 743 | } |
740 | 744 | ||
741 | void ip6_route_input(struct sk_buff *skb) | 745 | void ip6_route_input(struct sk_buff *skb) |
742 | { | 746 | { |
743 | struct ipv6hdr *iph = ipv6_hdr(skb); | 747 | struct ipv6hdr *iph = ipv6_hdr(skb); |
748 | struct net *net = dev_net(skb->dev); | ||
744 | int flags = RT6_LOOKUP_F_HAS_SADDR; | 749 | int flags = RT6_LOOKUP_F_HAS_SADDR; |
745 | struct flowi fl = { | 750 | struct flowi fl = { |
746 | .iif = skb->dev->ifindex, | 751 | .iif = skb->dev->ifindex, |
@@ -758,16 +763,17 @@ void ip6_route_input(struct sk_buff *skb) | |||
758 | if (rt6_need_strict(&iph->daddr)) | 763 | if (rt6_need_strict(&iph->daddr)) |
759 | flags |= RT6_LOOKUP_F_IFACE; | 764 | flags |= RT6_LOOKUP_F_IFACE; |
760 | 765 | ||
761 | skb->dst = fib6_rule_lookup(&fl, flags, ip6_pol_route_input); | 766 | skb->dst = fib6_rule_lookup(net, &fl, flags, ip6_pol_route_input); |
762 | } | 767 | } |
763 | 768 | ||
764 | static struct rt6_info *ip6_pol_route_output(struct fib6_table *table, | 769 | static struct rt6_info *ip6_pol_route_output(struct net *net, struct fib6_table *table, |
765 | struct flowi *fl, int flags) | 770 | struct flowi *fl, int flags) |
766 | { | 771 | { |
767 | return ip6_pol_route(table, fl->oif, fl, flags); | 772 | return ip6_pol_route(net, table, fl->oif, fl, flags); |
768 | } | 773 | } |
769 | 774 | ||
770 | struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl) | 775 | struct dst_entry * ip6_route_output(struct net *net, struct sock *sk, |
776 | struct flowi *fl) | ||
771 | { | 777 | { |
772 | int flags = 0; | 778 | int flags = 0; |
773 | 779 | ||
@@ -776,8 +782,17 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl) | |||
776 | 782 | ||
777 | if (!ipv6_addr_any(&fl->fl6_src)) | 783 | if (!ipv6_addr_any(&fl->fl6_src)) |
778 | flags |= RT6_LOOKUP_F_HAS_SADDR; | 784 | flags |= RT6_LOOKUP_F_HAS_SADDR; |
785 | else if (sk) { | ||
786 | unsigned int prefs = inet6_sk(sk)->srcprefs; | ||
787 | if (prefs & IPV6_PREFER_SRC_TMP) | ||
788 | flags |= RT6_LOOKUP_F_SRCPREF_TMP; | ||
789 | if (prefs & IPV6_PREFER_SRC_PUBLIC) | ||
790 | flags |= RT6_LOOKUP_F_SRCPREF_PUBLIC; | ||
791 | if (prefs & IPV6_PREFER_SRC_COA) | ||
792 | flags |= RT6_LOOKUP_F_SRCPREF_COA; | ||
793 | } | ||
779 | 794 | ||
780 | return fib6_rule_lookup(fl, flags, ip6_pol_route_output); | 795 | return fib6_rule_lookup(net, fl, flags, ip6_pol_route_output); |
781 | } | 796 | } |
782 | 797 | ||
783 | EXPORT_SYMBOL(ip6_route_output); | 798 | EXPORT_SYMBOL(ip6_route_output); |
@@ -886,12 +901,12 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
886 | 901 | ||
887 | static int ipv6_get_mtu(struct net_device *dev); | 902 | static int ipv6_get_mtu(struct net_device *dev); |
888 | 903 | ||
889 | static inline unsigned int ipv6_advmss(unsigned int mtu) | 904 | static inline unsigned int ipv6_advmss(struct net *net, unsigned int mtu) |
890 | { | 905 | { |
891 | mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr); | 906 | mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr); |
892 | 907 | ||
893 | if (mtu < init_net.ipv6.sysctl.ip6_rt_min_advmss) | 908 | if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss) |
894 | mtu = init_net.ipv6.sysctl.ip6_rt_min_advmss; | 909 | mtu = net->ipv6.sysctl.ip6_rt_min_advmss; |
895 | 910 | ||
896 | /* | 911 | /* |
897 | * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and | 912 | * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and |
@@ -904,21 +919,21 @@ static inline unsigned int ipv6_advmss(unsigned int mtu) | |||
904 | return mtu; | 919 | return mtu; |
905 | } | 920 | } |
906 | 921 | ||
907 | static struct dst_entry *ndisc_dst_gc_list; | 922 | static struct dst_entry *icmp6_dst_gc_list; |
908 | static DEFINE_SPINLOCK(ndisc_lock); | 923 | static DEFINE_SPINLOCK(icmp6_dst_lock); |
909 | 924 | ||
910 | struct dst_entry *ndisc_dst_alloc(struct net_device *dev, | 925 | struct dst_entry *icmp6_dst_alloc(struct net_device *dev, |
911 | struct neighbour *neigh, | 926 | struct neighbour *neigh, |
912 | struct in6_addr *addr, | 927 | struct in6_addr *addr) |
913 | int (*output)(struct sk_buff *)) | ||
914 | { | 928 | { |
915 | struct rt6_info *rt; | 929 | struct rt6_info *rt; |
916 | struct inet6_dev *idev = in6_dev_get(dev); | 930 | struct inet6_dev *idev = in6_dev_get(dev); |
931 | struct net *net = dev_net(dev); | ||
917 | 932 | ||
918 | if (unlikely(idev == NULL)) | 933 | if (unlikely(idev == NULL)) |
919 | return NULL; | 934 | return NULL; |
920 | 935 | ||
921 | rt = ip6_dst_alloc(); | 936 | rt = ip6_dst_alloc(net->ipv6.ip6_dst_ops); |
922 | if (unlikely(rt == NULL)) { | 937 | if (unlikely(rt == NULL)) { |
923 | in6_dev_put(idev); | 938 | in6_dev_put(idev); |
924 | goto out; | 939 | goto out; |
@@ -936,8 +951,8 @@ struct dst_entry *ndisc_dst_alloc(struct net_device *dev, | |||
936 | atomic_set(&rt->u.dst.__refcnt, 1); | 951 | atomic_set(&rt->u.dst.__refcnt, 1); |
937 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = 255; | 952 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = 255; |
938 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); | 953 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); |
939 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&rt->u.dst)); | 954 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); |
940 | rt->u.dst.output = output; | 955 | rt->u.dst.output = ip6_output; |
941 | 956 | ||
942 | #if 0 /* there's no chance to use these for ndisc */ | 957 | #if 0 /* there's no chance to use these for ndisc */ |
943 | rt->u.dst.flags = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST | 958 | rt->u.dst.flags = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST |
@@ -947,18 +962,18 @@ struct dst_entry *ndisc_dst_alloc(struct net_device *dev, | |||
947 | rt->rt6i_dst.plen = 128; | 962 | rt->rt6i_dst.plen = 128; |
948 | #endif | 963 | #endif |
949 | 964 | ||
950 | spin_lock_bh(&ndisc_lock); | 965 | spin_lock_bh(&icmp6_dst_lock); |
951 | rt->u.dst.next = ndisc_dst_gc_list; | 966 | rt->u.dst.next = icmp6_dst_gc_list; |
952 | ndisc_dst_gc_list = &rt->u.dst; | 967 | icmp6_dst_gc_list = &rt->u.dst; |
953 | spin_unlock_bh(&ndisc_lock); | 968 | spin_unlock_bh(&icmp6_dst_lock); |
954 | 969 | ||
955 | fib6_force_start_gc(); | 970 | fib6_force_start_gc(net); |
956 | 971 | ||
957 | out: | 972 | out: |
958 | return &rt->u.dst; | 973 | return &rt->u.dst; |
959 | } | 974 | } |
960 | 975 | ||
961 | int ndisc_dst_gc(int *more) | 976 | int icmp6_dst_gc(int *more) |
962 | { | 977 | { |
963 | struct dst_entry *dst, *next, **pprev; | 978 | struct dst_entry *dst, *next, **pprev; |
964 | int freed; | 979 | int freed; |
@@ -966,8 +981,8 @@ int ndisc_dst_gc(int *more) | |||
966 | next = NULL; | 981 | next = NULL; |
967 | freed = 0; | 982 | freed = 0; |
968 | 983 | ||
969 | spin_lock_bh(&ndisc_lock); | 984 | spin_lock_bh(&icmp6_dst_lock); |
970 | pprev = &ndisc_dst_gc_list; | 985 | pprev = &icmp6_dst_gc_list; |
971 | 986 | ||
972 | while ((dst = *pprev) != NULL) { | 987 | while ((dst = *pprev) != NULL) { |
973 | if (!atomic_read(&dst->__refcnt)) { | 988 | if (!atomic_read(&dst->__refcnt)) { |
@@ -980,30 +995,33 @@ int ndisc_dst_gc(int *more) | |||
980 | } | 995 | } |
981 | } | 996 | } |
982 | 997 | ||
983 | spin_unlock_bh(&ndisc_lock); | 998 | spin_unlock_bh(&icmp6_dst_lock); |
984 | 999 | ||
985 | return freed; | 1000 | return freed; |
986 | } | 1001 | } |
987 | 1002 | ||
988 | static int ip6_dst_gc(struct dst_ops *ops) | 1003 | static int ip6_dst_gc(struct dst_ops *ops) |
989 | { | 1004 | { |
990 | static unsigned expire = 30*HZ; | ||
991 | static unsigned long last_gc; | ||
992 | unsigned long now = jiffies; | 1005 | unsigned long now = jiffies; |
993 | 1006 | struct net *net = ops->dst_net; | |
994 | if (time_after(last_gc + init_net.ipv6.sysctl.ip6_rt_gc_min_interval, now) && | 1007 | int rt_min_interval = net->ipv6.sysctl.ip6_rt_gc_min_interval; |
995 | atomic_read(&ip6_dst_ops.entries) <= init_net.ipv6.sysctl.ip6_rt_max_size) | 1008 | int rt_max_size = net->ipv6.sysctl.ip6_rt_max_size; |
1009 | int rt_elasticity = net->ipv6.sysctl.ip6_rt_gc_elasticity; | ||
1010 | int rt_gc_timeout = net->ipv6.sysctl.ip6_rt_gc_timeout; | ||
1011 | unsigned long rt_last_gc = net->ipv6.ip6_rt_last_gc; | ||
1012 | |||
1013 | if (time_after(rt_last_gc + rt_min_interval, now) && | ||
1014 | atomic_read(&ops->entries) <= rt_max_size) | ||
996 | goto out; | 1015 | goto out; |
997 | 1016 | ||
998 | expire++; | 1017 | net->ipv6.ip6_rt_gc_expire++; |
999 | fib6_run_gc(expire); | 1018 | fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net); |
1000 | last_gc = now; | 1019 | net->ipv6.ip6_rt_last_gc = now; |
1001 | if (atomic_read(&ip6_dst_ops.entries) < ip6_dst_ops.gc_thresh) | 1020 | if (atomic_read(&ops->entries) < ops->gc_thresh) |
1002 | expire = init_net.ipv6.sysctl.ip6_rt_gc_timeout>>1; | 1021 | net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1; |
1003 | |||
1004 | out: | 1022 | out: |
1005 | expire -= expire>>init_net.ipv6.sysctl.ip6_rt_gc_elasticity; | 1023 | net->ipv6.ip6_rt_gc_expire -= net->ipv6.ip6_rt_gc_expire>>rt_elasticity; |
1006 | return (atomic_read(&ip6_dst_ops.entries) > init_net.ipv6.sysctl.ip6_rt_max_size); | 1024 | return (atomic_read(&ops->entries) > rt_max_size); |
1007 | } | 1025 | } |
1008 | 1026 | ||
1009 | /* Clean host part of a prefix. Not necessary in radix tree, | 1027 | /* Clean host part of a prefix. Not necessary in radix tree, |
@@ -1025,15 +1043,17 @@ static int ipv6_get_mtu(struct net_device *dev) | |||
1025 | return mtu; | 1043 | return mtu; |
1026 | } | 1044 | } |
1027 | 1045 | ||
1028 | int ipv6_get_hoplimit(struct net_device *dev) | 1046 | int ip6_dst_hoplimit(struct dst_entry *dst) |
1029 | { | 1047 | { |
1030 | int hoplimit = ipv6_devconf.hop_limit; | 1048 | int hoplimit = dst_metric(dst, RTAX_HOPLIMIT); |
1031 | struct inet6_dev *idev; | 1049 | if (hoplimit < 0) { |
1032 | 1050 | struct net_device *dev = dst->dev; | |
1033 | idev = in6_dev_get(dev); | 1051 | struct inet6_dev *idev = in6_dev_get(dev); |
1034 | if (idev) { | 1052 | if (idev) { |
1035 | hoplimit = idev->cnf.hop_limit; | 1053 | hoplimit = idev->cnf.hop_limit; |
1036 | in6_dev_put(idev); | 1054 | in6_dev_put(idev); |
1055 | } else | ||
1056 | hoplimit = ipv6_devconf.hop_limit; | ||
1037 | } | 1057 | } |
1038 | return hoplimit; | 1058 | return hoplimit; |
1039 | } | 1059 | } |
@@ -1045,6 +1065,7 @@ int ipv6_get_hoplimit(struct net_device *dev) | |||
1045 | int ip6_route_add(struct fib6_config *cfg) | 1065 | int ip6_route_add(struct fib6_config *cfg) |
1046 | { | 1066 | { |
1047 | int err; | 1067 | int err; |
1068 | struct net *net = cfg->fc_nlinfo.nl_net; | ||
1048 | struct rt6_info *rt = NULL; | 1069 | struct rt6_info *rt = NULL; |
1049 | struct net_device *dev = NULL; | 1070 | struct net_device *dev = NULL; |
1050 | struct inet6_dev *idev = NULL; | 1071 | struct inet6_dev *idev = NULL; |
@@ -1059,7 +1080,7 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1059 | #endif | 1080 | #endif |
1060 | if (cfg->fc_ifindex) { | 1081 | if (cfg->fc_ifindex) { |
1061 | err = -ENODEV; | 1082 | err = -ENODEV; |
1062 | dev = dev_get_by_index(&init_net, cfg->fc_ifindex); | 1083 | dev = dev_get_by_index(net, cfg->fc_ifindex); |
1063 | if (!dev) | 1084 | if (!dev) |
1064 | goto out; | 1085 | goto out; |
1065 | idev = in6_dev_get(dev); | 1086 | idev = in6_dev_get(dev); |
@@ -1070,13 +1091,13 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1070 | if (cfg->fc_metric == 0) | 1091 | if (cfg->fc_metric == 0) |
1071 | cfg->fc_metric = IP6_RT_PRIO_USER; | 1092 | cfg->fc_metric = IP6_RT_PRIO_USER; |
1072 | 1093 | ||
1073 | table = fib6_new_table(cfg->fc_table); | 1094 | table = fib6_new_table(net, cfg->fc_table); |
1074 | if (table == NULL) { | 1095 | if (table == NULL) { |
1075 | err = -ENOBUFS; | 1096 | err = -ENOBUFS; |
1076 | goto out; | 1097 | goto out; |
1077 | } | 1098 | } |
1078 | 1099 | ||
1079 | rt = ip6_dst_alloc(); | 1100 | rt = ip6_dst_alloc(net->ipv6.ip6_dst_ops); |
1080 | 1101 | ||
1081 | if (rt == NULL) { | 1102 | if (rt == NULL) { |
1082 | err = -ENOMEM; | 1103 | err = -ENOMEM; |
@@ -1117,12 +1138,12 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1117 | if ((cfg->fc_flags & RTF_REJECT) || | 1138 | if ((cfg->fc_flags & RTF_REJECT) || |
1118 | (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK))) { | 1139 | (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK))) { |
1119 | /* hold loopback dev/idev if we haven't done so. */ | 1140 | /* hold loopback dev/idev if we haven't done so. */ |
1120 | if (dev != init_net.loopback_dev) { | 1141 | if (dev != net->loopback_dev) { |
1121 | if (dev) { | 1142 | if (dev) { |
1122 | dev_put(dev); | 1143 | dev_put(dev); |
1123 | in6_dev_put(idev); | 1144 | in6_dev_put(idev); |
1124 | } | 1145 | } |
1125 | dev = init_net.loopback_dev; | 1146 | dev = net->loopback_dev; |
1126 | dev_hold(dev); | 1147 | dev_hold(dev); |
1127 | idev = in6_dev_get(dev); | 1148 | idev = in6_dev_get(dev); |
1128 | if (!idev) { | 1149 | if (!idev) { |
@@ -1159,7 +1180,7 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1159 | if (!(gwa_type&IPV6_ADDR_UNICAST)) | 1180 | if (!(gwa_type&IPV6_ADDR_UNICAST)) |
1160 | goto out; | 1181 | goto out; |
1161 | 1182 | ||
1162 | grt = rt6_lookup(gw_addr, NULL, cfg->fc_ifindex, 1); | 1183 | grt = rt6_lookup(net, gw_addr, NULL, cfg->fc_ifindex, 1); |
1163 | 1184 | ||
1164 | err = -EHOSTUNREACH; | 1185 | err = -EHOSTUNREACH; |
1165 | if (grt == NULL) | 1186 | if (grt == NULL) |
@@ -1226,10 +1247,13 @@ install_route: | |||
1226 | if (!rt->u.dst.metrics[RTAX_MTU-1]) | 1247 | if (!rt->u.dst.metrics[RTAX_MTU-1]) |
1227 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); | 1248 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); |
1228 | if (!rt->u.dst.metrics[RTAX_ADVMSS-1]) | 1249 | if (!rt->u.dst.metrics[RTAX_ADVMSS-1]) |
1229 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&rt->u.dst)); | 1250 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); |
1230 | rt->u.dst.dev = dev; | 1251 | rt->u.dst.dev = dev; |
1231 | rt->rt6i_idev = idev; | 1252 | rt->rt6i_idev = idev; |
1232 | rt->rt6i_table = table; | 1253 | rt->rt6i_table = table; |
1254 | |||
1255 | cfg->fc_nlinfo.nl_net = dev_net(dev); | ||
1256 | |||
1233 | return __ip6_ins_rt(rt, &cfg->fc_nlinfo); | 1257 | return __ip6_ins_rt(rt, &cfg->fc_nlinfo); |
1234 | 1258 | ||
1235 | out: | 1259 | out: |
@@ -1246,8 +1270,9 @@ static int __ip6_del_rt(struct rt6_info *rt, struct nl_info *info) | |||
1246 | { | 1270 | { |
1247 | int err; | 1271 | int err; |
1248 | struct fib6_table *table; | 1272 | struct fib6_table *table; |
1273 | struct net *net = dev_net(rt->rt6i_dev); | ||
1249 | 1274 | ||
1250 | if (rt == &ip6_null_entry) | 1275 | if (rt == net->ipv6.ip6_null_entry) |
1251 | return -ENOENT; | 1276 | return -ENOENT; |
1252 | 1277 | ||
1253 | table = rt->rt6i_table; | 1278 | table = rt->rt6i_table; |
@@ -1264,7 +1289,7 @@ static int __ip6_del_rt(struct rt6_info *rt, struct nl_info *info) | |||
1264 | int ip6_del_rt(struct rt6_info *rt) | 1289 | int ip6_del_rt(struct rt6_info *rt) |
1265 | { | 1290 | { |
1266 | struct nl_info info = { | 1291 | struct nl_info info = { |
1267 | .nl_net = &init_net, | 1292 | .nl_net = dev_net(rt->rt6i_dev), |
1268 | }; | 1293 | }; |
1269 | return __ip6_del_rt(rt, &info); | 1294 | return __ip6_del_rt(rt, &info); |
1270 | } | 1295 | } |
@@ -1276,7 +1301,7 @@ static int ip6_route_del(struct fib6_config *cfg) | |||
1276 | struct rt6_info *rt; | 1301 | struct rt6_info *rt; |
1277 | int err = -ESRCH; | 1302 | int err = -ESRCH; |
1278 | 1303 | ||
1279 | table = fib6_get_table(cfg->fc_table); | 1304 | table = fib6_get_table(cfg->fc_nlinfo.nl_net, cfg->fc_table); |
1280 | if (table == NULL) | 1305 | if (table == NULL) |
1281 | return err; | 1306 | return err; |
1282 | 1307 | ||
@@ -1316,7 +1341,8 @@ struct ip6rd_flowi { | |||
1316 | struct in6_addr gateway; | 1341 | struct in6_addr gateway; |
1317 | }; | 1342 | }; |
1318 | 1343 | ||
1319 | static struct rt6_info *__ip6_route_redirect(struct fib6_table *table, | 1344 | static struct rt6_info *__ip6_route_redirect(struct net *net, |
1345 | struct fib6_table *table, | ||
1320 | struct flowi *fl, | 1346 | struct flowi *fl, |
1321 | int flags) | 1347 | int flags) |
1322 | { | 1348 | { |
@@ -1359,8 +1385,8 @@ restart: | |||
1359 | } | 1385 | } |
1360 | 1386 | ||
1361 | if (!rt) | 1387 | if (!rt) |
1362 | rt = &ip6_null_entry; | 1388 | rt = net->ipv6.ip6_null_entry; |
1363 | BACKTRACK(&fl->fl6_src); | 1389 | BACKTRACK(net, &fl->fl6_src); |
1364 | out: | 1390 | out: |
1365 | dst_hold(&rt->u.dst); | 1391 | dst_hold(&rt->u.dst); |
1366 | 1392 | ||
@@ -1375,6 +1401,7 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest, | |||
1375 | struct net_device *dev) | 1401 | struct net_device *dev) |
1376 | { | 1402 | { |
1377 | int flags = RT6_LOOKUP_F_HAS_SADDR; | 1403 | int flags = RT6_LOOKUP_F_HAS_SADDR; |
1404 | struct net *net = dev_net(dev); | ||
1378 | struct ip6rd_flowi rdfl = { | 1405 | struct ip6rd_flowi rdfl = { |
1379 | .fl = { | 1406 | .fl = { |
1380 | .oif = dev->ifindex, | 1407 | .oif = dev->ifindex, |
@@ -1391,7 +1418,8 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest, | |||
1391 | if (rt6_need_strict(dest)) | 1418 | if (rt6_need_strict(dest)) |
1392 | flags |= RT6_LOOKUP_F_IFACE; | 1419 | flags |= RT6_LOOKUP_F_IFACE; |
1393 | 1420 | ||
1394 | return (struct rt6_info *)fib6_rule_lookup((struct flowi *)&rdfl, flags, __ip6_route_redirect); | 1421 | return (struct rt6_info *)fib6_rule_lookup(net, (struct flowi *)&rdfl, |
1422 | flags, __ip6_route_redirect); | ||
1395 | } | 1423 | } |
1396 | 1424 | ||
1397 | void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, | 1425 | void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, |
@@ -1400,10 +1428,11 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, | |||
1400 | { | 1428 | { |
1401 | struct rt6_info *rt, *nrt = NULL; | 1429 | struct rt6_info *rt, *nrt = NULL; |
1402 | struct netevent_redirect netevent; | 1430 | struct netevent_redirect netevent; |
1431 | struct net *net = dev_net(neigh->dev); | ||
1403 | 1432 | ||
1404 | rt = ip6_route_redirect(dest, src, saddr, neigh->dev); | 1433 | rt = ip6_route_redirect(dest, src, saddr, neigh->dev); |
1405 | 1434 | ||
1406 | if (rt == &ip6_null_entry) { | 1435 | if (rt == net->ipv6.ip6_null_entry) { |
1407 | if (net_ratelimit()) | 1436 | if (net_ratelimit()) |
1408 | printk(KERN_DEBUG "rt6_redirect: source isn't a valid nexthop " | 1437 | printk(KERN_DEBUG "rt6_redirect: source isn't a valid nexthop " |
1409 | "for redirect target\n"); | 1438 | "for redirect target\n"); |
@@ -1448,7 +1477,8 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, | |||
1448 | nrt->rt6i_nexthop = neigh_clone(neigh); | 1477 | nrt->rt6i_nexthop = neigh_clone(neigh); |
1449 | /* Reset pmtu, it may be better */ | 1478 | /* Reset pmtu, it may be better */ |
1450 | nrt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev); | 1479 | nrt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev); |
1451 | nrt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&nrt->u.dst)); | 1480 | nrt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dev_net(neigh->dev), |
1481 | dst_mtu(&nrt->u.dst)); | ||
1452 | 1482 | ||
1453 | if (ip6_ins_rt(nrt)) | 1483 | if (ip6_ins_rt(nrt)) |
1454 | goto out; | 1484 | goto out; |
@@ -1476,9 +1506,10 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1476 | struct net_device *dev, u32 pmtu) | 1506 | struct net_device *dev, u32 pmtu) |
1477 | { | 1507 | { |
1478 | struct rt6_info *rt, *nrt; | 1508 | struct rt6_info *rt, *nrt; |
1509 | struct net *net = dev_net(dev); | ||
1479 | int allfrag = 0; | 1510 | int allfrag = 0; |
1480 | 1511 | ||
1481 | rt = rt6_lookup(daddr, saddr, dev->ifindex, 0); | 1512 | rt = rt6_lookup(net, daddr, saddr, dev->ifindex, 0); |
1482 | if (rt == NULL) | 1513 | if (rt == NULL) |
1483 | return; | 1514 | return; |
1484 | 1515 | ||
@@ -1511,7 +1542,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1511 | rt->u.dst.metrics[RTAX_MTU-1] = pmtu; | 1542 | rt->u.dst.metrics[RTAX_MTU-1] = pmtu; |
1512 | if (allfrag) | 1543 | if (allfrag) |
1513 | rt->u.dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; | 1544 | rt->u.dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; |
1514 | dst_set_expires(&rt->u.dst, init_net.ipv6.sysctl.ip6_rt_mtu_expires); | 1545 | dst_set_expires(&rt->u.dst, net->ipv6.sysctl.ip6_rt_mtu_expires); |
1515 | rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES; | 1546 | rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES; |
1516 | goto out; | 1547 | goto out; |
1517 | } | 1548 | } |
@@ -1537,7 +1568,7 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1537 | * which is 10 mins. After 10 mins the decreased pmtu is expired | 1568 | * which is 10 mins. After 10 mins the decreased pmtu is expired |
1538 | * and detecting PMTU increase will be automatically happened. | 1569 | * and detecting PMTU increase will be automatically happened. |
1539 | */ | 1570 | */ |
1540 | dst_set_expires(&nrt->u.dst, init_net.ipv6.sysctl.ip6_rt_mtu_expires); | 1571 | dst_set_expires(&nrt->u.dst, net->ipv6.sysctl.ip6_rt_mtu_expires); |
1541 | nrt->rt6i_flags |= RTF_DYNAMIC|RTF_EXPIRES; | 1572 | nrt->rt6i_flags |= RTF_DYNAMIC|RTF_EXPIRES; |
1542 | 1573 | ||
1543 | ip6_ins_rt(nrt); | 1574 | ip6_ins_rt(nrt); |
@@ -1552,7 +1583,8 @@ out: | |||
1552 | 1583 | ||
1553 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) | 1584 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) |
1554 | { | 1585 | { |
1555 | struct rt6_info *rt = ip6_dst_alloc(); | 1586 | struct net *net = dev_net(ort->rt6i_dev); |
1587 | struct rt6_info *rt = ip6_dst_alloc(net->ipv6.ip6_dst_ops); | ||
1556 | 1588 | ||
1557 | if (rt) { | 1589 | if (rt) { |
1558 | rt->u.dst.input = ort->u.dst.input; | 1590 | rt->u.dst.input = ort->u.dst.input; |
@@ -1583,14 +1615,15 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) | |||
1583 | } | 1615 | } |
1584 | 1616 | ||
1585 | #ifdef CONFIG_IPV6_ROUTE_INFO | 1617 | #ifdef CONFIG_IPV6_ROUTE_INFO |
1586 | static struct rt6_info *rt6_get_route_info(struct in6_addr *prefix, int prefixlen, | 1618 | static struct rt6_info *rt6_get_route_info(struct net *net, |
1619 | struct in6_addr *prefix, int prefixlen, | ||
1587 | struct in6_addr *gwaddr, int ifindex) | 1620 | struct in6_addr *gwaddr, int ifindex) |
1588 | { | 1621 | { |
1589 | struct fib6_node *fn; | 1622 | struct fib6_node *fn; |
1590 | struct rt6_info *rt = NULL; | 1623 | struct rt6_info *rt = NULL; |
1591 | struct fib6_table *table; | 1624 | struct fib6_table *table; |
1592 | 1625 | ||
1593 | table = fib6_get_table(RT6_TABLE_INFO); | 1626 | table = fib6_get_table(net, RT6_TABLE_INFO); |
1594 | if (table == NULL) | 1627 | if (table == NULL) |
1595 | return NULL; | 1628 | return NULL; |
1596 | 1629 | ||
@@ -1614,7 +1647,8 @@ out: | |||
1614 | return rt; | 1647 | return rt; |
1615 | } | 1648 | } |
1616 | 1649 | ||
1617 | static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixlen, | 1650 | static struct rt6_info *rt6_add_route_info(struct net *net, |
1651 | struct in6_addr *prefix, int prefixlen, | ||
1618 | struct in6_addr *gwaddr, int ifindex, | 1652 | struct in6_addr *gwaddr, int ifindex, |
1619 | unsigned pref) | 1653 | unsigned pref) |
1620 | { | 1654 | { |
@@ -1625,6 +1659,9 @@ static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixle | |||
1625 | .fc_dst_len = prefixlen, | 1659 | .fc_dst_len = prefixlen, |
1626 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO | | 1660 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_ROUTEINFO | |
1627 | RTF_UP | RTF_PREF(pref), | 1661 | RTF_UP | RTF_PREF(pref), |
1662 | .fc_nlinfo.pid = 0, | ||
1663 | .fc_nlinfo.nlh = NULL, | ||
1664 | .fc_nlinfo.nl_net = net, | ||
1628 | }; | 1665 | }; |
1629 | 1666 | ||
1630 | ipv6_addr_copy(&cfg.fc_dst, prefix); | 1667 | ipv6_addr_copy(&cfg.fc_dst, prefix); |
@@ -1636,7 +1673,7 @@ static struct rt6_info *rt6_add_route_info(struct in6_addr *prefix, int prefixle | |||
1636 | 1673 | ||
1637 | ip6_route_add(&cfg); | 1674 | ip6_route_add(&cfg); |
1638 | 1675 | ||
1639 | return rt6_get_route_info(prefix, prefixlen, gwaddr, ifindex); | 1676 | return rt6_get_route_info(net, prefix, prefixlen, gwaddr, ifindex); |
1640 | } | 1677 | } |
1641 | #endif | 1678 | #endif |
1642 | 1679 | ||
@@ -1645,7 +1682,7 @@ struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *d | |||
1645 | struct rt6_info *rt; | 1682 | struct rt6_info *rt; |
1646 | struct fib6_table *table; | 1683 | struct fib6_table *table; |
1647 | 1684 | ||
1648 | table = fib6_get_table(RT6_TABLE_DFLT); | 1685 | table = fib6_get_table(dev_net(dev), RT6_TABLE_DFLT); |
1649 | if (table == NULL) | 1686 | if (table == NULL) |
1650 | return NULL; | 1687 | return NULL; |
1651 | 1688 | ||
@@ -1674,6 +1711,9 @@ struct rt6_info *rt6_add_dflt_router(struct in6_addr *gwaddr, | |||
1674 | .fc_ifindex = dev->ifindex, | 1711 | .fc_ifindex = dev->ifindex, |
1675 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT | | 1712 | .fc_flags = RTF_GATEWAY | RTF_ADDRCONF | RTF_DEFAULT | |
1676 | RTF_UP | RTF_EXPIRES | RTF_PREF(pref), | 1713 | RTF_UP | RTF_EXPIRES | RTF_PREF(pref), |
1714 | .fc_nlinfo.pid = 0, | ||
1715 | .fc_nlinfo.nlh = NULL, | ||
1716 | .fc_nlinfo.nl_net = dev_net(dev), | ||
1677 | }; | 1717 | }; |
1678 | 1718 | ||
1679 | ipv6_addr_copy(&cfg.fc_gateway, gwaddr); | 1719 | ipv6_addr_copy(&cfg.fc_gateway, gwaddr); |
@@ -1683,13 +1723,13 @@ struct rt6_info *rt6_add_dflt_router(struct in6_addr *gwaddr, | |||
1683 | return rt6_get_dflt_router(gwaddr, dev); | 1723 | return rt6_get_dflt_router(gwaddr, dev); |
1684 | } | 1724 | } |
1685 | 1725 | ||
1686 | void rt6_purge_dflt_routers(void) | 1726 | void rt6_purge_dflt_routers(struct net *net) |
1687 | { | 1727 | { |
1688 | struct rt6_info *rt; | 1728 | struct rt6_info *rt; |
1689 | struct fib6_table *table; | 1729 | struct fib6_table *table; |
1690 | 1730 | ||
1691 | /* NOTE: Keep consistent with rt6_get_dflt_router */ | 1731 | /* NOTE: Keep consistent with rt6_get_dflt_router */ |
1692 | table = fib6_get_table(RT6_TABLE_DFLT); | 1732 | table = fib6_get_table(net, RT6_TABLE_DFLT); |
1693 | if (table == NULL) | 1733 | if (table == NULL) |
1694 | return; | 1734 | return; |
1695 | 1735 | ||
@@ -1706,7 +1746,8 @@ restart: | |||
1706 | read_unlock_bh(&table->tb6_lock); | 1746 | read_unlock_bh(&table->tb6_lock); |
1707 | } | 1747 | } |
1708 | 1748 | ||
1709 | static void rtmsg_to_fib6_config(struct in6_rtmsg *rtmsg, | 1749 | static void rtmsg_to_fib6_config(struct net *net, |
1750 | struct in6_rtmsg *rtmsg, | ||
1710 | struct fib6_config *cfg) | 1751 | struct fib6_config *cfg) |
1711 | { | 1752 | { |
1712 | memset(cfg, 0, sizeof(*cfg)); | 1753 | memset(cfg, 0, sizeof(*cfg)); |
@@ -1719,14 +1760,14 @@ static void rtmsg_to_fib6_config(struct in6_rtmsg *rtmsg, | |||
1719 | cfg->fc_src_len = rtmsg->rtmsg_src_len; | 1760 | cfg->fc_src_len = rtmsg->rtmsg_src_len; |
1720 | cfg->fc_flags = rtmsg->rtmsg_flags; | 1761 | cfg->fc_flags = rtmsg->rtmsg_flags; |
1721 | 1762 | ||
1722 | cfg->fc_nlinfo.nl_net = &init_net; | 1763 | cfg->fc_nlinfo.nl_net = net; |
1723 | 1764 | ||
1724 | ipv6_addr_copy(&cfg->fc_dst, &rtmsg->rtmsg_dst); | 1765 | ipv6_addr_copy(&cfg->fc_dst, &rtmsg->rtmsg_dst); |
1725 | ipv6_addr_copy(&cfg->fc_src, &rtmsg->rtmsg_src); | 1766 | ipv6_addr_copy(&cfg->fc_src, &rtmsg->rtmsg_src); |
1726 | ipv6_addr_copy(&cfg->fc_gateway, &rtmsg->rtmsg_gateway); | 1767 | ipv6_addr_copy(&cfg->fc_gateway, &rtmsg->rtmsg_gateway); |
1727 | } | 1768 | } |
1728 | 1769 | ||
1729 | int ipv6_route_ioctl(unsigned int cmd, void __user *arg) | 1770 | int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg) |
1730 | { | 1771 | { |
1731 | struct fib6_config cfg; | 1772 | struct fib6_config cfg; |
1732 | struct in6_rtmsg rtmsg; | 1773 | struct in6_rtmsg rtmsg; |
@@ -1742,7 +1783,7 @@ int ipv6_route_ioctl(unsigned int cmd, void __user *arg) | |||
1742 | if (err) | 1783 | if (err) |
1743 | return -EFAULT; | 1784 | return -EFAULT; |
1744 | 1785 | ||
1745 | rtmsg_to_fib6_config(&rtmsg, &cfg); | 1786 | rtmsg_to_fib6_config(net, &rtmsg, &cfg); |
1746 | 1787 | ||
1747 | rtnl_lock(); | 1788 | rtnl_lock(); |
1748 | switch (cmd) { | 1789 | switch (cmd) { |
@@ -1821,21 +1862,22 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1821 | const struct in6_addr *addr, | 1862 | const struct in6_addr *addr, |
1822 | int anycast) | 1863 | int anycast) |
1823 | { | 1864 | { |
1824 | struct rt6_info *rt = ip6_dst_alloc(); | 1865 | struct net *net = dev_net(idev->dev); |
1866 | struct rt6_info *rt = ip6_dst_alloc(net->ipv6.ip6_dst_ops); | ||
1825 | 1867 | ||
1826 | if (rt == NULL) | 1868 | if (rt == NULL) |
1827 | return ERR_PTR(-ENOMEM); | 1869 | return ERR_PTR(-ENOMEM); |
1828 | 1870 | ||
1829 | dev_hold(init_net.loopback_dev); | 1871 | dev_hold(net->loopback_dev); |
1830 | in6_dev_hold(idev); | 1872 | in6_dev_hold(idev); |
1831 | 1873 | ||
1832 | rt->u.dst.flags = DST_HOST; | 1874 | rt->u.dst.flags = DST_HOST; |
1833 | rt->u.dst.input = ip6_input; | 1875 | rt->u.dst.input = ip6_input; |
1834 | rt->u.dst.output = ip6_output; | 1876 | rt->u.dst.output = ip6_output; |
1835 | rt->rt6i_dev = init_net.loopback_dev; | 1877 | rt->rt6i_dev = net->loopback_dev; |
1836 | rt->rt6i_idev = idev; | 1878 | rt->rt6i_idev = idev; |
1837 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); | 1879 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); |
1838 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dst_mtu(&rt->u.dst)); | 1880 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); |
1839 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; | 1881 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; |
1840 | rt->u.dst.obsolete = -1; | 1882 | rt->u.dst.obsolete = -1; |
1841 | 1883 | ||
@@ -1852,26 +1894,39 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1852 | 1894 | ||
1853 | ipv6_addr_copy(&rt->rt6i_dst.addr, addr); | 1895 | ipv6_addr_copy(&rt->rt6i_dst.addr, addr); |
1854 | rt->rt6i_dst.plen = 128; | 1896 | rt->rt6i_dst.plen = 128; |
1855 | rt->rt6i_table = fib6_get_table(RT6_TABLE_LOCAL); | 1897 | rt->rt6i_table = fib6_get_table(net, RT6_TABLE_LOCAL); |
1856 | 1898 | ||
1857 | atomic_set(&rt->u.dst.__refcnt, 1); | 1899 | atomic_set(&rt->u.dst.__refcnt, 1); |
1858 | 1900 | ||
1859 | return rt; | 1901 | return rt; |
1860 | } | 1902 | } |
1861 | 1903 | ||
1904 | struct arg_dev_net { | ||
1905 | struct net_device *dev; | ||
1906 | struct net *net; | ||
1907 | }; | ||
1908 | |||
1862 | static int fib6_ifdown(struct rt6_info *rt, void *arg) | 1909 | static int fib6_ifdown(struct rt6_info *rt, void *arg) |
1863 | { | 1910 | { |
1864 | if (((void*)rt->rt6i_dev == arg || arg == NULL) && | 1911 | struct net_device *dev = ((struct arg_dev_net *)arg)->dev; |
1865 | rt != &ip6_null_entry) { | 1912 | struct net *net = ((struct arg_dev_net *)arg)->net; |
1913 | |||
1914 | if (((void *)rt->rt6i_dev == dev || dev == NULL) && | ||
1915 | rt != net->ipv6.ip6_null_entry) { | ||
1866 | RT6_TRACE("deleted by ifdown %p\n", rt); | 1916 | RT6_TRACE("deleted by ifdown %p\n", rt); |
1867 | return -1; | 1917 | return -1; |
1868 | } | 1918 | } |
1869 | return 0; | 1919 | return 0; |
1870 | } | 1920 | } |
1871 | 1921 | ||
1872 | void rt6_ifdown(struct net_device *dev) | 1922 | void rt6_ifdown(struct net *net, struct net_device *dev) |
1873 | { | 1923 | { |
1874 | fib6_clean_all(fib6_ifdown, 0, dev); | 1924 | struct arg_dev_net adn = { |
1925 | .dev = dev, | ||
1926 | .net = net, | ||
1927 | }; | ||
1928 | |||
1929 | fib6_clean_all(net, fib6_ifdown, 0, &adn); | ||
1875 | } | 1930 | } |
1876 | 1931 | ||
1877 | struct rt6_mtu_change_arg | 1932 | struct rt6_mtu_change_arg |
@@ -1884,6 +1939,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) | |||
1884 | { | 1939 | { |
1885 | struct rt6_mtu_change_arg *arg = (struct rt6_mtu_change_arg *) p_arg; | 1940 | struct rt6_mtu_change_arg *arg = (struct rt6_mtu_change_arg *) p_arg; |
1886 | struct inet6_dev *idev; | 1941 | struct inet6_dev *idev; |
1942 | struct net *net = dev_net(arg->dev); | ||
1887 | 1943 | ||
1888 | /* In IPv6 pmtu discovery is not optional, | 1944 | /* In IPv6 pmtu discovery is not optional, |
1889 | so that RTAX_MTU lock cannot disable it. | 1945 | so that RTAX_MTU lock cannot disable it. |
@@ -1915,7 +1971,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) | |||
1915 | (dst_mtu(&rt->u.dst) < arg->mtu && | 1971 | (dst_mtu(&rt->u.dst) < arg->mtu && |
1916 | dst_mtu(&rt->u.dst) == idev->cnf.mtu6))) { | 1972 | dst_mtu(&rt->u.dst) == idev->cnf.mtu6))) { |
1917 | rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu; | 1973 | rt->u.dst.metrics[RTAX_MTU-1] = arg->mtu; |
1918 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(arg->mtu); | 1974 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, arg->mtu); |
1919 | } | 1975 | } |
1920 | return 0; | 1976 | return 0; |
1921 | } | 1977 | } |
@@ -1927,7 +1983,7 @@ void rt6_mtu_change(struct net_device *dev, unsigned mtu) | |||
1927 | .mtu = mtu, | 1983 | .mtu = mtu, |
1928 | }; | 1984 | }; |
1929 | 1985 | ||
1930 | fib6_clean_all(rt6_mtu_change_route, 0, &arg); | 1986 | fib6_clean_all(dev_net(dev), rt6_mtu_change_route, 0, &arg); |
1931 | } | 1987 | } |
1932 | 1988 | ||
1933 | static const struct nla_policy rtm_ipv6_policy[RTA_MAX+1] = { | 1989 | static const struct nla_policy rtm_ipv6_policy[RTA_MAX+1] = { |
@@ -1964,7 +2020,7 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
1964 | 2020 | ||
1965 | cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; | 2021 | cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; |
1966 | cfg->fc_nlinfo.nlh = nlh; | 2022 | cfg->fc_nlinfo.nlh = nlh; |
1967 | cfg->fc_nlinfo.nl_net = skb->sk->sk_net; | 2023 | cfg->fc_nlinfo.nl_net = sock_net(skb->sk); |
1968 | 2024 | ||
1969 | if (tb[RTA_GATEWAY]) { | 2025 | if (tb[RTA_GATEWAY]) { |
1970 | nla_memcpy(&cfg->fc_gateway, tb[RTA_GATEWAY], 16); | 2026 | nla_memcpy(&cfg->fc_gateway, tb[RTA_GATEWAY], 16); |
@@ -2010,13 +2066,9 @@ errout: | |||
2010 | 2066 | ||
2011 | static int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | 2067 | static int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) |
2012 | { | 2068 | { |
2013 | struct net *net = skb->sk->sk_net; | ||
2014 | struct fib6_config cfg; | 2069 | struct fib6_config cfg; |
2015 | int err; | 2070 | int err; |
2016 | 2071 | ||
2017 | if (net != &init_net) | ||
2018 | return -EINVAL; | ||
2019 | |||
2020 | err = rtm_to_fib6_config(skb, nlh, &cfg); | 2072 | err = rtm_to_fib6_config(skb, nlh, &cfg); |
2021 | if (err < 0) | 2073 | if (err < 0) |
2022 | return err; | 2074 | return err; |
@@ -2026,13 +2078,9 @@ static int inet6_rtm_delroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *a | |||
2026 | 2078 | ||
2027 | static int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) | 2079 | static int inet6_rtm_newroute(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg) |
2028 | { | 2080 | { |
2029 | struct net *net = skb->sk->sk_net; | ||
2030 | struct fib6_config cfg; | 2081 | struct fib6_config cfg; |
2031 | int err; | 2082 | int err; |
2032 | 2083 | ||
2033 | if (net != &init_net) | ||
2034 | return -EINVAL; | ||
2035 | |||
2036 | err = rtm_to_fib6_config(skb, nlh, &cfg); | 2084 | err = rtm_to_fib6_config(skb, nlh, &cfg); |
2037 | if (err < 0) | 2085 | if (err < 0) |
2038 | return err; | 2086 | return err; |
@@ -2122,7 +2170,8 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | |||
2122 | NLA_PUT_U32(skb, RTA_IIF, iif); | 2170 | NLA_PUT_U32(skb, RTA_IIF, iif); |
2123 | else if (dst) { | 2171 | else if (dst) { |
2124 | struct in6_addr saddr_buf; | 2172 | struct in6_addr saddr_buf; |
2125 | if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0) | 2173 | if (ipv6_dev_get_saddr(ip6_dst_idev(&rt->u.dst)->dev, |
2174 | dst, 0, &saddr_buf) == 0) | ||
2126 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); | 2175 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); |
2127 | } | 2176 | } |
2128 | 2177 | ||
@@ -2167,7 +2216,7 @@ int rt6_dump_route(struct rt6_info *rt, void *p_arg) | |||
2167 | 2216 | ||
2168 | static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg) | 2217 | static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void *arg) |
2169 | { | 2218 | { |
2170 | struct net *net = in_skb->sk->sk_net; | 2219 | struct net *net = sock_net(in_skb->sk); |
2171 | struct nlattr *tb[RTA_MAX+1]; | 2220 | struct nlattr *tb[RTA_MAX+1]; |
2172 | struct rt6_info *rt; | 2221 | struct rt6_info *rt; |
2173 | struct sk_buff *skb; | 2222 | struct sk_buff *skb; |
@@ -2175,9 +2224,6 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2175 | struct flowi fl; | 2224 | struct flowi fl; |
2176 | int err, iif = 0; | 2225 | int err, iif = 0; |
2177 | 2226 | ||
2178 | if (net != &init_net) | ||
2179 | return -EINVAL; | ||
2180 | |||
2181 | err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy); | 2227 | err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy); |
2182 | if (err < 0) | 2228 | if (err < 0) |
2183 | goto errout; | 2229 | goto errout; |
@@ -2207,7 +2253,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2207 | 2253 | ||
2208 | if (iif) { | 2254 | if (iif) { |
2209 | struct net_device *dev; | 2255 | struct net_device *dev; |
2210 | dev = __dev_get_by_index(&init_net, iif); | 2256 | dev = __dev_get_by_index(net, iif); |
2211 | if (!dev) { | 2257 | if (!dev) { |
2212 | err = -ENODEV; | 2258 | err = -ENODEV; |
2213 | goto errout; | 2259 | goto errout; |
@@ -2226,7 +2272,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2226 | skb_reset_mac_header(skb); | 2272 | skb_reset_mac_header(skb); |
2227 | skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr)); | 2273 | skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr)); |
2228 | 2274 | ||
2229 | rt = (struct rt6_info*) ip6_route_output(NULL, &fl); | 2275 | rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl); |
2230 | skb->dst = &rt->u.dst; | 2276 | skb->dst = &rt->u.dst; |
2231 | 2277 | ||
2232 | err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, | 2278 | err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, |
@@ -2237,7 +2283,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2237 | goto errout; | 2283 | goto errout; |
2238 | } | 2284 | } |
2239 | 2285 | ||
2240 | err = rtnl_unicast(skb, &init_net, NETLINK_CB(in_skb).pid); | 2286 | err = rtnl_unicast(skb, net, NETLINK_CB(in_skb).pid); |
2241 | errout: | 2287 | errout: |
2242 | return err; | 2288 | return err; |
2243 | } | 2289 | } |
@@ -2245,6 +2291,7 @@ errout: | |||
2245 | void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) | 2291 | void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) |
2246 | { | 2292 | { |
2247 | struct sk_buff *skb; | 2293 | struct sk_buff *skb; |
2294 | struct net *net = info->nl_net; | ||
2248 | u32 seq; | 2295 | u32 seq; |
2249 | int err; | 2296 | int err; |
2250 | 2297 | ||
@@ -2263,11 +2310,31 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) | |||
2263 | kfree_skb(skb); | 2310 | kfree_skb(skb); |
2264 | goto errout; | 2311 | goto errout; |
2265 | } | 2312 | } |
2266 | err = rtnl_notify(skb, &init_net, info->pid, | 2313 | err = rtnl_notify(skb, net, info->pid, RTNLGRP_IPV6_ROUTE, |
2267 | RTNLGRP_IPV6_ROUTE, info->nlh, gfp_any()); | 2314 | info->nlh, gfp_any()); |
2268 | errout: | 2315 | errout: |
2269 | if (err < 0) | 2316 | if (err < 0) |
2270 | rtnl_set_sk_err(&init_net, RTNLGRP_IPV6_ROUTE, err); | 2317 | rtnl_set_sk_err(net, RTNLGRP_IPV6_ROUTE, err); |
2318 | } | ||
2319 | |||
2320 | static int ip6_route_dev_notify(struct notifier_block *this, | ||
2321 | unsigned long event, void *data) | ||
2322 | { | ||
2323 | struct net_device *dev = (struct net_device *)data; | ||
2324 | struct net *net = dev_net(dev); | ||
2325 | |||
2326 | if (event == NETDEV_REGISTER && (dev->flags & IFF_LOOPBACK)) { | ||
2327 | net->ipv6.ip6_null_entry->u.dst.dev = dev; | ||
2328 | net->ipv6.ip6_null_entry->rt6i_idev = in6_dev_get(dev); | ||
2329 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | ||
2330 | net->ipv6.ip6_prohibit_entry->u.dst.dev = dev; | ||
2331 | net->ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(dev); | ||
2332 | net->ipv6.ip6_blk_hole_entry->u.dst.dev = dev; | ||
2333 | net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev); | ||
2334 | #endif | ||
2335 | } | ||
2336 | |||
2337 | return NOTIFY_OK; | ||
2271 | } | 2338 | } |
2272 | 2339 | ||
2273 | /* | 2340 | /* |
@@ -2316,13 +2383,33 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg) | |||
2316 | 2383 | ||
2317 | static int ipv6_route_show(struct seq_file *m, void *v) | 2384 | static int ipv6_route_show(struct seq_file *m, void *v) |
2318 | { | 2385 | { |
2319 | fib6_clean_all(rt6_info_route, 0, m); | 2386 | struct net *net = (struct net *)m->private; |
2387 | fib6_clean_all(net, rt6_info_route, 0, m); | ||
2320 | return 0; | 2388 | return 0; |
2321 | } | 2389 | } |
2322 | 2390 | ||
2323 | static int ipv6_route_open(struct inode *inode, struct file *file) | 2391 | static int ipv6_route_open(struct inode *inode, struct file *file) |
2324 | { | 2392 | { |
2325 | return single_open(file, ipv6_route_show, NULL); | 2393 | int err; |
2394 | struct net *net = get_proc_net(inode); | ||
2395 | if (!net) | ||
2396 | return -ENXIO; | ||
2397 | |||
2398 | err = single_open(file, ipv6_route_show, net); | ||
2399 | if (err < 0) { | ||
2400 | put_net(net); | ||
2401 | return err; | ||
2402 | } | ||
2403 | |||
2404 | return 0; | ||
2405 | } | ||
2406 | |||
2407 | static int ipv6_route_release(struct inode *inode, struct file *file) | ||
2408 | { | ||
2409 | struct seq_file *seq = file->private_data; | ||
2410 | struct net *net = seq->private; | ||
2411 | put_net(net); | ||
2412 | return single_release(inode, file); | ||
2326 | } | 2413 | } |
2327 | 2414 | ||
2328 | static const struct file_operations ipv6_route_proc_fops = { | 2415 | static const struct file_operations ipv6_route_proc_fops = { |
@@ -2330,24 +2417,46 @@ static const struct file_operations ipv6_route_proc_fops = { | |||
2330 | .open = ipv6_route_open, | 2417 | .open = ipv6_route_open, |
2331 | .read = seq_read, | 2418 | .read = seq_read, |
2332 | .llseek = seq_lseek, | 2419 | .llseek = seq_lseek, |
2333 | .release = single_release, | 2420 | .release = ipv6_route_release, |
2334 | }; | 2421 | }; |
2335 | 2422 | ||
2336 | static int rt6_stats_seq_show(struct seq_file *seq, void *v) | 2423 | static int rt6_stats_seq_show(struct seq_file *seq, void *v) |
2337 | { | 2424 | { |
2425 | struct net *net = (struct net *)seq->private; | ||
2338 | seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n", | 2426 | seq_printf(seq, "%04x %04x %04x %04x %04x %04x %04x\n", |
2339 | rt6_stats.fib_nodes, rt6_stats.fib_route_nodes, | 2427 | net->ipv6.rt6_stats->fib_nodes, |
2340 | rt6_stats.fib_rt_alloc, rt6_stats.fib_rt_entries, | 2428 | net->ipv6.rt6_stats->fib_route_nodes, |
2341 | rt6_stats.fib_rt_cache, | 2429 | net->ipv6.rt6_stats->fib_rt_alloc, |
2342 | atomic_read(&ip6_dst_ops.entries), | 2430 | net->ipv6.rt6_stats->fib_rt_entries, |
2343 | rt6_stats.fib_discarded_routes); | 2431 | net->ipv6.rt6_stats->fib_rt_cache, |
2432 | atomic_read(&net->ipv6.ip6_dst_ops->entries), | ||
2433 | net->ipv6.rt6_stats->fib_discarded_routes); | ||
2344 | 2434 | ||
2345 | return 0; | 2435 | return 0; |
2346 | } | 2436 | } |
2347 | 2437 | ||
2348 | static int rt6_stats_seq_open(struct inode *inode, struct file *file) | 2438 | static int rt6_stats_seq_open(struct inode *inode, struct file *file) |
2349 | { | 2439 | { |
2350 | return single_open(file, rt6_stats_seq_show, NULL); | 2440 | int err; |
2441 | struct net *net = get_proc_net(inode); | ||
2442 | if (!net) | ||
2443 | return -ENXIO; | ||
2444 | |||
2445 | err = single_open(file, rt6_stats_seq_show, net); | ||
2446 | if (err < 0) { | ||
2447 | put_net(net); | ||
2448 | return err; | ||
2449 | } | ||
2450 | |||
2451 | return 0; | ||
2452 | } | ||
2453 | |||
2454 | static int rt6_stats_seq_release(struct inode *inode, struct file *file) | ||
2455 | { | ||
2456 | struct seq_file *seq = file->private_data; | ||
2457 | struct net *net = (struct net *)seq->private; | ||
2458 | put_net(net); | ||
2459 | return single_release(inode, file); | ||
2351 | } | 2460 | } |
2352 | 2461 | ||
2353 | static const struct file_operations rt6_stats_seq_fops = { | 2462 | static const struct file_operations rt6_stats_seq_fops = { |
@@ -2355,42 +2464,8 @@ static const struct file_operations rt6_stats_seq_fops = { | |||
2355 | .open = rt6_stats_seq_open, | 2464 | .open = rt6_stats_seq_open, |
2356 | .read = seq_read, | 2465 | .read = seq_read, |
2357 | .llseek = seq_lseek, | 2466 | .llseek = seq_lseek, |
2358 | .release = single_release, | 2467 | .release = rt6_stats_seq_release, |
2359 | }; | 2468 | }; |
2360 | |||
2361 | static int ipv6_route_proc_init(struct net *net) | ||
2362 | { | ||
2363 | int ret = -ENOMEM; | ||
2364 | if (!proc_net_fops_create(net, "ipv6_route", | ||
2365 | 0, &ipv6_route_proc_fops)) | ||
2366 | goto out; | ||
2367 | |||
2368 | if (!proc_net_fops_create(net, "rt6_stats", | ||
2369 | S_IRUGO, &rt6_stats_seq_fops)) | ||
2370 | goto out_ipv6_route; | ||
2371 | |||
2372 | ret = 0; | ||
2373 | out: | ||
2374 | return ret; | ||
2375 | out_ipv6_route: | ||
2376 | proc_net_remove(net, "ipv6_route"); | ||
2377 | goto out; | ||
2378 | } | ||
2379 | |||
2380 | static void ipv6_route_proc_fini(struct net *net) | ||
2381 | { | ||
2382 | proc_net_remove(net, "ipv6_route"); | ||
2383 | proc_net_remove(net, "rt6_stats"); | ||
2384 | } | ||
2385 | #else | ||
2386 | static inline int ipv6_route_proc_init(struct net *net) | ||
2387 | { | ||
2388 | return 0; | ||
2389 | } | ||
2390 | static inline void ipv6_route_proc_fini(struct net *net) | ||
2391 | { | ||
2392 | return ; | ||
2393 | } | ||
2394 | #endif /* CONFIG_PROC_FS */ | 2469 | #endif /* CONFIG_PROC_FS */ |
2395 | 2470 | ||
2396 | #ifdef CONFIG_SYSCTL | 2471 | #ifdef CONFIG_SYSCTL |
@@ -2399,10 +2474,11 @@ static | |||
2399 | int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, struct file * filp, | 2474 | int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, struct file * filp, |
2400 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2475 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2401 | { | 2476 | { |
2402 | int delay = init_net.ipv6.sysctl.flush_delay; | 2477 | struct net *net = current->nsproxy->net_ns; |
2478 | int delay = net->ipv6.sysctl.flush_delay; | ||
2403 | if (write) { | 2479 | if (write) { |
2404 | proc_dointvec(ctl, write, filp, buffer, lenp, ppos); | 2480 | proc_dointvec(ctl, write, filp, buffer, lenp, ppos); |
2405 | fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay); | 2481 | fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net); |
2406 | return 0; | 2482 | return 0; |
2407 | } else | 2483 | } else |
2408 | return -EINVAL; | 2484 | return -EINVAL; |
@@ -2419,7 +2495,7 @@ ctl_table ipv6_route_table_template[] = { | |||
2419 | { | 2495 | { |
2420 | .ctl_name = NET_IPV6_ROUTE_GC_THRESH, | 2496 | .ctl_name = NET_IPV6_ROUTE_GC_THRESH, |
2421 | .procname = "gc_thresh", | 2497 | .procname = "gc_thresh", |
2422 | .data = &ip6_dst_ops.gc_thresh, | 2498 | .data = &ip6_dst_ops_template.gc_thresh, |
2423 | .maxlen = sizeof(int), | 2499 | .maxlen = sizeof(int), |
2424 | .mode = 0644, | 2500 | .mode = 0644, |
2425 | .proc_handler = &proc_dointvec, | 2501 | .proc_handler = &proc_dointvec, |
@@ -2505,33 +2581,141 @@ struct ctl_table *ipv6_route_sysctl_init(struct net *net) | |||
2505 | table = kmemdup(ipv6_route_table_template, | 2581 | table = kmemdup(ipv6_route_table_template, |
2506 | sizeof(ipv6_route_table_template), | 2582 | sizeof(ipv6_route_table_template), |
2507 | GFP_KERNEL); | 2583 | GFP_KERNEL); |
2584 | |||
2585 | if (table) { | ||
2586 | table[0].data = &net->ipv6.sysctl.flush_delay; | ||
2587 | table[1].data = &net->ipv6.ip6_dst_ops->gc_thresh; | ||
2588 | table[2].data = &net->ipv6.sysctl.ip6_rt_max_size; | ||
2589 | table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; | ||
2590 | table[4].data = &net->ipv6.sysctl.ip6_rt_gc_timeout; | ||
2591 | table[5].data = &net->ipv6.sysctl.ip6_rt_gc_interval; | ||
2592 | table[6].data = &net->ipv6.sysctl.ip6_rt_gc_elasticity; | ||
2593 | table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires; | ||
2594 | table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss; | ||
2595 | } | ||
2596 | |||
2508 | return table; | 2597 | return table; |
2509 | } | 2598 | } |
2510 | #endif | 2599 | #endif |
2511 | 2600 | ||
2601 | static int ip6_route_net_init(struct net *net) | ||
2602 | { | ||
2603 | int ret = 0; | ||
2604 | |||
2605 | ret = -ENOMEM; | ||
2606 | net->ipv6.ip6_dst_ops = kmemdup(&ip6_dst_ops_template, | ||
2607 | sizeof(*net->ipv6.ip6_dst_ops), | ||
2608 | GFP_KERNEL); | ||
2609 | if (!net->ipv6.ip6_dst_ops) | ||
2610 | goto out; | ||
2611 | net->ipv6.ip6_dst_ops->dst_net = net; | ||
2612 | |||
2613 | net->ipv6.ip6_null_entry = kmemdup(&ip6_null_entry_template, | ||
2614 | sizeof(*net->ipv6.ip6_null_entry), | ||
2615 | GFP_KERNEL); | ||
2616 | if (!net->ipv6.ip6_null_entry) | ||
2617 | goto out_ip6_dst_ops; | ||
2618 | net->ipv6.ip6_null_entry->u.dst.path = | ||
2619 | (struct dst_entry *)net->ipv6.ip6_null_entry; | ||
2620 | net->ipv6.ip6_null_entry->u.dst.ops = net->ipv6.ip6_dst_ops; | ||
2621 | |||
2622 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | ||
2623 | net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, | ||
2624 | sizeof(*net->ipv6.ip6_prohibit_entry), | ||
2625 | GFP_KERNEL); | ||
2626 | if (!net->ipv6.ip6_prohibit_entry) { | ||
2627 | kfree(net->ipv6.ip6_null_entry); | ||
2628 | goto out; | ||
2629 | } | ||
2630 | net->ipv6.ip6_prohibit_entry->u.dst.path = | ||
2631 | (struct dst_entry *)net->ipv6.ip6_prohibit_entry; | ||
2632 | net->ipv6.ip6_prohibit_entry->u.dst.ops = net->ipv6.ip6_dst_ops; | ||
2633 | |||
2634 | net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, | ||
2635 | sizeof(*net->ipv6.ip6_blk_hole_entry), | ||
2636 | GFP_KERNEL); | ||
2637 | if (!net->ipv6.ip6_blk_hole_entry) { | ||
2638 | kfree(net->ipv6.ip6_null_entry); | ||
2639 | kfree(net->ipv6.ip6_prohibit_entry); | ||
2640 | goto out; | ||
2641 | } | ||
2642 | net->ipv6.ip6_blk_hole_entry->u.dst.path = | ||
2643 | (struct dst_entry *)net->ipv6.ip6_blk_hole_entry; | ||
2644 | net->ipv6.ip6_blk_hole_entry->u.dst.ops = net->ipv6.ip6_dst_ops; | ||
2645 | #endif | ||
2646 | |||
2647 | #ifdef CONFIG_PROC_FS | ||
2648 | proc_net_fops_create(net, "ipv6_route", 0, &ipv6_route_proc_fops); | ||
2649 | proc_net_fops_create(net, "rt6_stats", S_IRUGO, &rt6_stats_seq_fops); | ||
2650 | #endif | ||
2651 | net->ipv6.ip6_rt_gc_expire = 30*HZ; | ||
2652 | |||
2653 | ret = 0; | ||
2654 | out: | ||
2655 | return ret; | ||
2656 | |||
2657 | out_ip6_dst_ops: | ||
2658 | kfree(net->ipv6.ip6_dst_ops); | ||
2659 | goto out; | ||
2660 | } | ||
2661 | |||
2662 | static void ip6_route_net_exit(struct net *net) | ||
2663 | { | ||
2664 | #ifdef CONFIG_PROC_FS | ||
2665 | proc_net_remove(net, "ipv6_route"); | ||
2666 | proc_net_remove(net, "rt6_stats"); | ||
2667 | #endif | ||
2668 | kfree(net->ipv6.ip6_null_entry); | ||
2669 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | ||
2670 | kfree(net->ipv6.ip6_prohibit_entry); | ||
2671 | kfree(net->ipv6.ip6_blk_hole_entry); | ||
2672 | #endif | ||
2673 | kfree(net->ipv6.ip6_dst_ops); | ||
2674 | } | ||
2675 | |||
2676 | static struct pernet_operations ip6_route_net_ops = { | ||
2677 | .init = ip6_route_net_init, | ||
2678 | .exit = ip6_route_net_exit, | ||
2679 | }; | ||
2680 | |||
2681 | static struct notifier_block ip6_route_dev_notifier = { | ||
2682 | .notifier_call = ip6_route_dev_notify, | ||
2683 | .priority = 0, | ||
2684 | }; | ||
2685 | |||
2512 | int __init ip6_route_init(void) | 2686 | int __init ip6_route_init(void) |
2513 | { | 2687 | { |
2514 | int ret; | 2688 | int ret; |
2515 | 2689 | ||
2516 | ip6_dst_ops.kmem_cachep = | 2690 | ret = -ENOMEM; |
2691 | ip6_dst_ops_template.kmem_cachep = | ||
2517 | kmem_cache_create("ip6_dst_cache", sizeof(struct rt6_info), 0, | 2692 | kmem_cache_create("ip6_dst_cache", sizeof(struct rt6_info), 0, |
2518 | SLAB_HWCACHE_ALIGN, NULL); | 2693 | SLAB_HWCACHE_ALIGN, NULL); |
2519 | if (!ip6_dst_ops.kmem_cachep) | 2694 | if (!ip6_dst_ops_template.kmem_cachep) |
2520 | return -ENOMEM; | 2695 | goto out;; |
2521 | 2696 | ||
2522 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops.kmem_cachep; | 2697 | ret = register_pernet_subsys(&ip6_route_net_ops); |
2523 | |||
2524 | ret = fib6_init(); | ||
2525 | if (ret) | 2698 | if (ret) |
2526 | goto out_kmem_cache; | 2699 | goto out_kmem_cache; |
2527 | 2700 | ||
2528 | ret = ipv6_route_proc_init(&init_net); | 2701 | /* Registering of the loopback is done before this portion of code, |
2702 | * the loopback reference in rt6_info will not be taken, do it | ||
2703 | * manually for init_net */ | ||
2704 | init_net.ipv6.ip6_null_entry->u.dst.dev = init_net.loopback_dev; | ||
2705 | init_net.ipv6.ip6_null_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); | ||
2706 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | ||
2707 | init_net.ipv6.ip6_prohibit_entry->u.dst.dev = init_net.loopback_dev; | ||
2708 | init_net.ipv6.ip6_prohibit_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); | ||
2709 | init_net.ipv6.ip6_blk_hole_entry->u.dst.dev = init_net.loopback_dev; | ||
2710 | init_net.ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(init_net.loopback_dev); | ||
2711 | #endif | ||
2712 | ret = fib6_init(); | ||
2529 | if (ret) | 2713 | if (ret) |
2530 | goto out_fib6_init; | 2714 | goto out_register_subsys; |
2531 | 2715 | ||
2532 | ret = xfrm6_init(); | 2716 | ret = xfrm6_init(); |
2533 | if (ret) | 2717 | if (ret) |
2534 | goto out_proc_init; | 2718 | goto out_fib6_init; |
2535 | 2719 | ||
2536 | ret = fib6_rules_init(); | 2720 | ret = fib6_rules_init(); |
2537 | if (ret) | 2721 | if (ret) |
@@ -2543,7 +2727,10 @@ int __init ip6_route_init(void) | |||
2543 | __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL)) | 2727 | __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL)) |
2544 | goto fib6_rules_init; | 2728 | goto fib6_rules_init; |
2545 | 2729 | ||
2546 | ret = 0; | 2730 | ret = register_netdevice_notifier(&ip6_route_dev_notifier); |
2731 | if (ret) | ||
2732 | goto fib6_rules_init; | ||
2733 | |||
2547 | out: | 2734 | out: |
2548 | return ret; | 2735 | return ret; |
2549 | 2736 | ||
@@ -2551,22 +2738,21 @@ fib6_rules_init: | |||
2551 | fib6_rules_cleanup(); | 2738 | fib6_rules_cleanup(); |
2552 | xfrm6_init: | 2739 | xfrm6_init: |
2553 | xfrm6_fini(); | 2740 | xfrm6_fini(); |
2554 | out_proc_init: | ||
2555 | ipv6_route_proc_fini(&init_net); | ||
2556 | out_fib6_init: | 2741 | out_fib6_init: |
2557 | rt6_ifdown(NULL); | ||
2558 | fib6_gc_cleanup(); | 2742 | fib6_gc_cleanup(); |
2743 | out_register_subsys: | ||
2744 | unregister_pernet_subsys(&ip6_route_net_ops); | ||
2559 | out_kmem_cache: | 2745 | out_kmem_cache: |
2560 | kmem_cache_destroy(ip6_dst_ops.kmem_cachep); | 2746 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); |
2561 | goto out; | 2747 | goto out; |
2562 | } | 2748 | } |
2563 | 2749 | ||
2564 | void ip6_route_cleanup(void) | 2750 | void ip6_route_cleanup(void) |
2565 | { | 2751 | { |
2752 | unregister_netdevice_notifier(&ip6_route_dev_notifier); | ||
2566 | fib6_rules_cleanup(); | 2753 | fib6_rules_cleanup(); |
2567 | ipv6_route_proc_fini(&init_net); | ||
2568 | xfrm6_fini(); | 2754 | xfrm6_fini(); |
2569 | rt6_ifdown(NULL); | ||
2570 | fib6_gc_cleanup(); | 2755 | fib6_gc_cleanup(); |
2571 | kmem_cache_destroy(ip6_dst_ops.kmem_cachep); | 2756 | unregister_pernet_subsys(&ip6_route_net_ops); |
2757 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); | ||
2572 | } | 2758 | } |