Skip to content

Commit

Permalink
ipv6: Move exception bucket to fib6_nh
Browse files Browse the repository at this point in the history
Similar to the pcpu routes exceptions are really per nexthop, so move
rt6i_exception_bucket from fib6_info to fib6_nh.

To avoid additional increases to the size of fib6_nh for a 1-bit flag,
use the lowest bit in the allocated memory pointer for the flushed flag.
Add helpers for retrieving the bucket pointer to mask off the flag.

The cleanup of the exception bucket is moved to fib6_nh_release.

fib6_nh_flush_exceptions can now be called from 2 contexts:
1. deleting a fib entry
2. deleting a fib6_nh

For 1., fib6_nh_flush_exceptions is called for a specific fib6_info that
is getting deleted. All exceptions in the cache using the entry are
deleted. For 2, the fib6_nh itself is getting destroyed so
fib6_nh_flush_exceptions is called for a NULL fib6_info which means
flush all entries.

The pmtu.sh selftest exercises the affected code paths - from creating
exceptions to cleaning them up on device delete. All tests pass without
any rcu locking or memleak warnings.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David Ahern authored and David S. Miller committed May 24, 2019
1 parent c0b220c commit cc5c073
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 73 deletions.
8 changes: 3 additions & 5 deletions include/net/ip6_fib.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ struct fib6_nh {
#endif

struct rt6_info * __percpu *rt6i_pcpu;
struct rt6_exception_bucket __rcu *rt6i_exception_bucket;
};

struct fib6_info {
Expand All @@ -158,18 +159,15 @@ struct fib6_info {
struct rt6key fib6_src;
struct rt6key fib6_prefsrc;

struct rt6_exception_bucket __rcu *rt6i_exception_bucket;

u32 fib6_metric;
u8 fib6_protocol;
u8 fib6_type;
u8 exception_bucket_flushed:1,
should_flush:1,
u8 should_flush:1,
dst_nocount:1,
dst_nopolicy:1,
dst_host:1,
fib6_destroying:1,
unused:2;
unused:3;

struct fib6_nh fib6_nh;
struct rcu_head rcu;
Expand Down
6 changes: 0 additions & 6 deletions net/ipv6/ip6_fib.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,11 @@ struct fib6_info *fib6_info_alloc(gfp_t gfp_flags)
void fib6_info_destroy_rcu(struct rcu_head *head)
{
struct fib6_info *f6i = container_of(head, struct fib6_info, rcu);
struct rt6_exception_bucket *bucket;

WARN_ON(f6i->fib6_node);

bucket = rcu_dereference_protected(f6i->rt6i_exception_bucket, 1);
kfree(bucket);

fib6_nh_release(&f6i->fib6_nh);

ip_fib_metrics_put(f6i->fib6_metrics);

kfree(f6i);
}
EXPORT_SYMBOL_GPL(fib6_info_destroy_rcu);
Expand Down
Loading

0 comments on commit cc5c073

Please sign in to comment.