diff options
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 589 |
1 files changed, 365 insertions, 224 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index a275c6e1e25c..0ef1f086feb8 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -72,10 +72,10 @@ | |||
72 | #define RT6_TRACE(x...) do { ; } while (0) | 72 | #define RT6_TRACE(x...) do { ; } while (0) |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | #define CLONE_OFFLINK_ROUTE 0 | ||
76 | |||
77 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort); | 75 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort); |
78 | static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); | 76 | static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); |
77 | static unsigned int ip6_default_advmss(const struct dst_entry *dst); | ||
78 | static unsigned int ip6_default_mtu(const struct dst_entry *dst); | ||
79 | static struct dst_entry *ip6_negative_advice(struct dst_entry *); | 79 | static struct dst_entry *ip6_negative_advice(struct dst_entry *); |
80 | static void ip6_dst_destroy(struct dst_entry *); | 80 | static void ip6_dst_destroy(struct dst_entry *); |
81 | static void ip6_dst_ifdown(struct dst_entry *, | 81 | static void ip6_dst_ifdown(struct dst_entry *, |
@@ -89,40 +89,89 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu); | |||
89 | 89 | ||
90 | #ifdef CONFIG_IPV6_ROUTE_INFO | 90 | #ifdef CONFIG_IPV6_ROUTE_INFO |
91 | static struct rt6_info *rt6_add_route_info(struct net *net, | 91 | static struct rt6_info *rt6_add_route_info(struct net *net, |
92 | struct in6_addr *prefix, int prefixlen, | 92 | const struct in6_addr *prefix, int prefixlen, |
93 | struct in6_addr *gwaddr, int ifindex, | 93 | const struct in6_addr *gwaddr, int ifindex, |
94 | unsigned pref); | 94 | unsigned pref); |
95 | static struct rt6_info *rt6_get_route_info(struct net *net, | 95 | static struct rt6_info *rt6_get_route_info(struct net *net, |
96 | struct in6_addr *prefix, int prefixlen, | 96 | const struct in6_addr *prefix, int prefixlen, |
97 | struct in6_addr *gwaddr, int ifindex); | 97 | const struct in6_addr *gwaddr, int ifindex); |
98 | #endif | 98 | #endif |
99 | 99 | ||
100 | static u32 *ipv6_cow_metrics(struct dst_entry *dst, unsigned long old) | ||
101 | { | ||
102 | struct rt6_info *rt = (struct rt6_info *) dst; | ||
103 | struct inet_peer *peer; | ||
104 | u32 *p = NULL; | ||
105 | |||
106 | if (!rt->rt6i_peer) | ||
107 | rt6_bind_peer(rt, 1); | ||
108 | |||
109 | peer = rt->rt6i_peer; | ||
110 | if (peer) { | ||
111 | u32 *old_p = __DST_METRICS_PTR(old); | ||
112 | unsigned long prev, new; | ||
113 | |||
114 | p = peer->metrics; | ||
115 | if (inet_metrics_new(peer)) | ||
116 | memcpy(p, old_p, sizeof(u32) * RTAX_MAX); | ||
117 | |||
118 | new = (unsigned long) p; | ||
119 | prev = cmpxchg(&dst->_metrics, old, new); | ||
120 | |||
121 | if (prev != old) { | ||
122 | p = __DST_METRICS_PTR(prev); | ||
123 | if (prev & DST_METRICS_READ_ONLY) | ||
124 | p = NULL; | ||
125 | } | ||
126 | } | ||
127 | return p; | ||
128 | } | ||
129 | |||
100 | static struct dst_ops ip6_dst_ops_template = { | 130 | static struct dst_ops ip6_dst_ops_template = { |
101 | .family = AF_INET6, | 131 | .family = AF_INET6, |
102 | .protocol = cpu_to_be16(ETH_P_IPV6), | 132 | .protocol = cpu_to_be16(ETH_P_IPV6), |
103 | .gc = ip6_dst_gc, | 133 | .gc = ip6_dst_gc, |
104 | .gc_thresh = 1024, | 134 | .gc_thresh = 1024, |
105 | .check = ip6_dst_check, | 135 | .check = ip6_dst_check, |
136 | .default_advmss = ip6_default_advmss, | ||
137 | .default_mtu = ip6_default_mtu, | ||
138 | .cow_metrics = ipv6_cow_metrics, | ||
106 | .destroy = ip6_dst_destroy, | 139 | .destroy = ip6_dst_destroy, |
107 | .ifdown = ip6_dst_ifdown, | 140 | .ifdown = ip6_dst_ifdown, |
108 | .negative_advice = ip6_negative_advice, | 141 | .negative_advice = ip6_negative_advice, |
109 | .link_failure = ip6_link_failure, | 142 | .link_failure = ip6_link_failure, |
110 | .update_pmtu = ip6_rt_update_pmtu, | 143 | .update_pmtu = ip6_rt_update_pmtu, |
111 | .local_out = __ip6_local_out, | 144 | .local_out = __ip6_local_out, |
112 | .entries = ATOMIC_INIT(0), | ||
113 | }; | 145 | }; |
114 | 146 | ||
147 | static unsigned int ip6_blackhole_default_mtu(const struct dst_entry *dst) | ||
148 | { | ||
149 | return 0; | ||
150 | } | ||
151 | |||
115 | static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) | 152 | static void ip6_rt_blackhole_update_pmtu(struct dst_entry *dst, u32 mtu) |
116 | { | 153 | { |
117 | } | 154 | } |
118 | 155 | ||
156 | static u32 *ip6_rt_blackhole_cow_metrics(struct dst_entry *dst, | ||
157 | unsigned long old) | ||
158 | { | ||
159 | return NULL; | ||
160 | } | ||
161 | |||
119 | static struct dst_ops ip6_dst_blackhole_ops = { | 162 | static struct dst_ops ip6_dst_blackhole_ops = { |
120 | .family = AF_INET6, | 163 | .family = AF_INET6, |
121 | .protocol = cpu_to_be16(ETH_P_IPV6), | 164 | .protocol = cpu_to_be16(ETH_P_IPV6), |
122 | .destroy = ip6_dst_destroy, | 165 | .destroy = ip6_dst_destroy, |
123 | .check = ip6_dst_check, | 166 | .check = ip6_dst_check, |
167 | .default_mtu = ip6_blackhole_default_mtu, | ||
168 | .default_advmss = ip6_default_advmss, | ||
124 | .update_pmtu = ip6_rt_blackhole_update_pmtu, | 169 | .update_pmtu = ip6_rt_blackhole_update_pmtu, |
125 | .entries = ATOMIC_INIT(0), | 170 | .cow_metrics = ip6_rt_blackhole_cow_metrics, |
171 | }; | ||
172 | |||
173 | static const u32 ip6_template_metrics[RTAX_MAX] = { | ||
174 | [RTAX_HOPLIMIT - 1] = 255, | ||
126 | }; | 175 | }; |
127 | 176 | ||
128 | static struct rt6_info ip6_null_entry_template = { | 177 | static struct rt6_info ip6_null_entry_template = { |
@@ -131,7 +180,6 @@ static struct rt6_info ip6_null_entry_template = { | |||
131 | .__use = 1, | 180 | .__use = 1, |
132 | .obsolete = -1, | 181 | .obsolete = -1, |
133 | .error = -ENETUNREACH, | 182 | .error = -ENETUNREACH, |
134 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | ||
135 | .input = ip6_pkt_discard, | 183 | .input = ip6_pkt_discard, |
136 | .output = ip6_pkt_discard_out, | 184 | .output = ip6_pkt_discard_out, |
137 | }, | 185 | }, |
@@ -152,7 +200,6 @@ static struct rt6_info ip6_prohibit_entry_template = { | |||
152 | .__use = 1, | 200 | .__use = 1, |
153 | .obsolete = -1, | 201 | .obsolete = -1, |
154 | .error = -EACCES, | 202 | .error = -EACCES, |
155 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | ||
156 | .input = ip6_pkt_prohibit, | 203 | .input = ip6_pkt_prohibit, |
157 | .output = ip6_pkt_prohibit_out, | 204 | .output = ip6_pkt_prohibit_out, |
158 | }, | 205 | }, |
@@ -168,7 +215,6 @@ static struct rt6_info ip6_blk_hole_entry_template = { | |||
168 | .__use = 1, | 215 | .__use = 1, |
169 | .obsolete = -1, | 216 | .obsolete = -1, |
170 | .error = -EINVAL, | 217 | .error = -EINVAL, |
171 | .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, | ||
172 | .input = dst_discard, | 218 | .input = dst_discard, |
173 | .output = dst_discard, | 219 | .output = dst_discard, |
174 | }, | 220 | }, |
@@ -181,20 +227,49 @@ static struct rt6_info ip6_blk_hole_entry_template = { | |||
181 | #endif | 227 | #endif |
182 | 228 | ||
183 | /* allocate dst with ip6_dst_ops */ | 229 | /* allocate dst with ip6_dst_ops */ |
184 | static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops) | 230 | static inline struct rt6_info *ip6_dst_alloc(struct dst_ops *ops, |
231 | struct net_device *dev, | ||
232 | int flags) | ||
185 | { | 233 | { |
186 | return (struct rt6_info *)dst_alloc(ops); | 234 | struct rt6_info *rt = dst_alloc(ops, dev, 0, 0, flags); |
235 | |||
236 | memset(&rt->rt6i_table, 0, sizeof(*rt) - sizeof(struct dst_entry)); | ||
237 | |||
238 | return rt; | ||
187 | } | 239 | } |
188 | 240 | ||
189 | static void ip6_dst_destroy(struct dst_entry *dst) | 241 | static void ip6_dst_destroy(struct dst_entry *dst) |
190 | { | 242 | { |
191 | struct rt6_info *rt = (struct rt6_info *)dst; | 243 | struct rt6_info *rt = (struct rt6_info *)dst; |
192 | struct inet6_dev *idev = rt->rt6i_idev; | 244 | struct inet6_dev *idev = rt->rt6i_idev; |
245 | struct inet_peer *peer = rt->rt6i_peer; | ||
193 | 246 | ||
194 | if (idev != NULL) { | 247 | if (idev != NULL) { |
195 | rt->rt6i_idev = NULL; | 248 | rt->rt6i_idev = NULL; |
196 | in6_dev_put(idev); | 249 | in6_dev_put(idev); |
197 | } | 250 | } |
251 | if (peer) { | ||
252 | rt->rt6i_peer = NULL; | ||
253 | inet_putpeer(peer); | ||
254 | } | ||
255 | } | ||
256 | |||
257 | static atomic_t __rt6_peer_genid = ATOMIC_INIT(0); | ||
258 | |||
259 | static u32 rt6_peer_genid(void) | ||
260 | { | ||
261 | return atomic_read(&__rt6_peer_genid); | ||
262 | } | ||
263 | |||
264 | void rt6_bind_peer(struct rt6_info *rt, int create) | ||
265 | { | ||
266 | struct inet_peer *peer; | ||
267 | |||
268 | peer = inet_getpeer_v6(&rt->rt6i_dst.addr, create); | ||
269 | if (peer && cmpxchg(&rt->rt6i_peer, NULL, peer) != NULL) | ||
270 | inet_putpeer(peer); | ||
271 | else | ||
272 | rt->rt6i_peer_genid = rt6_peer_genid(); | ||
198 | } | 273 | } |
199 | 274 | ||
200 | static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | 275 | static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, |
@@ -217,14 +292,14 @@ static void ip6_dst_ifdown(struct dst_entry *dst, struct net_device *dev, | |||
217 | 292 | ||
218 | static __inline__ int rt6_check_expired(const struct rt6_info *rt) | 293 | static __inline__ int rt6_check_expired(const struct rt6_info *rt) |
219 | { | 294 | { |
220 | return (rt->rt6i_flags & RTF_EXPIRES && | 295 | return (rt->rt6i_flags & RTF_EXPIRES) && |
221 | time_after(jiffies, rt->rt6i_expires)); | 296 | time_after(jiffies, rt->rt6i_expires); |
222 | } | 297 | } |
223 | 298 | ||
224 | static inline int rt6_need_strict(struct in6_addr *daddr) | 299 | static inline int rt6_need_strict(const struct in6_addr *daddr) |
225 | { | 300 | { |
226 | return (ipv6_addr_type(daddr) & | 301 | return ipv6_addr_type(daddr) & |
227 | (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK)); | 302 | (IPV6_ADDR_MULTICAST | IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK); |
228 | } | 303 | } |
229 | 304 | ||
230 | /* | 305 | /* |
@@ -233,7 +308,7 @@ static inline int rt6_need_strict(struct in6_addr *daddr) | |||
233 | 308 | ||
234 | static inline struct rt6_info *rt6_device_match(struct net *net, | 309 | static inline struct rt6_info *rt6_device_match(struct net *net, |
235 | struct rt6_info *rt, | 310 | struct rt6_info *rt, |
236 | struct in6_addr *saddr, | 311 | const struct in6_addr *saddr, |
237 | int oif, | 312 | int oif, |
238 | int flags) | 313 | int flags) |
239 | { | 314 | { |
@@ -440,12 +515,12 @@ static struct rt6_info *rt6_select(struct fib6_node *fn, int oif, int strict) | |||
440 | __func__, match); | 515 | __func__, match); |
441 | 516 | ||
442 | net = dev_net(rt0->rt6i_dev); | 517 | net = dev_net(rt0->rt6i_dev); |
443 | return (match ? match : net->ipv6.ip6_null_entry); | 518 | return match ? match : net->ipv6.ip6_null_entry; |
444 | } | 519 | } |
445 | 520 | ||
446 | #ifdef CONFIG_IPV6_ROUTE_INFO | 521 | #ifdef CONFIG_IPV6_ROUTE_INFO |
447 | int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, | 522 | int rt6_route_rcv(struct net_device *dev, u8 *opt, int len, |
448 | struct in6_addr *gwaddr) | 523 | const struct in6_addr *gwaddr) |
449 | { | 524 | { |
450 | struct net *net = dev_net(dev); | 525 | struct net *net = dev_net(dev); |
451 | struct route_info *rinfo = (struct route_info *) opt; | 526 | struct route_info *rinfo = (struct route_info *) opt; |
@@ -537,17 +612,17 @@ do { \ | |||
537 | 612 | ||
538 | static struct rt6_info *ip6_pol_route_lookup(struct net *net, | 613 | static struct rt6_info *ip6_pol_route_lookup(struct net *net, |
539 | struct fib6_table *table, | 614 | struct fib6_table *table, |
540 | struct flowi *fl, int flags) | 615 | struct flowi6 *fl6, int flags) |
541 | { | 616 | { |
542 | struct fib6_node *fn; | 617 | struct fib6_node *fn; |
543 | struct rt6_info *rt; | 618 | struct rt6_info *rt; |
544 | 619 | ||
545 | read_lock_bh(&table->tb6_lock); | 620 | read_lock_bh(&table->tb6_lock); |
546 | fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); | 621 | fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr); |
547 | restart: | 622 | restart: |
548 | rt = fn->leaf; | 623 | rt = fn->leaf; |
549 | rt = rt6_device_match(net, rt, &fl->fl6_src, fl->oif, flags); | 624 | rt = rt6_device_match(net, rt, &fl6->saddr, fl6->flowi6_oif, flags); |
550 | BACKTRACK(net, &fl->fl6_src); | 625 | BACKTRACK(net, &fl6->saddr); |
551 | out: | 626 | out: |
552 | dst_use(&rt->dst, jiffies); | 627 | dst_use(&rt->dst, jiffies); |
553 | read_unlock_bh(&table->tb6_lock); | 628 | read_unlock_bh(&table->tb6_lock); |
@@ -558,23 +633,19 @@ out: | |||
558 | struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr, | 633 | struct rt6_info *rt6_lookup(struct net *net, const struct in6_addr *daddr, |
559 | const struct in6_addr *saddr, int oif, int strict) | 634 | const struct in6_addr *saddr, int oif, int strict) |
560 | { | 635 | { |
561 | struct flowi fl = { | 636 | struct flowi6 fl6 = { |
562 | .oif = oif, | 637 | .flowi6_oif = oif, |
563 | .nl_u = { | 638 | .daddr = *daddr, |
564 | .ip6_u = { | ||
565 | .daddr = *daddr, | ||
566 | }, | ||
567 | }, | ||
568 | }; | 639 | }; |
569 | struct dst_entry *dst; | 640 | struct dst_entry *dst; |
570 | int flags = strict ? RT6_LOOKUP_F_IFACE : 0; | 641 | int flags = strict ? RT6_LOOKUP_F_IFACE : 0; |
571 | 642 | ||
572 | if (saddr) { | 643 | if (saddr) { |
573 | memcpy(&fl.fl6_src, saddr, sizeof(*saddr)); | 644 | memcpy(&fl6.saddr, saddr, sizeof(*saddr)); |
574 | flags |= RT6_LOOKUP_F_HAS_SADDR; | 645 | flags |= RT6_LOOKUP_F_HAS_SADDR; |
575 | } | 646 | } |
576 | 647 | ||
577 | dst = fib6_rule_lookup(net, &fl, flags, ip6_pol_route_lookup); | 648 | dst = fib6_rule_lookup(net, &fl6, flags, ip6_pol_route_lookup); |
578 | if (dst->error == 0) | 649 | if (dst->error == 0) |
579 | return (struct rt6_info *) dst; | 650 | return (struct rt6_info *) dst; |
580 | 651 | ||
@@ -612,8 +683,8 @@ int ip6_ins_rt(struct rt6_info *rt) | |||
612 | return __ip6_ins_rt(rt, &info); | 683 | return __ip6_ins_rt(rt, &info); |
613 | } | 684 | } |
614 | 685 | ||
615 | static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *daddr, | 686 | static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, const struct in6_addr *daddr, |
616 | struct in6_addr *saddr) | 687 | const struct in6_addr *saddr) |
617 | { | 688 | { |
618 | struct rt6_info *rt; | 689 | struct rt6_info *rt; |
619 | 690 | ||
@@ -681,7 +752,7 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *dad | |||
681 | return rt; | 752 | return rt; |
682 | } | 753 | } |
683 | 754 | ||
684 | static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *daddr) | 755 | static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, const struct in6_addr *daddr) |
685 | { | 756 | { |
686 | struct rt6_info *rt = ip6_rt_copy(ort); | 757 | struct rt6_info *rt = ip6_rt_copy(ort); |
687 | if (rt) { | 758 | if (rt) { |
@@ -695,7 +766,7 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, struct in6_addr *d | |||
695 | } | 766 | } |
696 | 767 | ||
697 | static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, int oif, | 768 | static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table, int oif, |
698 | struct flowi *fl, int flags) | 769 | struct flowi6 *fl6, int flags) |
699 | { | 770 | { |
700 | struct fib6_node *fn; | 771 | struct fib6_node *fn; |
701 | struct rt6_info *rt, *nrt; | 772 | struct rt6_info *rt, *nrt; |
@@ -710,12 +781,12 @@ relookup: | |||
710 | read_lock_bh(&table->tb6_lock); | 781 | read_lock_bh(&table->tb6_lock); |
711 | 782 | ||
712 | restart_2: | 783 | restart_2: |
713 | fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); | 784 | fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr); |
714 | 785 | ||
715 | restart: | 786 | restart: |
716 | rt = rt6_select(fn, oif, strict | reachable); | 787 | rt = rt6_select(fn, oif, strict | reachable); |
717 | 788 | ||
718 | BACKTRACK(net, &fl->fl6_src); | 789 | BACKTRACK(net, &fl6->saddr); |
719 | if (rt == net->ipv6.ip6_null_entry || | 790 | if (rt == net->ipv6.ip6_null_entry || |
720 | rt->rt6i_flags & RTF_CACHE) | 791 | rt->rt6i_flags & RTF_CACHE) |
721 | goto out; | 792 | goto out; |
@@ -724,14 +795,11 @@ restart: | |||
724 | read_unlock_bh(&table->tb6_lock); | 795 | read_unlock_bh(&table->tb6_lock); |
725 | 796 | ||
726 | if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) | 797 | if (!rt->rt6i_nexthop && !(rt->rt6i_flags & RTF_NONEXTHOP)) |
727 | nrt = rt6_alloc_cow(rt, &fl->fl6_dst, &fl->fl6_src); | 798 | nrt = rt6_alloc_cow(rt, &fl6->daddr, &fl6->saddr); |
728 | else { | 799 | else if (!(rt->dst.flags & DST_HOST)) |
729 | #if CLONE_OFFLINK_ROUTE | 800 | nrt = rt6_alloc_clone(rt, &fl6->daddr); |
730 | nrt = rt6_alloc_clone(rt, &fl->fl6_dst); | 801 | else |
731 | #else | ||
732 | goto out2; | 802 | goto out2; |
733 | #endif | ||
734 | } | ||
735 | 803 | ||
736 | dst_release(&rt->dst); | 804 | dst_release(&rt->dst); |
737 | rt = nrt ? : net->ipv6.ip6_null_entry; | 805 | rt = nrt ? : net->ipv6.ip6_null_entry; |
@@ -768,78 +836,71 @@ out2: | |||
768 | } | 836 | } |
769 | 837 | ||
770 | static struct rt6_info *ip6_pol_route_input(struct net *net, struct fib6_table *table, | 838 | static struct rt6_info *ip6_pol_route_input(struct net *net, struct fib6_table *table, |
771 | struct flowi *fl, int flags) | 839 | struct flowi6 *fl6, int flags) |
772 | { | 840 | { |
773 | return ip6_pol_route(net, table, fl->iif, fl, flags); | 841 | return ip6_pol_route(net, table, fl6->flowi6_iif, fl6, flags); |
774 | } | 842 | } |
775 | 843 | ||
776 | void ip6_route_input(struct sk_buff *skb) | 844 | void ip6_route_input(struct sk_buff *skb) |
777 | { | 845 | { |
778 | struct ipv6hdr *iph = ipv6_hdr(skb); | 846 | const struct ipv6hdr *iph = ipv6_hdr(skb); |
779 | struct net *net = dev_net(skb->dev); | 847 | struct net *net = dev_net(skb->dev); |
780 | int flags = RT6_LOOKUP_F_HAS_SADDR; | 848 | int flags = RT6_LOOKUP_F_HAS_SADDR; |
781 | struct flowi fl = { | 849 | struct flowi6 fl6 = { |
782 | .iif = skb->dev->ifindex, | 850 | .flowi6_iif = skb->dev->ifindex, |
783 | .nl_u = { | 851 | .daddr = iph->daddr, |
784 | .ip6_u = { | 852 | .saddr = iph->saddr, |
785 | .daddr = iph->daddr, | 853 | .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK, |
786 | .saddr = iph->saddr, | 854 | .flowi6_mark = skb->mark, |
787 | .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK, | 855 | .flowi6_proto = iph->nexthdr, |
788 | }, | ||
789 | }, | ||
790 | .mark = skb->mark, | ||
791 | .proto = iph->nexthdr, | ||
792 | }; | 856 | }; |
793 | 857 | ||
794 | if (rt6_need_strict(&iph->daddr) && skb->dev->type != ARPHRD_PIMREG) | 858 | if (rt6_need_strict(&iph->daddr) && skb->dev->type != ARPHRD_PIMREG) |
795 | flags |= RT6_LOOKUP_F_IFACE; | 859 | flags |= RT6_LOOKUP_F_IFACE; |
796 | 860 | ||
797 | skb_dst_set(skb, fib6_rule_lookup(net, &fl, flags, ip6_pol_route_input)); | 861 | skb_dst_set(skb, fib6_rule_lookup(net, &fl6, flags, ip6_pol_route_input)); |
798 | } | 862 | } |
799 | 863 | ||
800 | static struct rt6_info *ip6_pol_route_output(struct net *net, struct fib6_table *table, | 864 | static struct rt6_info *ip6_pol_route_output(struct net *net, struct fib6_table *table, |
801 | struct flowi *fl, int flags) | 865 | struct flowi6 *fl6, int flags) |
802 | { | 866 | { |
803 | return ip6_pol_route(net, table, fl->oif, fl, flags); | 867 | return ip6_pol_route(net, table, fl6->flowi6_oif, fl6, flags); |
804 | } | 868 | } |
805 | 869 | ||
806 | struct dst_entry * ip6_route_output(struct net *net, struct sock *sk, | 870 | struct dst_entry * ip6_route_output(struct net *net, const struct sock *sk, |
807 | struct flowi *fl) | 871 | struct flowi6 *fl6) |
808 | { | 872 | { |
809 | int flags = 0; | 873 | int flags = 0; |
810 | 874 | ||
811 | if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl->fl6_dst)) | 875 | if ((sk && sk->sk_bound_dev_if) || rt6_need_strict(&fl6->daddr)) |
812 | flags |= RT6_LOOKUP_F_IFACE; | 876 | flags |= RT6_LOOKUP_F_IFACE; |
813 | 877 | ||
814 | if (!ipv6_addr_any(&fl->fl6_src)) | 878 | if (!ipv6_addr_any(&fl6->saddr)) |
815 | flags |= RT6_LOOKUP_F_HAS_SADDR; | 879 | flags |= RT6_LOOKUP_F_HAS_SADDR; |
816 | else if (sk) | 880 | else if (sk) |
817 | flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs); | 881 | flags |= rt6_srcprefs2flags(inet6_sk(sk)->srcprefs); |
818 | 882 | ||
819 | return fib6_rule_lookup(net, fl, flags, ip6_pol_route_output); | 883 | return fib6_rule_lookup(net, fl6, flags, ip6_pol_route_output); |
820 | } | 884 | } |
821 | 885 | ||
822 | EXPORT_SYMBOL(ip6_route_output); | 886 | EXPORT_SYMBOL(ip6_route_output); |
823 | 887 | ||
824 | int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl) | 888 | struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_orig) |
825 | { | 889 | { |
826 | struct rt6_info *ort = (struct rt6_info *) *dstp; | 890 | struct rt6_info *rt, *ort = (struct rt6_info *) dst_orig; |
827 | struct rt6_info *rt = (struct rt6_info *) | ||
828 | dst_alloc(&ip6_dst_blackhole_ops); | ||
829 | struct dst_entry *new = NULL; | 891 | struct dst_entry *new = NULL; |
830 | 892 | ||
893 | rt = dst_alloc(&ip6_dst_blackhole_ops, ort->dst.dev, 1, 0, 0); | ||
831 | if (rt) { | 894 | if (rt) { |
895 | memset(&rt->rt6i_table, 0, sizeof(*rt) - sizeof(struct dst_entry)); | ||
896 | |||
832 | new = &rt->dst; | 897 | new = &rt->dst; |
833 | 898 | ||
834 | atomic_set(&new->__refcnt, 1); | ||
835 | new->__use = 1; | 899 | new->__use = 1; |
836 | new->input = dst_discard; | 900 | new->input = dst_discard; |
837 | new->output = dst_discard; | 901 | new->output = dst_discard; |
838 | 902 | ||
839 | memcpy(new->metrics, ort->dst.metrics, RTAX_MAX*sizeof(u32)); | 903 | dst_copy_metrics(new, &ort->dst); |
840 | new->dev = ort->dst.dev; | ||
841 | if (new->dev) | ||
842 | dev_hold(new->dev); | ||
843 | rt->rt6i_idev = ort->rt6i_idev; | 904 | rt->rt6i_idev = ort->rt6i_idev; |
844 | if (rt->rt6i_idev) | 905 | if (rt->rt6i_idev) |
845 | in6_dev_hold(rt->rt6i_idev); | 906 | in6_dev_hold(rt->rt6i_idev); |
@@ -857,11 +918,9 @@ int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl | |||
857 | dst_free(new); | 918 | dst_free(new); |
858 | } | 919 | } |
859 | 920 | ||
860 | dst_release(*dstp); | 921 | dst_release(dst_orig); |
861 | *dstp = new; | 922 | return new ? new : ERR_PTR(-ENOMEM); |
862 | return (new ? 0 : -ENOMEM); | ||
863 | } | 923 | } |
864 | EXPORT_SYMBOL_GPL(ip6_dst_blackhole); | ||
865 | 924 | ||
866 | /* | 925 | /* |
867 | * Destination cache support functions | 926 | * Destination cache support functions |
@@ -873,9 +932,14 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie) | |||
873 | 932 | ||
874 | rt = (struct rt6_info *) dst; | 933 | rt = (struct rt6_info *) dst; |
875 | 934 | ||
876 | if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) | 935 | if (rt->rt6i_node && (rt->rt6i_node->fn_sernum == cookie)) { |
936 | if (rt->rt6i_peer_genid != rt6_peer_genid()) { | ||
937 | if (!rt->rt6i_peer) | ||
938 | rt6_bind_peer(rt, 0); | ||
939 | rt->rt6i_peer_genid = rt6_peer_genid(); | ||
940 | } | ||
877 | return dst; | 941 | return dst; |
878 | 942 | } | |
879 | return NULL; | 943 | return NULL; |
880 | } | 944 | } |
881 | 945 | ||
@@ -920,18 +984,21 @@ static void ip6_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
920 | if (mtu < dst_mtu(dst) && rt6->rt6i_dst.plen == 128) { | 984 | if (mtu < dst_mtu(dst) && rt6->rt6i_dst.plen == 128) { |
921 | rt6->rt6i_flags |= RTF_MODIFIED; | 985 | rt6->rt6i_flags |= RTF_MODIFIED; |
922 | if (mtu < IPV6_MIN_MTU) { | 986 | if (mtu < IPV6_MIN_MTU) { |
987 | u32 features = dst_metric(dst, RTAX_FEATURES); | ||
923 | mtu = IPV6_MIN_MTU; | 988 | mtu = IPV6_MIN_MTU; |
924 | dst->metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; | 989 | features |= RTAX_FEATURE_ALLFRAG; |
990 | dst_metric_set(dst, RTAX_FEATURES, features); | ||
925 | } | 991 | } |
926 | dst->metrics[RTAX_MTU-1] = mtu; | 992 | dst_metric_set(dst, RTAX_MTU, mtu); |
927 | call_netevent_notifiers(NETEVENT_PMTU_UPDATE, dst); | ||
928 | } | 993 | } |
929 | } | 994 | } |
930 | 995 | ||
931 | static int ipv6_get_mtu(struct net_device *dev); | 996 | static unsigned int ip6_default_advmss(const struct dst_entry *dst) |
932 | |||
933 | static inline unsigned int ipv6_advmss(struct net *net, unsigned int mtu) | ||
934 | { | 997 | { |
998 | struct net_device *dev = dst->dev; | ||
999 | unsigned int mtu = dst_mtu(dst); | ||
1000 | struct net *net = dev_net(dev); | ||
1001 | |||
935 | mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr); | 1002 | mtu -= sizeof(struct ipv6hdr) + sizeof(struct tcphdr); |
936 | 1003 | ||
937 | if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss) | 1004 | if (mtu < net->ipv6.sysctl.ip6_rt_min_advmss) |
@@ -948,6 +1015,20 @@ static inline unsigned int ipv6_advmss(struct net *net, unsigned int mtu) | |||
948 | return mtu; | 1015 | return mtu; |
949 | } | 1016 | } |
950 | 1017 | ||
1018 | static unsigned int ip6_default_mtu(const struct dst_entry *dst) | ||
1019 | { | ||
1020 | unsigned int mtu = IPV6_MIN_MTU; | ||
1021 | struct inet6_dev *idev; | ||
1022 | |||
1023 | rcu_read_lock(); | ||
1024 | idev = __in6_dev_get(dst->dev); | ||
1025 | if (idev) | ||
1026 | mtu = idev->cnf.mtu6; | ||
1027 | rcu_read_unlock(); | ||
1028 | |||
1029 | return mtu; | ||
1030 | } | ||
1031 | |||
951 | static struct dst_entry *icmp6_dst_gc_list; | 1032 | static struct dst_entry *icmp6_dst_gc_list; |
952 | static DEFINE_SPINLOCK(icmp6_dst_lock); | 1033 | static DEFINE_SPINLOCK(icmp6_dst_lock); |
953 | 1034 | ||
@@ -962,13 +1043,12 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev, | |||
962 | if (unlikely(idev == NULL)) | 1043 | if (unlikely(idev == NULL)) |
963 | return NULL; | 1044 | return NULL; |
964 | 1045 | ||
965 | rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); | 1046 | rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev, 0); |
966 | if (unlikely(rt == NULL)) { | 1047 | if (unlikely(rt == NULL)) { |
967 | in6_dev_put(idev); | 1048 | in6_dev_put(idev); |
968 | goto out; | 1049 | goto out; |
969 | } | 1050 | } |
970 | 1051 | ||
971 | dev_hold(dev); | ||
972 | if (neigh) | 1052 | if (neigh) |
973 | neigh_hold(neigh); | 1053 | neigh_hold(neigh); |
974 | else { | 1054 | else { |
@@ -977,23 +1057,12 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev, | |||
977 | neigh = NULL; | 1057 | neigh = NULL; |
978 | } | 1058 | } |
979 | 1059 | ||
980 | rt->rt6i_dev = dev; | ||
981 | rt->rt6i_idev = idev; | 1060 | rt->rt6i_idev = idev; |
982 | rt->rt6i_nexthop = neigh; | 1061 | rt->rt6i_nexthop = neigh; |
983 | atomic_set(&rt->dst.__refcnt, 1); | 1062 | atomic_set(&rt->dst.__refcnt, 1); |
984 | rt->dst.metrics[RTAX_HOPLIMIT-1] = 255; | 1063 | dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255); |
985 | rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); | ||
986 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst)); | ||
987 | rt->dst.output = ip6_output; | 1064 | rt->dst.output = ip6_output; |
988 | 1065 | ||
989 | #if 0 /* there's no chance to use these for ndisc */ | ||
990 | rt->dst.flags = ipv6_addr_type(addr) & IPV6_ADDR_UNICAST | ||
991 | ? DST_HOST | ||
992 | : 0; | ||
993 | ipv6_addr_copy(&rt->rt6i_dst.addr, addr); | ||
994 | rt->rt6i_dst.plen = 128; | ||
995 | #endif | ||
996 | |||
997 | spin_lock_bh(&icmp6_dst_lock); | 1066 | spin_lock_bh(&icmp6_dst_lock); |
998 | rt->dst.next = icmp6_dst_gc_list; | 1067 | rt->dst.next = icmp6_dst_gc_list; |
999 | icmp6_dst_gc_list = &rt->dst; | 1068 | icmp6_dst_gc_list = &rt->dst; |
@@ -1007,11 +1076,9 @@ out: | |||
1007 | 1076 | ||
1008 | int icmp6_dst_gc(void) | 1077 | int icmp6_dst_gc(void) |
1009 | { | 1078 | { |
1010 | struct dst_entry *dst, *next, **pprev; | 1079 | struct dst_entry *dst, **pprev; |
1011 | int more = 0; | 1080 | int more = 0; |
1012 | 1081 | ||
1013 | next = NULL; | ||
1014 | |||
1015 | spin_lock_bh(&icmp6_dst_lock); | 1082 | spin_lock_bh(&icmp6_dst_lock); |
1016 | pprev = &icmp6_dst_gc_list; | 1083 | pprev = &icmp6_dst_gc_list; |
1017 | 1084 | ||
@@ -1058,19 +1125,22 @@ static int ip6_dst_gc(struct dst_ops *ops) | |||
1058 | int rt_elasticity = net->ipv6.sysctl.ip6_rt_gc_elasticity; | 1125 | int rt_elasticity = net->ipv6.sysctl.ip6_rt_gc_elasticity; |
1059 | int rt_gc_timeout = net->ipv6.sysctl.ip6_rt_gc_timeout; | 1126 | int rt_gc_timeout = net->ipv6.sysctl.ip6_rt_gc_timeout; |
1060 | unsigned long rt_last_gc = net->ipv6.ip6_rt_last_gc; | 1127 | unsigned long rt_last_gc = net->ipv6.ip6_rt_last_gc; |
1128 | int entries; | ||
1061 | 1129 | ||
1130 | entries = dst_entries_get_fast(ops); | ||
1062 | if (time_after(rt_last_gc + rt_min_interval, now) && | 1131 | if (time_after(rt_last_gc + rt_min_interval, now) && |
1063 | atomic_read(&ops->entries) <= rt_max_size) | 1132 | entries <= rt_max_size) |
1064 | goto out; | 1133 | goto out; |
1065 | 1134 | ||
1066 | net->ipv6.ip6_rt_gc_expire++; | 1135 | net->ipv6.ip6_rt_gc_expire++; |
1067 | fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net); | 1136 | fib6_run_gc(net->ipv6.ip6_rt_gc_expire, net); |
1068 | net->ipv6.ip6_rt_last_gc = now; | 1137 | net->ipv6.ip6_rt_last_gc = now; |
1069 | if (atomic_read(&ops->entries) < ops->gc_thresh) | 1138 | entries = dst_entries_get_slow(ops); |
1139 | if (entries < ops->gc_thresh) | ||
1070 | net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1; | 1140 | net->ipv6.ip6_rt_gc_expire = rt_gc_timeout>>1; |
1071 | out: | 1141 | out: |
1072 | net->ipv6.ip6_rt_gc_expire -= net->ipv6.ip6_rt_gc_expire>>rt_elasticity; | 1142 | net->ipv6.ip6_rt_gc_expire -= net->ipv6.ip6_rt_gc_expire>>rt_elasticity; |
1073 | return (atomic_read(&ops->entries) > rt_max_size); | 1143 | return entries > rt_max_size; |
1074 | } | 1144 | } |
1075 | 1145 | ||
1076 | /* Clean host part of a prefix. Not necessary in radix tree, | 1146 | /* Clean host part of a prefix. Not necessary in radix tree, |
@@ -1079,23 +1149,10 @@ out: | |||
1079 | Remove it only when all the things will work! | 1149 | Remove it only when all the things will work! |
1080 | */ | 1150 | */ |
1081 | 1151 | ||
1082 | static int ipv6_get_mtu(struct net_device *dev) | ||
1083 | { | ||
1084 | int mtu = IPV6_MIN_MTU; | ||
1085 | struct inet6_dev *idev; | ||
1086 | |||
1087 | rcu_read_lock(); | ||
1088 | idev = __in6_dev_get(dev); | ||
1089 | if (idev) | ||
1090 | mtu = idev->cnf.mtu6; | ||
1091 | rcu_read_unlock(); | ||
1092 | return mtu; | ||
1093 | } | ||
1094 | |||
1095 | int ip6_dst_hoplimit(struct dst_entry *dst) | 1152 | int ip6_dst_hoplimit(struct dst_entry *dst) |
1096 | { | 1153 | { |
1097 | int hoplimit = dst_metric(dst, RTAX_HOPLIMIT); | 1154 | int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT); |
1098 | if (hoplimit < 0) { | 1155 | if (hoplimit == 0) { |
1099 | struct net_device *dev = dst->dev; | 1156 | struct net_device *dev = dst->dev; |
1100 | struct inet6_dev *idev; | 1157 | struct inet6_dev *idev; |
1101 | 1158 | ||
@@ -1109,6 +1166,7 @@ int ip6_dst_hoplimit(struct dst_entry *dst) | |||
1109 | } | 1166 | } |
1110 | return hoplimit; | 1167 | return hoplimit; |
1111 | } | 1168 | } |
1169 | EXPORT_SYMBOL(ip6_dst_hoplimit); | ||
1112 | 1170 | ||
1113 | /* | 1171 | /* |
1114 | * | 1172 | * |
@@ -1149,7 +1207,7 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1149 | goto out; | 1207 | goto out; |
1150 | } | 1208 | } |
1151 | 1209 | ||
1152 | rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); | 1210 | rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, NULL, DST_NOCOUNT); |
1153 | 1211 | ||
1154 | if (rt == NULL) { | 1212 | if (rt == NULL) { |
1155 | err = -ENOMEM; | 1213 | err = -ENOMEM; |
@@ -1169,6 +1227,8 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1169 | 1227 | ||
1170 | if (addr_type & IPV6_ADDR_MULTICAST) | 1228 | if (addr_type & IPV6_ADDR_MULTICAST) |
1171 | rt->dst.input = ip6_mc_input; | 1229 | rt->dst.input = ip6_mc_input; |
1230 | else if (cfg->fc_flags & RTF_LOCAL) | ||
1231 | rt->dst.input = ip6_input; | ||
1172 | else | 1232 | else |
1173 | rt->dst.input = ip6_forward; | 1233 | rt->dst.input = ip6_forward; |
1174 | 1234 | ||
@@ -1177,7 +1237,7 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1177 | ipv6_addr_prefix(&rt->rt6i_dst.addr, &cfg->fc_dst, cfg->fc_dst_len); | 1237 | ipv6_addr_prefix(&rt->rt6i_dst.addr, &cfg->fc_dst, cfg->fc_dst_len); |
1178 | rt->rt6i_dst.plen = cfg->fc_dst_len; | 1238 | rt->rt6i_dst.plen = cfg->fc_dst_len; |
1179 | if (rt->rt6i_dst.plen == 128) | 1239 | if (rt->rt6i_dst.plen == 128) |
1180 | rt->dst.flags = DST_HOST; | 1240 | rt->dst.flags |= DST_HOST; |
1181 | 1241 | ||
1182 | #ifdef CONFIG_IPV6_SUBTREES | 1242 | #ifdef CONFIG_IPV6_SUBTREES |
1183 | ipv6_addr_prefix(&rt->rt6i_src.addr, &cfg->fc_src, cfg->fc_src_len); | 1243 | ipv6_addr_prefix(&rt->rt6i_src.addr, &cfg->fc_src, cfg->fc_src_len); |
@@ -1190,7 +1250,8 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1190 | they would result in kernel looping; promote them to reject routes | 1250 | they would result in kernel looping; promote them to reject routes |
1191 | */ | 1251 | */ |
1192 | if ((cfg->fc_flags & RTF_REJECT) || | 1252 | if ((cfg->fc_flags & RTF_REJECT) || |
1193 | (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK))) { | 1253 | (dev && (dev->flags&IFF_LOOPBACK) && !(addr_type&IPV6_ADDR_LOOPBACK) |
1254 | && !(cfg->fc_flags&RTF_LOCAL))) { | ||
1194 | /* hold loopback dev/idev if we haven't done so. */ | 1255 | /* hold loopback dev/idev if we haven't done so. */ |
1195 | if (dev != net->loopback_dev) { | 1256 | if (dev != net->loopback_dev) { |
1196 | if (dev) { | 1257 | if (dev) { |
@@ -1213,7 +1274,7 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1213 | } | 1274 | } |
1214 | 1275 | ||
1215 | if (cfg->fc_flags & RTF_GATEWAY) { | 1276 | if (cfg->fc_flags & RTF_GATEWAY) { |
1216 | struct in6_addr *gw_addr; | 1277 | const struct in6_addr *gw_addr; |
1217 | int gwa_type; | 1278 | int gwa_type; |
1218 | 1279 | ||
1219 | gw_addr = &cfg->fc_gateway; | 1280 | gw_addr = &cfg->fc_gateway; |
@@ -1266,6 +1327,16 @@ int ip6_route_add(struct fib6_config *cfg) | |||
1266 | if (dev == NULL) | 1327 | if (dev == NULL) |
1267 | goto out; | 1328 | goto out; |
1268 | 1329 | ||
1330 | if (!ipv6_addr_any(&cfg->fc_prefsrc)) { | ||
1331 | if (!ipv6_chk_addr(net, &cfg->fc_prefsrc, dev, 0)) { | ||
1332 | err = -EINVAL; | ||
1333 | goto out; | ||
1334 | } | ||
1335 | ipv6_addr_copy(&rt->rt6i_prefsrc.addr, &cfg->fc_prefsrc); | ||
1336 | rt->rt6i_prefsrc.plen = 128; | ||
1337 | } else | ||
1338 | rt->rt6i_prefsrc.plen = 0; | ||
1339 | |||
1269 | if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) { | 1340 | if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) { |
1270 | rt->rt6i_nexthop = __neigh_lookup_errno(&nd_tbl, &rt->rt6i_gateway, dev); | 1341 | rt->rt6i_nexthop = __neigh_lookup_errno(&nd_tbl, &rt->rt6i_gateway, dev); |
1271 | if (IS_ERR(rt->rt6i_nexthop)) { | 1342 | if (IS_ERR(rt->rt6i_nexthop)) { |
@@ -1291,17 +1362,11 @@ install_route: | |||
1291 | goto out; | 1362 | goto out; |
1292 | } | 1363 | } |
1293 | 1364 | ||
1294 | rt->dst.metrics[type - 1] = nla_get_u32(nla); | 1365 | dst_metric_set(&rt->dst, type, nla_get_u32(nla)); |
1295 | } | 1366 | } |
1296 | } | 1367 | } |
1297 | } | 1368 | } |
1298 | 1369 | ||
1299 | if (dst_metric(&rt->dst, RTAX_HOPLIMIT) == 0) | ||
1300 | rt->dst.metrics[RTAX_HOPLIMIT-1] = -1; | ||
1301 | if (!dst_mtu(&rt->dst)) | ||
1302 | rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); | ||
1303 | if (!dst_metric(&rt->dst, RTAX_ADVMSS)) | ||
1304 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst)); | ||
1305 | rt->dst.dev = dev; | 1370 | rt->dst.dev = dev; |
1306 | rt->rt6i_idev = idev; | 1371 | rt->rt6i_idev = idev; |
1307 | rt->rt6i_table = table; | 1372 | rt->rt6i_table = table; |
@@ -1391,16 +1456,16 @@ static int ip6_route_del(struct fib6_config *cfg) | |||
1391 | * Handle redirects | 1456 | * Handle redirects |
1392 | */ | 1457 | */ |
1393 | struct ip6rd_flowi { | 1458 | struct ip6rd_flowi { |
1394 | struct flowi fl; | 1459 | struct flowi6 fl6; |
1395 | struct in6_addr gateway; | 1460 | struct in6_addr gateway; |
1396 | }; | 1461 | }; |
1397 | 1462 | ||
1398 | static struct rt6_info *__ip6_route_redirect(struct net *net, | 1463 | static struct rt6_info *__ip6_route_redirect(struct net *net, |
1399 | struct fib6_table *table, | 1464 | struct fib6_table *table, |
1400 | struct flowi *fl, | 1465 | struct flowi6 *fl6, |
1401 | int flags) | 1466 | int flags) |
1402 | { | 1467 | { |
1403 | struct ip6rd_flowi *rdfl = (struct ip6rd_flowi *)fl; | 1468 | struct ip6rd_flowi *rdfl = (struct ip6rd_flowi *)fl6; |
1404 | struct rt6_info *rt; | 1469 | struct rt6_info *rt; |
1405 | struct fib6_node *fn; | 1470 | struct fib6_node *fn; |
1406 | 1471 | ||
@@ -1416,7 +1481,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net, | |||
1416 | */ | 1481 | */ |
1417 | 1482 | ||
1418 | read_lock_bh(&table->tb6_lock); | 1483 | read_lock_bh(&table->tb6_lock); |
1419 | fn = fib6_lookup(&table->tb6_root, &fl->fl6_dst, &fl->fl6_src); | 1484 | fn = fib6_lookup(&table->tb6_root, &fl6->daddr, &fl6->saddr); |
1420 | restart: | 1485 | restart: |
1421 | for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) { | 1486 | for (rt = fn->leaf; rt; rt = rt->dst.rt6_next) { |
1422 | /* | 1487 | /* |
@@ -1431,7 +1496,7 @@ restart: | |||
1431 | continue; | 1496 | continue; |
1432 | if (!(rt->rt6i_flags & RTF_GATEWAY)) | 1497 | if (!(rt->rt6i_flags & RTF_GATEWAY)) |
1433 | continue; | 1498 | continue; |
1434 | if (fl->oif != rt->rt6i_dev->ifindex) | 1499 | if (fl6->flowi6_oif != rt->rt6i_dev->ifindex) |
1435 | continue; | 1500 | continue; |
1436 | if (!ipv6_addr_equal(&rdfl->gateway, &rt->rt6i_gateway)) | 1501 | if (!ipv6_addr_equal(&rdfl->gateway, &rt->rt6i_gateway)) |
1437 | continue; | 1502 | continue; |
@@ -1440,7 +1505,7 @@ restart: | |||
1440 | 1505 | ||
1441 | if (!rt) | 1506 | if (!rt) |
1442 | rt = net->ipv6.ip6_null_entry; | 1507 | rt = net->ipv6.ip6_null_entry; |
1443 | BACKTRACK(net, &fl->fl6_src); | 1508 | BACKTRACK(net, &fl6->saddr); |
1444 | out: | 1509 | out: |
1445 | dst_hold(&rt->dst); | 1510 | dst_hold(&rt->dst); |
1446 | 1511 | ||
@@ -1449,22 +1514,18 @@ out: | |||
1449 | return rt; | 1514 | return rt; |
1450 | }; | 1515 | }; |
1451 | 1516 | ||
1452 | static struct rt6_info *ip6_route_redirect(struct in6_addr *dest, | 1517 | static struct rt6_info *ip6_route_redirect(const struct in6_addr *dest, |
1453 | struct in6_addr *src, | 1518 | const struct in6_addr *src, |
1454 | struct in6_addr *gateway, | 1519 | const struct in6_addr *gateway, |
1455 | struct net_device *dev) | 1520 | struct net_device *dev) |
1456 | { | 1521 | { |
1457 | int flags = RT6_LOOKUP_F_HAS_SADDR; | 1522 | int flags = RT6_LOOKUP_F_HAS_SADDR; |
1458 | struct net *net = dev_net(dev); | 1523 | struct net *net = dev_net(dev); |
1459 | struct ip6rd_flowi rdfl = { | 1524 | struct ip6rd_flowi rdfl = { |
1460 | .fl = { | 1525 | .fl6 = { |
1461 | .oif = dev->ifindex, | 1526 | .flowi6_oif = dev->ifindex, |
1462 | .nl_u = { | 1527 | .daddr = *dest, |
1463 | .ip6_u = { | 1528 | .saddr = *src, |
1464 | .daddr = *dest, | ||
1465 | .saddr = *src, | ||
1466 | }, | ||
1467 | }, | ||
1468 | }, | 1529 | }, |
1469 | }; | 1530 | }; |
1470 | 1531 | ||
@@ -1473,12 +1534,12 @@ static struct rt6_info *ip6_route_redirect(struct in6_addr *dest, | |||
1473 | if (rt6_need_strict(dest)) | 1534 | if (rt6_need_strict(dest)) |
1474 | flags |= RT6_LOOKUP_F_IFACE; | 1535 | flags |= RT6_LOOKUP_F_IFACE; |
1475 | 1536 | ||
1476 | return (struct rt6_info *)fib6_rule_lookup(net, (struct flowi *)&rdfl, | 1537 | return (struct rt6_info *)fib6_rule_lookup(net, &rdfl.fl6, |
1477 | flags, __ip6_route_redirect); | 1538 | flags, __ip6_route_redirect); |
1478 | } | 1539 | } |
1479 | 1540 | ||
1480 | void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, | 1541 | void rt6_redirect(const struct in6_addr *dest, const struct in6_addr *src, |
1481 | struct in6_addr *saddr, | 1542 | const struct in6_addr *saddr, |
1482 | struct neighbour *neigh, u8 *lladdr, int on_link) | 1543 | struct neighbour *neigh, u8 *lladdr, int on_link) |
1483 | { | 1544 | { |
1484 | struct rt6_info *rt, *nrt = NULL; | 1545 | struct rt6_info *rt, *nrt = NULL; |
@@ -1530,10 +1591,6 @@ void rt6_redirect(struct in6_addr *dest, struct in6_addr *src, | |||
1530 | 1591 | ||
1531 | ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key); | 1592 | ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key); |
1532 | nrt->rt6i_nexthop = neigh_clone(neigh); | 1593 | nrt->rt6i_nexthop = neigh_clone(neigh); |
1533 | /* Reset pmtu, it may be better */ | ||
1534 | nrt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(neigh->dev); | ||
1535 | nrt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(dev_net(neigh->dev), | ||
1536 | dst_mtu(&nrt->dst)); | ||
1537 | 1594 | ||
1538 | if (ip6_ins_rt(nrt)) | 1595 | if (ip6_ins_rt(nrt)) |
1539 | goto out; | 1596 | goto out; |
@@ -1556,16 +1613,21 @@ out: | |||
1556 | * i.e. Path MTU discovery | 1613 | * i.e. Path MTU discovery |
1557 | */ | 1614 | */ |
1558 | 1615 | ||
1559 | static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, | 1616 | static void rt6_do_pmtu_disc(const struct in6_addr *daddr, const struct in6_addr *saddr, |
1560 | struct net *net, u32 pmtu, int ifindex) | 1617 | struct net *net, u32 pmtu, int ifindex) |
1561 | { | 1618 | { |
1562 | struct rt6_info *rt, *nrt; | 1619 | struct rt6_info *rt, *nrt; |
1563 | int allfrag = 0; | 1620 | int allfrag = 0; |
1564 | 1621 | again: | |
1565 | rt = rt6_lookup(net, daddr, saddr, ifindex, 0); | 1622 | rt = rt6_lookup(net, daddr, saddr, ifindex, 0); |
1566 | if (rt == NULL) | 1623 | if (rt == NULL) |
1567 | return; | 1624 | return; |
1568 | 1625 | ||
1626 | if (rt6_check_expired(rt)) { | ||
1627 | ip6_del_rt(rt); | ||
1628 | goto again; | ||
1629 | } | ||
1630 | |||
1569 | if (pmtu >= dst_mtu(&rt->dst)) | 1631 | if (pmtu >= dst_mtu(&rt->dst)) |
1570 | goto out; | 1632 | goto out; |
1571 | 1633 | ||
@@ -1592,9 +1654,12 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1592 | would return automatically. | 1654 | would return automatically. |
1593 | */ | 1655 | */ |
1594 | if (rt->rt6i_flags & RTF_CACHE) { | 1656 | if (rt->rt6i_flags & RTF_CACHE) { |
1595 | rt->dst.metrics[RTAX_MTU-1] = pmtu; | 1657 | dst_metric_set(&rt->dst, RTAX_MTU, pmtu); |
1596 | if (allfrag) | 1658 | if (allfrag) { |
1597 | rt->dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; | 1659 | u32 features = dst_metric(&rt->dst, RTAX_FEATURES); |
1660 | features |= RTAX_FEATURE_ALLFRAG; | ||
1661 | dst_metric_set(&rt->dst, RTAX_FEATURES, features); | ||
1662 | } | ||
1598 | dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires); | 1663 | dst_set_expires(&rt->dst, net->ipv6.sysctl.ip6_rt_mtu_expires); |
1599 | rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES; | 1664 | rt->rt6i_flags |= RTF_MODIFIED|RTF_EXPIRES; |
1600 | goto out; | 1665 | goto out; |
@@ -1611,9 +1676,12 @@ static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1611 | nrt = rt6_alloc_clone(rt, daddr); | 1676 | nrt = rt6_alloc_clone(rt, daddr); |
1612 | 1677 | ||
1613 | if (nrt) { | 1678 | if (nrt) { |
1614 | nrt->dst.metrics[RTAX_MTU-1] = pmtu; | 1679 | dst_metric_set(&nrt->dst, RTAX_MTU, pmtu); |
1615 | if (allfrag) | 1680 | if (allfrag) { |
1616 | nrt->dst.metrics[RTAX_FEATURES-1] |= RTAX_FEATURE_ALLFRAG; | 1681 | u32 features = dst_metric(&nrt->dst, RTAX_FEATURES); |
1682 | features |= RTAX_FEATURE_ALLFRAG; | ||
1683 | dst_metric_set(&nrt->dst, RTAX_FEATURES, features); | ||
1684 | } | ||
1617 | 1685 | ||
1618 | /* According to RFC 1981, detecting PMTU increase shouldn't be | 1686 | /* According to RFC 1981, detecting PMTU increase shouldn't be |
1619 | * happened within 5 mins, the recommended timer is 10 mins. | 1687 | * happened within 5 mins, the recommended timer is 10 mins. |
@@ -1630,7 +1698,7 @@ out: | |||
1630 | dst_release(&rt->dst); | 1698 | dst_release(&rt->dst); |
1631 | } | 1699 | } |
1632 | 1700 | ||
1633 | void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, | 1701 | void rt6_pmtu_discovery(const struct in6_addr *daddr, const struct in6_addr *saddr, |
1634 | struct net_device *dev, u32 pmtu) | 1702 | struct net_device *dev, u32 pmtu) |
1635 | { | 1703 | { |
1636 | struct net *net = dev_net(dev); | 1704 | struct net *net = dev_net(dev); |
@@ -1658,17 +1726,15 @@ void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, | |||
1658 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) | 1726 | static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) |
1659 | { | 1727 | { |
1660 | struct net *net = dev_net(ort->rt6i_dev); | 1728 | struct net *net = dev_net(ort->rt6i_dev); |
1661 | struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); | 1729 | struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, |
1730 | ort->dst.dev, 0); | ||
1662 | 1731 | ||
1663 | if (rt) { | 1732 | if (rt) { |
1664 | rt->dst.input = ort->dst.input; | 1733 | rt->dst.input = ort->dst.input; |
1665 | rt->dst.output = ort->dst.output; | 1734 | rt->dst.output = ort->dst.output; |
1666 | 1735 | ||
1667 | memcpy(rt->dst.metrics, ort->dst.metrics, RTAX_MAX*sizeof(u32)); | 1736 | dst_copy_metrics(&rt->dst, &ort->dst); |
1668 | rt->dst.error = ort->dst.error; | 1737 | rt->dst.error = ort->dst.error; |
1669 | rt->dst.dev = ort->dst.dev; | ||
1670 | if (rt->dst.dev) | ||
1671 | dev_hold(rt->dst.dev); | ||
1672 | rt->rt6i_idev = ort->rt6i_idev; | 1738 | rt->rt6i_idev = ort->rt6i_idev; |
1673 | if (rt->rt6i_idev) | 1739 | if (rt->rt6i_idev) |
1674 | in6_dev_hold(rt->rt6i_idev); | 1740 | in6_dev_hold(rt->rt6i_idev); |
@@ -1683,6 +1749,7 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) | |||
1683 | #ifdef CONFIG_IPV6_SUBTREES | 1749 | #ifdef CONFIG_IPV6_SUBTREES |
1684 | memcpy(&rt->rt6i_src, &ort->rt6i_src, sizeof(struct rt6key)); | 1750 | memcpy(&rt->rt6i_src, &ort->rt6i_src, sizeof(struct rt6key)); |
1685 | #endif | 1751 | #endif |
1752 | memcpy(&rt->rt6i_prefsrc, &ort->rt6i_prefsrc, sizeof(struct rt6key)); | ||
1686 | rt->rt6i_table = ort->rt6i_table; | 1753 | rt->rt6i_table = ort->rt6i_table; |
1687 | } | 1754 | } |
1688 | return rt; | 1755 | return rt; |
@@ -1690,8 +1757,8 @@ static struct rt6_info * ip6_rt_copy(struct rt6_info *ort) | |||
1690 | 1757 | ||
1691 | #ifdef CONFIG_IPV6_ROUTE_INFO | 1758 | #ifdef CONFIG_IPV6_ROUTE_INFO |
1692 | static struct rt6_info *rt6_get_route_info(struct net *net, | 1759 | static struct rt6_info *rt6_get_route_info(struct net *net, |
1693 | struct in6_addr *prefix, int prefixlen, | 1760 | const struct in6_addr *prefix, int prefixlen, |
1694 | struct in6_addr *gwaddr, int ifindex) | 1761 | const struct in6_addr *gwaddr, int ifindex) |
1695 | { | 1762 | { |
1696 | struct fib6_node *fn; | 1763 | struct fib6_node *fn; |
1697 | struct rt6_info *rt = NULL; | 1764 | struct rt6_info *rt = NULL; |
@@ -1722,8 +1789,8 @@ out: | |||
1722 | } | 1789 | } |
1723 | 1790 | ||
1724 | static struct rt6_info *rt6_add_route_info(struct net *net, | 1791 | static struct rt6_info *rt6_add_route_info(struct net *net, |
1725 | struct in6_addr *prefix, int prefixlen, | 1792 | const struct in6_addr *prefix, int prefixlen, |
1726 | struct in6_addr *gwaddr, int ifindex, | 1793 | const struct in6_addr *gwaddr, int ifindex, |
1727 | unsigned pref) | 1794 | unsigned pref) |
1728 | { | 1795 | { |
1729 | struct fib6_config cfg = { | 1796 | struct fib6_config cfg = { |
@@ -1751,7 +1818,7 @@ static struct rt6_info *rt6_add_route_info(struct net *net, | |||
1751 | } | 1818 | } |
1752 | #endif | 1819 | #endif |
1753 | 1820 | ||
1754 | struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *dev) | 1821 | struct rt6_info *rt6_get_dflt_router(const struct in6_addr *addr, struct net_device *dev) |
1755 | { | 1822 | { |
1756 | struct rt6_info *rt; | 1823 | struct rt6_info *rt; |
1757 | struct fib6_table *table; | 1824 | struct fib6_table *table; |
@@ -1773,7 +1840,7 @@ struct rt6_info *rt6_get_dflt_router(struct in6_addr *addr, struct net_device *d | |||
1773 | return rt; | 1840 | return rt; |
1774 | } | 1841 | } |
1775 | 1842 | ||
1776 | struct rt6_info *rt6_add_dflt_router(struct in6_addr *gwaddr, | 1843 | struct rt6_info *rt6_add_dflt_router(const struct in6_addr *gwaddr, |
1777 | struct net_device *dev, | 1844 | struct net_device *dev, |
1778 | unsigned int pref) | 1845 | unsigned int pref) |
1779 | { | 1846 | { |
@@ -1938,23 +2005,23 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1938 | int anycast) | 2005 | int anycast) |
1939 | { | 2006 | { |
1940 | struct net *net = dev_net(idev->dev); | 2007 | struct net *net = dev_net(idev->dev); |
1941 | struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops); | 2008 | struct rt6_info *rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, |
2009 | net->loopback_dev, 0); | ||
1942 | struct neighbour *neigh; | 2010 | struct neighbour *neigh; |
1943 | 2011 | ||
1944 | if (rt == NULL) | 2012 | if (rt == NULL) { |
2013 | if (net_ratelimit()) | ||
2014 | pr_warning("IPv6: Maximum number of routes reached," | ||
2015 | " consider increasing route/max_size.\n"); | ||
1945 | return ERR_PTR(-ENOMEM); | 2016 | return ERR_PTR(-ENOMEM); |
2017 | } | ||
1946 | 2018 | ||
1947 | dev_hold(net->loopback_dev); | ||
1948 | in6_dev_hold(idev); | 2019 | in6_dev_hold(idev); |
1949 | 2020 | ||
1950 | rt->dst.flags = DST_HOST; | 2021 | rt->dst.flags |= DST_HOST; |
1951 | rt->dst.input = ip6_input; | 2022 | rt->dst.input = ip6_input; |
1952 | rt->dst.output = ip6_output; | 2023 | rt->dst.output = ip6_output; |
1953 | rt->rt6i_dev = net->loopback_dev; | ||
1954 | rt->rt6i_idev = idev; | 2024 | rt->rt6i_idev = idev; |
1955 | rt->dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(rt->rt6i_dev); | ||
1956 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->dst)); | ||
1957 | rt->dst.metrics[RTAX_HOPLIMIT-1] = -1; | ||
1958 | rt->dst.obsolete = -1; | 2025 | rt->dst.obsolete = -1; |
1959 | 2026 | ||
1960 | rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; | 2027 | rt->rt6i_flags = RTF_UP | RTF_NONEXTHOP; |
@@ -1966,12 +2033,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1966 | if (IS_ERR(neigh)) { | 2033 | if (IS_ERR(neigh)) { |
1967 | dst_free(&rt->dst); | 2034 | dst_free(&rt->dst); |
1968 | 2035 | ||
1969 | /* We are casting this because that is the return | 2036 | return ERR_CAST(neigh); |
1970 | * value type. But an errno encoded pointer is the | ||
1971 | * same regardless of the underlying pointer type, | ||
1972 | * and that's what we are returning. So this is OK. | ||
1973 | */ | ||
1974 | return (struct rt6_info *) neigh; | ||
1975 | } | 2037 | } |
1976 | rt->rt6i_nexthop = neigh; | 2038 | rt->rt6i_nexthop = neigh; |
1977 | 2039 | ||
@@ -1984,6 +2046,55 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | |||
1984 | return rt; | 2046 | return rt; |
1985 | } | 2047 | } |
1986 | 2048 | ||
2049 | int ip6_route_get_saddr(struct net *net, | ||
2050 | struct rt6_info *rt, | ||
2051 | const struct in6_addr *daddr, | ||
2052 | unsigned int prefs, | ||
2053 | struct in6_addr *saddr) | ||
2054 | { | ||
2055 | struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt); | ||
2056 | int err = 0; | ||
2057 | if (rt->rt6i_prefsrc.plen) | ||
2058 | ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr); | ||
2059 | else | ||
2060 | err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL, | ||
2061 | daddr, prefs, saddr); | ||
2062 | return err; | ||
2063 | } | ||
2064 | |||
2065 | /* remove deleted ip from prefsrc entries */ | ||
2066 | struct arg_dev_net_ip { | ||
2067 | struct net_device *dev; | ||
2068 | struct net *net; | ||
2069 | struct in6_addr *addr; | ||
2070 | }; | ||
2071 | |||
2072 | static int fib6_remove_prefsrc(struct rt6_info *rt, void *arg) | ||
2073 | { | ||
2074 | struct net_device *dev = ((struct arg_dev_net_ip *)arg)->dev; | ||
2075 | struct net *net = ((struct arg_dev_net_ip *)arg)->net; | ||
2076 | struct in6_addr *addr = ((struct arg_dev_net_ip *)arg)->addr; | ||
2077 | |||
2078 | if (((void *)rt->rt6i_dev == dev || dev == NULL) && | ||
2079 | rt != net->ipv6.ip6_null_entry && | ||
2080 | ipv6_addr_equal(addr, &rt->rt6i_prefsrc.addr)) { | ||
2081 | /* remove prefsrc entry */ | ||
2082 | rt->rt6i_prefsrc.plen = 0; | ||
2083 | } | ||
2084 | return 0; | ||
2085 | } | ||
2086 | |||
2087 | void rt6_remove_prefsrc(struct inet6_ifaddr *ifp) | ||
2088 | { | ||
2089 | struct net *net = dev_net(ifp->idev->dev); | ||
2090 | struct arg_dev_net_ip adni = { | ||
2091 | .dev = ifp->idev->dev, | ||
2092 | .net = net, | ||
2093 | .addr = &ifp->addr, | ||
2094 | }; | ||
2095 | fib6_clean_all(net, fib6_remove_prefsrc, 0, &adni); | ||
2096 | } | ||
2097 | |||
1987 | struct arg_dev_net { | 2098 | struct arg_dev_net { |
1988 | struct net_device *dev; | 2099 | struct net_device *dev; |
1989 | struct net *net; | 2100 | struct net *net; |
@@ -1991,11 +2102,11 @@ struct arg_dev_net { | |||
1991 | 2102 | ||
1992 | static int fib6_ifdown(struct rt6_info *rt, void *arg) | 2103 | static int fib6_ifdown(struct rt6_info *rt, void *arg) |
1993 | { | 2104 | { |
1994 | struct net_device *dev = ((struct arg_dev_net *)arg)->dev; | 2105 | const struct arg_dev_net *adn = arg; |
1995 | struct net *net = ((struct arg_dev_net *)arg)->net; | 2106 | const struct net_device *dev = adn->dev; |
1996 | 2107 | ||
1997 | if (((void *)rt->rt6i_dev == dev || dev == NULL) && | 2108 | if ((rt->rt6i_dev == dev || dev == NULL) && |
1998 | rt != net->ipv6.ip6_null_entry) { | 2109 | rt != adn->net->ipv6.ip6_null_entry) { |
1999 | RT6_TRACE("deleted by ifdown %p\n", rt); | 2110 | RT6_TRACE("deleted by ifdown %p\n", rt); |
2000 | return -1; | 2111 | return -1; |
2001 | } | 2112 | } |
@@ -2023,7 +2134,6 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) | |||
2023 | { | 2134 | { |
2024 | struct rt6_mtu_change_arg *arg = (struct rt6_mtu_change_arg *) p_arg; | 2135 | struct rt6_mtu_change_arg *arg = (struct rt6_mtu_change_arg *) p_arg; |
2025 | struct inet6_dev *idev; | 2136 | struct inet6_dev *idev; |
2026 | struct net *net = dev_net(arg->dev); | ||
2027 | 2137 | ||
2028 | /* In IPv6 pmtu discovery is not optional, | 2138 | /* In IPv6 pmtu discovery is not optional, |
2029 | so that RTAX_MTU lock cannot disable it. | 2139 | so that RTAX_MTU lock cannot disable it. |
@@ -2054,8 +2164,7 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) | |||
2054 | (dst_mtu(&rt->dst) >= arg->mtu || | 2164 | (dst_mtu(&rt->dst) >= arg->mtu || |
2055 | (dst_mtu(&rt->dst) < arg->mtu && | 2165 | (dst_mtu(&rt->dst) < arg->mtu && |
2056 | dst_mtu(&rt->dst) == idev->cnf.mtu6))) { | 2166 | dst_mtu(&rt->dst) == idev->cnf.mtu6))) { |
2057 | rt->dst.metrics[RTAX_MTU-1] = arg->mtu; | 2167 | dst_metric_set(&rt->dst, RTAX_MTU, arg->mtu); |
2058 | rt->dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, arg->mtu); | ||
2059 | } | 2168 | } |
2060 | return 0; | 2169 | return 0; |
2061 | } | 2170 | } |
@@ -2102,6 +2211,9 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
2102 | if (rtm->rtm_type == RTN_UNREACHABLE) | 2211 | if (rtm->rtm_type == RTN_UNREACHABLE) |
2103 | cfg->fc_flags |= RTF_REJECT; | 2212 | cfg->fc_flags |= RTF_REJECT; |
2104 | 2213 | ||
2214 | if (rtm->rtm_type == RTN_LOCAL) | ||
2215 | cfg->fc_flags |= RTF_LOCAL; | ||
2216 | |||
2105 | cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; | 2217 | cfg->fc_nlinfo.pid = NETLINK_CB(skb).pid; |
2106 | cfg->fc_nlinfo.nlh = nlh; | 2218 | cfg->fc_nlinfo.nlh = nlh; |
2107 | cfg->fc_nlinfo.nl_net = sock_net(skb->sk); | 2219 | cfg->fc_nlinfo.nl_net = sock_net(skb->sk); |
@@ -2129,6 +2241,9 @@ static int rtm_to_fib6_config(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
2129 | nla_memcpy(&cfg->fc_src, tb[RTA_SRC], plen); | 2241 | nla_memcpy(&cfg->fc_src, tb[RTA_SRC], plen); |
2130 | } | 2242 | } |
2131 | 2243 | ||
2244 | if (tb[RTA_PREFSRC]) | ||
2245 | nla_memcpy(&cfg->fc_prefsrc, tb[RTA_PREFSRC], 16); | ||
2246 | |||
2132 | if (tb[RTA_OIF]) | 2247 | if (tb[RTA_OIF]) |
2133 | cfg->fc_ifindex = nla_get_u32(tb[RTA_OIF]); | 2248 | cfg->fc_ifindex = nla_get_u32(tb[RTA_OIF]); |
2134 | 2249 | ||
@@ -2222,6 +2337,8 @@ static int rt6_fill_node(struct net *net, | |||
2222 | NLA_PUT_U32(skb, RTA_TABLE, table); | 2337 | NLA_PUT_U32(skb, RTA_TABLE, table); |
2223 | if (rt->rt6i_flags&RTF_REJECT) | 2338 | if (rt->rt6i_flags&RTF_REJECT) |
2224 | rtm->rtm_type = RTN_UNREACHABLE; | 2339 | rtm->rtm_type = RTN_UNREACHABLE; |
2340 | else if (rt->rt6i_flags&RTF_LOCAL) | ||
2341 | rtm->rtm_type = RTN_LOCAL; | ||
2225 | else if (rt->rt6i_dev && (rt->rt6i_dev->flags&IFF_LOOPBACK)) | 2342 | else if (rt->rt6i_dev && (rt->rt6i_dev->flags&IFF_LOOPBACK)) |
2226 | rtm->rtm_type = RTN_LOCAL; | 2343 | rtm->rtm_type = RTN_LOCAL; |
2227 | else | 2344 | else |
@@ -2269,14 +2386,18 @@ static int rt6_fill_node(struct net *net, | |||
2269 | #endif | 2386 | #endif |
2270 | NLA_PUT_U32(skb, RTA_IIF, iif); | 2387 | NLA_PUT_U32(skb, RTA_IIF, iif); |
2271 | } else if (dst) { | 2388 | } else if (dst) { |
2272 | struct inet6_dev *idev = ip6_dst_idev(&rt->dst); | ||
2273 | struct in6_addr saddr_buf; | 2389 | struct in6_addr saddr_buf; |
2274 | if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL, | 2390 | if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0) |
2275 | dst, 0, &saddr_buf) == 0) | ||
2276 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); | 2391 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); |
2277 | } | 2392 | } |
2278 | 2393 | ||
2279 | if (rtnetlink_put_metrics(skb, rt->dst.metrics) < 0) | 2394 | if (rt->rt6i_prefsrc.plen) { |
2395 | struct in6_addr saddr_buf; | ||
2396 | ipv6_addr_copy(&saddr_buf, &rt->rt6i_prefsrc.addr); | ||
2397 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); | ||
2398 | } | ||
2399 | |||
2400 | if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0) | ||
2280 | goto nla_put_failure; | 2401 | goto nla_put_failure; |
2281 | 2402 | ||
2282 | if (rt->dst.neighbour) | 2403 | if (rt->dst.neighbour) |
@@ -2329,7 +2450,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2329 | struct rt6_info *rt; | 2450 | struct rt6_info *rt; |
2330 | struct sk_buff *skb; | 2451 | struct sk_buff *skb; |
2331 | struct rtmsg *rtm; | 2452 | struct rtmsg *rtm; |
2332 | struct flowi fl; | 2453 | struct flowi6 fl6; |
2333 | int err, iif = 0; | 2454 | int err, iif = 0; |
2334 | 2455 | ||
2335 | err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy); | 2456 | err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv6_policy); |
@@ -2337,27 +2458,27 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2337 | goto errout; | 2458 | goto errout; |
2338 | 2459 | ||
2339 | err = -EINVAL; | 2460 | err = -EINVAL; |
2340 | memset(&fl, 0, sizeof(fl)); | 2461 | memset(&fl6, 0, sizeof(fl6)); |
2341 | 2462 | ||
2342 | if (tb[RTA_SRC]) { | 2463 | if (tb[RTA_SRC]) { |
2343 | if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr)) | 2464 | if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr)) |
2344 | goto errout; | 2465 | goto errout; |
2345 | 2466 | ||
2346 | ipv6_addr_copy(&fl.fl6_src, nla_data(tb[RTA_SRC])); | 2467 | ipv6_addr_copy(&fl6.saddr, nla_data(tb[RTA_SRC])); |
2347 | } | 2468 | } |
2348 | 2469 | ||
2349 | if (tb[RTA_DST]) { | 2470 | if (tb[RTA_DST]) { |
2350 | if (nla_len(tb[RTA_DST]) < sizeof(struct in6_addr)) | 2471 | if (nla_len(tb[RTA_DST]) < sizeof(struct in6_addr)) |
2351 | goto errout; | 2472 | goto errout; |
2352 | 2473 | ||
2353 | ipv6_addr_copy(&fl.fl6_dst, nla_data(tb[RTA_DST])); | 2474 | ipv6_addr_copy(&fl6.daddr, nla_data(tb[RTA_DST])); |
2354 | } | 2475 | } |
2355 | 2476 | ||
2356 | if (tb[RTA_IIF]) | 2477 | if (tb[RTA_IIF]) |
2357 | iif = nla_get_u32(tb[RTA_IIF]); | 2478 | iif = nla_get_u32(tb[RTA_IIF]); |
2358 | 2479 | ||
2359 | if (tb[RTA_OIF]) | 2480 | if (tb[RTA_OIF]) |
2360 | fl.oif = nla_get_u32(tb[RTA_OIF]); | 2481 | fl6.flowi6_oif = nla_get_u32(tb[RTA_OIF]); |
2361 | 2482 | ||
2362 | if (iif) { | 2483 | if (iif) { |
2363 | struct net_device *dev; | 2484 | struct net_device *dev; |
@@ -2380,10 +2501,10 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2380 | skb_reset_mac_header(skb); | 2501 | skb_reset_mac_header(skb); |
2381 | skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr)); | 2502 | skb_reserve(skb, MAX_HEADER + sizeof(struct ipv6hdr)); |
2382 | 2503 | ||
2383 | rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl); | 2504 | rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl6); |
2384 | skb_dst_set(skb, &rt->dst); | 2505 | skb_dst_set(skb, &rt->dst); |
2385 | 2506 | ||
2386 | err = rt6_fill_node(net, skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, | 2507 | err = rt6_fill_node(net, skb, rt, &fl6.daddr, &fl6.saddr, iif, |
2387 | RTM_NEWROUTE, NETLINK_CB(in_skb).pid, | 2508 | RTM_NEWROUTE, NETLINK_CB(in_skb).pid, |
2388 | nlh->nlmsg_seq, 0, 0, 0); | 2509 | nlh->nlmsg_seq, 0, 0, 0); |
2389 | if (err < 0) { | 2510 | if (err < 0) { |
@@ -2452,8 +2573,6 @@ static int ip6_route_dev_notify(struct notifier_block *this, | |||
2452 | 2573 | ||
2453 | #ifdef CONFIG_PROC_FS | 2574 | #ifdef CONFIG_PROC_FS |
2454 | 2575 | ||
2455 | #define RT6_INFO_LEN (32 + 4 + 32 + 4 + 32 + 40 + 5 + 1) | ||
2456 | |||
2457 | struct rt6_proc_arg | 2576 | struct rt6_proc_arg |
2458 | { | 2577 | { |
2459 | char *buffer; | 2578 | char *buffer; |
@@ -2516,7 +2635,7 @@ static int rt6_stats_seq_show(struct seq_file *seq, void *v) | |||
2516 | net->ipv6.rt6_stats->fib_rt_alloc, | 2635 | net->ipv6.rt6_stats->fib_rt_alloc, |
2517 | net->ipv6.rt6_stats->fib_rt_entries, | 2636 | net->ipv6.rt6_stats->fib_rt_entries, |
2518 | net->ipv6.rt6_stats->fib_rt_cache, | 2637 | net->ipv6.rt6_stats->fib_rt_cache, |
2519 | atomic_read(&net->ipv6.ip6_dst_ops.entries), | 2638 | dst_entries_get_slow(&net->ipv6.ip6_dst_ops), |
2520 | net->ipv6.rt6_stats->fib_discarded_routes); | 2639 | net->ipv6.rt6_stats->fib_discarded_routes); |
2521 | 2640 | ||
2522 | return 0; | 2641 | return 0; |
@@ -2542,14 +2661,16 @@ static | |||
2542 | int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, | 2661 | int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, |
2543 | void __user *buffer, size_t *lenp, loff_t *ppos) | 2662 | void __user *buffer, size_t *lenp, loff_t *ppos) |
2544 | { | 2663 | { |
2545 | struct net *net = current->nsproxy->net_ns; | 2664 | struct net *net; |
2546 | int delay = net->ipv6.sysctl.flush_delay; | 2665 | int delay; |
2547 | if (write) { | 2666 | if (!write) |
2548 | proc_dointvec(ctl, write, buffer, lenp, ppos); | ||
2549 | fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net); | ||
2550 | return 0; | ||
2551 | } else | ||
2552 | return -EINVAL; | 2667 | return -EINVAL; |
2668 | |||
2669 | net = (struct net *)ctl->extra1; | ||
2670 | delay = net->ipv6.sysctl.flush_delay; | ||
2671 | proc_dointvec(ctl, write, buffer, lenp, ppos); | ||
2672 | fib6_run_gc(delay <= 0 ? ~0UL : (unsigned long)delay, net); | ||
2673 | return 0; | ||
2553 | } | 2674 | } |
2554 | 2675 | ||
2555 | ctl_table ipv6_route_table_template[] = { | 2676 | ctl_table ipv6_route_table_template[] = { |
@@ -2636,6 +2757,7 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net) | |||
2636 | 2757 | ||
2637 | if (table) { | 2758 | if (table) { |
2638 | table[0].data = &net->ipv6.sysctl.flush_delay; | 2759 | table[0].data = &net->ipv6.sysctl.flush_delay; |
2760 | table[0].extra1 = net; | ||
2639 | table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh; | 2761 | table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh; |
2640 | table[2].data = &net->ipv6.sysctl.ip6_rt_max_size; | 2762 | table[2].data = &net->ipv6.sysctl.ip6_rt_max_size; |
2641 | table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; | 2763 | table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval; |
@@ -2658,14 +2780,19 @@ static int __net_init ip6_route_net_init(struct net *net) | |||
2658 | memcpy(&net->ipv6.ip6_dst_ops, &ip6_dst_ops_template, | 2780 | memcpy(&net->ipv6.ip6_dst_ops, &ip6_dst_ops_template, |
2659 | sizeof(net->ipv6.ip6_dst_ops)); | 2781 | sizeof(net->ipv6.ip6_dst_ops)); |
2660 | 2782 | ||
2783 | if (dst_entries_init(&net->ipv6.ip6_dst_ops) < 0) | ||
2784 | goto out_ip6_dst_ops; | ||
2785 | |||
2661 | net->ipv6.ip6_null_entry = kmemdup(&ip6_null_entry_template, | 2786 | net->ipv6.ip6_null_entry = kmemdup(&ip6_null_entry_template, |
2662 | sizeof(*net->ipv6.ip6_null_entry), | 2787 | sizeof(*net->ipv6.ip6_null_entry), |
2663 | GFP_KERNEL); | 2788 | GFP_KERNEL); |
2664 | if (!net->ipv6.ip6_null_entry) | 2789 | if (!net->ipv6.ip6_null_entry) |
2665 | goto out_ip6_dst_ops; | 2790 | goto out_ip6_dst_entries; |
2666 | net->ipv6.ip6_null_entry->dst.path = | 2791 | net->ipv6.ip6_null_entry->dst.path = |
2667 | (struct dst_entry *)net->ipv6.ip6_null_entry; | 2792 | (struct dst_entry *)net->ipv6.ip6_null_entry; |
2668 | net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops; | 2793 | net->ipv6.ip6_null_entry->dst.ops = &net->ipv6.ip6_dst_ops; |
2794 | dst_init_metrics(&net->ipv6.ip6_null_entry->dst, | ||
2795 | ip6_template_metrics, true); | ||
2669 | 2796 | ||
2670 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 2797 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
2671 | net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, | 2798 | net->ipv6.ip6_prohibit_entry = kmemdup(&ip6_prohibit_entry_template, |
@@ -2676,6 +2803,8 @@ static int __net_init ip6_route_net_init(struct net *net) | |||
2676 | net->ipv6.ip6_prohibit_entry->dst.path = | 2803 | net->ipv6.ip6_prohibit_entry->dst.path = |
2677 | (struct dst_entry *)net->ipv6.ip6_prohibit_entry; | 2804 | (struct dst_entry *)net->ipv6.ip6_prohibit_entry; |
2678 | net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops; | 2805 | net->ipv6.ip6_prohibit_entry->dst.ops = &net->ipv6.ip6_dst_ops; |
2806 | dst_init_metrics(&net->ipv6.ip6_prohibit_entry->dst, | ||
2807 | ip6_template_metrics, true); | ||
2679 | 2808 | ||
2680 | net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, | 2809 | net->ipv6.ip6_blk_hole_entry = kmemdup(&ip6_blk_hole_entry_template, |
2681 | sizeof(*net->ipv6.ip6_blk_hole_entry), | 2810 | sizeof(*net->ipv6.ip6_blk_hole_entry), |
@@ -2685,6 +2814,8 @@ static int __net_init ip6_route_net_init(struct net *net) | |||
2685 | net->ipv6.ip6_blk_hole_entry->dst.path = | 2814 | net->ipv6.ip6_blk_hole_entry->dst.path = |
2686 | (struct dst_entry *)net->ipv6.ip6_blk_hole_entry; | 2815 | (struct dst_entry *)net->ipv6.ip6_blk_hole_entry; |
2687 | net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; | 2816 | net->ipv6.ip6_blk_hole_entry->dst.ops = &net->ipv6.ip6_dst_ops; |
2817 | dst_init_metrics(&net->ipv6.ip6_blk_hole_entry->dst, | ||
2818 | ip6_template_metrics, true); | ||
2688 | #endif | 2819 | #endif |
2689 | 2820 | ||
2690 | net->ipv6.sysctl.flush_delay = 0; | 2821 | net->ipv6.sysctl.flush_delay = 0; |
@@ -2712,6 +2843,8 @@ out_ip6_prohibit_entry: | |||
2712 | out_ip6_null_entry: | 2843 | out_ip6_null_entry: |
2713 | kfree(net->ipv6.ip6_null_entry); | 2844 | kfree(net->ipv6.ip6_null_entry); |
2714 | #endif | 2845 | #endif |
2846 | out_ip6_dst_entries: | ||
2847 | dst_entries_destroy(&net->ipv6.ip6_dst_ops); | ||
2715 | out_ip6_dst_ops: | 2848 | out_ip6_dst_ops: |
2716 | goto out; | 2849 | goto out; |
2717 | } | 2850 | } |
@@ -2727,6 +2860,7 @@ static void __net_exit ip6_route_net_exit(struct net *net) | |||
2727 | kfree(net->ipv6.ip6_prohibit_entry); | 2860 | kfree(net->ipv6.ip6_prohibit_entry); |
2728 | kfree(net->ipv6.ip6_blk_hole_entry); | 2861 | kfree(net->ipv6.ip6_blk_hole_entry); |
2729 | #endif | 2862 | #endif |
2863 | dst_entries_destroy(&net->ipv6.ip6_dst_ops); | ||
2730 | } | 2864 | } |
2731 | 2865 | ||
2732 | static struct pernet_operations ip6_route_net_ops = { | 2866 | static struct pernet_operations ip6_route_net_ops = { |
@@ -2750,10 +2884,14 @@ int __init ip6_route_init(void) | |||
2750 | if (!ip6_dst_ops_template.kmem_cachep) | 2884 | if (!ip6_dst_ops_template.kmem_cachep) |
2751 | goto out; | 2885 | goto out; |
2752 | 2886 | ||
2753 | ret = register_pernet_subsys(&ip6_route_net_ops); | 2887 | ret = dst_entries_init(&ip6_dst_blackhole_ops); |
2754 | if (ret) | 2888 | if (ret) |
2755 | goto out_kmem_cache; | 2889 | goto out_kmem_cache; |
2756 | 2890 | ||
2891 | ret = register_pernet_subsys(&ip6_route_net_ops); | ||
2892 | if (ret) | ||
2893 | goto out_dst_entries; | ||
2894 | |||
2757 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops_template.kmem_cachep; | 2895 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops_template.kmem_cachep; |
2758 | 2896 | ||
2759 | /* Registering of the loopback is done before this portion of code, | 2897 | /* Registering of the loopback is done before this portion of code, |
@@ -2800,6 +2938,8 @@ out_fib6_init: | |||
2800 | fib6_gc_cleanup(); | 2938 | fib6_gc_cleanup(); |
2801 | out_register_subsys: | 2939 | out_register_subsys: |
2802 | unregister_pernet_subsys(&ip6_route_net_ops); | 2940 | unregister_pernet_subsys(&ip6_route_net_ops); |
2941 | out_dst_entries: | ||
2942 | dst_entries_destroy(&ip6_dst_blackhole_ops); | ||
2803 | out_kmem_cache: | 2943 | out_kmem_cache: |
2804 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); | 2944 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); |
2805 | goto out; | 2945 | goto out; |
@@ -2812,5 +2952,6 @@ void ip6_route_cleanup(void) | |||
2812 | xfrm6_fini(); | 2952 | xfrm6_fini(); |
2813 | fib6_gc_cleanup(); | 2953 | fib6_gc_cleanup(); |
2814 | unregister_pernet_subsys(&ip6_route_net_ops); | 2954 | unregister_pernet_subsys(&ip6_route_net_ops); |
2955 | dst_entries_destroy(&ip6_dst_blackhole_ops); | ||
2815 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); | 2956 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); |
2816 | } | 2957 | } |