net/ipv6: do not copy dst flags on rt init
Subsystems (3)
PATCH v2 1/1 net/ipv6: do not copy dst flags on rt init
DST_NOCOUNT in dst_entry::flags tracks whether the entry counts toward route cache size (net->ipv6.sysctl.ip6_rt_max_size).
If the flag is NOT set, dst_ops::pcpuc_entries counter is incremented in dist_init() and decremented in dst_destroy().
This flag is tied to allocation/deallocation of dst_entry and should not be copied from another dst/route. Otherwise it can happen that dst_ops::pcpuc_entries counter grows until no new routes can be allocated because the counter reached ip6_rt_max_size due to DST_NOCOUNT not set and thus no counter decrements on gc-ed routes.
--- net/ipv6/route.c | 2 -- 1 file changed, 2 deletions(-)
net/ipv6/route.c +0 -2
@@ -946,8 +946,6 @@ static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct fib6_info *ort)static void ip6_rt_init_dst (struct rt6_info *rt,struct fib6_info *ort) { - rt->dst.flags |=fib6_info_dst_flags (ort); -if (ort->fib6_flags &RTF_REJECT ) {ip6_rt_init_dst_reject (rt, ort);return ;
Signature · 1 line
2.19.0.397.gdd90340f6a-goog
Quoted 26 lines · Peter Oskolkov
DST_NOCOUNTindst_entry::flagstracks whether the entry counts toward route cache size (net->ipv6.sysctl.ip6_rt_max_size).If the flag is NOT set,
dst_ops::pcpuc_entriescounter is incremented indist_init()and decremented indst_destroy().This flag is tied to allocation/deallocation of
dst_entryand should not be copied from another dst/route. Otherwise it can happen thatdst_ops::pcpuc_entriescounter grows until no new routes can be allocated because the counter reachedip6_rt_max_sizedue toDST_NOCOUNTnot set and thus no counter decrements on gc-ed routes.Fixes 3b6761d18bc1 ("net/ipv6: Move dst flags to booleans in fib entries")Cc David Ahern <[email protected]>Acked-by Wei Wang <[email protected]>Signed-off-by Peter Oskolkov <[email protected]>--- net/ipv6/route.c | 2 -- 1 file changed, 2 deletions(-)net/ipv6/route.c +0
-0
net/ipv6/route.c static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct fib6_info *ort) · line 951
Quoted 8 lines
net/ipv6/route.c +0
-2@@ -946,8 +946,6 @@ static void ip6_rt_init_dst_reject(struct rt6_info *rt, struct fib6_info *ort)static void ip6_rt_init_dst (struct rt6_info *rt,struct fib6_info *ort) { - rt->dst.flags |=fib6_info_dst_flags (ort); -if (ort->fib6_flags &RTF_REJECT ) {ip6_rt_init_dst_reject (rt, ort);return ;
Thanks for the patch.
David Miller
maintainerFrom: Peter Oskolkov <[email protected]>
Date: Mon, 17 Sep 2018 10:20:53 -0700
Quoted 12 lines
DST_NOCOUNTindst_entry::flagstracks whether the entry counts toward route cache size (net->ipv6.sysctl.ip6_rt_max_size).If the flag is NOT set,
dst_ops::pcpuc_entriescounter is incremented indist_init()and decremented indst_destroy().This flag is tied to allocation/deallocation of
dst_entryand should not be copied from another dst/route. Otherwise it can happen thatdst_ops::pcpuc_entriescounter grows until no new routes can be allocated because the counter reachedip6_rt_max_sizedue toDST_NOCOUNTnot set and thus no counter decrements on gc-ed routes.
Quoted 4 lines
Fixes 3b6761d18bc1 ("net/ipv6: Move dst flags to booleans in fib entries")Cc David Ahern <[email protected]>Acked-by Wei Wang <[email protected]>Signed-off-by Peter Oskolkov <[email protected]>
Applied and queued up for -stable, thank you.