mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 15:27:29 +00:00
udp: implement complete book-keeping for encap_needed
The *encap_needed static keys are enabled by UDP tunnels and several UDP encapsulations type, but they are never turned off. This can cause unneeded overall performance degradation for systems where such features are used transiently. This patch introduces complete book-keeping for such keys, decreasing the usage at socket destruction time, if needed, and avoiding that the same socket could increase the key usage multiple times. rfc v3 -> v1: - add socket lock around udp_tunnel_encap_enable() rfc v2 -> rfc v3: - use udp_tunnel_encap_enable() in setsockopt() Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
7e225619e8
commit
60fb9567bf
4 changed files with 34 additions and 12 deletions
|
@ -1456,11 +1456,15 @@ void udpv6_destroy_sock(struct sock *sk)
|
|||
udp_v6_flush_pending_frames(sk);
|
||||
release_sock(sk);
|
||||
|
||||
if (static_branch_unlikely(&udpv6_encap_needed_key) && up->encap_type) {
|
||||
void (*encap_destroy)(struct sock *sk);
|
||||
encap_destroy = READ_ONCE(up->encap_destroy);
|
||||
if (encap_destroy)
|
||||
encap_destroy(sk);
|
||||
if (static_branch_unlikely(&udpv6_encap_needed_key)) {
|
||||
if (up->encap_type) {
|
||||
void (*encap_destroy)(struct sock *sk);
|
||||
encap_destroy = READ_ONCE(up->encap_destroy);
|
||||
if (encap_destroy)
|
||||
encap_destroy(sk);
|
||||
}
|
||||
if (up->encap_enabled)
|
||||
static_branch_disable(&udpv6_encap_needed_key);
|
||||
}
|
||||
|
||||
inet6_destroy_sock(sk);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue