Received: by 10.223.185.116 with SMTP id b49csp829004wrg; Sat, 10 Feb 2018 21:24:01 -0800 (PST) X-Google-Smtp-Source: AH8x226oErq2nxdAwXUoQ1BiZM13bWZQtdU1kDlcBfhGjNXuntc3RFF/0BDpOHom/F7y4zf2/Okd X-Received: by 10.98.70.20 with SMTP id t20mr1746948pfa.201.1518326641261; Sat, 10 Feb 2018 21:24:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326641; cv=none; d=google.com; s=arc-20160816; b=XYJwNEcCiBUpjWRudHCu1QZC9HxLpdGNScFchskB7Gey99n4FWfd2Y3A6rinuBgx+2 qsp5nV7PiPDPYCNpg16yD141hK6B5WYKY4dNog8AUKPHFdqMhicgx9iRToaiTpF5QA4G 7bfGx+wWWI8Z5PHAmSQBffxbSJTt9j+o/2MYe7bGowrzY5yEgHn4NDknH5U+Y4PuNtT8 F+mdtSR/ewzuAQT6R1BJRGQ8G4u4TrY6GNmVBqo/azGP6iX7MMNEO/U+4BGMtvJkEcTt oLgmdt8VWQyFAc79iwTUGsop85DY8q34xiyXmxHdstmSA39Oy01Ltd3GdzVRrcN3gHce pocQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=rlcBzeJdX+0T2jrB+gB32fbwG7AdVug1isCBI0EibQ0=; b=u8kb4PivrlgH2GeMD3dw3tsW2ou/P5OlrITSlRvczmZ/k6GG9f3FiTxG4DlhdEPK3L P7FdmtrfshQm0ClXubuyp7qYEhnirvolVtGQBSS5jjWpeFdyR0GPaL1/DROmmUSxLzVB AIw5sbffI8w9hIzZuf2QRBJyyg15rvVPkoxcelOISFONSZJKLLuyhdM9FaVpCyFXVF/j 0JG0DAqlIGL/PVriGbELyI7cNdSo1pR6lfkxpsFgeaI+JZ0xh7Gck3+DcSz5IbbrI2cV ce+Cpzdg8Szr2SXmMYHDNphDhk62eoaDyR9DJYar7XlNjAyq6u44rSFeq51IHkWiTAnj 0jeg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a33-v6si4048805plc.237.2018.02.10.21.23.47; Sat, 10 Feb 2018 21:24:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753997AbeBKFRh (ORCPT + 99 others); Sun, 11 Feb 2018 00:17:37 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41357 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752575AbeBKEdk (ORCPT ); Sat, 10 Feb 2018 23:33:40 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ekjKc-0002hQ-R0; Sun, 11 Feb 2018 04:33:38 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKX-0004Si-DR; Sun, 11 Feb 2018 04:33:33 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Tom Parkin" , "David S. Miller" , "James Chapman" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 16/79] l2tp: push all ppp pseudowire shutdown through .release handler In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Tom Parkin commit cf2f5c886a209377daefd5d2ba0bcd49c3887813 upstream. If userspace deletes a ppp pseudowire using the netlink API, either by directly deleting the session or by deleting the tunnel that contains the session, we need to tear down the corresponding pppox channel. Rather than trying to manage two pppox unbind codepaths, switch the netlink and l2tp_core session_close handlers to close via. the l2tp_ppp socket .release handler. Signed-off-by: Tom Parkin Signed-off-by: James Chapman Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/l2tp/l2tp_ppp.c | 53 ++++++++++------------------------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -95,6 +95,7 @@ #include #include #include +#include #include #include @@ -460,34 +461,16 @@ static void pppol2tp_session_close(struc { struct pppol2tp_session *ps = l2tp_session_priv(session); struct sock *sk = ps->sock; - struct sk_buff *skb; + struct socket *sock = sk->sk_socket; BUG_ON(session->magic != L2TP_SESSION_MAGIC); - if (session->session_id == 0) - goto out; - - if (sk != NULL) { - lock_sock(sk); - - if (sk->sk_state & (PPPOX_CONNECTED | PPPOX_BOUND)) { - pppox_unbind_sock(sk); - sk->sk_state = PPPOX_DEAD; - sk->sk_state_change(sk); - } - - /* Purge any queued data */ - skb_queue_purge(&sk->sk_receive_queue); - skb_queue_purge(&sk->sk_write_queue); - while ((skb = skb_dequeue(&session->reorder_q))) { - kfree_skb(skb); - sock_put(sk); - } - release_sock(sk); + if (sock) { + inet_shutdown(sock, 2); + /* Don't let the session go away before our socket does */ + l2tp_session_inc_refcount(session); } - -out: return; } @@ -538,16 +521,12 @@ static int pppol2tp_release(struct socke session = pppol2tp_sock_to_session(sk); /* Purge any queued data */ - skb_queue_purge(&sk->sk_receive_queue); - skb_queue_purge(&sk->sk_write_queue); if (session != NULL) { - struct sk_buff *skb; - while ((skb = skb_dequeue(&session->reorder_q))) { - kfree_skb(skb); - sock_put(sk); - } + l2tp_session_queue_purge(session); sock_put(sk); } + skb_queue_purge(&sk->sk_receive_queue); + skb_queue_purge(&sk->sk_write_queue); release_sock(sk); @@ -872,18 +851,6 @@ out: return error; } -/* Called when deleting sessions via the netlink interface. - */ -static int pppol2tp_session_delete(struct l2tp_session *session) -{ - struct pppol2tp_session *ps = l2tp_session_priv(session); - - if (ps->sock == NULL) - l2tp_session_dec_refcount(session); - - return 0; -} - #endif /* CONFIG_L2TP_V3 */ /* getname() support. @@ -1801,7 +1768,7 @@ static const struct pppox_proto pppol2tp static const struct l2tp_nl_cmd_ops pppol2tp_nl_cmd_ops = { .session_create = pppol2tp_session_create, - .session_delete = pppol2tp_session_delete, + .session_delete = l2tp_session_delete, }; #endif /* CONFIG_L2TP_V3 */