From patchwork Thu Sep 3 08:54:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Parkin X-Patchwork-Id: 261589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71A20C433E2 for ; Thu, 3 Sep 2020 08:55:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F6E62065F for ; Thu, 3 Sep 2020 08:55:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=katalix.com header.i=@katalix.com header.b="SgeeKOra" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727989AbgICIzI (ORCPT ); Thu, 3 Sep 2020 04:55:08 -0400 Received: from mail.katalix.com ([3.9.82.81]:42250 "EHLO mail.katalix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgICIzH (ORCPT ); Thu, 3 Sep 2020 04:55:07 -0400 Received: from localhost.localdomain (82-69-49-219.dsl.in-addr.zen.co.uk [82.69.49.219]) (Authenticated sender: tom) by mail.katalix.com (Postfix) with ESMTPSA id 167D086C71; Thu, 3 Sep 2020 09:55:05 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=katalix.com; s=mail; t=1599123305; bh=PTBEx0iwJaF/IziJNTk93viL8CQz2z9UiXUweD8PwE0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:From; z=From:=20Tom=20Parkin=20|To:=20netdev@vger.ke rnel.org|Cc:=20jchapman@katalix.com,=0D=0A=09Tom=20Parkin=20|Subject:=20[PATCH=20net-next=202/6]=20l2tp:=20drop =20data_len=20argument=20from=20l2tp_xmit_core|Date:=20Thu,=20=203 =20Sep=202020=2009:54:48=20+0100|Message-Id:=20<20200903085452.948 7-3-tparkin@katalix.com>|In-Reply-To:=20<20200903085452.9487-1-tpa rkin@katalix.com>|References:=20<20200903085452.9487-1-tparkin@kat alix.com>; b=SgeeKOraFqcxOg+iPfY2ddnHMIiQEtriP99sw4wqhYcrkCXk38zGW4A+mqL1uYh4E O78ck2KCi19J3HSshSmdxcGZnCgjLnebOVqUHCANCNGnb7FRnGC9Vf/OWSw/+fDG+7 RYeZjUdG7HTmVQQY8cc0xUvlB/H0qRcIvU7RPA3dX/P7AdrRGvMriWNLkFX8BCfCRu YglcnqIyjwm3UfRdGo8msU7xvWVuvZvg0XHojwga+3/dV3XQe/gu0bN8ni7ZdmNszV J+TJyqfiIK0waegy5GiH+p4WPXXH83sbX5nUwQEz2Rx/waPi1MFF/lNb511N1ORgaD ZSHkp5Pcoc8cw== From: Tom Parkin To: netdev@vger.kernel.org Cc: jchapman@katalix.com, Tom Parkin Subject: [PATCH net-next 2/6] l2tp: drop data_len argument from l2tp_xmit_core Date: Thu, 3 Sep 2020 09:54:48 +0100 Message-Id: <20200903085452.9487-3-tparkin@katalix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200903085452.9487-1-tparkin@katalix.com> References: <20200903085452.9487-1-tparkin@katalix.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The data_len argument passed to l2tp_xmit_core is no longer used, so remove it. Signed-off-by: Tom Parkin --- net/l2tp/l2tp_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index c95b58b2ab3c..4a8fb285fada 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -985,8 +985,7 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf) return bufp - optr; } -static void l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, - struct flowi *fl, size_t data_len) +static void l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, struct flowi *fl) { struct l2tp_tunnel *tunnel = session->tunnel; unsigned int len = skb->len; @@ -1098,7 +1097,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb) break; } - l2tp_xmit_core(session, skb, fl, data_len); + l2tp_xmit_core(session, skb, fl); out_unlock: bh_unlock_sock(sk); From patchwork Thu Sep 3 08:54:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Parkin X-Patchwork-Id: 261587 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EEA4C433E2 for ; Thu, 3 Sep 2020 08:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC7F72071B for ; Thu, 3 Sep 2020 08:55:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=katalix.com header.i=@katalix.com header.b="ItlMc6u6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728157AbgICIzO (ORCPT ); Thu, 3 Sep 2020 04:55:14 -0400 Received: from mail.katalix.com ([3.9.82.81]:42252 "EHLO mail.katalix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726726AbgICIzJ (ORCPT ); Thu, 3 Sep 2020 04:55:09 -0400 Received: from localhost.localdomain (82-69-49-219.dsl.in-addr.zen.co.uk [82.69.49.219]) (Authenticated sender: tom) by mail.katalix.com (Postfix) with ESMTPSA id 45AFB86C72; Thu, 3 Sep 2020 09:55:06 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=katalix.com; s=mail; t=1599123306; bh=RBVGU1T3ZOMGmU8xZc6RIZhXD5Vx8GtLhe85IXLD/h0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:From; z=From:=20Tom=20Parkin=20|To:=20netdev@vger.ke rnel.org|Cc:=20jchapman@katalix.com,=0D=0A=09Tom=20Parkin=20|Subject:=20[PATCH=20net-next=203/6]=20l2tp:=20drop =20net=20argument=20from=20l2tp_tunnel_create|Date:=20Thu,=20=203= 20Sep=202020=2009:54:49=20+0100|Message-Id:=20<20200903085452.9487 -4-tparkin@katalix.com>|In-Reply-To:=20<20200903085452.9487-1-tpar kin@katalix.com>|References:=20<20200903085452.9487-1-tparkin@kata lix.com>; b=ItlMc6u6oQn1hMqDzatFDElb7zCZYYwf+54BtsGQ8I01Ji9xw/Itu8WNGnX//g1ZA fO4K48UkP2Api8e5cMeIDb4B1OpTIKp9LANhfjsHZmxqiURViwx6vOse9TWhx/Hw72 mX0lDOvdTY+p/qzaIcdBHoulwIex42Whbn8HkdTiIMFKw2MGM56HMQgdXLO9GpBTE1 MCGfzE4UTKJ9GEHc6ObU098Cc7fKu7WWco4Si9RyMoDJ9TrrR2p8/0+j2PqVGqnC+t 5zKJmYogjTSn3p7QyfjzusyoI/GEND7X5t/bHehJjUG2A9pvdMEtQ3hOGcSIXEaxxT WGE9bVGLGllyQ== From: Tom Parkin To: netdev@vger.kernel.org Cc: jchapman@katalix.com, Tom Parkin Subject: [PATCH net-next 3/6] l2tp: drop net argument from l2tp_tunnel_create Date: Thu, 3 Sep 2020 09:54:49 +0100 Message-Id: <20200903085452.9487-4-tparkin@katalix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200903085452.9487-1-tparkin@katalix.com> References: <20200903085452.9487-1-tparkin@katalix.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The argument is unused, so remove it. Signed-off-by: Tom Parkin --- net/l2tp/l2tp_core.c | 2 +- net/l2tp/l2tp_core.h | 2 +- net/l2tp/l2tp_netlink.c | 2 +- net/l2tp/l2tp_ppp.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 4a8fb285fada..da66a6ed8993 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -1381,7 +1381,7 @@ static int l2tp_tunnel_sock_create(struct net *net, static struct lock_class_key l2tp_socket_class; -int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 peer_tunnel_id, +int l2tp_tunnel_create(int fd, int version, u32 tunnel_id, u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg, struct l2tp_tunnel **tunnelp) { struct l2tp_tunnel *tunnel = NULL; diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h index 5550a42dda04..3ce90c3f3491 100644 --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h @@ -235,7 +235,7 @@ struct l2tp_session *l2tp_session_get_by_ifname(const struct net *net, * Creation of a new instance is a two-step process: create, then register. * Destruction is triggered using the *_delete functions, and completes asynchronously. */ -int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, +int l2tp_tunnel_create(int fd, int version, u32 tunnel_id, u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg, struct l2tp_tunnel **tunnelp); int l2tp_tunnel_register(struct l2tp_tunnel *tunnel, struct net *net, diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c index 31a1e27eab20..83c015f7f20d 100644 --- a/net/l2tp/l2tp_netlink.c +++ b/net/l2tp/l2tp_netlink.c @@ -233,7 +233,7 @@ static int l2tp_nl_cmd_tunnel_create(struct sk_buff *skb, struct genl_info *info switch (cfg.encap) { case L2TP_ENCAPTYPE_UDP: case L2TP_ENCAPTYPE_IP: - ret = l2tp_tunnel_create(net, fd, proto_version, tunnel_id, + ret = l2tp_tunnel_create(fd, proto_version, tunnel_id, peer_tunnel_id, &cfg, &tunnel); break; } diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 998e0c6abf25..68d2489fc133 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -712,7 +712,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr, goto end; } - error = l2tp_tunnel_create(sock_net(sk), info.fd, + error = l2tp_tunnel_create(info.fd, info.version, info.tunnel_id, info.peer_tunnel_id, &tcfg, From patchwork Thu Sep 3 08:54:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Parkin X-Patchwork-Id: 261588 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3749BC433E7 for ; Thu, 3 Sep 2020 08:55:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F23CC2065F for ; Thu, 3 Sep 2020 08:55:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=katalix.com header.i=@katalix.com header.b="ORVNv6uQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728308AbgICIzS (ORCPT ); Thu, 3 Sep 2020 04:55:18 -0400 Received: from mail.katalix.com ([3.9.82.81]:42260 "EHLO mail.katalix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgICIzJ (ORCPT ); Thu, 3 Sep 2020 04:55:09 -0400 Received: from localhost.localdomain (82-69-49-219.dsl.in-addr.zen.co.uk [82.69.49.219]) (Authenticated sender: tom) by mail.katalix.com (Postfix) with ESMTPSA id 5AE8D86C66; Thu, 3 Sep 2020 09:55:08 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=katalix.com; s=mail; t=1599123308; bh=VEXEUb+/oqevL+R8UCQD7uxoPxCgimpGygm9z3+Pjms=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:From; z=From:=20Tom=20Parkin=20|To:=20netdev@vger.ke rnel.org|Cc:=20jchapman@katalix.com,=0D=0A=09Tom=20Parkin=20|Subject:=20[PATCH=20net-next=206/6]=20l2tp:=20avoi d=20duplicated=20code=20in=20l2tp_tunnel_closeall|Date:=20Thu,=20= 203=20Sep=202020=2009:54:52=20+0100|Message-Id:=20<20200903085452. 9487-7-tparkin@katalix.com>|In-Reply-To:=20<20200903085452.9487-1- tparkin@katalix.com>|References:=20<20200903085452.9487-1-tparkin@ katalix.com>; b=ORVNv6uQFXlPWEipAhuIGUXMb54XuU5RqfgWmEYgLsNEqj+AqWsBD2iIOpa6Jmq6H dXuWwQ1oNW/3GfEdoMhqSQMSkY68gLGwHbNB2bU2EuE9ZhRTJyY/+alwmrzNH/wEMS LnPmGrKDu84g3hKzaA8BCXSvnvHL/YiWK5S01o2RL+JidwzWyI+gzrn07MvJSiDwNI +nsjHO4CKA2qLMGYQ22ZID+bENB+mdR1iF/GpLDCEwWTKy1JhHK14Tdg7+uAzuCjOP 3+s/b7mAR1uKkwUWoxyR5qMOHb3Wnemm7c3CPI7udARmsLg9iyGFGkyZLGiN9RrxAw 8HJazh2RB6+Xw== From: Tom Parkin To: netdev@vger.kernel.org Cc: jchapman@katalix.com, Tom Parkin Subject: [PATCH net-next 6/6] l2tp: avoid duplicated code in l2tp_tunnel_closeall Date: Thu, 3 Sep 2020 09:54:52 +0100 Message-Id: <20200903085452.9487-7-tparkin@katalix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200903085452.9487-1-tparkin@katalix.com> References: <20200903085452.9487-1-tparkin@katalix.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org l2tp_tunnel_closeall is called as a part of tunnel shutdown in order to close all the sessions held by the tunnel. The code it uses to close a session duplicates what l2tp_session_delete does. Rather than duplicating the code, have l2tp_tunnel_closeall call l2tp_session_delete instead. This involves a very minor change to locking in l2tp_tunnel_closeall. Previously, l2tp_tunnel_closeall checked the session "dead" flag while holding tunnel->hlist_lock. This allowed for the code to step to the next session in the list without releasing the lock if the current session happened to be in the process of closing already. By calling l2tp_session_delete instead, l2tp_tunnel_closeall must now drop and regain the hlist lock for each session in the tunnel list. Given that the likelihood of a session being in the process of closing when the tunnel is closed, it seems worth this very minor potential loss of efficiency to avoid duplication of the session delete code. Signed-off-by: Tom Parkin --- net/l2tp/l2tp_core.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index b02b3cc67df0..7de05be4fc33 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -1191,22 +1191,10 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel) again: hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) { session = hlist_entry(walk, struct l2tp_session, hlist); - hlist_del_init(&session->hlist); - if (test_and_set_bit(0, &session->dead)) - goto again; - write_unlock_bh(&tunnel->hlist_lock); - - l2tp_session_unhash(session); - l2tp_session_queue_purge(session); - - if (session->session_close) - (*session->session_close)(session); - - l2tp_session_dec_refcount(session); - + l2tp_session_delete(session); write_lock_bh(&tunnel->hlist_lock); /* Now restart from the beginning of this hash