From patchwork Sat Jun 2 15:26:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17397 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 83B1680D96; Sat, 2 Jun 2018 17:26:52 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="uLkA1emA"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id 025E3805E4 for ; Sat, 2 Jun 2018 17:26:50 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593EE47FD0000000000004065.dip0.t-ipconnect.de [IPv6:2003:c5:93ee:47fd::4065]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 1FE64110126; Sat, 2 Jun 2018 17:26:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1527953210; bh=MmC3b5mDMRVXU1ycB4HboI9mHfLClYXqDeqnZUJSkwI=; h=From:To:Cc:Subject:Date:From; b=uLkA1emAMOcybOIlTqaufiPq2miX06W2W7zl3ZfoJ3XeIoW9J8RXB5LZ5z+LH5wPE zx/+YTz/lsYv22vZYUoQm/ccD4xtR61+ZHc7xAllYHAytnY4DZxuutbtYqA76CeDnD qocRqTVdktiXmtCbKpiuoCP+nQXJf45hYLtEBlEo= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 2 Jun 2018 17:26:34 +0200 Message-Id: <20180602152635.2923-1-sven@narfation.org> X-Mailer: git-send-email 2.17.0 Subject: [B.A.T.M.A.N.] [PATCH maint 1/2] batman-adv: Fix bat_ogm_iv best gw refcnt after netlink dump X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: Andreas Ziegler Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST. After the comparison of the current entry is done, batadv_iv_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it). Fixes: fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations") Reported-by: Andreas Ziegler Signed-off-by: Sven Eckelmann Acked-by: Marek Lindner Tested-by: Andreas Ziegler --- Cc: Andreas Ziegler net/batman-adv/bat_iv_ogm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index be09a988..73bf6a93 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -2732,7 +2732,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, { struct batadv_neigh_ifinfo *router_ifinfo = NULL; struct batadv_neigh_node *router; - struct batadv_gw_node *curr_gw; + struct batadv_gw_node *curr_gw = NULL; int ret = 0; void *hdr; @@ -2780,6 +2780,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ret = 0; out: + if (curr_gw) + batadv_gw_node_put(curr_gw); if (router_ifinfo) batadv_neigh_ifinfo_put(router_ifinfo); if (router) From patchwork Sat Jun 2 15:26:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17398 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 8925081F83; Sat, 2 Jun 2018 17:27:06 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="VDEN0D0E"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 51F84805E4 for ; Sat, 2 Jun 2018 17:26:59 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593EE47FD0000000000004065.dip0.t-ipconnect.de [IPv6:2003:c5:93ee:47fd::4065]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 0C7D7110126; Sat, 2 Jun 2018 17:26:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1527953218; bh=POuy6bKvnubV3p1dZ5mDMa8IVszLo2c3MrR3+RquBAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VDEN0D0ESjc85c224T25/UET355utCTQz30tHJC/Mo7KczkrQjD53wgURei1mbM9x A7fyyoXyecUtorefyey/KmQP/bFlunvVaVavRsQwyzYh3v5bCsoj+ZkHvuV+zvtCBV X09XmUJ8oIltGh8VJtTc3BTx7VVZd0Wf2dQp+/cY= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 2 Jun 2018 17:26:35 +0200 Message-Id: <20180602152635.2923-2-sven@narfation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180602152635.2923-1-sven@narfation.org> References: <20180602152635.2923-1-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix bat_v best gw refcnt after netlink dump X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: Andreas Ziegler Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST. After the comparison of the current entry is done, batadv_v_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it). Fixes: 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations") Signed-off-by: Sven Eckelmann Acked-by: Marek Lindner Tested-by: Andreas Ziegler --- Cc: Andreas Ziegler net/batman-adv/bat_v.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index ec93337e..6baec4e6 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -927,7 +927,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, { struct batadv_neigh_ifinfo *router_ifinfo = NULL; struct batadv_neigh_node *router; - struct batadv_gw_node *curr_gw; + struct batadv_gw_node *curr_gw = NULL; int ret = 0; void *hdr; @@ -995,6 +995,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq, ret = 0; out: + if (curr_gw) + batadv_gw_node_put(curr_gw); if (router_ifinfo) batadv_neigh_ifinfo_put(router_ifinfo); if (router)