]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
frag6: fix vnet teardown leak
authorBjoern A. Zeeb <bz@FreeBSD.org>
Mon, 21 Oct 2019 08:48:47 +0000 (08:48 +0000)
committerBjoern A. Zeeb <bz@FreeBSD.org>
Mon, 21 Oct 2019 08:48:47 +0000 (08:48 +0000)
commit67a10c464436f1ddd16d41cac6c02802c9ce2f4d
treee01f413b71b527ee619b4be4c8b5e3b1de7e0ff5
parent65456706c08be5025e10319f2ea011ebdbc64f38
frag6: fix vnet teardown leak

When shutting down a VNET we did not cleanup the fragmentation hashes.
This has multiple problems: (1) leak memory but also (2) leak on the
global counters, which might eventually lead to a problem on a system
starting and stopping a lot of vnets and dealing with a lot of IPv6
fragments that the counters/limits would be exhausted and processing
would no longer take place.

Unfortunately we do not have a useable variable to indicate when
per-VNET initialization of frag6 has happened (or when destroy happened)
so introduce a boolean to flag this. This is needed here as well as
it was in r353635 for ip_reass.c in order to avoid tripping over the
already destroyed locks if interfaces go away after the frag6 destroy.

While splitting things up convert the TRY_LOCK to a LOCK operation in
now frag6_drain_one().  The try-lock was derived from a manual hand-rolled
implementation and carried forward all the time.  We no longer can afford
not to get the lock as that would mean we would continue to leak memory.

Assert that all the buckets are empty before destroying to lock to
ensure long-term stability of a clean shutdown.

Reported by: hselasky
Reviewed by: hselasky
MFC after: 3 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D22054
sys/netinet6/frag6.c
sys/netinet6/ip6_input.c
sys/netinet6/ip6_var.h