Received: by 10.223.185.116 with SMTP id b49csp829418wrg; Sat, 10 Feb 2018 21:24:48 -0800 (PST) X-Google-Smtp-Source: AH8x224jwNocuT7Rj1l/kvz+mDeKTmlVP4bIcKAgKlhClz92xix1zCVUTEY1L9wvUCSEXiSiM2u+ X-Received: by 10.98.12.1 with SMTP id u1mr7616170pfi.192.1518326688304; Sat, 10 Feb 2018 21:24:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326688; cv=none; d=google.com; s=arc-20160816; b=dDT93WaDP8lGw6mTujZGtRVwT8z1N1Yp8oCpjDcd9fXKpepQxuOuCMYnYhRMEv/+md wWODaXg4OMZmFwvsOb6akUsXGlxlTYf672Hr6KVrOqSMIVZ2urqE4eEWK52mKq/HtNQ/ HyRsAAZh1hXA6BgWLfR/URW6XTPvHfQ/KZ0blzLIWkgwhyJs/nszP8G7JK/jnpSVBjZL JkB9bjRTc3eDap+Ohm1/YjHD3kvOHpERBeb8rxHTZBvq7n8gkBskx93jlyUHN/jKDyyy OBg4pZKX7lkTGRk7Ka0l/ksBAvXidyAzl/AnGmONA8MGxbTYmDOt3mN+RyJvhsPEzYKS eeEQ== 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=AP0gGeBMyCupWjjxk16DTVvOq25YXd9hDLw+SjvDS5g=; b=oYp9zm664LQXbGv4qHX8WvbRxy3zmZP7PDotNB8cOaX9SX2K1e/vH4pRVMco7ndors dGQBvwy069Vt2Wl1cVa1fPhi+RDgbts/H2rN7ydIAoo7Hvf6cTqmPVeODygyutTJNHdR wWuaByGz4e6nbPzgVCHM+32ClrvTyqOGM6XhDyHO32dqMxPVtLQK/ybKOvLjMd7uAEwU 66N/wkVAePOHE0ANUEZGlMZ446nOmEz3DHC1oxRDGA6sOH6MDgUcJUQ8A2SrgKCVNliR BwoUkMgLQREIgPYCucKmvW/gMIPE5WeBqk/P4naEY9uL5MA5S67kfoSbeeFhwD3X9rAV tMYw== 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 b8si1726870pgt.383.2018.02.10.21.24.34; Sat, 10 Feb 2018 21:24:48 -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 S932087AbeBKFRk (ORCPT + 99 others); Sun, 11 Feb 2018 00:17:40 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41356 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752562AbeBKEdk (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-0002hO-SG; Sun, 11 Feb 2018 04:33:39 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKX-0004SY-BP; 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" , "James Chapman" , "David S. Miller" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 14/79] l2tp: add session reorder queue purge function to core 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 48f72f92b31431c40279b0fba6c5588e07e67d95 upstream. If an l2tp session is deleted, it is necessary to delete skbs in-flight on the session's reorder queue before taking it down. Rather than having each pseudowire implementation reaching into the l2tp_session struct to handle this itself, provide a function in l2tp_core to purge the session queue. Signed-off-by: Tom Parkin Signed-off-by: James Chapman Signed-off-by: David S. Miller [bwh: Backported to 3.2: use non-atomic increment on rx_errors] Signed-off-by: Ben Hutchings --- net/l2tp/l2tp_core.c | 17 +++++++++++++++++ net/l2tp/l2tp_core.h | 1 + 2 files changed, 18 insertions(+) --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -830,6 +830,23 @@ discard: } EXPORT_SYMBOL(l2tp_recv_common); +/* Drop skbs from the session's reorder_q + */ +int l2tp_session_queue_purge(struct l2tp_session *session) +{ + struct sk_buff *skb = NULL; + BUG_ON(!session); + BUG_ON(session->magic != L2TP_SESSION_MAGIC); + while ((skb = skb_dequeue(&session->reorder_q))) { + session->stats.rx_errors++; + kfree_skb(skb); + if (session->deref) + (*session->deref)(session); + } + return 0; +} +EXPORT_SYMBOL_GPL(l2tp_session_queue_purge); + /* Internal UDP receive frame. Do the real work of receiving an L2TP data frame * here. The skb is not on a list when we get here. * Returns 0 if the packet was a data packet and was successfully passed on. --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h @@ -249,6 +249,7 @@ extern struct l2tp_session *l2tp_session extern int l2tp_session_delete(struct l2tp_session *session); extern void l2tp_session_free(struct l2tp_session *session); extern void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, unsigned char *ptr, unsigned char *optr, u16 hdrflags, int length, int (*payload_hook)(struct sk_buff *skb)); +extern int l2tp_session_queue_purge(struct l2tp_session *session); extern int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb); extern int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len);