summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2018-04-17 20:33:27 -0400
committerDavid S. Miller <davem@davemloft.net>2018-04-17 23:41:18 -0400
commit77634cc67dc1ffc8ae6d869af6dee4b2ea6025ee (patch)
tree1afc177ac88677e08348b2cb9eb4201d73b324f7
parent8d1c802b2815edc97af8a58c5045ebaf3848621a (diff)
net/ipv6: Remove unused code and variables for rt6_info
Drop unneeded elements from rt6_info struct and rearrange layout to something more relevant for the data path. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/ip6_fib.h60
-rw-r--r--net/ipv6/ip6_fib.c22
-rw-r--r--net/ipv6/route.c27
-rw-r--r--net/ipv6/xfrm6_policy.c2
4 files changed, 5 insertions, 106 deletions
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index d41b7bd69fb3..a36116b92100 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -175,58 +175,20 @@ struct fib6_info {
175 175
176struct rt6_info { 176struct rt6_info {
177 struct dst_entry dst; 177 struct dst_entry dst;
178 struct rt6_info __rcu *rt6_next;
179 struct fib6_info *from; 178 struct fib6_info *from;
180 179
181 /* 180 struct rt6key rt6i_dst;
182 * Tail elements of dst_entry (__refcnt etc.) 181 struct rt6key rt6i_src;
183 * and these elements (rarely used in hot path) are in
184 * the same cache line.
185 */
186 struct fib6_table *rt6i_table;
187 struct fib6_node __rcu *rt6i_node;
188
189 struct in6_addr rt6i_gateway; 182 struct in6_addr rt6i_gateway;
190 183 struct inet6_dev *rt6i_idev;
191 /* Multipath routes:
192 * siblings is a list of rt6_info that have the the same metric/weight,
193 * destination, but not the same gateway. nsiblings is just a cache
194 * to speed up lookup.
195 */
196 struct list_head rt6i_siblings;
197 unsigned int rt6i_nsiblings;
198
199 atomic_t rt6i_ref;
200
201 /* These are in a separate cache line. */
202 struct rt6key rt6i_dst ____cacheline_aligned_in_smp;
203 u32 rt6i_flags; 184 u32 rt6i_flags;
204 struct rt6key rt6i_src;
205 struct rt6key rt6i_prefsrc; 185 struct rt6key rt6i_prefsrc;
206 186
207 struct list_head rt6i_uncached; 187 struct list_head rt6i_uncached;
208 struct uncached_list *rt6i_uncached_list; 188 struct uncached_list *rt6i_uncached_list;
209 189
210 struct inet6_dev *rt6i_idev;
211 struct rt6_info * __percpu *rt6i_pcpu;
212 struct rt6_exception_bucket __rcu *rt6i_exception_bucket;
213
214 u32 rt6i_metric;
215 /* more non-fragment space at head required */ 190 /* more non-fragment space at head required */
216 unsigned short rt6i_nfheader_len; 191 unsigned short rt6i_nfheader_len;
217 u8 rt6i_protocol;
218 u8 fib6_type;
219 u8 exception_bucket_flushed:1,
220 should_flush:1,
221 dst_nocount:1,
222 dst_nopolicy:1,
223 dst_host:1,
224 unused:3;
225
226 unsigned long expires;
227 struct dst_metrics *fib6_metrics;
228#define fib6_pmtu fib6_metrics->metrics[RTAX_MTU-1]
229 struct fib6_nh fib6_nh;
230}; 192};
231 193
232#define for_each_fib6_node_rt_rcu(fn) \ 194#define for_each_fib6_node_rt_rcu(fn) \
@@ -328,8 +290,6 @@ static inline void ip6_rt_put(struct rt6_info *rt)
328 dst_release(&rt->dst); 290 dst_release(&rt->dst);
329} 291}
330 292
331void rt6_free_pcpu(struct rt6_info *non_pcpu_rt);
332
333struct fib6_info *fib6_info_alloc(gfp_t gfp_flags); 293struct fib6_info *fib6_info_alloc(gfp_t gfp_flags);
334void fib6_info_destroy(struct fib6_info *f6i); 294void fib6_info_destroy(struct fib6_info *f6i);
335 295
@@ -344,20 +304,6 @@ static inline void fib6_info_release(struct fib6_info *f6i)
344 fib6_info_destroy(f6i); 304 fib6_info_destroy(f6i);
345} 305}
346 306
347static inline void rt6_hold(struct rt6_info *rt)
348{
349 atomic_inc(&rt->rt6i_ref);
350}
351
352static inline void rt6_release(struct rt6_info *rt)
353{
354 if (atomic_dec_and_test(&rt->rt6i_ref)) {
355 rt6_free_pcpu(rt);
356 dst_dev_put(&rt->dst);
357 dst_release(&rt->dst);
358 }
359}
360
361enum fib6_walk_state { 307enum fib6_walk_state {
362#ifdef CONFIG_IPV6_SUBTREES 308#ifdef CONFIG_IPV6_SUBTREES
363 FWS_S, 309 FWS_S,
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 77cf43b2d858..2ab49b7cac22 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -240,28 +240,6 @@ static void node_free(struct net *net, struct fib6_node *fn)
240 net->ipv6.rt6_stats->fib_nodes--; 240 net->ipv6.rt6_stats->fib_nodes--;
241} 241}
242 242
243void rt6_free_pcpu(struct rt6_info *non_pcpu_rt)
244{
245 int cpu;
246
247 if (!non_pcpu_rt->rt6i_pcpu)
248 return;
249
250 for_each_possible_cpu(cpu) {
251 struct rt6_info **ppcpu_rt;
252 struct rt6_info *pcpu_rt;
253
254 ppcpu_rt = per_cpu_ptr(non_pcpu_rt->rt6i_pcpu, cpu);
255 pcpu_rt = *ppcpu_rt;
256 if (pcpu_rt) {
257 dst_dev_put(&pcpu_rt->dst);
258 dst_release(&pcpu_rt->dst);
259 *ppcpu_rt = NULL;
260 }
261 }
262}
263EXPORT_SYMBOL_GPL(rt6_free_pcpu);
264
265static void fib6_free_table(struct fib6_table *table) 243static void fib6_free_table(struct fib6_table *table)
266{ 244{
267 inetpeer_invalidate_tree(&table->tb6_peers); 245 inetpeer_invalidate_tree(&table->tb6_peers);
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 2ccf939e1a20..f9c363327d62 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -302,10 +302,6 @@ static const struct rt6_info ip6_null_entry_template = {
302 .output = ip6_pkt_discard_out, 302 .output = ip6_pkt_discard_out,
303 }, 303 },
304 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), 304 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
305 .rt6i_protocol = RTPROT_KERNEL,
306 .rt6i_metric = ~(u32) 0,
307 .rt6i_ref = ATOMIC_INIT(1),
308 .fib6_type = RTN_UNREACHABLE,
309}; 305};
310 306
311#ifdef CONFIG_IPV6_MULTIPLE_TABLES 307#ifdef CONFIG_IPV6_MULTIPLE_TABLES
@@ -320,10 +316,6 @@ static const struct rt6_info ip6_prohibit_entry_template = {
320 .output = ip6_pkt_prohibit_out, 316 .output = ip6_pkt_prohibit_out,
321 }, 317 },
322 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), 318 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
323 .rt6i_protocol = RTPROT_KERNEL,
324 .rt6i_metric = ~(u32) 0,
325 .rt6i_ref = ATOMIC_INIT(1),
326 .fib6_type = RTN_PROHIBIT,
327}; 319};
328 320
329static const struct rt6_info ip6_blk_hole_entry_template = { 321static const struct rt6_info ip6_blk_hole_entry_template = {
@@ -336,10 +328,6 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
336 .output = dst_discard_out, 328 .output = dst_discard_out,
337 }, 329 },
338 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP), 330 .rt6i_flags = (RTF_REJECT | RTF_NONEXTHOP),
339 .rt6i_protocol = RTPROT_KERNEL,
340 .rt6i_metric = ~(u32) 0,
341 .rt6i_ref = ATOMIC_INIT(1),
342 .fib6_type = RTN_BLACKHOLE,
343}; 331};
344 332
345#endif 333#endif
@@ -349,7 +337,6 @@ static void rt6_info_init(struct rt6_info *rt)
349 struct dst_entry *dst = &rt->dst; 337 struct dst_entry *dst = &rt->dst;
350 338
351 memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst)); 339 memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
352 INIT_LIST_HEAD(&rt->rt6i_siblings);
353 INIT_LIST_HEAD(&rt->rt6i_uncached); 340 INIT_LIST_HEAD(&rt->rt6i_uncached);
354} 341}
355 342
@@ -999,12 +986,10 @@ static void ip6_rt_copy_init(struct rt6_info *rt, struct fib6_info *ort)
999 rt->rt6i_gateway = ort->fib6_nh.nh_gw; 986 rt->rt6i_gateway = ort->fib6_nh.nh_gw;
1000 rt->rt6i_flags = ort->rt6i_flags; 987 rt->rt6i_flags = ort->rt6i_flags;
1001 rt6_set_from(rt, ort); 988 rt6_set_from(rt, ort);
1002 rt->rt6i_metric = ort->rt6i_metric;
1003#ifdef CONFIG_IPV6_SUBTREES 989#ifdef CONFIG_IPV6_SUBTREES
1004 rt->rt6i_src = ort->rt6i_src; 990 rt->rt6i_src = ort->rt6i_src;
1005#endif 991#endif
1006 rt->rt6i_prefsrc = ort->rt6i_prefsrc; 992 rt->rt6i_prefsrc = ort->rt6i_prefsrc;
1007 rt->rt6i_table = ort->rt6i_table;
1008 rt->dst.lwtstate = lwtstate_get(ort->fib6_nh.nh_lwtstate); 993 rt->dst.lwtstate = lwtstate_get(ort->fib6_nh.nh_lwtstate);
1009} 994}
1010 995
@@ -1192,7 +1177,6 @@ static struct rt6_info *ip6_rt_cache_alloc(struct fib6_info *ort,
1192 1177
1193 ip6_rt_copy_init(rt, ort); 1178 ip6_rt_copy_init(rt, ort);
1194 rt->rt6i_flags |= RTF_CACHE; 1179 rt->rt6i_flags |= RTF_CACHE;
1195 rt->rt6i_metric = 0;
1196 rt->dst.flags |= DST_HOST; 1180 rt->dst.flags |= DST_HOST;
1197 rt->rt6i_dst.addr = *daddr; 1181 rt->rt6i_dst.addr = *daddr;
1198 rt->rt6i_dst.plen = 128; 1182 rt->rt6i_dst.plen = 128;
@@ -1225,7 +1209,6 @@ static struct rt6_info *ip6_rt_pcpu_alloc(struct fib6_info *rt)
1225 if (!pcpu_rt) 1209 if (!pcpu_rt)
1226 return NULL; 1210 return NULL;
1227 ip6_rt_copy_init(pcpu_rt, rt); 1211 ip6_rt_copy_init(pcpu_rt, rt);
1228 pcpu_rt->rt6i_protocol = rt->rt6i_protocol;
1229 pcpu_rt->rt6i_flags |= RTF_PCPU; 1212 pcpu_rt->rt6i_flags |= RTF_PCPU;
1230 return pcpu_rt; 1213 return pcpu_rt;
1231} 1214}
@@ -1279,9 +1262,8 @@ static void rt6_remove_exception(struct rt6_exception_bucket *bucket,
1279 return; 1262 return;
1280 1263
1281 net = dev_net(rt6_ex->rt6i->dst.dev); 1264 net = dev_net(rt6_ex->rt6i->dst.dev);
1282 rt6_ex->rt6i->rt6i_node = NULL;
1283 hlist_del_rcu(&rt6_ex->hlist); 1265 hlist_del_rcu(&rt6_ex->hlist);
1284 ip6_rt_put(rt6_ex->rt6i); 1266 dst_release(&rt6_ex->rt6i->dst);
1285 kfree_rcu(rt6_ex, rcu); 1267 kfree_rcu(rt6_ex, rcu);
1286 WARN_ON_ONCE(!bucket->depth); 1268 WARN_ON_ONCE(!bucket->depth);
1287 bucket->depth--; 1269 bucket->depth--;
@@ -1463,8 +1445,6 @@ static int rt6_insert_exception(struct rt6_info *nrt,
1463 } 1445 }
1464 rt6_ex->rt6i = nrt; 1446 rt6_ex->rt6i = nrt;
1465 rt6_ex->stamp = jiffies; 1447 rt6_ex->stamp = jiffies;
1466 atomic_inc(&nrt->rt6i_ref);
1467 nrt->rt6i_node = ort->rt6i_node;
1468 hlist_add_head_rcu(&rt6_ex->hlist, &bucket->chain); 1448 hlist_add_head_rcu(&rt6_ex->hlist, &bucket->chain);
1469 bucket->depth++; 1449 bucket->depth++;
1470 net->ipv6.rt6_stats->fib_rt_cache++; 1450 net->ipv6.rt6_stats->fib_rt_cache++;
@@ -2122,7 +2102,6 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
2122 rt->rt6i_idev = in6_dev_get(loopback_dev); 2102 rt->rt6i_idev = in6_dev_get(loopback_dev);
2123 rt->rt6i_gateway = ort->rt6i_gateway; 2103 rt->rt6i_gateway = ort->rt6i_gateway;
2124 rt->rt6i_flags = ort->rt6i_flags & ~RTF_PCPU; 2104 rt->rt6i_flags = ort->rt6i_flags & ~RTF_PCPU;
2125 rt->rt6i_metric = 0;
2126 2105
2127 memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key)); 2106 memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key));
2128#ifdef CONFIG_IPV6_SUBTREES 2107#ifdef CONFIG_IPV6_SUBTREES
@@ -2247,8 +2226,7 @@ static void rt6_do_update_pmtu(struct rt6_info *rt, u32 mtu)
2247static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt) 2226static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
2248{ 2227{
2249 return !(rt->rt6i_flags & RTF_CACHE) && 2228 return !(rt->rt6i_flags & RTF_CACHE) &&
2250 (rt->rt6i_flags & RTF_PCPU || 2229 (rt->rt6i_flags & RTF_PCPU || rt->from);
2251 rcu_access_pointer(rt->rt6i_node));
2252} 2230}
2253 2231
2254static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk, 2232static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
@@ -3313,7 +3291,6 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
3313 if (on_link) 3291 if (on_link)
3314 nrt->rt6i_flags &= ~RTF_GATEWAY; 3292 nrt->rt6i_flags &= ~RTF_GATEWAY;
3315 3293
3316 nrt->rt6i_protocol = RTPROT_REDIRECT;
3317 nrt->rt6i_gateway = *(struct in6_addr *)neigh->primary_key; 3294 nrt->rt6i_gateway = *(struct in6_addr *)neigh->primary_key;
3318 3295
3319 /* No need to remove rt from the exception table if rt is 3296 /* No need to remove rt from the exception table if rt is
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index 416fe67271a9..2cff209d0fc1 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -107,8 +107,6 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
107 * it was magically lost, so this code needs audit */ 107 * it was magically lost, so this code needs audit */
108 xdst->u.rt6.rt6i_flags = rt->rt6i_flags & (RTF_ANYCAST | 108 xdst->u.rt6.rt6i_flags = rt->rt6i_flags & (RTF_ANYCAST |
109 RTF_LOCAL); 109 RTF_LOCAL);
110 xdst->u.rt6.rt6i_metric = rt->rt6i_metric;
111 xdst->u.rt6.rt6i_node = rt->rt6i_node;
112 xdst->route_cookie = rt6_get_cookie(rt); 110 xdst->route_cookie = rt6_get_cookie(rt);
113 xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway; 111 xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway;
114 xdst->u.rt6.rt6i_dst = rt->rt6i_dst; 112 xdst->u.rt6.rt6i_dst = rt->rt6i_dst;