diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/l2tp/l2tp_core.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index d36875f3427e..ee726a752292 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c | |||
@@ -1282,6 +1282,7 @@ static void l2tp_tunnel_destruct(struct sock *sk) | |||
1282 | /* No longer an encapsulation socket. See net/ipv4/udp.c */ | 1282 | /* No longer an encapsulation socket. See net/ipv4/udp.c */ |
1283 | (udp_sk(sk))->encap_type = 0; | 1283 | (udp_sk(sk))->encap_type = 0; |
1284 | (udp_sk(sk))->encap_rcv = NULL; | 1284 | (udp_sk(sk))->encap_rcv = NULL; |
1285 | (udp_sk(sk))->encap_destroy = NULL; | ||
1285 | break; | 1286 | break; |
1286 | case L2TP_ENCAPTYPE_IP: | 1287 | case L2TP_ENCAPTYPE_IP: |
1287 | break; | 1288 | break; |
@@ -1360,6 +1361,8 @@ again: | |||
1360 | if (session->deref != NULL) | 1361 | if (session->deref != NULL) |
1361 | (*session->deref)(session); | 1362 | (*session->deref)(session); |
1362 | 1363 | ||
1364 | l2tp_session_dec_refcount(session); | ||
1365 | |||
1363 | write_lock_bh(&tunnel->hlist_lock); | 1366 | write_lock_bh(&tunnel->hlist_lock); |
1364 | 1367 | ||
1365 | /* Now restart from the beginning of this hash | 1368 | /* Now restart from the beginning of this hash |
@@ -1373,6 +1376,16 @@ again: | |||
1373 | write_unlock_bh(&tunnel->hlist_lock); | 1376 | write_unlock_bh(&tunnel->hlist_lock); |
1374 | } | 1377 | } |
1375 | 1378 | ||
1379 | /* Tunnel socket destroy hook for UDP encapsulation */ | ||
1380 | static void l2tp_udp_encap_destroy(struct sock *sk) | ||
1381 | { | ||
1382 | struct l2tp_tunnel *tunnel = l2tp_sock_to_tunnel(sk); | ||
1383 | if (tunnel) { | ||
1384 | l2tp_tunnel_closeall(tunnel); | ||
1385 | sock_put(sk); | ||
1386 | } | ||
1387 | } | ||
1388 | |||
1376 | /* Really kill the tunnel. | 1389 | /* Really kill the tunnel. |
1377 | * Come here only when all sessions have been cleared from the tunnel. | 1390 | * Come here only when all sessions have been cleared from the tunnel. |
1378 | */ | 1391 | */ |
@@ -1668,6 +1681,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 | |||
1668 | /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */ | 1681 | /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */ |
1669 | udp_sk(sk)->encap_type = UDP_ENCAP_L2TPINUDP; | 1682 | udp_sk(sk)->encap_type = UDP_ENCAP_L2TPINUDP; |
1670 | udp_sk(sk)->encap_rcv = l2tp_udp_encap_recv; | 1683 | udp_sk(sk)->encap_rcv = l2tp_udp_encap_recv; |
1684 | udp_sk(sk)->encap_destroy = l2tp_udp_encap_destroy; | ||
1671 | #if IS_ENABLED(CONFIG_IPV6) | 1685 | #if IS_ENABLED(CONFIG_IPV6) |
1672 | if (sk->sk_family == PF_INET6) | 1686 | if (sk->sk_family == PF_INET6) |
1673 | udpv6_encap_enable(); | 1687 | udpv6_encap_enable(); |