Skip to content

Commit 77634cc

Browse files
dsaherndavem330
authored andcommitted
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>
1 parent 8d1c802 commit 77634cc

File tree

4 files changed

+5
-106
lines changed

4 files changed

+5
-106
lines changed

include/net/ip6_fib.h

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -175,58 +175,20 @@ struct fib6_info {
175175

176176
struct rt6_info {
177177
struct dst_entry dst;
178-
struct rt6_info __rcu *rt6_next;
179178
struct fib6_info *from;
180179

181-
/*
182-
* Tail elements of dst_entry (__refcnt etc.)
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-
180+
struct rt6key rt6i_dst;
181+
struct rt6key rt6i_src;
189182
struct in6_addr rt6i_gateway;
190-
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;
183+
struct inet6_dev *rt6i_idev;
203184
u32 rt6i_flags;
204-
struct rt6key rt6i_src;
205185
struct rt6key rt6i_prefsrc;
206186

207187
struct list_head rt6i_uncached;
208188
struct uncached_list *rt6i_uncached_list;
209189

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;
215190
/* more non-fragment space at head required */
216191
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;
230192
};
231193

232194
#define for_each_fib6_node_rt_rcu(fn) \
@@ -328,8 +290,6 @@ static inline void ip6_rt_put(struct rt6_info *rt)
328290
dst_release(&rt->dst);
329291
}
330292

331-
void rt6_free_pcpu(struct rt6_info *non_pcpu_rt);
332-
333293
struct fib6_info *fib6_info_alloc(gfp_t gfp_flags);
334294
void fib6_info_destroy(struct fib6_info *f6i);
335295

@@ -344,20 +304,6 @@ static inline void fib6_info_release(struct fib6_info *f6i)
344304
fib6_info_destroy(f6i);
345305
}
346306

347-
static inline void rt6_hold(struct rt6_info *rt)
348-
{
349-
atomic_inc(&rt->rt6i_ref);
350-
}
351-
352-
static 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-
361307
enum fib6_walk_state {
362308
#ifdef CONFIG_IPV6_SUBTREES
363309
FWS_S,

net/ipv6/ip6_fib.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -240,28 +240,6 @@ static void node_free(struct net *net, struct fib6_node *fn)
240240
net->ipv6.rt6_stats->fib_nodes--;
241241
}
242242

243-
void 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-
}
263-
EXPORT_SYMBOL_GPL(rt6_free_pcpu);
264-
265243
static void fib6_free_table(struct fib6_table *table)
266244
{
267245
inetpeer_invalidate_tree(&table->tb6_peers);

net/ipv6/route.c

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,6 @@ static const struct rt6_info ip6_null_entry_template = {
302302
.output = ip6_pkt_discard_out,
303303
},
304304
.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,
309305
};
310306

311307
#ifdef CONFIG_IPV6_MULTIPLE_TABLES
@@ -320,10 +316,6 @@ static const struct rt6_info ip6_prohibit_entry_template = {
320316
.output = ip6_pkt_prohibit_out,
321317
},
322318
.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,
327319
};
328320

329321
static const struct rt6_info ip6_blk_hole_entry_template = {
@@ -336,10 +328,6 @@ static const struct rt6_info ip6_blk_hole_entry_template = {
336328
.output = dst_discard_out,
337329
},
338330
.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,
343331
};
344332

345333
#endif
@@ -349,7 +337,6 @@ static void rt6_info_init(struct rt6_info *rt)
349337
struct dst_entry *dst = &rt->dst;
350338

351339
memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
352-
INIT_LIST_HEAD(&rt->rt6i_siblings);
353340
INIT_LIST_HEAD(&rt->rt6i_uncached);
354341
}
355342

@@ -999,12 +986,10 @@ static void ip6_rt_copy_init(struct rt6_info *rt, struct fib6_info *ort)
999986
rt->rt6i_gateway = ort->fib6_nh.nh_gw;
1000987
rt->rt6i_flags = ort->rt6i_flags;
1001988
rt6_set_from(rt, ort);
1002-
rt->rt6i_metric = ort->rt6i_metric;
1003989
#ifdef CONFIG_IPV6_SUBTREES
1004990
rt->rt6i_src = ort->rt6i_src;
1005991
#endif
1006992
rt->rt6i_prefsrc = ort->rt6i_prefsrc;
1007-
rt->rt6i_table = ort->rt6i_table;
1008993
rt->dst.lwtstate = lwtstate_get(ort->fib6_nh.nh_lwtstate);
1009994
}
1010995

@@ -1192,7 +1177,6 @@ static struct rt6_info *ip6_rt_cache_alloc(struct fib6_info *ort,
11921177

11931178
ip6_rt_copy_init(rt, ort);
11941179
rt->rt6i_flags |= RTF_CACHE;
1195-
rt->rt6i_metric = 0;
11961180
rt->dst.flags |= DST_HOST;
11971181
rt->rt6i_dst.addr = *daddr;
11981182
rt->rt6i_dst.plen = 128;
@@ -1225,7 +1209,6 @@ static struct rt6_info *ip6_rt_pcpu_alloc(struct fib6_info *rt)
12251209
if (!pcpu_rt)
12261210
return NULL;
12271211
ip6_rt_copy_init(pcpu_rt, rt);
1228-
pcpu_rt->rt6i_protocol = rt->rt6i_protocol;
12291212
pcpu_rt->rt6i_flags |= RTF_PCPU;
12301213
return pcpu_rt;
12311214
}
@@ -1279,9 +1262,8 @@ static void rt6_remove_exception(struct rt6_exception_bucket *bucket,
12791262
return;
12801263

12811264
net = dev_net(rt6_ex->rt6i->dst.dev);
1282-
rt6_ex->rt6i->rt6i_node = NULL;
12831265
hlist_del_rcu(&rt6_ex->hlist);
1284-
ip6_rt_put(rt6_ex->rt6i);
1266+
dst_release(&rt6_ex->rt6i->dst);
12851267
kfree_rcu(rt6_ex, rcu);
12861268
WARN_ON_ONCE(!bucket->depth);
12871269
bucket->depth--;
@@ -1463,8 +1445,6 @@ static int rt6_insert_exception(struct rt6_info *nrt,
14631445
}
14641446
rt6_ex->rt6i = nrt;
14651447
rt6_ex->stamp = jiffies;
1466-
atomic_inc(&nrt->rt6i_ref);
1467-
nrt->rt6i_node = ort->rt6i_node;
14681448
hlist_add_head_rcu(&rt6_ex->hlist, &bucket->chain);
14691449
bucket->depth++;
14701450
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
21222102
rt->rt6i_idev = in6_dev_get(loopback_dev);
21232103
rt->rt6i_gateway = ort->rt6i_gateway;
21242104
rt->rt6i_flags = ort->rt6i_flags & ~RTF_PCPU;
2125-
rt->rt6i_metric = 0;
21262105

21272106
memcpy(&rt->rt6i_dst, &ort->rt6i_dst, sizeof(struct rt6key));
21282107
#ifdef CONFIG_IPV6_SUBTREES
@@ -2247,8 +2226,7 @@ static void rt6_do_update_pmtu(struct rt6_info *rt, u32 mtu)
22472226
static bool rt6_cache_allowed_for_pmtu(const struct rt6_info *rt)
22482227
{
22492228
return !(rt->rt6i_flags & RTF_CACHE) &&
2250-
(rt->rt6i_flags & RTF_PCPU ||
2251-
rcu_access_pointer(rt->rt6i_node));
2229+
(rt->rt6i_flags & RTF_PCPU || rt->from);
22522230
}
22532231

22542232
static 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
33133291
if (on_link)
33143292
nrt->rt6i_flags &= ~RTF_GATEWAY;
33153293

3316-
nrt->rt6i_protocol = RTPROT_REDIRECT;
33173294
nrt->rt6i_gateway = *(struct in6_addr *)neigh->primary_key;
33183295

33193296
/* No need to remove rt from the exception table if rt is

net/ipv6/xfrm6_policy.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
107107
* it was magically lost, so this code needs audit */
108108
xdst->u.rt6.rt6i_flags = rt->rt6i_flags & (RTF_ANYCAST |
109109
RTF_LOCAL);
110-
xdst->u.rt6.rt6i_metric = rt->rt6i_metric;
111-
xdst->u.rt6.rt6i_node = rt->rt6i_node;
112110
xdst->route_cookie = rt6_get_cookie(rt);
113111
xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway;
114112
xdst->u.rt6.rt6i_dst = rt->rt6i_dst;

0 commit comments

Comments
 (0)