Skip to content

Commit

Permalink
l2tp: close sessions in ip socket destroy callback
Browse files Browse the repository at this point in the history
l2tp_core hooks UDP's .destroy handler to gain advance warning of a tunnel
socket being closed from userspace.  We need to do the same thing for
IP-encapsulation sockets.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tom Parkin authored and David S. Miller committed Mar 20, 2013
1 parent e34f4c7 commit 9360631
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions net/l2tp/l2tp_ip.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,16 @@ static void l2tp_ip_close(struct sock *sk, long timeout)
static void l2tp_ip_destroy_sock(struct sock *sk)
{
struct sk_buff *skb;
struct l2tp_tunnel *tunnel = l2tp_sock_to_tunnel(sk);

while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL)
kfree_skb(skb);

if (tunnel) {
l2tp_tunnel_closeall(tunnel);
sock_put(sk);
}

sk_refcnt_debug_dec(sk);
}

Expand Down
7 changes: 7 additions & 0 deletions net/l2tp/l2tp_ip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,17 @@ static void l2tp_ip6_close(struct sock *sk, long timeout)

static void l2tp_ip6_destroy_sock(struct sock *sk)
{
struct l2tp_tunnel *tunnel = l2tp_sock_to_tunnel(sk);

lock_sock(sk);
ip6_flush_pending_frames(sk);
release_sock(sk);

if (tunnel) {
l2tp_tunnel_closeall(tunnel);
sock_put(sk);
}

inet6_destroy_sock(sk);
}

Expand Down

0 comments on commit 9360631

Please sign in to comment.