Skip to content

Commit 125d9e9

Browse files
ordexNipaLocal
authored and
NipaLocal
committed
ovpn: properly deconfigure UDP-tunnel
When deconfiguring a UDP-tunnel from a socket, we cannot call setup_udp_tunnel_sock() with an empty config, because this helper is expected to be invoked only during setup. Get rid of the call to setup_udp_tunnel_sock() and just revert what it did during socket initialization.. Note that the global udp_encap_needed_key and the GRO state are left untouched: udp_destroy_socket() will eventually take care of them. Cc: Sabrina Dubroca <[email protected]> Cc: Oleksandr Natalenko <[email protected]> Fixes: ab66abb ("ovpn: implement basic RX path (UDP)") Reported-by: Paolo Abeni <[email protected]> Closes: https://lore.kernel.org/netdev/[email protected] Signed-off-by: Antonio Quartulli <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 81e5d1a commit 125d9e9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/net/ovpn/udp.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,16 @@ int ovpn_udp_socket_attach(struct ovpn_socket *ovpn_sock,
442442
*/
443443
void ovpn_udp_socket_detach(struct ovpn_socket *ovpn_sock)
444444
{
445-
struct udp_tunnel_sock_cfg cfg = { };
445+
struct sock *sk = ovpn_sock->sock->sk;
446446

447-
setup_udp_tunnel_sock(sock_net(ovpn_sock->sock->sk), ovpn_sock->sock,
448-
&cfg);
447+
/* Re-enable multicast loopback */
448+
inet_set_bit(MC_LOOP, sk);
449+
/* Disable CHECKSUM_UNNECESSARY to CHECKSUM_COMPLETE conversion */
450+
inet_dec_convert_csum(sk);
451+
452+
udp_sk(sk)->encap_type = 0;
453+
udp_sk(sk)->encap_rcv = NULL;
454+
udp_sk(sk)->encap_destroy = NULL;
455+
456+
rcu_assign_sk_user_data(sk, NULL);
449457
}

0 commit comments

Comments
 (0)