From patchwork Fri Dec 4 15:46:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18234 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 58F4582638; Fri, 4 Dec 2020 16:55:17 +0100 (CET) Received: from simonwunderlich.de (packetmixer.de [IPv6:2001:4d88:2000:24::c0de]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 8F46B80D64 for ; Fri, 4 Dec 2020 16:55:07 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 3E00D174060; Fri, 4 Dec 2020 16:46:33 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 1/8] batman-adv: Start new development cycle Date: Fri, 4 Dec 2020 16:46:24 +0100 Message-Id: <20201204154631.21063-2-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s0fgS0IVwLDa87paquJannSX+rRImagr1ylafFZ0I6s=; b=jjL1nJLUZsXhwCOtXF9tjcnrPTKRge/qwVjzjopQcSp2bRfeHm5tK7eM5j89hcGBnHvEXz eTd6rmEJ/apQUXKhq059HsNIWojASRopvJwQUz42e2dojkuap5Mf6BEtVOhVDj+MgIoGDz SoXNwOsjIsAgx0aZGEGwP+kVS/9ItGo= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097307; a=rsa-sha256; cv=none; b=dhicehEnmhLmr1QVziAwQIWc/FRwI7wpRTOpREDQpuQwsiqs8v6gjGUwLVegoy3Io5GHPw yhF5YkPur1E/iq7ygxoM/UNFiyUp4RmvofkTgn2Mjzfod9EdmbuHR0wD/3Umnx1TTG89By dCLWMbWA4I9wMAAFwZGZd8ExYK1p4FU= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 2001:4d88:2000:24::c0de as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: E7VDZ6IDCQY3ENOWF5KZDFOZBQNL23VR X-Message-ID-Hash: E7VDZ6IDCQY3ENOWF5KZDFOZBQNL23VR X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Simon Wunderlich --- net/batman-adv/main.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index a47dc332d796..9254c6ee0c0a 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -13,7 +13,7 @@ #define BATADV_DRIVER_DEVICE "batman-adv" #ifndef BATADV_SOURCE_VERSION -#define BATADV_SOURCE_VERSION "2020.4" +#define BATADV_SOURCE_VERSION "2021.0" #endif /* B.A.T.M.A.N. parameters */ From patchwork Fri Dec 4 15:46:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18231 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 3EA94800E2; Fri, 4 Dec 2020 16:55:10 +0100 (CET) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 7EE85803EB for ; Fri, 4 Dec 2020 16:55:07 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 9EA3F174061; Fri, 4 Dec 2020 16:46:33 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 2/8] batman-adv: Add new include for min/max helpers Date: Fri, 4 Dec 2020 16:46:25 +0100 Message-Id: <20201204154631.21063-3-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CRAgfEbwqZvZ6oQCw7XHd9W2hUrKzxTS2rh/TBTgaXg=; b=1PeJG3IdP5Ce4jx1fW0bG+adZ3YWimWrSuSgLzL+Fu0pCfG6klWo5lHlVZwWQ2uBCqTC0w GmK9rt5603qiBetqsu71qg7g2FJd5x5cqkzb2e2PwanhqsW+nZJ5/r0B5pZF6GIVZPc1PC fi56P2evlSem5HNmVuD7ESTDcBwtTMo= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097307; a=rsa-sha256; cv=none; b=aF5RctPYNw5+48OBOu2/O2cQzsJrFOvlQOUHQ2fj+LvFoaeDrPmoR0rzO2WoUrwmFPhh6X kuxoY17eVAWA225EiPPhAIbqt5f3HhDDjdz2kvKLp/vUvez3oTyrTlYfTI8StN2YQrWe/H fSRRMudjqlY8+TASX98Kx7LcTzB8asA= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 79.140.42.25 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: 4P4X6JPV4GOWP2L2REPV7V7YOINJKNVZ X-Message-ID-Hash: 4P4X6JPV4GOWP2L2REPV7V7YOINJKNVZ X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann The commit b296a6d53339 ("kernel.h: split out min()/max() et al. helpers") moved the min/max helper functionality from kernel.h to minmax.h. Adjust the kernel code accordingly to avoid fragile indirect includes. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/bat_v.c | 1 + net/batman-adv/bat_v_elp.c | 1 + net/batman-adv/bat_v_ogm.c | 1 + net/batman-adv/fragmentation.c | 2 +- net/batman-adv/hard-interface.c | 1 + net/batman-adv/icmp_socket.c | 1 + net/batman-adv/main.c | 1 + net/batman-adv/netlink.c | 1 + net/batman-adv/tp_meter.c | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 0ecaf1bb0068..e91d2c0720c4 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index 79a7dfc32e76..0512ea6cd818 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 8c1148fc73d7..798d659855d0 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index 1f1f5b0873b2..59ebd73125bf 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 33904595fc56..3838a6165c5e 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index 8bdabc03b0b2..56de4bf21aa5 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 70fee9b42e25..293c62edd9ed 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index c7a55647b520..97bcf149633d 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index db7e3774825b..d4e10005df6c 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include From patchwork Fri Dec 4 15:46:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18237 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id C5A7B82648; Fri, 4 Dec 2020 16:55:28 +0100 (CET) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 025E380DFD for ; Fri, 4 Dec 2020 16:55:08 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 23AF1174062; Fri, 4 Dec 2020 16:46:34 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 3/8] batman-adv: Prepare infrastructure for newlink settings Date: Fri, 4 Dec 2020 16:46:26 +0100 Message-Id: <20201204154631.21063-4-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FJsqWjV0zvMLt4M1VWbbp7PAELV28y24AhLVp4NhqQw=; b=S8BAYJnn4Vba5ujlQvryNL4yWswkpFJYTBhEvijTEv97VUbi03rtGjwLPjaRH08Sh3X9+Q B9ysO4dQpTAc3CUkLUy2xGPxME113wV+7FNGJWOc+8gwvsn4nwAo63IomXJpOgRDpNOeLQ +ESwZayuy++ana/bIQZeSzXv9mdQ3iQ= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097308; a=rsa-sha256; cv=none; b=Tr5ThdZe9WHUVi2SQeDcUq7tOJUIQMucORwVXQcglNqy+FuuW8Ugkytywq3ZEhFYPWmTdd zRZiS8Tw8lQWtgV6YBMFynD10GeNMqnR0sK1CDKHk0faBsnQV6aLaVIqTp2be3J5Uht6Cp aQYaChlvEVDP+NMVgXZI8Hy2OlzHqok= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 79.140.42.25 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: IGCQ4MQPXOKGLMOJQEHVUE6YWEQZQJY4 X-Message-ID-Hash: IGCQ4MQPXOKGLMOJQEHVUE6YWEQZQJY4 X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann The batadv generic netlink family can be used to retrieve the current state and set various configuration settings. But there are also settings which must be set before the actual interface is created. The rtnetlink already uses IFLA_INFO_DATA to allow net_device families to transfer such configurations. The minimal required functionality for this is now available for the batadv rtnl_link_ops. Also a new IFLA class of attributes will be attached to it because rtnetlink only allows 51 different attributes but batadv_nl_attrs already contains 62 attributes. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- include/uapi/linux/batman_adv.h | 20 +++++++++++++++++ net/batman-adv/soft-interface.c | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h index bb0ae945b36a..b05399d8a127 100644 --- a/include/uapi/linux/batman_adv.h +++ b/include/uapi/linux/batman_adv.h @@ -675,4 +675,24 @@ enum batadv_tp_meter_reason { BATADV_TP_REASON_TOO_MANY = 133, }; +/** + * enum batadv_ifla_attrs - batman-adv ifla nested attributes + */ +enum batadv_ifla_attrs { + /** + * @IFLA_BATADV_UNSPEC: unspecified attribute which is not parsed by + * rtnetlink + */ + IFLA_BATADV_UNSPEC, + + /* add attributes above here, update the policy in soft-interface.c */ + + /** + * @__IFLA_BATADV_MAX: internal use + */ + __IFLA_BATADV_MAX, +}; + +#define IFLA_BATADV_MAX (__IFLA_BATADV_MAX - 1) + #endif /* _UAPI_LINUX_BATMAN_ADV_H_ */ diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 82e7ca886605..9c7b89689c97 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -1073,6 +1074,37 @@ static void batadv_softif_init_early(struct net_device *dev) dev->ethtool_ops = &batadv_ethtool_ops; } +/** + * batadv_softif_validate() - validate configuration of new batadv link + * @tb: IFLA_INFO_DATA netlink attributes + * @data: enum batadv_ifla_attrs attributes + * @extack: extended ACK report struct + * + * Return: 0 if successful or error otherwise. + */ +static int batadv_softif_validate(struct nlattr *tb[], struct nlattr *data[], + struct netlink_ext_ack *extack) +{ + return 0; +} + +/** + * batadv_softif_newlink() - pre-initialize and register new batadv link + * @src_net: the applicable net namespace + * @dev: network device to register + * @tb: IFLA_INFO_DATA netlink attributes + * @data: enum batadv_ifla_attrs attributes + * @extack: extended ACK report struct + * + * Return: 0 if successful or error otherwise. + */ +static int batadv_softif_newlink(struct net *src_net, struct net_device *dev, + struct nlattr *tb[], struct nlattr *data[], + struct netlink_ext_ack *extack) +{ + return register_netdevice(dev); +} + /** * batadv_softif_create() - Create and register soft interface * @net: the applicable net namespace @@ -1171,9 +1203,16 @@ bool batadv_softif_is_valid(const struct net_device *net_dev) return false; } +static const struct nla_policy batadv_ifla_policy[IFLA_BATADV_MAX + 1] = { +}; + struct rtnl_link_ops batadv_link_ops __read_mostly = { .kind = "batadv", .priv_size = sizeof(struct batadv_priv), .setup = batadv_softif_init_early, + .maxtype = IFLA_BATADV_MAX, + .policy = batadv_ifla_policy, + .validate = batadv_softif_validate, + .newlink = batadv_softif_newlink, .dellink = batadv_softif_destroy_netlink, }; From patchwork Fri Dec 4 15:46:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18235 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id D91E682193; Fri, 4 Dec 2020 16:55:22 +0100 (CET) Received: from simonwunderlich.de (packetmixer.de [IPv6:2001:4d88:2000:24::c0de]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 909D180DFD for ; Fri, 4 Dec 2020 16:55:07 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 86118174063; Fri, 4 Dec 2020 16:46:34 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 4/8] batman-adv: Allow selection of routing algorithm over rtnetlink Date: Fri, 4 Dec 2020 16:46:27 +0100 Message-Id: <20201204154631.21063-5-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gHSscaY49kPhT/lJg7JUYR3g7uuFXmA8dQPGgz/T5oI=; b=t3dgRxrwuZjOVJc0Q4w/WAe67IeSPMT1r/E5YQpc5DMRzEMhy4MYwrh6csyGScB4Oswly+ 9+jZDwwDNqHmyk5YD4icr+vN3llqn3aXn1YjkLDMO9Q+HYRVyOtht3/WIbkEupVoSeKyfu vxqF9+oNi3FYq/QcXeSO/1USoj97ELc= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097307; a=rsa-sha256; cv=none; b=0Ly2n0pBNjds9/36XRZwGyjf90JxoJLhqICdlGyiDLyRA9mLzFGX5ksJBGlgOnc3q+GdMB TlG3bz0s3JgyGsKZW+2REhASlPpQL3ZVNHsUrYOrSSfrOW4F5R3oWE68+yvcmtdqC3sc31 TX7+HlbNptMJQCjbyE2tAN6CsQWB7Ys= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 2001:4d88:2000:24::c0de as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: Z5TNWWFNXPZRVJADAQ3W5O5AKUCRV656 X-Message-ID-Hash: Z5TNWWFNXPZRVJADAQ3W5O5AKUCRV656 X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann A batadv net_device is associated to a B.A.T.M.A.N. routing algorithm. This algorithm has to be selected before the interface is initialized and cannot be changed after that. The only way to select this algorithm was a module parameter which specifies the default algorithm used during the creation of the net_device. This module parameter is writeable over /sys/module/batman_adv/parameters/routing_algo and thus allows switching of the routing algorithm: 1. change routing_algo parameter 2. create new batadv net_device But this is not race free because another process can be scheduled between 1 + 2 and in that time frame change the routing_algo parameter again. It is much cleaner to directly provide this information inside the rtnetlink's RTM_NEWLINK message. The two processes would be (in regards of the creation parameter of their batadv interfaces) be isolated. This also eases the integration of batadv devices inside tools like network-manager or systemd-networkd which are not expecting to operate on /sys before a new net_device is created. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- include/uapi/linux/batman_adv.h | 6 ++++++ net/batman-adv/bat_algo.c | 10 ++++++++-- net/batman-adv/bat_algo.h | 3 ++- net/batman-adv/soft-interface.c | 31 ++++++++++++++++++++++++++++--- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h index b05399d8a127..bdb317faa1dc 100644 --- a/include/uapi/linux/batman_adv.h +++ b/include/uapi/linux/batman_adv.h @@ -685,6 +685,12 @@ enum batadv_ifla_attrs { */ IFLA_BATADV_UNSPEC, + /** + * @IFLA_BATADV_ALGO_NAME: routing algorithm (name) which should be + * used by the newly registered batadv net_device. + */ + IFLA_BATADV_ALGO_NAME, + /* add attributes above here, update the policy in soft-interface.c */ /** diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c index 382fbe51fd34..500db94a6b50 100644 --- a/net/batman-adv/bat_algo.c +++ b/net/batman-adv/bat_algo.c @@ -34,7 +34,13 @@ void batadv_algo_init(void) INIT_HLIST_HEAD(&batadv_algo_list); } -static struct batadv_algo_ops *batadv_algo_get(char *name) +/** + * batadv_algo_get() - Search for algorithm with specific name + * @name: algorithm name to find + * + * Return: Pointer to batadv_algo_ops on success, NULL otherwise + */ +struct batadv_algo_ops *batadv_algo_get(const char *name) { struct batadv_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp; @@ -97,7 +103,7 @@ int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops) * * Return: 0 on success or negative error number in case of failure */ -int batadv_algo_select(struct batadv_priv *bat_priv, char *name) +int batadv_algo_select(struct batadv_priv *bat_priv, const char *name) { struct batadv_algo_ops *bat_algo_ops; diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h index 686a60bc9492..2ae140eac45d 100644 --- a/net/batman-adv/bat_algo.h +++ b/net/batman-adv/bat_algo.h @@ -18,8 +18,9 @@ extern char batadv_routing_algo[]; extern struct list_head batadv_hardif_list; void batadv_algo_init(void); +struct batadv_algo_ops *batadv_algo_get(const char *name); int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops); -int batadv_algo_select(struct batadv_priv *bat_priv, char *name); +int batadv_algo_select(struct batadv_priv *bat_priv, const char *name); int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); int batadv_algo_dump(struct sk_buff *msg, struct netlink_callback *cb); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 9c7b89689c97..8116631c11c5 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -846,9 +846,11 @@ static int batadv_softif_init_late(struct net_device *dev) batadv_nc_init_bat_priv(bat_priv); - ret = batadv_algo_select(bat_priv, batadv_routing_algo); - if (ret < 0) - goto free_bat_counters; + if (!bat_priv->algo_ops) { + ret = batadv_algo_select(bat_priv, batadv_routing_algo); + if (ret < 0) + goto free_bat_counters; + } ret = batadv_debugfs_add_meshif(dev); if (ret < 0) @@ -1085,6 +1087,17 @@ static void batadv_softif_init_early(struct net_device *dev) static int batadv_softif_validate(struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { + struct batadv_algo_ops *algo_ops; + + if (!data) + return 0; + + if (data[IFLA_BATADV_ALGO_NAME]) { + algo_ops = batadv_algo_get(nla_data(data[IFLA_BATADV_ALGO_NAME])); + if (!algo_ops) + return -EINVAL; + } + return 0; } @@ -1102,6 +1115,17 @@ static int batadv_softif_newlink(struct net *src_net, struct net_device *dev, struct nlattr *tb[], struct nlattr *data[], struct netlink_ext_ack *extack) { + struct batadv_priv *bat_priv = netdev_priv(dev); + const char *algo_name; + int err; + + if (data && data[IFLA_BATADV_ALGO_NAME]) { + algo_name = nla_data(data[IFLA_BATADV_ALGO_NAME]); + err = batadv_algo_select(bat_priv, algo_name); + if (err) + return -EINVAL; + } + return register_netdevice(dev); } @@ -1204,6 +1228,7 @@ bool batadv_softif_is_valid(const struct net_device *net_dev) } static const struct nla_policy batadv_ifla_policy[IFLA_BATADV_MAX + 1] = { + [IFLA_BATADV_ALGO_NAME] = { .type = NLA_NUL_STRING }, }; struct rtnl_link_ops batadv_link_ops __read_mostly = { From patchwork Fri Dec 4 15:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18232 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 1E6C181A84; Fri, 4 Dec 2020 16:55:11 +0100 (CET) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 8060C807A0 for ; Fri, 4 Dec 2020 16:55:07 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id E8EE4174064; Fri, 4 Dec 2020 16:46:34 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 5/8] batman-adv: Drop deprecated sysfs support Date: Fri, 4 Dec 2020 16:46:28 +0100 Message-Id: <20201204154631.21063-6-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L3aYqR9BRsKy6A5BS4LaUugJe1TcJD5jEMSq24gAgow=; b=yausJly1RVqxTLXjuVQVkQdTUTE3abwzwGqnCYlQUXrF/JILGvmc/6Ocw6l2IKFZTtXqjT GKQlE6vPJQzyusJR8XLJptF/bAdAU5wbV1mGGyQZcDCi2Etv1XcKtfUhaLonfJiiQCSeGJ qrdQB3/u2LywHwCcTXg+Q66SmDyjL6w= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097307; a=rsa-sha256; cv=none; b=hrMYHThJbsCgLlX1AQAboHnpQNU+TladQ1DMBUHER269MwZOJbflEhSb9mwqBb7G0QgKaK EDsXO+klwa4Uxv70wOwJYn9MEEDY1jmRlSb7e3+iFhpu0qDFaGf42cUCazx9wVfxXWOJNC 4ZCp9Z82v1p1qsf1zttPkCWx5v7ouHI= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 79.140.42.25 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: IXZO77FUBVN3PXKZK64G7U2HGWWAKLRP X-Message-ID-Hash: IXZO77FUBVN3PXKZK64G7U2HGWWAKLRP X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann The sysfs in batman-adv support was marked as deprecated by the commit 42cdd521487f ("batman-adv: ABI: Mark sysfs files as deprecated") and scheduled for removal in 2021. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- .../ABI/obsolete/sysfs-class-net-batman-adv | 32 - .../ABI/obsolete/sysfs-class-net-mesh | 110 -- MAINTAINERS | 2 - net/batman-adv/Kconfig | 11 - net/batman-adv/Makefile | 1 - net/batman-adv/bat_v.c | 9 - net/batman-adv/hard-interface.c | 16 +- net/batman-adv/hard-interface.h | 6 - net/batman-adv/soft-interface.c | 52 - net/batman-adv/soft-interface.h | 1 - net/batman-adv/sysfs.c | 1272 ----------------- net/batman-adv/sysfs.h | 93 -- net/batman-adv/types.h | 30 - 13 files changed, 1 insertion(+), 1634 deletions(-) delete mode 100644 Documentation/ABI/obsolete/sysfs-class-net-batman-adv delete mode 100644 Documentation/ABI/obsolete/sysfs-class-net-mesh delete mode 100644 net/batman-adv/sysfs.c delete mode 100644 net/batman-adv/sysfs.h diff --git a/Documentation/ABI/obsolete/sysfs-class-net-batman-adv b/Documentation/ABI/obsolete/sysfs-class-net-batman-adv deleted file mode 100644 index 5bdbc8d40256..000000000000 --- a/Documentation/ABI/obsolete/sysfs-class-net-batman-adv +++ /dev/null @@ -1,32 +0,0 @@ -This ABI is deprecated and will be removed after 2021. It is -replaced with the batadv generic netlink family. - -What: /sys/class/net//batman-adv/elp_interval -Date: Feb 2014 -Contact: Linus Lüssing -Description: - Defines the interval in milliseconds in which batman - emits probing packets for neighbor sensing (ELP). - -What: /sys/class/net//batman-adv/iface_status -Date: May 2010 -Contact: Marek Lindner -Description: - Indicates the status of as it is seen by batman. - -What: /sys/class/net//batman-adv/mesh_iface -Date: May 2010 -Contact: Marek Lindner -Description: - The /sys/class/net//batman-adv/mesh_iface file - displays the batman mesh interface this - currently is associated with. - -What: /sys/class/net//batman-adv/throughput_override -Date: Feb 2014 -Contact: Antonio Quartulli -description: - Defines the throughput value to be used by B.A.T.M.A.N. V - when estimating the link throughput using this interface. - If the value is set to 0 then batman-adv will try to - estimate the throughput by itself. diff --git a/Documentation/ABI/obsolete/sysfs-class-net-mesh b/Documentation/ABI/obsolete/sysfs-class-net-mesh deleted file mode 100644 index 04c1a2932507..000000000000 --- a/Documentation/ABI/obsolete/sysfs-class-net-mesh +++ /dev/null @@ -1,110 +0,0 @@ -This ABI is deprecated and will be removed after 2021. It is -replaced with the batadv generic netlink family. - -What: /sys/class/net//mesh/aggregated_ogms -Date: May 2010 -Contact: Marek Lindner -Description: - Indicates whether the batman protocol messages of the - mesh shall be aggregated or not. - -What: /sys/class/net//mesh//ap_isolation -Date: May 2011 -Contact: Antonio Quartulli -Description: - Indicates whether the data traffic going from a - wireless client to another wireless client will be - silently dropped. is empty when referring - to the untagged lan. - -What: /sys/class/net//mesh/bonding -Date: June 2010 -Contact: Simon Wunderlich -Description: - Indicates whether the data traffic going through the - mesh will be sent using multiple interfaces at the - same time (if available). - -What: /sys/class/net//mesh/bridge_loop_avoidance -Date: November 2011 -Contact: Simon Wunderlich -Description: - Indicates whether the bridge loop avoidance feature - is enabled. This feature detects and avoids loops - between the mesh and devices bridged with the soft - interface . - -What: /sys/class/net//mesh/fragmentation -Date: October 2010 -Contact: Andreas Langer -Description: - Indicates whether the data traffic going through the - mesh will be fragmented or silently discarded if the - packet size exceeds the outgoing interface MTU. - -What: /sys/class/net//mesh/gw_bandwidth -Date: October 2010 -Contact: Marek Lindner -Description: - Defines the bandwidth which is propagated by this - node if gw_mode was set to 'server'. - -What: /sys/class/net//mesh/gw_mode -Date: October 2010 -Contact: Marek Lindner -Description: - Defines the state of the gateway features. Can be - either 'off', 'client' or 'server'. - -What: /sys/class/net//mesh/gw_sel_class -Date: October 2010 -Contact: Marek Lindner -Description: - Defines the selection criteria this node will use - to choose a gateway if gw_mode was set to 'client'. - -What: /sys/class/net//mesh/hop_penalty -Date: Oct 2010 -Contact: Linus Lüssing -Description: - Defines the penalty which will be applied to an - originator message's tq-field on every hop. - -What: /sys/class/net//mesh/isolation_mark -Date: Nov 2013 -Contact: Antonio Quartulli -Description: - Defines the isolation mark (and its bitmask) which - is used to classify clients as "isolated" by the - Extended Isolation feature. - -What: /sys/class/net//mesh/multicast_mode -Date: Feb 2014 -Contact: Linus Lüssing -Description: - Indicates whether multicast optimizations are enabled - or disabled. If set to zero then all nodes in the - mesh are going to use classic flooding for any - multicast packet with no optimizations. - -What: /sys/class/net//mesh/network_coding -Date: Nov 2012 -Contact: Martin Hundeboll -Description: - Controls whether Network Coding (using some magic - to send fewer wifi packets but still the same - content) is enabled or not. - -What: /sys/class/net//mesh/orig_interval -Date: May 2010 -Contact: Marek Lindner -Description: - Defines the interval in milliseconds in which batman - sends its protocol messages. - -What: /sys/class/net//mesh/routing_algo -Date: Dec 2011 -Contact: Marek Lindner -Description: - Defines the routing procotol this mesh instance - uses to find the optimal paths through the mesh. diff --git a/MAINTAINERS b/MAINTAINERS index 3da6d8c154e4..c381ab27b05e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3120,8 +3120,6 @@ Q: https://patchwork.open-mesh.org/project/batman/list/ B: https://www.open-mesh.org/projects/batman-adv/issues C: irc://chat.freenode.net/batman T: git https://git.open-mesh.org/linux-merge.git -F: Documentation/ABI/obsolete/sysfs-class-net-batman-adv -F: Documentation/ABI/obsolete/sysfs-class-net-mesh F: Documentation/networking/batman-adv.rst F: include/uapi/linux/batadv_packet.h F: include/uapi/linux/batman_adv.h diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig index c762758a4649..84bbf72b764e 100644 --- a/net/batman-adv/Kconfig +++ b/net/batman-adv/Kconfig @@ -97,17 +97,6 @@ config BATMAN_ADV_DEBUG buffer. The output is controlled via the batadv netdev specific log_level setting. -config BATMAN_ADV_SYSFS - bool "batman-adv sysfs entries" - depends on BATMAN_ADV - help - Say Y here if you want to enable batman-adv device configuration and - status interface through sysfs attributes. It is replaced by the - batadv generic netlink family but still used by various userspace - tools and scripts. - - If unsure, say Y. - config BATMAN_ADV_TRACING bool "B.A.T.M.A.N. tracing support" depends on BATMAN_ADV diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile index daa49af7ff40..306615caba6c 100644 --- a/net/batman-adv/Makefile +++ b/net/batman-adv/Makefile @@ -28,7 +28,6 @@ batman-adv-y += originator.o batman-adv-y += routing.o batman-adv-y += send.o batman-adv-y += soft-interface.o -batman-adv-$(CONFIG_BATMAN_ADV_SYSFS) += sysfs.o batman-adv-$(CONFIG_BATMAN_ADV_TRACING) += trace.o batman-adv-y += tp_meter.o batman-adv-y += translation-table.o diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index e91d2c0720c4..ee7a95aa7bd4 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -686,13 +685,6 @@ static ssize_t batadv_v_store_sel_class(struct batadv_priv *bat_priv, return count; } -static ssize_t batadv_v_show_sel_class(struct batadv_priv *bat_priv, char *buff) -{ - u32 class = atomic_read(&bat_priv->gw.sel_class); - - return sprintf(buff, "%u.%u MBit\n", class / 10, class % 10); -} - /** * batadv_v_gw_throughput_get() - retrieve the GW-bandwidth for a given GW * @gw_node: the GW to retrieve the metric for @@ -1061,7 +1053,6 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .gw = { .init_sel_class = batadv_v_init_sel_class, .store_sel_class = batadv_v_store_sel_class, - .show_sel_class = batadv_v_show_sel_class, .get_best_gw_node = batadv_v_gw_get_best_gw_node, .is_eligible = batadv_v_gw_is_eligible, #ifdef CONFIG_BATMAN_ADV_DEBUGFS diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 3838a6165c5e..6f827a6be4ed 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -39,7 +39,6 @@ #include "originator.h" #include "send.h" #include "soft-interface.h" -#include "sysfs.h" #include "translation-table.h" /** @@ -889,13 +888,9 @@ void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, batadv_hardif_recalc_extra_skbroom(hard_iface->soft_iface); /* nobody uses this interface anymore */ - if (batadv_hardif_cnt(hard_iface->soft_iface) <= 1) { + if (batadv_hardif_cnt(hard_iface->soft_iface) <= 1) batadv_gw_check_client_stop(bat_priv); - if (autodel == BATADV_IF_CLEANUP_AUTO) - batadv_softif_destroy_sysfs(hard_iface->soft_iface); - } - hard_iface->soft_iface = NULL; batadv_hardif_put(hard_iface); @@ -908,7 +903,6 @@ static struct batadv_hard_iface * batadv_hardif_add_interface(struct net_device *net_dev) { struct batadv_hard_iface *hard_iface; - int ret; ASSERT_RTNL(); @@ -921,10 +915,6 @@ batadv_hardif_add_interface(struct net_device *net_dev) if (!hard_iface) goto release_dev; - ret = batadv_sysfs_add_hardif(&hard_iface->hardif_obj, net_dev); - if (ret) - goto free_if; - hard_iface->net_dev = net_dev; hard_iface->soft_iface = NULL; hard_iface->if_status = BATADV_IF_NOT_IN_USE; @@ -954,8 +944,6 @@ batadv_hardif_add_interface(struct net_device *net_dev) return hard_iface; -free_if: - kfree(hard_iface); release_dev: dev_put(net_dev); out: @@ -976,7 +964,6 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; batadv_debugfs_del_hardif(hard_iface); - batadv_sysfs_del_hardif(&hard_iface->hardif_obj); batadv_hardif_put(hard_iface); } @@ -994,7 +981,6 @@ static int batadv_hard_if_event_softif(unsigned long event, switch (event) { case NETDEV_REGISTER: - batadv_sysfs_add_meshif(net_dev); bat_priv = netdev_priv(net_dev); batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS); break; diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h index b1855d9d0b06..1ee45b615399 100644 --- a/net/batman-adv/hard-interface.h +++ b/net/batman-adv/hard-interface.h @@ -42,12 +42,6 @@ enum batadv_hard_if_state { /** @BATADV_IF_TO_BE_ACTIVATED: interface is getting activated */ BATADV_IF_TO_BE_ACTIVATED, - - /** - * @BATADV_IF_I_WANT_YOU: interface is queued up (using sysfs) for being - * added as slave interface of a batman-adv soft interface - */ - BATADV_IF_I_WANT_YOU, }; /** diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 8116631c11c5..072b76259bf7 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -52,7 +51,6 @@ #include "network-coding.h" #include "originator.h" #include "send.h" -#include "sysfs.h" #include "translation-table.h" /** @@ -575,7 +573,6 @@ struct batadv_softif_vlan *batadv_softif_vlan_get(struct batadv_priv *bat_priv, int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) { struct batadv_softif_vlan *vlan; - int err; spin_lock_bh(&bat_priv->softif_vlan_list_lock); @@ -602,19 +599,6 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); spin_unlock_bh(&bat_priv->softif_vlan_list_lock); - /* batadv_sysfs_add_vlan cannot be in the spinlock section due to the - * sleeping behavior of the sysfs functions and the fs_reclaim lock - */ - err = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan); - if (err) { - /* ref for the function */ - batadv_softif_vlan_put(vlan); - - /* ref for the list */ - batadv_softif_vlan_put(vlan); - return err; - } - /* add a new TT local entry. This one will be marked with the NOPURGE * flag */ @@ -642,7 +626,6 @@ static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv, batadv_tt_local_remove(bat_priv, bat_priv->soft_iface->dev_addr, vlan->vid, "vlan interface destroyed", false); - batadv_sysfs_del_vlan(bat_priv, vlan); batadv_softif_vlan_put(vlan); } @@ -662,7 +645,6 @@ static int batadv_interface_add_vid(struct net_device *dev, __be16 proto, { struct batadv_priv *bat_priv = netdev_priv(dev); struct batadv_softif_vlan *vlan; - int ret; /* only 802.1Q vlans are supported. * batman-adv does not know how to handle other types @@ -682,17 +664,6 @@ static int batadv_interface_add_vid(struct net_device *dev, __be16 proto, if (!vlan) return batadv_softif_create_vlan(bat_priv, vid); - /* recreate the sysfs object if it was already destroyed (and it should - * be since we received a kill_vid() for this vlan - */ - if (!vlan->kobj) { - ret = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan); - if (ret) { - batadv_softif_vlan_put(vlan); - return ret; - } - } - /* add a new TT local entry. This one will be marked with the NOPURGE * flag. This must be added again, even if the vlan object already * exists, because the entry was deleted by kill_vid() @@ -1161,28 +1132,6 @@ struct net_device *batadv_softif_create(struct net *net, const char *name) return soft_iface; } -/** - * batadv_softif_destroy_sysfs() - deletion of batadv_soft_interface via sysfs - * @soft_iface: the to-be-removed batman-adv interface - */ -void batadv_softif_destroy_sysfs(struct net_device *soft_iface) -{ - struct batadv_priv *bat_priv = netdev_priv(soft_iface); - struct batadv_softif_vlan *vlan; - - ASSERT_RTNL(); - - /* destroy the "untagged" VLAN */ - vlan = batadv_softif_vlan_get(bat_priv, BATADV_NO_FLAGS); - if (vlan) { - batadv_softif_destroy_vlan(bat_priv, vlan); - batadv_softif_vlan_put(vlan); - } - - batadv_sysfs_del_meshif(soft_iface); - unregister_netdevice(soft_iface); -} - /** * batadv_softif_destroy_netlink() - deletion of batadv_soft_interface via * netlink @@ -1209,7 +1158,6 @@ static void batadv_softif_destroy_netlink(struct net_device *soft_iface, batadv_softif_vlan_put(vlan); } - batadv_sysfs_del_meshif(soft_iface); unregister_netdevice_queue(soft_iface, head); } diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h index 534e08d6ad91..74716d9ca4f6 100644 --- a/net/batman-adv/soft-interface.h +++ b/net/batman-adv/soft-interface.h @@ -20,7 +20,6 @@ void batadv_interface_rx(struct net_device *soft_iface, struct sk_buff *skb, int hdr_size, struct batadv_orig_node *orig_node); struct net_device *batadv_softif_create(struct net *net, const char *name); -void batadv_softif_destroy_sysfs(struct net_device *soft_iface); bool batadv_softif_is_valid(const struct net_device *net_dev); extern struct rtnl_link_ops batadv_link_ops; int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid); diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c deleted file mode 100644 index 0f962dcd239e..000000000000 --- a/net/batman-adv/sysfs.c +++ /dev/null @@ -1,1272 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2010-2020 B.A.T.M.A.N. contributors: - * - * Marek Lindner - */ - -#include "sysfs.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bridge_loop_avoidance.h" -#include "distributed-arp-table.h" -#include "gateway_client.h" -#include "gateway_common.h" -#include "hard-interface.h" -#include "log.h" -#include "netlink.h" -#include "network-coding.h" -#include "soft-interface.h" - -/** - * batadv_sysfs_deprecated() - Log use of deprecated batadv sysfs access - * @attr: attribute which was accessed - */ -static void batadv_sysfs_deprecated(struct attribute *attr) -{ - pr_warn_ratelimited(DEPRECATED "%s (pid %d) Use of sysfs file \"%s\".\nUse batadv genl family instead", - current->comm, task_pid_nr(current), attr->name); -} - -static struct net_device *batadv_kobj_to_netdev(struct kobject *obj) -{ - struct device *dev = container_of(obj->parent, struct device, kobj); - - return to_net_dev(dev); -} - -static struct batadv_priv *batadv_kobj_to_batpriv(struct kobject *obj) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(obj); - - return netdev_priv(net_dev); -} - -/** - * batadv_vlan_kobj_to_batpriv() - convert a vlan kobj in the associated batpriv - * @obj: kobject to covert - * - * Return: the associated batadv_priv struct. - */ -static struct batadv_priv *batadv_vlan_kobj_to_batpriv(struct kobject *obj) -{ - /* VLAN specific attributes are located in the root sysfs folder if they - * refer to the untagged VLAN.. - */ - if (!strcmp(BATADV_SYSFS_IF_MESH_SUBDIR, obj->name)) - return batadv_kobj_to_batpriv(obj); - - /* ..while the attributes for the tagged vlans are located in - * the in the corresponding "vlan%VID" subfolder - */ - return batadv_kobj_to_batpriv(obj->parent); -} - -/** - * batadv_kobj_to_vlan() - convert a kobj in the associated softif_vlan struct - * @bat_priv: the bat priv with all the soft interface information - * @obj: kobject to covert - * - * Return: the associated softif_vlan struct if found, NULL otherwise. - */ -static struct batadv_softif_vlan * -batadv_kobj_to_vlan(struct batadv_priv *bat_priv, struct kobject *obj) -{ - struct batadv_softif_vlan *vlan_tmp, *vlan = NULL; - - rcu_read_lock(); - hlist_for_each_entry_rcu(vlan_tmp, &bat_priv->softif_vlan_list, list) { - if (vlan_tmp->kobj != obj) - continue; - - if (!kref_get_unless_zero(&vlan_tmp->refcount)) - continue; - - vlan = vlan_tmp; - break; - } - rcu_read_unlock(); - - return vlan; -} - -/* Use this, if you have customized show and store functions for vlan attrs */ -#define BATADV_ATTR_VLAN(_name, _mode, _show, _store) \ -struct batadv_attribute batadv_attr_vlan_##_name = { \ - .attr = {.name = __stringify(_name), \ - .mode = _mode }, \ - .show = _show, \ - .store = _store, \ -} - -/* Use this, if you have customized show and store functions */ -#define BATADV_ATTR(_name, _mode, _show, _store) \ -struct batadv_attribute batadv_attr_##_name = { \ - .attr = {.name = __stringify(_name), \ - .mode = _mode }, \ - .show = _show, \ - .store = _store, \ -} - -#define BATADV_ATTR_SIF_STORE_BOOL(_name, _post_func) \ -ssize_t batadv_store_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff, \ - size_t count) \ -{ \ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ - struct batadv_priv *bat_priv = netdev_priv(net_dev); \ - ssize_t length; \ - \ - batadv_sysfs_deprecated(attr); \ - length = __batadv_store_bool_attr(buff, count, _post_func, attr,\ - &bat_priv->_name, net_dev); \ - \ - batadv_netlink_notify_mesh(bat_priv); \ - \ - return length; \ -} - -#define BATADV_ATTR_SIF_SHOW_BOOL(_name) \ -ssize_t batadv_show_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff) \ -{ \ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \ - \ - batadv_sysfs_deprecated(attr); \ - return sprintf(buff, "%s\n", \ - atomic_read(&bat_priv->_name) == 0 ? \ - "disabled" : "enabled"); \ -} \ - -/* Use this, if you are going to turn a [name] in the soft-interface - * (bat_priv) on or off - */ -#define BATADV_ATTR_SIF_BOOL(_name, _mode, _post_func) \ - static BATADV_ATTR_SIF_STORE_BOOL(_name, _post_func) \ - static BATADV_ATTR_SIF_SHOW_BOOL(_name) \ - static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ - batadv_store_##_name) - -#define BATADV_ATTR_SIF_STORE_UINT(_name, _var, _min, _max, _post_func) \ -ssize_t batadv_store_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff, \ - size_t count) \ -{ \ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ - struct batadv_priv *bat_priv = netdev_priv(net_dev); \ - ssize_t length; \ - \ - batadv_sysfs_deprecated(attr); \ - length = __batadv_store_uint_attr(buff, count, _min, _max, \ - _post_func, attr, \ - &bat_priv->_var, net_dev, \ - NULL); \ - \ - batadv_netlink_notify_mesh(bat_priv); \ - \ - return length; \ -} - -#define BATADV_ATTR_SIF_SHOW_UINT(_name, _var) \ -ssize_t batadv_show_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff) \ -{ \ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); \ - \ - batadv_sysfs_deprecated(attr); \ - return sprintf(buff, "%i\n", atomic_read(&bat_priv->_var)); \ -} \ - -/* Use this, if you are going to set [name] in the soft-interface - * (bat_priv) to an unsigned integer value - */ -#define BATADV_ATTR_SIF_UINT(_name, _var, _mode, _min, _max, _post_func)\ - static BATADV_ATTR_SIF_STORE_UINT(_name, _var, _min, _max, _post_func)\ - static BATADV_ATTR_SIF_SHOW_UINT(_name, _var) \ - static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ - batadv_store_##_name) - -#define BATADV_ATTR_VLAN_STORE_BOOL(_name, _post_func) \ -ssize_t batadv_store_vlan_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff, \ - size_t count) \ -{ \ - struct batadv_priv *bat_priv = batadv_vlan_kobj_to_batpriv(kobj);\ - struct batadv_softif_vlan *vlan = batadv_kobj_to_vlan(bat_priv, \ - kobj); \ - size_t res = __batadv_store_bool_attr(buff, count, _post_func, \ - attr, &vlan->_name, \ - bat_priv->soft_iface); \ - \ - batadv_sysfs_deprecated(attr); \ - if (vlan->vid) \ - batadv_netlink_notify_vlan(bat_priv, vlan); \ - else \ - batadv_netlink_notify_mesh(bat_priv); \ - \ - batadv_softif_vlan_put(vlan); \ - return res; \ -} - -#define BATADV_ATTR_VLAN_SHOW_BOOL(_name) \ -ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff) \ -{ \ - struct batadv_priv *bat_priv = batadv_vlan_kobj_to_batpriv(kobj);\ - struct batadv_softif_vlan *vlan = batadv_kobj_to_vlan(bat_priv, \ - kobj); \ - size_t res = sprintf(buff, "%s\n", \ - atomic_read(&vlan->_name) == 0 ? \ - "disabled" : "enabled"); \ - \ - batadv_sysfs_deprecated(attr); \ - batadv_softif_vlan_put(vlan); \ - return res; \ -} - -/* Use this, if you are going to turn a [name] in the vlan struct on or off */ -#define BATADV_ATTR_VLAN_BOOL(_name, _mode, _post_func) \ - static BATADV_ATTR_VLAN_STORE_BOOL(_name, _post_func) \ - static BATADV_ATTR_VLAN_SHOW_BOOL(_name) \ - static BATADV_ATTR_VLAN(_name, _mode, batadv_show_vlan_##_name, \ - batadv_store_vlan_##_name) - -#define BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, _max, _post_func) \ -ssize_t batadv_store_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff, \ - size_t count) \ -{ \ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ - struct batadv_hard_iface *hard_iface; \ - struct batadv_priv *bat_priv; \ - ssize_t length; \ - \ - batadv_sysfs_deprecated(attr); \ - hard_iface = batadv_hardif_get_by_netdev(net_dev); \ - if (!hard_iface) \ - return 0; \ - \ - length = __batadv_store_uint_attr(buff, count, _min, _max, \ - _post_func, attr, \ - &hard_iface->_var, \ - hard_iface->soft_iface, \ - net_dev); \ - \ - if (hard_iface->soft_iface) { \ - bat_priv = netdev_priv(hard_iface->soft_iface); \ - batadv_netlink_notify_hardif(bat_priv, hard_iface); \ - } \ - \ - batadv_hardif_put(hard_iface); \ - return length; \ -} - -#define BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \ -ssize_t batadv_show_##_name(struct kobject *kobj, \ - struct attribute *attr, char *buff) \ -{ \ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); \ - struct batadv_hard_iface *hard_iface; \ - ssize_t length; \ - \ - batadv_sysfs_deprecated(attr); \ - hard_iface = batadv_hardif_get_by_netdev(net_dev); \ - if (!hard_iface) \ - return 0; \ - \ - length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_var)); \ - \ - batadv_hardif_put(hard_iface); \ - return length; \ -} - -/* Use this, if you are going to set [name] in hard_iface to an - * unsigned integer value - */ -#define BATADV_ATTR_HIF_UINT(_name, _var, _mode, _min, _max, _post_func)\ - static BATADV_ATTR_HIF_STORE_UINT(_name, _var, _min, \ - _max, _post_func) \ - static BATADV_ATTR_HIF_SHOW_UINT(_name, _var) \ - static BATADV_ATTR(_name, _mode, batadv_show_##_name, \ - batadv_store_##_name) - -static int batadv_store_bool_attr(char *buff, size_t count, - struct net_device *net_dev, - const char *attr_name, atomic_t *attr, - bool *changed) -{ - int enabled = -1; - - *changed = false; - - if (buff[count - 1] == '\n') - buff[count - 1] = '\0'; - - if ((strncmp(buff, "1", 2) == 0) || - (strncmp(buff, "enable", 7) == 0) || - (strncmp(buff, "enabled", 8) == 0)) - enabled = 1; - - if ((strncmp(buff, "0", 2) == 0) || - (strncmp(buff, "disable", 8) == 0) || - (strncmp(buff, "disabled", 9) == 0)) - enabled = 0; - - if (enabled < 0) { - batadv_info(net_dev, "%s: Invalid parameter received: %s\n", - attr_name, buff); - return -EINVAL; - } - - if (atomic_read(attr) == enabled) - return count; - - batadv_info(net_dev, "%s: Changing from: %s to: %s\n", attr_name, - atomic_read(attr) == 1 ? "enabled" : "disabled", - enabled == 1 ? "enabled" : "disabled"); - - *changed = true; - - atomic_set(attr, (unsigned int)enabled); - return count; -} - -static inline ssize_t -__batadv_store_bool_attr(char *buff, size_t count, - void (*post_func)(struct net_device *), - struct attribute *attr, - atomic_t *attr_store, struct net_device *net_dev) -{ - bool changed; - int ret; - - ret = batadv_store_bool_attr(buff, count, net_dev, attr->name, - attr_store, &changed); - if (post_func && changed) - post_func(net_dev); - - return ret; -} - -static int batadv_store_uint_attr(const char *buff, size_t count, - struct net_device *net_dev, - struct net_device *slave_dev, - const char *attr_name, - unsigned int min, unsigned int max, - atomic_t *attr) -{ - char ifname[IFNAMSIZ + 3] = ""; - unsigned long uint_val; - int ret; - - ret = kstrtoul(buff, 10, &uint_val); - if (ret) { - batadv_info(net_dev, "%s: Invalid parameter received: %s\n", - attr_name, buff); - return -EINVAL; - } - - if (uint_val < min) { - batadv_info(net_dev, "%s: Value is too small: %lu min: %u\n", - attr_name, uint_val, min); - return -EINVAL; - } - - if (uint_val > max) { - batadv_info(net_dev, "%s: Value is too big: %lu max: %u\n", - attr_name, uint_val, max); - return -EINVAL; - } - - if (atomic_read(attr) == uint_val) - return count; - - if (slave_dev) - snprintf(ifname, sizeof(ifname), "%s: ", slave_dev->name); - - batadv_info(net_dev, "%s: %sChanging from: %i to: %lu\n", - attr_name, ifname, atomic_read(attr), uint_val); - - atomic_set(attr, uint_val); - return count; -} - -static ssize_t __batadv_store_uint_attr(const char *buff, size_t count, - int min, int max, - void (*post_func)(struct net_device *), - const struct attribute *attr, - atomic_t *attr_store, - struct net_device *net_dev, - struct net_device *slave_dev) -{ - int ret; - - ret = batadv_store_uint_attr(buff, count, net_dev, slave_dev, - attr->name, min, max, attr_store); - if (post_func && ret) - post_func(net_dev); - - return ret; -} - -static ssize_t batadv_show_bat_algo(struct kobject *kobj, - struct attribute *attr, char *buff) -{ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); - - batadv_sysfs_deprecated(attr); - return sprintf(buff, "%s\n", bat_priv->algo_ops->name); -} - -static void batadv_post_gw_reselect(struct net_device *net_dev) -{ - struct batadv_priv *bat_priv = netdev_priv(net_dev); - - batadv_gw_reselect(bat_priv); -} - -static ssize_t batadv_show_gw_mode(struct kobject *kobj, struct attribute *attr, - char *buff) -{ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); - int bytes_written; - - batadv_sysfs_deprecated(attr); - - /* GW mode is not available if the routing algorithm in use does not - * implement the GW API - */ - if (!bat_priv->algo_ops->gw.get_best_gw_node || - !bat_priv->algo_ops->gw.is_eligible) - return -ENOENT; - - switch (atomic_read(&bat_priv->gw.mode)) { - case BATADV_GW_MODE_CLIENT: - bytes_written = sprintf(buff, "%s\n", - BATADV_GW_MODE_CLIENT_NAME); - break; - case BATADV_GW_MODE_SERVER: - bytes_written = sprintf(buff, "%s\n", - BATADV_GW_MODE_SERVER_NAME); - break; - default: - bytes_written = sprintf(buff, "%s\n", - BATADV_GW_MODE_OFF_NAME); - break; - } - - return bytes_written; -} - -static ssize_t batadv_store_gw_mode(struct kobject *kobj, - struct attribute *attr, char *buff, - size_t count) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - struct batadv_priv *bat_priv = netdev_priv(net_dev); - char *curr_gw_mode_str; - int gw_mode_tmp = -1; - - batadv_sysfs_deprecated(attr); - - /* toggling GW mode is allowed only if the routing algorithm in use - * provides the GW API - */ - if (!bat_priv->algo_ops->gw.get_best_gw_node || - !bat_priv->algo_ops->gw.is_eligible) - return -EINVAL; - - if (buff[count - 1] == '\n') - buff[count - 1] = '\0'; - - if (strncmp(buff, BATADV_GW_MODE_OFF_NAME, - strlen(BATADV_GW_MODE_OFF_NAME)) == 0) - gw_mode_tmp = BATADV_GW_MODE_OFF; - - if (strncmp(buff, BATADV_GW_MODE_CLIENT_NAME, - strlen(BATADV_GW_MODE_CLIENT_NAME)) == 0) - gw_mode_tmp = BATADV_GW_MODE_CLIENT; - - if (strncmp(buff, BATADV_GW_MODE_SERVER_NAME, - strlen(BATADV_GW_MODE_SERVER_NAME)) == 0) - gw_mode_tmp = BATADV_GW_MODE_SERVER; - - if (gw_mode_tmp < 0) { - batadv_info(net_dev, - "Invalid parameter for 'gw mode' setting received: %s\n", - buff); - return -EINVAL; - } - - if (atomic_read(&bat_priv->gw.mode) == gw_mode_tmp) - return count; - - switch (atomic_read(&bat_priv->gw.mode)) { - case BATADV_GW_MODE_CLIENT: - curr_gw_mode_str = BATADV_GW_MODE_CLIENT_NAME; - break; - case BATADV_GW_MODE_SERVER: - curr_gw_mode_str = BATADV_GW_MODE_SERVER_NAME; - break; - default: - curr_gw_mode_str = BATADV_GW_MODE_OFF_NAME; - break; - } - - batadv_info(net_dev, "Changing gw mode from: %s to: %s\n", - curr_gw_mode_str, buff); - - /* Invoking batadv_gw_reselect() is not enough to really de-select the - * current GW. It will only instruct the gateway client code to perform - * a re-election the next time that this is needed. - * - * When gw client mode is being switched off the current GW must be - * de-selected explicitly otherwise no GW_ADD uevent is thrown on - * client mode re-activation. This is operation is performed in - * batadv_gw_check_client_stop(). - */ - batadv_gw_reselect(bat_priv); - /* always call batadv_gw_check_client_stop() before changing the gateway - * state - */ - batadv_gw_check_client_stop(bat_priv); - atomic_set(&bat_priv->gw.mode, (unsigned int)gw_mode_tmp); - batadv_gw_tvlv_container_update(bat_priv); - - batadv_netlink_notify_mesh(bat_priv); - - return count; -} - -static ssize_t batadv_show_gw_sel_class(struct kobject *kobj, - struct attribute *attr, char *buff) -{ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); - - batadv_sysfs_deprecated(attr); - - /* GW selection class is not available if the routing algorithm in use - * does not implement the GW API - */ - if (!bat_priv->algo_ops->gw.get_best_gw_node || - !bat_priv->algo_ops->gw.is_eligible) - return -ENOENT; - - if (bat_priv->algo_ops->gw.show_sel_class) - return bat_priv->algo_ops->gw.show_sel_class(bat_priv, buff); - - return sprintf(buff, "%i\n", atomic_read(&bat_priv->gw.sel_class)); -} - -static ssize_t batadv_store_gw_sel_class(struct kobject *kobj, - struct attribute *attr, char *buff, - size_t count) -{ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); - ssize_t length; - - batadv_sysfs_deprecated(attr); - - /* setting the GW selection class is allowed only if the routing - * algorithm in use implements the GW API - */ - if (!bat_priv->algo_ops->gw.get_best_gw_node || - !bat_priv->algo_ops->gw.is_eligible) - return -EINVAL; - - if (buff[count - 1] == '\n') - buff[count - 1] = '\0'; - - if (bat_priv->algo_ops->gw.store_sel_class) - return bat_priv->algo_ops->gw.store_sel_class(bat_priv, buff, - count); - - length = __batadv_store_uint_attr(buff, count, 1, BATADV_TQ_MAX_VALUE, - batadv_post_gw_reselect, attr, - &bat_priv->gw.sel_class, - bat_priv->soft_iface, NULL); - - batadv_netlink_notify_mesh(bat_priv); - - return length; -} - -static ssize_t batadv_show_gw_bwidth(struct kobject *kobj, - struct attribute *attr, char *buff) -{ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); - u32 down, up; - - batadv_sysfs_deprecated(attr); - - down = atomic_read(&bat_priv->gw.bandwidth_down); - up = atomic_read(&bat_priv->gw.bandwidth_up); - - return sprintf(buff, "%u.%u/%u.%u MBit\n", down / 10, - down % 10, up / 10, up % 10); -} - -static ssize_t batadv_store_gw_bwidth(struct kobject *kobj, - struct attribute *attr, char *buff, - size_t count) -{ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - ssize_t length; - - batadv_sysfs_deprecated(attr); - - if (buff[count - 1] == '\n') - buff[count - 1] = '\0'; - - length = batadv_gw_bandwidth_set(net_dev, buff, count); - - batadv_netlink_notify_mesh(bat_priv); - - return length; -} - -/** - * batadv_show_isolation_mark() - print the current isolation mark/mask - * @kobj: kobject representing the private mesh sysfs directory - * @attr: the batman-adv attribute the user is interacting with - * @buff: the buffer that will contain the data to send back to the user - * - * Return: the number of bytes written into 'buff' on success or a negative - * error code in case of failure - */ -static ssize_t batadv_show_isolation_mark(struct kobject *kobj, - struct attribute *attr, char *buff) -{ - struct batadv_priv *bat_priv = batadv_kobj_to_batpriv(kobj); - - batadv_sysfs_deprecated(attr); - return sprintf(buff, "%#.8x/%#.8x\n", bat_priv->isolation_mark, - bat_priv->isolation_mark_mask); -} - -/** - * batadv_store_isolation_mark() - parse and store the isolation mark/mask - * entered by the user - * @kobj: kobject representing the private mesh sysfs directory - * @attr: the batman-adv attribute the user is interacting with - * @buff: the buffer containing the user data - * @count: number of bytes in the buffer - * - * Return: 'count' on success or a negative error code in case of failure - */ -static ssize_t batadv_store_isolation_mark(struct kobject *kobj, - struct attribute *attr, char *buff, - size_t count) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - struct batadv_priv *bat_priv = netdev_priv(net_dev); - u32 mark, mask; - char *mask_ptr; - - batadv_sysfs_deprecated(attr); - - /* parse the mask if it has been specified, otherwise assume the mask is - * the biggest possible - */ - mask = 0xFFFFFFFF; - mask_ptr = strchr(buff, '/'); - if (mask_ptr) { - *mask_ptr = '\0'; - mask_ptr++; - - /* the mask must be entered in hex base as it is going to be a - * bitmask and not a prefix length - */ - if (kstrtou32(mask_ptr, 16, &mask) < 0) - return -EINVAL; - } - - /* the mark can be entered in any base */ - if (kstrtou32(buff, 0, &mark) < 0) - return -EINVAL; - - bat_priv->isolation_mark_mask = mask; - /* erase bits not covered by the mask */ - bat_priv->isolation_mark = mark & bat_priv->isolation_mark_mask; - - batadv_info(net_dev, - "New skb mark for extended isolation: %#.8x/%#.8x\n", - bat_priv->isolation_mark, bat_priv->isolation_mark_mask); - - batadv_netlink_notify_mesh(bat_priv); - - return count; -} - -BATADV_ATTR_SIF_BOOL(aggregated_ogms, 0644, NULL); -BATADV_ATTR_SIF_BOOL(bonding, 0644, NULL); -#ifdef CONFIG_BATMAN_ADV_BLA -BATADV_ATTR_SIF_BOOL(bridge_loop_avoidance, 0644, batadv_bla_status_update); -#endif -#ifdef CONFIG_BATMAN_ADV_DAT -BATADV_ATTR_SIF_BOOL(distributed_arp_table, 0644, batadv_dat_status_update); -#endif -BATADV_ATTR_SIF_BOOL(fragmentation, 0644, batadv_update_min_mtu); -static BATADV_ATTR(routing_algo, 0444, batadv_show_bat_algo, NULL); -static BATADV_ATTR(gw_mode, 0644, batadv_show_gw_mode, batadv_store_gw_mode); -BATADV_ATTR_SIF_UINT(orig_interval, orig_interval, 0644, 2 * BATADV_JITTER, - INT_MAX, NULL); -BATADV_ATTR_SIF_UINT(hop_penalty, hop_penalty, 0644, 0, BATADV_TQ_MAX_VALUE, - NULL); -static BATADV_ATTR(gw_sel_class, 0644, batadv_show_gw_sel_class, - batadv_store_gw_sel_class); -static BATADV_ATTR(gw_bandwidth, 0644, batadv_show_gw_bwidth, - batadv_store_gw_bwidth); -#ifdef CONFIG_BATMAN_ADV_MCAST -BATADV_ATTR_SIF_BOOL(multicast_mode, 0644, NULL); -#endif -#ifdef CONFIG_BATMAN_ADV_DEBUG -BATADV_ATTR_SIF_UINT(log_level, log_level, 0644, 0, BATADV_DBG_ALL, NULL); -#endif -#ifdef CONFIG_BATMAN_ADV_NC -BATADV_ATTR_SIF_BOOL(network_coding, 0644, batadv_nc_status_update); -#endif -static BATADV_ATTR(isolation_mark, 0644, batadv_show_isolation_mark, - batadv_store_isolation_mark); - -static struct batadv_attribute *batadv_mesh_attrs[] = { - &batadv_attr_aggregated_ogms, - &batadv_attr_bonding, -#ifdef CONFIG_BATMAN_ADV_BLA - &batadv_attr_bridge_loop_avoidance, -#endif -#ifdef CONFIG_BATMAN_ADV_DAT - &batadv_attr_distributed_arp_table, -#endif -#ifdef CONFIG_BATMAN_ADV_MCAST - &batadv_attr_multicast_mode, -#endif - &batadv_attr_fragmentation, - &batadv_attr_routing_algo, - &batadv_attr_gw_mode, - &batadv_attr_orig_interval, - &batadv_attr_hop_penalty, - &batadv_attr_gw_sel_class, - &batadv_attr_gw_bandwidth, -#ifdef CONFIG_BATMAN_ADV_DEBUG - &batadv_attr_log_level, -#endif -#ifdef CONFIG_BATMAN_ADV_NC - &batadv_attr_network_coding, -#endif - &batadv_attr_isolation_mark, - NULL, -}; - -BATADV_ATTR_VLAN_BOOL(ap_isolation, 0644, NULL); - -/* array of vlan specific sysfs attributes */ -static struct batadv_attribute *batadv_vlan_attrs[] = { - &batadv_attr_vlan_ap_isolation, - NULL, -}; - -/** - * batadv_sysfs_add_meshif() - Add soft interface specific sysfs entries - * @dev: netdev struct of the soft interface - * - * Return: 0 on success or negative error number in case of failure - */ -int batadv_sysfs_add_meshif(struct net_device *dev) -{ - struct kobject *batif_kobject = &dev->dev.kobj; - struct batadv_priv *bat_priv = netdev_priv(dev); - struct batadv_attribute **bat_attr; - int err; - - bat_priv->mesh_obj = kobject_create_and_add(BATADV_SYSFS_IF_MESH_SUBDIR, - batif_kobject); - if (!bat_priv->mesh_obj) { - batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, - BATADV_SYSFS_IF_MESH_SUBDIR); - goto out; - } - - for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr) { - err = sysfs_create_file(bat_priv->mesh_obj, - &((*bat_attr)->attr)); - if (err) { - batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n", - dev->name, BATADV_SYSFS_IF_MESH_SUBDIR, - ((*bat_attr)->attr).name); - goto rem_attr; - } - } - - return 0; - -rem_attr: - for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr) - sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); - - kobject_uevent(bat_priv->mesh_obj, KOBJ_REMOVE); - kobject_del(bat_priv->mesh_obj); - kobject_put(bat_priv->mesh_obj); - bat_priv->mesh_obj = NULL; -out: - return -ENOMEM; -} - -/** - * batadv_sysfs_del_meshif() - Remove soft interface specific sysfs entries - * @dev: netdev struct of the soft interface - */ -void batadv_sysfs_del_meshif(struct net_device *dev) -{ - struct batadv_priv *bat_priv = netdev_priv(dev); - struct batadv_attribute **bat_attr; - - for (bat_attr = batadv_mesh_attrs; *bat_attr; ++bat_attr) - sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); - - kobject_uevent(bat_priv->mesh_obj, KOBJ_REMOVE); - kobject_del(bat_priv->mesh_obj); - kobject_put(bat_priv->mesh_obj); - bat_priv->mesh_obj = NULL; -} - -/** - * batadv_sysfs_add_vlan() - add all the needed sysfs objects for the new vlan - * @dev: netdev of the mesh interface - * @vlan: private data of the newly added VLAN interface - * - * Return: 0 on success and -ENOMEM if any of the structure allocations fails. - */ -int batadv_sysfs_add_vlan(struct net_device *dev, - struct batadv_softif_vlan *vlan) -{ - char vlan_subdir[sizeof(BATADV_SYSFS_VLAN_SUBDIR_PREFIX) + 5]; - struct batadv_priv *bat_priv = netdev_priv(dev); - struct batadv_attribute **bat_attr; - int err; - - if (vlan->vid & BATADV_VLAN_HAS_TAG) { - sprintf(vlan_subdir, BATADV_SYSFS_VLAN_SUBDIR_PREFIX "%hu", - vlan->vid & VLAN_VID_MASK); - - vlan->kobj = kobject_create_and_add(vlan_subdir, - bat_priv->mesh_obj); - if (!vlan->kobj) { - batadv_err(dev, "Can't add sysfs directory: %s/%s\n", - dev->name, vlan_subdir); - goto out; - } - } else { - /* the untagged LAN uses the root folder to store its "VLAN - * specific attributes" - */ - vlan->kobj = bat_priv->mesh_obj; - kobject_get(bat_priv->mesh_obj); - } - - for (bat_attr = batadv_vlan_attrs; *bat_attr; ++bat_attr) { - err = sysfs_create_file(vlan->kobj, - &((*bat_attr)->attr)); - if (err) { - batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n", - dev->name, vlan_subdir, - ((*bat_attr)->attr).name); - goto rem_attr; - } - } - - return 0; - -rem_attr: - for (bat_attr = batadv_vlan_attrs; *bat_attr; ++bat_attr) - sysfs_remove_file(vlan->kobj, &((*bat_attr)->attr)); - - if (vlan->kobj != bat_priv->mesh_obj) { - kobject_uevent(vlan->kobj, KOBJ_REMOVE); - kobject_del(vlan->kobj); - } - kobject_put(vlan->kobj); - vlan->kobj = NULL; -out: - return -ENOMEM; -} - -/** - * batadv_sysfs_del_vlan() - remove all the sysfs objects for a given VLAN - * @bat_priv: the bat priv with all the soft interface information - * @vlan: the private data of the VLAN to destroy - */ -void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv, - struct batadv_softif_vlan *vlan) -{ - struct batadv_attribute **bat_attr; - - for (bat_attr = batadv_vlan_attrs; *bat_attr; ++bat_attr) - sysfs_remove_file(vlan->kobj, &((*bat_attr)->attr)); - - if (vlan->kobj != bat_priv->mesh_obj) { - kobject_uevent(vlan->kobj, KOBJ_REMOVE); - kobject_del(vlan->kobj); - } - kobject_put(vlan->kobj); - vlan->kobj = NULL; -} - -static ssize_t batadv_show_mesh_iface(struct kobject *kobj, - struct attribute *attr, char *buff) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - struct batadv_hard_iface *hard_iface; - ssize_t length; - const char *ifname; - - batadv_sysfs_deprecated(attr); - - hard_iface = batadv_hardif_get_by_netdev(net_dev); - if (!hard_iface) - return 0; - - if (hard_iface->if_status == BATADV_IF_NOT_IN_USE) - ifname = "none"; - else - ifname = hard_iface->soft_iface->name; - - length = sprintf(buff, "%s\n", ifname); - - batadv_hardif_put(hard_iface); - - return length; -} - -/** - * batadv_store_mesh_iface_finish() - store new hardif mesh_iface state - * @net_dev: netdevice to add/remove to/from batman-adv soft-interface - * @ifname: name of soft-interface to modify - * - * Changes the parts of the hard+soft interface which can not be modified under - * sysfs lock (to prevent deadlock situations). - * - * Return: 0 on success, 0 < on failure - */ -static int batadv_store_mesh_iface_finish(struct net_device *net_dev, - char ifname[IFNAMSIZ]) -{ - struct net *net = dev_net(net_dev); - struct batadv_hard_iface *hard_iface; - int status_tmp; - int ret = 0; - - ASSERT_RTNL(); - - hard_iface = batadv_hardif_get_by_netdev(net_dev); - if (!hard_iface) - return 0; - - if (strncmp(ifname, "none", 4) == 0) - status_tmp = BATADV_IF_NOT_IN_USE; - else - status_tmp = BATADV_IF_I_WANT_YOU; - - if (hard_iface->if_status == status_tmp) - goto out; - - if (hard_iface->soft_iface && - strncmp(hard_iface->soft_iface->name, ifname, IFNAMSIZ) == 0) - goto out; - - if (status_tmp == BATADV_IF_NOT_IN_USE) { - batadv_hardif_disable_interface(hard_iface, - BATADV_IF_CLEANUP_AUTO); - goto out; - } - - /* if the interface already is in use */ - if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) - batadv_hardif_disable_interface(hard_iface, - BATADV_IF_CLEANUP_AUTO); - - ret = batadv_hardif_enable_interface(hard_iface, net, ifname); -out: - batadv_hardif_put(hard_iface); - return ret; -} - -/** - * batadv_store_mesh_iface_work() - store new hardif mesh_iface state - * @work: work queue item - * - * Changes the parts of the hard+soft interface which can not be modified under - * sysfs lock (to prevent deadlock situations). - */ -static void batadv_store_mesh_iface_work(struct work_struct *work) -{ - struct batadv_store_mesh_work *store_work; - int ret; - - store_work = container_of(work, struct batadv_store_mesh_work, work); - - rtnl_lock(); - ret = batadv_store_mesh_iface_finish(store_work->net_dev, - store_work->soft_iface_name); - rtnl_unlock(); - - if (ret < 0) - pr_err("Failed to store new mesh_iface state %s for %s: %d\n", - store_work->soft_iface_name, store_work->net_dev->name, - ret); - - dev_put(store_work->net_dev); - kfree(store_work); -} - -static ssize_t batadv_store_mesh_iface(struct kobject *kobj, - struct attribute *attr, char *buff, - size_t count) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - struct batadv_store_mesh_work *store_work; - - batadv_sysfs_deprecated(attr); - - if (buff[count - 1] == '\n') - buff[count - 1] = '\0'; - - if (strlen(buff) >= IFNAMSIZ) { - pr_err("Invalid parameter for 'mesh_iface' setting received: interface name too long '%s'\n", - buff); - return -EINVAL; - } - - store_work = kmalloc(sizeof(*store_work), GFP_KERNEL); - if (!store_work) - return -ENOMEM; - - dev_hold(net_dev); - INIT_WORK(&store_work->work, batadv_store_mesh_iface_work); - store_work->net_dev = net_dev; - strscpy(store_work->soft_iface_name, buff, - sizeof(store_work->soft_iface_name)); - - queue_work(batadv_event_workqueue, &store_work->work); - - return count; -} - -static ssize_t batadv_show_iface_status(struct kobject *kobj, - struct attribute *attr, char *buff) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - struct batadv_hard_iface *hard_iface; - ssize_t length; - - batadv_sysfs_deprecated(attr); - - hard_iface = batadv_hardif_get_by_netdev(net_dev); - if (!hard_iface) - return 0; - - switch (hard_iface->if_status) { - case BATADV_IF_TO_BE_REMOVED: - length = sprintf(buff, "disabling\n"); - break; - case BATADV_IF_INACTIVE: - length = sprintf(buff, "inactive\n"); - break; - case BATADV_IF_ACTIVE: - length = sprintf(buff, "active\n"); - break; - case BATADV_IF_TO_BE_ACTIVATED: - length = sprintf(buff, "enabling\n"); - break; - case BATADV_IF_NOT_IN_USE: - default: - length = sprintf(buff, "not in use\n"); - break; - } - - batadv_hardif_put(hard_iface); - - return length; -} - -#ifdef CONFIG_BATMAN_ADV_BATMAN_V - -/** - * batadv_store_throughput_override() - parse and store throughput override - * entered by the user - * @kobj: kobject representing the private mesh sysfs directory - * @attr: the batman-adv attribute the user is interacting with - * @buff: the buffer containing the user data - * @count: number of bytes in the buffer - * - * Return: 'count' on success or a negative error code in case of failure - */ -static ssize_t batadv_store_throughput_override(struct kobject *kobj, - struct attribute *attr, - char *buff, size_t count) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - struct batadv_hard_iface *hard_iface; - struct batadv_priv *bat_priv; - u32 tp_override; - u32 old_tp_override; - bool ret; - - batadv_sysfs_deprecated(attr); - - hard_iface = batadv_hardif_get_by_netdev(net_dev); - if (!hard_iface) - return -EINVAL; - - if (buff[count - 1] == '\n') - buff[count - 1] = '\0'; - - ret = batadv_parse_throughput(net_dev, buff, "throughput_override", - &tp_override); - if (!ret) - goto out; - - old_tp_override = atomic_read(&hard_iface->bat_v.throughput_override); - if (old_tp_override == tp_override) - goto out; - - batadv_info(hard_iface->soft_iface, - "%s: %s: Changing from: %u.%u MBit to: %u.%u MBit\n", - "throughput_override", net_dev->name, - old_tp_override / 10, old_tp_override % 10, - tp_override / 10, tp_override % 10); - - atomic_set(&hard_iface->bat_v.throughput_override, tp_override); - - if (hard_iface->soft_iface) { - bat_priv = netdev_priv(hard_iface->soft_iface); - batadv_netlink_notify_hardif(bat_priv, hard_iface); - } - -out: - batadv_hardif_put(hard_iface); - return count; -} - -static ssize_t batadv_show_throughput_override(struct kobject *kobj, - struct attribute *attr, - char *buff) -{ - struct net_device *net_dev = batadv_kobj_to_netdev(kobj); - struct batadv_hard_iface *hard_iface; - u32 tp_override; - - batadv_sysfs_deprecated(attr); - - hard_iface = batadv_hardif_get_by_netdev(net_dev); - if (!hard_iface) - return -EINVAL; - - tp_override = atomic_read(&hard_iface->bat_v.throughput_override); - - batadv_hardif_put(hard_iface); - return sprintf(buff, "%u.%u MBit\n", tp_override / 10, - tp_override % 10); -} - -#endif - -static BATADV_ATTR(mesh_iface, 0644, batadv_show_mesh_iface, - batadv_store_mesh_iface); -static BATADV_ATTR(iface_status, 0444, batadv_show_iface_status, NULL); -#ifdef CONFIG_BATMAN_ADV_BATMAN_V -BATADV_ATTR_HIF_UINT(elp_interval, bat_v.elp_interval, 0644, - 2 * BATADV_JITTER, INT_MAX, NULL); -static BATADV_ATTR(throughput_override, 0644, batadv_show_throughput_override, - batadv_store_throughput_override); -#endif - -static struct batadv_attribute *batadv_batman_attrs[] = { - &batadv_attr_mesh_iface, - &batadv_attr_iface_status, -#ifdef CONFIG_BATMAN_ADV_BATMAN_V - &batadv_attr_elp_interval, - &batadv_attr_throughput_override, -#endif - NULL, -}; - -/** - * batadv_sysfs_add_hardif() - Add hard interface specific sysfs entries - * @hardif_obj: address where to store the pointer to new sysfs folder - * @dev: netdev struct of the hard interface - * - * Return: 0 on success or negative error number in case of failure - */ -int batadv_sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) -{ - struct kobject *hardif_kobject = &dev->dev.kobj; - struct batadv_attribute **bat_attr; - int err; - - *hardif_obj = kobject_create_and_add(BATADV_SYSFS_IF_BAT_SUBDIR, - hardif_kobject); - - if (!*hardif_obj) { - batadv_err(dev, "Can't add sysfs directory: %s/%s\n", dev->name, - BATADV_SYSFS_IF_BAT_SUBDIR); - goto out; - } - - for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr) { - err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); - if (err) { - batadv_err(dev, "Can't add sysfs file: %s/%s/%s\n", - dev->name, BATADV_SYSFS_IF_BAT_SUBDIR, - ((*bat_attr)->attr).name); - goto rem_attr; - } - } - - return 0; - -rem_attr: - for (bat_attr = batadv_batman_attrs; *bat_attr; ++bat_attr) - sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr)); -out: - return -ENOMEM; -} - -/** - * batadv_sysfs_del_hardif() - Remove hard interface specific sysfs entries - * @hardif_obj: address to the pointer to which stores batman-adv sysfs folder - * of the hard interface - */ -void batadv_sysfs_del_hardif(struct kobject **hardif_obj) -{ - kobject_uevent(*hardif_obj, KOBJ_REMOVE); - kobject_del(*hardif_obj); - kobject_put(*hardif_obj); - *hardif_obj = NULL; -} diff --git a/net/batman-adv/sysfs.h b/net/batman-adv/sysfs.h deleted file mode 100644 index d987f8b30a98..000000000000 --- a/net/batman-adv/sysfs.h +++ /dev/null @@ -1,93 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2010-2020 B.A.T.M.A.N. contributors: - * - * Marek Lindner - */ - -#ifndef _NET_BATMAN_ADV_SYSFS_H_ -#define _NET_BATMAN_ADV_SYSFS_H_ - -#include "main.h" - -#include -#include -#include -#include - -#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh" -#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv" -/** - * BATADV_SYSFS_VLAN_SUBDIR_PREFIX - prefix of the subfolder that will be - * created in the sysfs hierarchy for each VLAN interface. The subfolder will - * be named "BATADV_SYSFS_VLAN_SUBDIR_PREFIX%vid". - */ -#define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan" - -/** - * struct batadv_attribute - sysfs export helper for batman-adv attributes - */ -struct batadv_attribute { - /** @attr: sysfs attribute file */ - struct attribute attr; - - /** - * @show: function to export the current attribute's content to sysfs - */ - ssize_t (*show)(struct kobject *kobj, struct attribute *attr, - char *buf); - - /** - * @store: function to load new value from character buffer and save it - * in batman-adv attribute - */ - ssize_t (*store)(struct kobject *kobj, struct attribute *attr, - char *buf, size_t count); -}; - -#ifdef CONFIG_BATMAN_ADV_SYSFS - -int batadv_sysfs_add_meshif(struct net_device *dev); -void batadv_sysfs_del_meshif(struct net_device *dev); -int batadv_sysfs_add_hardif(struct kobject **hardif_obj, - struct net_device *dev); -void batadv_sysfs_del_hardif(struct kobject **hardif_obj); -int batadv_sysfs_add_vlan(struct net_device *dev, - struct batadv_softif_vlan *vlan); -void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv, - struct batadv_softif_vlan *vlan); - -#else - -static inline int batadv_sysfs_add_meshif(struct net_device *dev) -{ - return 0; -} - -static inline void batadv_sysfs_del_meshif(struct net_device *dev) -{ -} - -static inline int batadv_sysfs_add_hardif(struct kobject **hardif_obj, - struct net_device *dev) -{ - return 0; -} - -static inline void batadv_sysfs_del_hardif(struct kobject **hardif_obj) -{ -} - -static inline int batadv_sysfs_add_vlan(struct net_device *dev, - struct batadv_softif_vlan *vlan) -{ - return 0; -} - -static inline void batadv_sysfs_del_vlan(struct batadv_priv *bat_priv, - struct batadv_softif_vlan *vlan) -{ -} - -#endif - -#endif /* _NET_BATMAN_ADV_SYSFS_H_ */ diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 965336a3b89d..7cfe3081039e 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -187,9 +187,6 @@ struct batadv_hard_iface { /** @net_dev: pointer to the net_device */ struct net_device *net_dev; - /** @hardif_obj: kobject of the per interface sysfs "mesh" directory */ - struct kobject *hardif_obj; - /** @refcount: number of contexts the object is used */ struct kref refcount; @@ -1512,9 +1509,6 @@ struct batadv_softif_vlan { /** @vid: VLAN identifier */ unsigned short vid; - /** @kobj: kobject for sysfs vlan subdirectory */ - struct kobject *kobj; - /** @ap_isolation: AP isolation state */ atomic_t ap_isolation; /* boolean */ @@ -1667,9 +1661,6 @@ struct batadv_priv { /** @batman_queue_left: number of remaining OGM packet slots */ atomic_t batman_queue_left; - /** @mesh_obj: kobject for sysfs mesh subdirectory */ - struct kobject *mesh_obj; - #ifdef CONFIG_BATMAN_ADV_DEBUGFS /** @debug_dir: dentry for debugfs batman-adv subdirectory */ struct dentry *debug_dir; @@ -2274,10 +2265,6 @@ struct batadv_algo_gw_ops { */ ssize_t (*store_sel_class)(struct batadv_priv *bat_priv, char *buff, size_t count); - - /** @show_sel_class: prints the current GW selection class (optional) */ - ssize_t (*show_sel_class)(struct batadv_priv *bat_priv, char *buff); - /** * @get_best_gw_node: select the best GW from the list of available * nodes (optional) @@ -2456,21 +2443,4 @@ enum batadv_tvlv_handler_flags { BATADV_TVLV_HANDLER_OGM_CALLED = BIT(2), }; -/** - * struct batadv_store_mesh_work - Work queue item to detach add/del interface - * from sysfs locks - */ -struct batadv_store_mesh_work { - /** - * @net_dev: netdevice to add/remove to/from batman-adv soft-interface - */ - struct net_device *net_dev; - - /** @soft_iface_name: name of soft-interface to modify */ - char soft_iface_name[IFNAMSIZ]; - - /** @work: work queue item */ - struct work_struct work; -}; - #endif /* _NET_BATMAN_ADV_TYPES_H_ */ From patchwork Fri Dec 4 15:46:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18238 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 974158264A; Fri, 4 Dec 2020 16:55:43 +0100 (CET) Received: from simonwunderlich.de (simonwunderlich.de [79.140.42.25]) by diktynna.open-mesh.org (Postfix) with ESMTPS id F2CEF80D64 for ; Fri, 4 Dec 2020 16:55:07 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 641C5174065; Fri, 4 Dec 2020 16:46:35 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 6/8] batman-adv: Drop deprecated debugfs support Date: Fri, 4 Dec 2020 16:46:29 +0100 Message-Id: <20201204154631.21063-7-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gsVMta9bz3kUJa8/5WZU0kHoUNx55WfN9mH6UmeXgIk=; b=gVdJR1wH+mR97a0C6NhXEW6nLZ50rBKcIFpdM11DDU9MW/Fhi7zdcEVo12PG2pYgndsfcv vIGapLGx42BpS72g80TvfrDpM/Oeq6Ytu850QKdHwIi82n8hH1dF0RJ/jo58uCcmGsWG44 ao1zmwhLyDGCGjeHJUAZjx+w2nDbSxA= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097308; a=rsa-sha256; cv=none; b=X2I/ZkNSl2Ug2leZJa5P0fmBFP0Pr5DCAueuBh8o/qgJK2glcsXwHqRfq0QIfShTNEXx12 tCxWLUDYTVFQESRg5i2RmmiDOXjmL7ahulGHKDTu+wodR0giJ7hxmKf6qnBN4M8Zm24AW5 bg3Eleul17crEk6+s1gtLVo13vNpuM8= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 79.140.42.25 as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: FHBFUZIWL65YWJJJ6C23AGSHO2QMSRTG X-Message-ID-Hash: FHBFUZIWL65YWJJJ6C23AGSHO2QMSRTG X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann The debugfs support in batman-adv was marked as deprecated by the commit 00caf6a2b318 ("batman-adv: Mark debugfs functionality as deprecated") and scheduled for removal in 2021. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/Kconfig | 16 +- net/batman-adv/Makefile | 2 - net/batman-adv/bat_algo.c | 24 -- net/batman-adv/bat_algo.h | 2 - net/batman-adv/bat_iv_ogm.c | 229 ------------- net/batman-adv/bat_v.c | 237 ------------- net/batman-adv/bridge_loop_avoidance.c | 130 -------- net/batman-adv/bridge_loop_avoidance.h | 16 - net/batman-adv/debugfs.c | 442 ------------------------- net/batman-adv/debugfs.h | 73 ---- net/batman-adv/distributed-arp-table.c | 55 --- net/batman-adv/distributed-arp-table.h | 2 - net/batman-adv/gateway_client.c | 39 --- net/batman-adv/gateway_client.h | 2 - net/batman-adv/hard-interface.c | 10 - net/batman-adv/icmp_socket.c | 393 ---------------------- net/batman-adv/icmp_socket.h | 38 --- net/batman-adv/log.c | 209 ------------ net/batman-adv/main.c | 45 --- net/batman-adv/main.h | 3 - net/batman-adv/multicast.c | 111 ------- net/batman-adv/multicast.h | 3 - net/batman-adv/network-coding.c | 87 ----- net/batman-adv/network-coding.h | 13 - net/batman-adv/originator.c | 121 ------- net/batman-adv/originator.h | 4 - net/batman-adv/routing.c | 10 - net/batman-adv/soft-interface.c | 10 +- net/batman-adv/translation-table.c | 212 ------------ net/batman-adv/translation-table.h | 3 - net/batman-adv/types.h | 36 -- 31 files changed, 3 insertions(+), 2574 deletions(-) delete mode 100644 net/batman-adv/debugfs.c delete mode 100644 net/batman-adv/debugfs.h delete mode 100644 net/batman-adv/icmp_socket.c delete mode 100644 net/batman-adv/icmp_socket.h diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig index 84bbf72b764e..993afd5ff7bb 100644 --- a/net/batman-adv/Kconfig +++ b/net/batman-adv/Kconfig @@ -76,26 +76,14 @@ config BATMAN_ADV_MCAST reduce the air overhead while improving the reliability of multicast messages. -config BATMAN_ADV_DEBUGFS - bool "batman-adv debugfs entries" - depends on BATMAN_ADV - depends on DEBUG_FS - help - Enable this to export routing related debug tables via debugfs. - The information for each soft-interface and used hard-interface can be - found under batman_adv/ - - If unsure, say N. - config BATMAN_ADV_DEBUG bool "B.A.T.M.A.N. debugging" depends on BATMAN_ADV help This is an option for use by developers; most people should say N here. This enables compilation of support for - outputting debugging information to the debugfs log or tracing - buffer. The output is controlled via the batadv netdev specific - log_level setting. + outputting debugging information to the tracing buffer. The output is + controlled via the batadv netdev specific log_level setting. config BATMAN_ADV_TRACING bool "B.A.T.M.A.N. tracing support" diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile index 306615caba6c..8010c34b987c 100644 --- a/net/batman-adv/Makefile +++ b/net/batman-adv/Makefile @@ -11,14 +11,12 @@ batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_elp.o batman-adv-$(CONFIG_BATMAN_ADV_BATMAN_V) += bat_v_ogm.o batman-adv-y += bitarray.o batman-adv-$(CONFIG_BATMAN_ADV_BLA) += bridge_loop_avoidance.o -batman-adv-$(CONFIG_BATMAN_ADV_DEBUGFS) += debugfs.o batman-adv-$(CONFIG_BATMAN_ADV_DAT) += distributed-arp-table.o batman-adv-y += fragmentation.o batman-adv-y += gateway_client.o batman-adv-y += gateway_common.o batman-adv-y += hard-interface.o batman-adv-y += hash.o -batman-adv-$(CONFIG_BATMAN_ADV_DEBUGFS) += icmp_socket.o batman-adv-$(CONFIG_BATMAN_ADV_DEBUG) += log.o batman-adv-y += main.o batman-adv-$(CONFIG_BATMAN_ADV_MCAST) += multicast.o diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c index 500db94a6b50..c5f404f6892f 100644 --- a/net/batman-adv/bat_algo.c +++ b/net/batman-adv/bat_algo.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -116,29 +115,6 @@ int batadv_algo_select(struct batadv_priv *bat_priv, const char *name) return 0; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - -/** - * batadv_algo_seq_print_text() - Print the supported algorithms in a seq file - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) -{ - struct batadv_algo_ops *bat_algo_ops; - - seq_puts(seq, "Available routing algorithms:\n"); - - hlist_for_each_entry(bat_algo_ops, &batadv_algo_list, list) { - seq_printf(seq, " * %s\n", bat_algo_ops->name); - } - - return 0; -} -#endif - static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) { struct batadv_algo_ops *bat_algo_ops; diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h index 2ae140eac45d..43b045ac8ac7 100644 --- a/net/batman-adv/bat_algo.h +++ b/net/batman-adv/bat_algo.h @@ -10,7 +10,6 @@ #include "main.h" #include -#include #include #include @@ -21,7 +20,6 @@ void batadv_algo_init(void); struct batadv_algo_ops *batadv_algo_get(const char *name); int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops); int batadv_algo_select(struct batadv_priv *bat_priv, const char *name); -int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); int batadv_algo_dump(struct sk_buff *msg, struct netlink_callback *cb); #endif /* _NET_BATMAN_ADV_BAT_ALGO_H_ */ diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 206d0b424712..168621c9a081 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -1780,106 +1779,6 @@ static int batadv_iv_ogm_receive(struct sk_buff *skb, return ret; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_iv_ogm_orig_print_neigh() - print neighbors for the originator table - * @orig_node: the orig_node for which the neighbors are printed - * @if_outgoing: outgoing interface for these entries - * @seq: debugfs table seq_file struct - * - * Must be called while holding an rcu lock. - */ -static void -batadv_iv_ogm_orig_print_neigh(struct batadv_orig_node *orig_node, - struct batadv_hard_iface *if_outgoing, - struct seq_file *seq) -{ - struct batadv_neigh_node *neigh_node; - struct batadv_neigh_ifinfo *n_ifinfo; - - hlist_for_each_entry_rcu(neigh_node, &orig_node->neigh_list, list) { - n_ifinfo = batadv_neigh_ifinfo_get(neigh_node, if_outgoing); - if (!n_ifinfo) - continue; - - seq_printf(seq, " %pM (%3i)", - neigh_node->addr, - n_ifinfo->bat_iv.tq_avg); - - batadv_neigh_ifinfo_put(n_ifinfo); - } -} - -/** - * batadv_iv_ogm_orig_print() - print the originator table - * @bat_priv: the bat priv with all the soft interface information - * @seq: debugfs table seq_file struct - * @if_outgoing: the outgoing interface for which this should be printed - */ -static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv, - struct seq_file *seq, - struct batadv_hard_iface *if_outgoing) -{ - struct batadv_neigh_node *neigh_node; - struct batadv_hashtable *hash = bat_priv->orig_hash; - int last_seen_msecs, last_seen_secs; - struct batadv_orig_node *orig_node; - struct batadv_neigh_ifinfo *n_ifinfo; - unsigned long last_seen_jiffies; - struct hlist_head *head; - int batman_count = 0; - u32 i; - - seq_puts(seq, - " Originator last-seen (#/255) Nexthop [outgoingIF]: Potential nexthops ...\n"); - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, head, hash_entry) { - neigh_node = batadv_orig_router_get(orig_node, - if_outgoing); - if (!neigh_node) - continue; - - n_ifinfo = batadv_neigh_ifinfo_get(neigh_node, - if_outgoing); - if (!n_ifinfo) - goto next; - - if (n_ifinfo->bat_iv.tq_avg == 0) - goto next; - - last_seen_jiffies = jiffies - orig_node->last_seen; - last_seen_msecs = jiffies_to_msecs(last_seen_jiffies); - last_seen_secs = last_seen_msecs / 1000; - last_seen_msecs = last_seen_msecs % 1000; - - seq_printf(seq, "%pM %4i.%03is (%3i) %pM [%10s]:", - orig_node->orig, last_seen_secs, - last_seen_msecs, n_ifinfo->bat_iv.tq_avg, - neigh_node->addr, - neigh_node->if_incoming->net_dev->name); - - batadv_iv_ogm_orig_print_neigh(orig_node, if_outgoing, - seq); - seq_putc(seq, '\n'); - batman_count++; - -next: - batadv_neigh_node_put(neigh_node); - if (n_ifinfo) - batadv_neigh_ifinfo_put(n_ifinfo); - } - rcu_read_unlock(); - } - - if (batman_count == 0) - seq_puts(seq, "No batman nodes in range ...\n"); -} -#endif - /** * batadv_iv_ogm_neigh_get_tq_avg() - Get the TQ average for a neighbour on a * given outgoing interface. @@ -2109,59 +2008,6 @@ batadv_iv_ogm_orig_dump(struct sk_buff *msg, struct netlink_callback *cb, cb->args[2] = sub; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_iv_hardif_neigh_print() - print a single hop neighbour node - * @seq: neighbour table seq_file struct - * @hardif_neigh: hardif neighbour information - */ -static void -batadv_iv_hardif_neigh_print(struct seq_file *seq, - struct batadv_hardif_neigh_node *hardif_neigh) -{ - int last_secs, last_msecs; - - last_secs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen) / 1000; - last_msecs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen) % 1000; - - seq_printf(seq, " %10s %pM %4i.%03is\n", - hardif_neigh->if_incoming->net_dev->name, - hardif_neigh->addr, last_secs, last_msecs); -} - -/** - * batadv_iv_ogm_neigh_print() - print the single hop neighbour list - * @bat_priv: the bat priv with all the soft interface information - * @seq: neighbour table seq_file struct - */ -static void batadv_iv_neigh_print(struct batadv_priv *bat_priv, - struct seq_file *seq) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_hardif_neigh_node *hardif_neigh; - struct batadv_hard_iface *hard_iface; - int batman_count = 0; - - seq_puts(seq, " IF Neighbor last-seen\n"); - - rcu_read_lock(); - list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { - if (hard_iface->soft_iface != net_dev) - continue; - - hlist_for_each_entry_rcu(hardif_neigh, - &hard_iface->neigh_list, list) { - batadv_iv_hardif_neigh_print(seq, hardif_neigh); - batman_count++; - } - } - rcu_read_unlock(); - - if (batman_count == 0) - seq_puts(seq, "No batman nodes in range ...\n"); -} -#endif - /** * batadv_iv_ogm_neigh_diff() - calculate tq difference of two neighbors * @neigh1: the first neighbor object of the comparison @@ -2557,72 +2403,6 @@ static bool batadv_iv_gw_is_eligible(struct batadv_priv *bat_priv, return ret; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/* fails if orig_node has no router */ -static int batadv_iv_gw_write_buffer_text(struct batadv_priv *bat_priv, - struct seq_file *seq, - const struct batadv_gw_node *gw_node) -{ - struct batadv_gw_node *curr_gw; - struct batadv_neigh_node *router; - struct batadv_neigh_ifinfo *router_ifinfo = NULL; - int ret = -1; - - router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); - if (!router) - goto out; - - router_ifinfo = batadv_neigh_ifinfo_get(router, BATADV_IF_DEFAULT); - if (!router_ifinfo) - goto out; - - curr_gw = batadv_gw_get_selected_gw_node(bat_priv); - - seq_printf(seq, "%s %pM (%3i) %pM [%10s]: %u.%u/%u.%u MBit\n", - (curr_gw == gw_node ? "=>" : " "), - gw_node->orig_node->orig, - router_ifinfo->bat_iv.tq_avg, router->addr, - router->if_incoming->net_dev->name, - gw_node->bandwidth_down / 10, - gw_node->bandwidth_down % 10, - gw_node->bandwidth_up / 10, - gw_node->bandwidth_up % 10); - ret = seq_has_overflowed(seq) ? -1 : 0; - - if (curr_gw) - batadv_gw_node_put(curr_gw); -out: - if (router_ifinfo) - batadv_neigh_ifinfo_put(router_ifinfo); - if (router) - batadv_neigh_node_put(router); - return ret; -} - -static void batadv_iv_gw_print(struct batadv_priv *bat_priv, - struct seq_file *seq) -{ - struct batadv_gw_node *gw_node; - int gw_count = 0; - - seq_puts(seq, - " Gateway (#/255) Nexthop [outgoingIF]: advertised uplink bandwidth\n"); - - rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { - /* fails if orig_node has no router */ - if (batadv_iv_gw_write_buffer_text(bat_priv, seq, gw_node) < 0) - continue; - - gw_count++; - } - rcu_read_unlock(); - - if (gw_count == 0) - seq_puts(seq, "No gateways in range ...\n"); -} -#endif - /** * batadv_iv_gw_dump_entry() - Dump a gateway into a message * @msg: Netlink message to dump into @@ -2747,24 +2527,15 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = { .neigh = { .cmp = batadv_iv_ogm_neigh_cmp, .is_similar_or_better = batadv_iv_ogm_neigh_is_sob, -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_iv_neigh_print, -#endif .dump = batadv_iv_ogm_neigh_dump, }, .orig = { -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_iv_ogm_orig_print, -#endif .dump = batadv_iv_ogm_orig_dump, }, .gw = { .init_sel_class = batadv_iv_init_sel_class, .get_best_gw_node = batadv_iv_gw_get_best_gw_node, .is_eligible = batadv_iv_gw_is_eligible, -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_iv_gw_print, -#endif .dump = batadv_iv_gw_dump, }, }; diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index ee7a95aa7bd4..e4455babe4c2 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -119,92 +118,6 @@ batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node *hardif_neigh) batadv_v_elp_throughput_metric_update); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_v_orig_print_neigh() - print neighbors for the originator table - * @orig_node: the orig_node for which the neighbors are printed - * @if_outgoing: outgoing interface for these entries - * @seq: debugfs table seq_file struct - * - * Must be called while holding an rcu lock. - */ -static void -batadv_v_orig_print_neigh(struct batadv_orig_node *orig_node, - struct batadv_hard_iface *if_outgoing, - struct seq_file *seq) -{ - struct batadv_neigh_node *neigh_node; - struct batadv_neigh_ifinfo *n_ifinfo; - - hlist_for_each_entry_rcu(neigh_node, &orig_node->neigh_list, list) { - n_ifinfo = batadv_neigh_ifinfo_get(neigh_node, if_outgoing); - if (!n_ifinfo) - continue; - - seq_printf(seq, " %pM (%9u.%1u)", - neigh_node->addr, - n_ifinfo->bat_v.throughput / 10, - n_ifinfo->bat_v.throughput % 10); - - batadv_neigh_ifinfo_put(n_ifinfo); - } -} - -/** - * batadv_v_hardif_neigh_print() - print a single ELP neighbour node - * @seq: neighbour table seq_file struct - * @hardif_neigh: hardif neighbour information - */ -static void -batadv_v_hardif_neigh_print(struct seq_file *seq, - struct batadv_hardif_neigh_node *hardif_neigh) -{ - int last_secs, last_msecs; - u32 throughput; - - last_secs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen) / 1000; - last_msecs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen) % 1000; - throughput = ewma_throughput_read(&hardif_neigh->bat_v.throughput); - - seq_printf(seq, "%pM %4i.%03is (%9u.%1u) [%10s]\n", - hardif_neigh->addr, last_secs, last_msecs, throughput / 10, - throughput % 10, hardif_neigh->if_incoming->net_dev->name); -} - -/** - * batadv_v_neigh_print() - print the single hop neighbour list - * @bat_priv: the bat priv with all the soft interface information - * @seq: neighbour table seq_file struct - */ -static void batadv_v_neigh_print(struct batadv_priv *bat_priv, - struct seq_file *seq) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_hardif_neigh_node *hardif_neigh; - struct batadv_hard_iface *hard_iface; - int batman_count = 0; - - seq_puts(seq, - " Neighbor last-seen ( throughput) [ IF]\n"); - - rcu_read_lock(); - list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { - if (hard_iface->soft_iface != net_dev) - continue; - - hlist_for_each_entry_rcu(hardif_neigh, - &hard_iface->neigh_list, list) { - batadv_v_hardif_neigh_print(seq, hardif_neigh); - batman_count++; - } - } - rcu_read_unlock(); - - if (batman_count == 0) - seq_puts(seq, "No batman nodes in range ...\n"); -} -#endif - /** * batadv_v_neigh_dump_neigh() - Dump a neighbour into a message * @msg: Netlink message to dump into @@ -337,75 +250,6 @@ batadv_v_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb, cb->args[1] = idx; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_v_orig_print() - print the originator table - * @bat_priv: the bat priv with all the soft interface information - * @seq: debugfs table seq_file struct - * @if_outgoing: the outgoing interface for which this should be printed - */ -static void batadv_v_orig_print(struct batadv_priv *bat_priv, - struct seq_file *seq, - struct batadv_hard_iface *if_outgoing) -{ - struct batadv_neigh_node *neigh_node; - struct batadv_hashtable *hash = bat_priv->orig_hash; - int last_seen_msecs, last_seen_secs; - struct batadv_orig_node *orig_node; - struct batadv_neigh_ifinfo *n_ifinfo; - unsigned long last_seen_jiffies; - struct hlist_head *head; - int batman_count = 0; - u32 i; - - seq_puts(seq, - " Originator last-seen ( throughput) Nexthop [outgoingIF]: Potential nexthops ...\n"); - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, head, hash_entry) { - neigh_node = batadv_orig_router_get(orig_node, - if_outgoing); - if (!neigh_node) - continue; - - n_ifinfo = batadv_neigh_ifinfo_get(neigh_node, - if_outgoing); - if (!n_ifinfo) - goto next; - - last_seen_jiffies = jiffies - orig_node->last_seen; - last_seen_msecs = jiffies_to_msecs(last_seen_jiffies); - last_seen_secs = last_seen_msecs / 1000; - last_seen_msecs = last_seen_msecs % 1000; - - seq_printf(seq, "%pM %4i.%03is (%9u.%1u) %pM [%10s]:", - orig_node->orig, last_seen_secs, - last_seen_msecs, - n_ifinfo->bat_v.throughput / 10, - n_ifinfo->bat_v.throughput % 10, - neigh_node->addr, - neigh_node->if_incoming->net_dev->name); - - batadv_v_orig_print_neigh(orig_node, if_outgoing, seq); - seq_putc(seq, '\n'); - batman_count++; - -next: - batadv_neigh_node_put(neigh_node); - if (n_ifinfo) - batadv_neigh_ifinfo_put(n_ifinfo); - } - rcu_read_unlock(); - } - - if (batman_count == 0) - seq_puts(seq, "No batman nodes in range ...\n"); -} -#endif - /** * batadv_v_orig_dump_subentry() - Dump an originator subentry into a message * @msg: Netlink message to dump into @@ -822,78 +666,6 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv *bat_priv, return ret; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/* fails if orig_node has no router */ -static int batadv_v_gw_write_buffer_text(struct batadv_priv *bat_priv, - struct seq_file *seq, - const struct batadv_gw_node *gw_node) -{ - struct batadv_gw_node *curr_gw; - struct batadv_neigh_node *router; - struct batadv_neigh_ifinfo *router_ifinfo = NULL; - int ret = -1; - - router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); - if (!router) - goto out; - - router_ifinfo = batadv_neigh_ifinfo_get(router, BATADV_IF_DEFAULT); - if (!router_ifinfo) - goto out; - - curr_gw = batadv_gw_get_selected_gw_node(bat_priv); - - seq_printf(seq, "%s %pM (%9u.%1u) %pM [%10s]: %u.%u/%u.%u MBit\n", - (curr_gw == gw_node ? "=>" : " "), - gw_node->orig_node->orig, - router_ifinfo->bat_v.throughput / 10, - router_ifinfo->bat_v.throughput % 10, router->addr, - router->if_incoming->net_dev->name, - gw_node->bandwidth_down / 10, - gw_node->bandwidth_down % 10, - gw_node->bandwidth_up / 10, - gw_node->bandwidth_up % 10); - ret = seq_has_overflowed(seq) ? -1 : 0; - - if (curr_gw) - batadv_gw_node_put(curr_gw); -out: - if (router_ifinfo) - batadv_neigh_ifinfo_put(router_ifinfo); - if (router) - batadv_neigh_node_put(router); - return ret; -} - -/** - * batadv_v_gw_print() - print the gateway list - * @bat_priv: the bat priv with all the soft interface information - * @seq: gateway table seq_file struct - */ -static void batadv_v_gw_print(struct batadv_priv *bat_priv, - struct seq_file *seq) -{ - struct batadv_gw_node *gw_node; - int gw_count = 0; - - seq_puts(seq, - " Gateway ( throughput) Nexthop [outgoingIF]: advertised uplink bandwidth\n"); - - rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { - /* fails if orig_node has no router */ - if (batadv_v_gw_write_buffer_text(bat_priv, seq, gw_node) < 0) - continue; - - gw_count++; - } - rcu_read_unlock(); - - if (gw_count == 0) - seq_puts(seq, "No gateways in range ...\n"); -} -#endif - /** * batadv_v_gw_dump_entry() - Dump a gateway into a message * @msg: Netlink message to dump into @@ -1039,15 +811,9 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .hardif_init = batadv_v_hardif_neigh_init, .cmp = batadv_v_neigh_cmp, .is_similar_or_better = batadv_v_neigh_is_sob, -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_v_neigh_print, -#endif .dump = batadv_v_neigh_dump, }, .orig = { -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_v_orig_print, -#endif .dump = batadv_v_orig_dump, }, .gw = { @@ -1055,9 +821,6 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .store_sel_class = batadv_v_store_sel_class, .get_best_gw_node = batadv_v_gw_get_best_gw_node, .is_eligible = batadv_v_gw_is_eligible, -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_v_gw_print, -#endif .dump = batadv_v_gw_dump, }, }; diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index ba0027d1f2df..d2de12e527ba 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -2115,69 +2114,6 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, return ret; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_bla_claim_table_seq_print_text() - print the claim table in a seq file - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hashtable *hash = bat_priv->bla.claim_hash; - struct batadv_bla_backbone_gw *backbone_gw; - struct batadv_bla_claim *claim; - struct batadv_hard_iface *primary_if; - struct hlist_head *head; - u16 backbone_crc; - u32 i; - bool is_own; - u8 *primary_addr; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - goto out; - - primary_addr = primary_if->net_dev->dev_addr; - seq_printf(seq, - "Claims announced for the mesh %s (orig %pM, group id %#.4x)\n", - net_dev->name, primary_addr, - ntohs(bat_priv->bla.claim_dest.group)); - seq_puts(seq, - " Client VID Originator [o] (CRC )\n"); - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(claim, head, hash_entry) { - backbone_gw = batadv_bla_claim_get_backbone_gw(claim); - - is_own = batadv_compare_eth(backbone_gw->orig, - primary_addr); - - spin_lock_bh(&backbone_gw->crc_lock); - backbone_crc = backbone_gw->crc; - spin_unlock_bh(&backbone_gw->crc_lock); - seq_printf(seq, " * %pM on %5d by %pM [%c] (%#.4x)\n", - claim->addr, batadv_print_vid(claim->vid), - backbone_gw->orig, - (is_own ? 'x' : ' '), - backbone_crc); - - batadv_backbone_gw_put(backbone_gw); - } - rcu_read_unlock(); - } -out: - if (primary_if) - batadv_hardif_put(primary_if); - return 0; -} -#endif - /** * batadv_bla_claim_dump_entry() - dump one entry of the claim table * to a netlink socket @@ -2348,72 +2284,6 @@ int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb) return ret; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_bla_backbone_table_seq_print_text() - print the backbone table in a - * seq file - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hashtable *hash = bat_priv->bla.backbone_hash; - struct batadv_bla_backbone_gw *backbone_gw; - struct batadv_hard_iface *primary_if; - struct hlist_head *head; - int secs, msecs; - u16 backbone_crc; - u32 i; - bool is_own; - u8 *primary_addr; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - goto out; - - primary_addr = primary_if->net_dev->dev_addr; - seq_printf(seq, - "Backbones announced for the mesh %s (orig %pM, group id %#.4x)\n", - net_dev->name, primary_addr, - ntohs(bat_priv->bla.claim_dest.group)); - seq_puts(seq, " Originator VID last seen (CRC )\n"); - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) { - msecs = jiffies_to_msecs(jiffies - - backbone_gw->lasttime); - secs = msecs / 1000; - msecs = msecs % 1000; - - is_own = batadv_compare_eth(backbone_gw->orig, - primary_addr); - if (is_own) - continue; - - spin_lock_bh(&backbone_gw->crc_lock); - backbone_crc = backbone_gw->crc; - spin_unlock_bh(&backbone_gw->crc_lock); - - seq_printf(seq, " * %pM on %5d %4i.%03is (%#.4x)\n", - backbone_gw->orig, - batadv_print_vid(backbone_gw->vid), secs, - msecs, backbone_crc); - } - rcu_read_unlock(); - } -out: - if (primary_if) - batadv_hardif_put(primary_if); - return 0; -} -#endif - /** * batadv_bla_backbone_dump_entry() - dump one entry of the backbone table to a * netlink socket diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h index a81c41b636f9..7dc6d3571925 100644 --- a/net/batman-adv/bridge_loop_avoidance.h +++ b/net/batman-adv/bridge_loop_avoidance.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -41,10 +40,7 @@ bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, bool batadv_bla_is_backbone_gw(struct sk_buff *skb, struct batadv_orig_node *orig_node, int hdr_size); -int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset); int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb); -int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, - void *offset); int batadv_bla_backbone_dump(struct sk_buff *msg, struct netlink_callback *cb); bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig, unsigned short vid); @@ -84,18 +80,6 @@ static inline bool batadv_bla_is_backbone_gw(struct sk_buff *skb, return false; } -static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, - void *offset) -{ - return 0; -} - -static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, - void *offset) -{ - return 0; -} - static inline bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig, unsigned short vid) { diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c deleted file mode 100644 index 452856c27d20..000000000000 --- a/net/batman-adv/debugfs.c +++ /dev/null @@ -1,442 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2010-2020 B.A.T.M.A.N. contributors: - * - * Marek Lindner - */ - -#include "debugfs.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bat_algo.h" -#include "bridge_loop_avoidance.h" -#include "distributed-arp-table.h" -#include "gateway_client.h" -#include "icmp_socket.h" -#include "log.h" -#include "multicast.h" -#include "network-coding.h" -#include "originator.h" -#include "translation-table.h" - -static struct dentry *batadv_debugfs; - -/** - * batadv_debugfs_deprecated() - Log use of deprecated batadv debugfs access - * @file: file which was accessed - * @alt: explanation what can be used as alternative - */ -void batadv_debugfs_deprecated(struct file *file, const char *alt) -{ - struct dentry *dentry = file_dentry(file); - const char *name = dentry->d_name.name; - - pr_warn_ratelimited(DEPRECATED "%s (pid %d) Use of debugfs file \"%s\".\n%s", - current->comm, task_pid_nr(current), name, alt); -} - -static int batadv_algorithms_open(struct inode *inode, struct file *file) -{ - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_ROUTING_ALGOS instead\n"); - return single_open(file, batadv_algo_seq_print_text, NULL); -} - -static int neighbors_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_NEIGHBORS instead\n"); - return single_open(file, batadv_hardif_neigh_seq_print_text, net_dev); -} - -static int batadv_originators_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_ORIGINATORS instead\n"); - return single_open(file, batadv_orig_seq_print_text, net_dev); -} - -/** - * batadv_originators_hardif_open() - handles debugfs output for the originator - * table of an hard interface - * @inode: inode pointer to debugfs file - * @file: pointer to the seq_file - * - * Return: 0 on success or negative error number in case of failure - */ -static int batadv_originators_hardif_open(struct inode *inode, - struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_HARDIFS instead\n"); - return single_open(file, batadv_orig_hardif_seq_print_text, net_dev); -} - -static int batadv_gateways_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_GATEWAYS instead\n"); - return single_open(file, batadv_gw_client_seq_print_text, net_dev); -} - -static int batadv_transtable_global_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_TRANSTABLE_GLOBAL instead\n"); - return single_open(file, batadv_tt_global_seq_print_text, net_dev); -} - -#ifdef CONFIG_BATMAN_ADV_BLA -static int batadv_bla_claim_table_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_BLA_CLAIM instead\n"); - return single_open(file, batadv_bla_claim_table_seq_print_text, - net_dev); -} - -static int batadv_bla_backbone_table_open(struct inode *inode, - struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_BLA_BACKBONE instead\n"); - return single_open(file, batadv_bla_backbone_table_seq_print_text, - net_dev); -} - -#endif - -#ifdef CONFIG_BATMAN_ADV_DAT -/** - * batadv_dat_cache_open() - Prepare file handler for reads from dat_cache - * @inode: inode which was opened - * @file: file handle to be initialized - * - * Return: 0 on success or negative error number in case of failure - */ -static int batadv_dat_cache_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_DAT_CACHE instead\n"); - return single_open(file, batadv_dat_cache_seq_print_text, net_dev); -} -#endif - -static int batadv_transtable_local_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_TRANSTABLE_LOCAL instead\n"); - return single_open(file, batadv_tt_local_seq_print_text, net_dev); -} - -struct batadv_debuginfo { - struct attribute attr; - const struct file_operations fops; -}; - -#ifdef CONFIG_BATMAN_ADV_NC -static int batadv_nc_nodes_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, ""); - return single_open(file, batadv_nc_nodes_seq_print_text, net_dev); -} -#endif - -#ifdef CONFIG_BATMAN_ADV_MCAST -/** - * batadv_mcast_flags_open() - prepare file handler for reads from mcast_flags - * @inode: inode which was opened - * @file: file handle to be initialized - * - * Return: 0 on success or negative error number in case of failure - */ -static int batadv_mcast_flags_open(struct inode *inode, struct file *file) -{ - struct net_device *net_dev = (struct net_device *)inode->i_private; - - batadv_debugfs_deprecated(file, - "Use genl command BATADV_CMD_GET_MCAST_FLAGS instead\n"); - return single_open(file, batadv_mcast_flags_seq_print_text, net_dev); -} -#endif - -#define BATADV_DEBUGINFO(_name, _mode, _open) \ -struct batadv_debuginfo batadv_debuginfo_##_name = { \ - .attr = { \ - .name = __stringify(_name), \ - .mode = _mode, \ - }, \ - .fops = { \ - .owner = THIS_MODULE, \ - .open = _open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ - }, \ -} - -/* the following attributes are general and therefore they will be directly - * placed in the BATADV_DEBUGFS_SUBDIR subdirectory of debugfs - */ -static BATADV_DEBUGINFO(routing_algos, 0444, batadv_algorithms_open); - -static struct batadv_debuginfo *batadv_general_debuginfos[] = { - &batadv_debuginfo_routing_algos, - NULL, -}; - -/* The following attributes are per soft interface */ -static BATADV_DEBUGINFO(neighbors, 0444, neighbors_open); -static BATADV_DEBUGINFO(originators, 0444, batadv_originators_open); -static BATADV_DEBUGINFO(gateways, 0444, batadv_gateways_open); -static BATADV_DEBUGINFO(transtable_global, 0444, batadv_transtable_global_open); -#ifdef CONFIG_BATMAN_ADV_BLA -static BATADV_DEBUGINFO(bla_claim_table, 0444, batadv_bla_claim_table_open); -static BATADV_DEBUGINFO(bla_backbone_table, 0444, - batadv_bla_backbone_table_open); -#endif -#ifdef CONFIG_BATMAN_ADV_DAT -static BATADV_DEBUGINFO(dat_cache, 0444, batadv_dat_cache_open); -#endif -static BATADV_DEBUGINFO(transtable_local, 0444, batadv_transtable_local_open); -#ifdef CONFIG_BATMAN_ADV_NC -static BATADV_DEBUGINFO(nc_nodes, 0444, batadv_nc_nodes_open); -#endif -#ifdef CONFIG_BATMAN_ADV_MCAST -static BATADV_DEBUGINFO(mcast_flags, 0444, batadv_mcast_flags_open); -#endif - -static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { - &batadv_debuginfo_neighbors, - &batadv_debuginfo_originators, - &batadv_debuginfo_gateways, - &batadv_debuginfo_transtable_global, -#ifdef CONFIG_BATMAN_ADV_BLA - &batadv_debuginfo_bla_claim_table, - &batadv_debuginfo_bla_backbone_table, -#endif -#ifdef CONFIG_BATMAN_ADV_DAT - &batadv_debuginfo_dat_cache, -#endif - &batadv_debuginfo_transtable_local, -#ifdef CONFIG_BATMAN_ADV_NC - &batadv_debuginfo_nc_nodes, -#endif -#ifdef CONFIG_BATMAN_ADV_MCAST - &batadv_debuginfo_mcast_flags, -#endif - NULL, -}; - -#define BATADV_HARDIF_DEBUGINFO(_name, _mode, _open) \ -struct batadv_debuginfo batadv_hardif_debuginfo_##_name = { \ - .attr = { \ - .name = __stringify(_name), \ - .mode = _mode, \ - }, \ - .fops = { \ - .owner = THIS_MODULE, \ - .open = _open, \ - .read = seq_read, \ - .llseek = seq_lseek, \ - .release = single_release, \ - }, \ -} - -static BATADV_HARDIF_DEBUGINFO(originators, 0444, - batadv_originators_hardif_open); - -static struct batadv_debuginfo *batadv_hardif_debuginfos[] = { - &batadv_hardif_debuginfo_originators, - NULL, -}; - -/** - * batadv_debugfs_init() - Initialize soft interface independent debugfs entries - */ -void batadv_debugfs_init(void) -{ - struct batadv_debuginfo **bat_debug; - - batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL); - - for (bat_debug = batadv_general_debuginfos; *bat_debug; ++bat_debug) - debugfs_create_file(((*bat_debug)->attr).name, - S_IFREG | ((*bat_debug)->attr).mode, - batadv_debugfs, NULL, &(*bat_debug)->fops); -} - -/** - * batadv_debugfs_destroy() - Remove all debugfs entries - */ -void batadv_debugfs_destroy(void) -{ - debugfs_remove_recursive(batadv_debugfs); - batadv_debugfs = NULL; -} - -/** - * batadv_debugfs_add_hardif() - creates the base directory for a hard interface - * in debugfs. - * @hard_iface: hard interface which should be added. - */ -void batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface) -{ - struct net *net = dev_net(hard_iface->net_dev); - struct batadv_debuginfo **bat_debug; - - if (net != &init_net) - return; - - hard_iface->debug_dir = debugfs_create_dir(hard_iface->net_dev->name, - batadv_debugfs); - - for (bat_debug = batadv_hardif_debuginfos; *bat_debug; ++bat_debug) - debugfs_create_file(((*bat_debug)->attr).name, - S_IFREG | ((*bat_debug)->attr).mode, - hard_iface->debug_dir, hard_iface->net_dev, - &(*bat_debug)->fops); -} - -/** - * batadv_debugfs_rename_hardif() - Fix debugfs path for renamed hardif - * @hard_iface: hard interface which was renamed - */ -void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface) -{ - const char *name = hard_iface->net_dev->name; - struct dentry *dir; - - dir = hard_iface->debug_dir; - if (!dir) - return; - - debugfs_rename(dir->d_parent, dir, dir->d_parent, name); -} - -/** - * batadv_debugfs_del_hardif() - delete the base directory for a hard interface - * in debugfs. - * @hard_iface: hard interface which is deleted. - */ -void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface) -{ - struct net *net = dev_net(hard_iface->net_dev); - - if (net != &init_net) - return; - - if (batadv_debugfs) { - debugfs_remove_recursive(hard_iface->debug_dir); - hard_iface->debug_dir = NULL; - } -} - -/** - * batadv_debugfs_add_meshif() - Initialize interface dependent debugfs entries - * @dev: netdev struct of the soft interface - * - * Return: 0 on success or negative error number in case of failure - */ -int batadv_debugfs_add_meshif(struct net_device *dev) -{ - struct batadv_priv *bat_priv = netdev_priv(dev); - struct batadv_debuginfo **bat_debug; - struct net *net = dev_net(dev); - - if (net != &init_net) - return 0; - - bat_priv->debug_dir = debugfs_create_dir(dev->name, batadv_debugfs); - - batadv_socket_setup(bat_priv); - - if (batadv_debug_log_setup(bat_priv) < 0) - goto rem_attr; - - for (bat_debug = batadv_mesh_debuginfos; *bat_debug; ++bat_debug) - debugfs_create_file(((*bat_debug)->attr).name, - S_IFREG | ((*bat_debug)->attr).mode, - bat_priv->debug_dir, dev, - &(*bat_debug)->fops); - - batadv_nc_init_debugfs(bat_priv); - - return 0; -rem_attr: - debugfs_remove_recursive(bat_priv->debug_dir); - bat_priv->debug_dir = NULL; - return -ENOMEM; -} - -/** - * batadv_debugfs_rename_meshif() - Fix debugfs path for renamed softif - * @dev: net_device which was renamed - */ -void batadv_debugfs_rename_meshif(struct net_device *dev) -{ - struct batadv_priv *bat_priv = netdev_priv(dev); - const char *name = dev->name; - struct dentry *dir; - - dir = bat_priv->debug_dir; - if (!dir) - return; - - debugfs_rename(dir->d_parent, dir, dir->d_parent, name); -} - -/** - * batadv_debugfs_del_meshif() - Remove interface dependent debugfs entries - * @dev: netdev struct of the soft interface - */ -void batadv_debugfs_del_meshif(struct net_device *dev) -{ - struct batadv_priv *bat_priv = netdev_priv(dev); - struct net *net = dev_net(dev); - - if (net != &init_net) - return; - - batadv_debug_log_cleanup(bat_priv); - - if (batadv_debugfs) { - debugfs_remove_recursive(bat_priv->debug_dir); - bat_priv->debug_dir = NULL; - } -} diff --git a/net/batman-adv/debugfs.h b/net/batman-adv/debugfs.h deleted file mode 100644 index 7e2e8f586f42..000000000000 --- a/net/batman-adv/debugfs.h +++ /dev/null @@ -1,73 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2010-2020 B.A.T.M.A.N. contributors: - * - * Marek Lindner - */ - -#ifndef _NET_BATMAN_ADV_DEBUGFS_H_ -#define _NET_BATMAN_ADV_DEBUGFS_H_ - -#include "main.h" - -#include -#include - -#define BATADV_DEBUGFS_SUBDIR "batman_adv" - -#if IS_ENABLED(CONFIG_BATMAN_ADV_DEBUGFS) - -void batadv_debugfs_deprecated(struct file *file, const char *alt); -void batadv_debugfs_init(void); -void batadv_debugfs_destroy(void); -int batadv_debugfs_add_meshif(struct net_device *dev); -void batadv_debugfs_rename_meshif(struct net_device *dev); -void batadv_debugfs_del_meshif(struct net_device *dev); -void batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface); -void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface); -void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface); - -#else - -static inline void batadv_debugfs_deprecated(struct file *file, const char *alt) -{ -} - -static inline void batadv_debugfs_init(void) -{ -} - -static inline void batadv_debugfs_destroy(void) -{ -} - -static inline int batadv_debugfs_add_meshif(struct net_device *dev) -{ - return 0; -} - -static inline void batadv_debugfs_rename_meshif(struct net_device *dev) -{ -} - -static inline void batadv_debugfs_del_meshif(struct net_device *dev) -{ -} - -static inline -void batadv_debugfs_add_hardif(struct batadv_hard_iface *hard_iface) -{ -} - -static inline -void batadv_debugfs_rename_hardif(struct batadv_hard_iface *hard_iface) -{ -} - -static inline -void batadv_debugfs_del_hardif(struct batadv_hard_iface *hard_iface) -{ -} - -#endif - -#endif /* _NET_BATMAN_ADV_DEBUGFS_H_ */ diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 0e6e53e9b5f3..fd7ba6bbdf85 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -842,60 +841,6 @@ void batadv_dat_free(struct batadv_priv *bat_priv) batadv_dat_hash_free(bat_priv); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_dat_cache_seq_print_text() - print the local DAT hash table - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hashtable *hash = bat_priv->dat.hash; - struct batadv_dat_entry *dat_entry; - struct batadv_hard_iface *primary_if; - struct hlist_head *head; - unsigned long last_seen_jiffies; - int last_seen_msecs, last_seen_secs, last_seen_mins; - u32 i; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - goto out; - - seq_printf(seq, "Distributed ARP Table (%s):\n", net_dev->name); - seq_puts(seq, - " IPv4 MAC VID last-seen\n"); - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(dat_entry, head, hash_entry) { - last_seen_jiffies = jiffies - dat_entry->last_update; - last_seen_msecs = jiffies_to_msecs(last_seen_jiffies); - last_seen_mins = last_seen_msecs / 60000; - last_seen_msecs = last_seen_msecs % 60000; - last_seen_secs = last_seen_msecs / 1000; - - seq_printf(seq, " * %15pI4 %pM %4i %6i:%02i\n", - &dat_entry->ip, dat_entry->mac_addr, - batadv_print_vid(dat_entry->vid), - last_seen_mins, last_seen_secs); - } - rcu_read_unlock(); - } - -out: - if (primary_if) - batadv_hardif_put(primary_if); - return 0; -} -#endif - /** * batadv_dat_cache_dump_entry() - dump one entry of the DAT cache table to a * netlink socket diff --git a/net/batman-adv/distributed-arp-table.h b/net/batman-adv/distributed-arp-table.h index 4e031661682a..e980fb45693a 100644 --- a/net/batman-adv/distributed-arp-table.h +++ b/net/batman-adv/distributed-arp-table.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -74,7 +73,6 @@ batadv_dat_init_own_addr(struct batadv_priv *bat_priv, int batadv_dat_init(struct batadv_priv *bat_priv); void batadv_dat_free(struct batadv_priv *bat_priv); -int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset); int batadv_dat_cache_dump(struct sk_buff *msg, struct netlink_callback *cb); /** diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index ef3f85b576c4..cffe72f4edd7 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -511,44 +510,6 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv) spin_unlock_bh(&bat_priv->gw.list_lock); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - -/** - * batadv_gw_client_seq_print_text() - Print the gateway table in a seq file - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hard_iface *primary_if; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - return 0; - - seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n", - BATADV_SOURCE_VERSION, primary_if->net_dev->name, - primary_if->net_dev->dev_addr, net_dev->name, - bat_priv->algo_ops->name); - - batadv_hardif_put(primary_if); - - if (!bat_priv->algo_ops->gw.print) { - seq_puts(seq, - "No printing function for this routing protocol\n"); - return 0; - } - - bat_priv->algo_ops->gw.print(bat_priv, seq); - - return 0; -} -#endif - /** * batadv_gw_dump() - Dump gateways into a message * @msg: Netlink message to dump into diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h index 88b5dba84354..2fbc500f0ac1 100644 --- a/net/batman-adv/gateway_client.h +++ b/net/batman-adv/gateway_client.h @@ -10,7 +10,6 @@ #include "main.h" #include -#include #include #include #include @@ -31,7 +30,6 @@ void batadv_gw_node_free(struct batadv_priv *bat_priv); void batadv_gw_node_put(struct batadv_gw_node *gw_node); struct batadv_gw_node * batadv_gw_get_selected_gw_node(struct batadv_priv *bat_priv); -int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset); int batadv_gw_dump(struct sk_buff *msg, struct netlink_callback *cb); bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb); enum batadv_dhcp_recipient diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 6f827a6be4ed..bbedb9a422c0 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -32,7 +32,6 @@ #include "bat_v.h" #include "bridge_loop_avoidance.h" -#include "debugfs.h" #include "distributed-arp-table.h" #include "gateway_client.h" #include "log.h" @@ -919,8 +918,6 @@ batadv_hardif_add_interface(struct net_device *net_dev) hard_iface->soft_iface = NULL; hard_iface->if_status = BATADV_IF_NOT_IN_USE; - batadv_debugfs_add_hardif(hard_iface); - INIT_LIST_HEAD(&hard_iface->list); INIT_HLIST_HEAD(&hard_iface->neigh_list); @@ -963,7 +960,6 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) return; hard_iface->if_status = BATADV_IF_TO_BE_REMOVED; - batadv_debugfs_del_hardif(hard_iface); batadv_hardif_put(hard_iface); } @@ -984,9 +980,6 @@ static int batadv_hard_if_event_softif(unsigned long event, bat_priv = netdev_priv(net_dev); batadv_softif_create_vlan(bat_priv, BATADV_NO_FLAGS); break; - case NETDEV_CHANGENAME: - batadv_debugfs_rename_meshif(net_dev); - break; } return NOTIFY_DONE; @@ -1051,9 +1044,6 @@ static int batadv_hard_if_event(struct notifier_block *this, if (batadv_is_wifi_hardif(hard_iface)) hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS; break; - case NETDEV_CHANGENAME: - batadv_debugfs_rename_hardif(hard_iface); - break; default: break; } diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c deleted file mode 100644 index 56de4bf21aa5..000000000000 --- a/net/batman-adv/icmp_socket.c +++ /dev/null @@ -1,393 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors: - * - * Marek Lindner - */ - -#include "icmp_socket.h" -#include "main.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for linux/wait.h */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "debugfs.h" -#include "hard-interface.h" -#include "log.h" -#include "originator.h" -#include "send.h" - -static struct batadv_socket_client *batadv_socket_client_hash[256]; - -static void batadv_socket_add_packet(struct batadv_socket_client *socket_client, - struct batadv_icmp_header *icmph, - size_t icmp_len); - -/** - * batadv_socket_init() - Initialize soft interface independent socket data - */ -void batadv_socket_init(void) -{ - memset(batadv_socket_client_hash, 0, sizeof(batadv_socket_client_hash)); -} - -static int batadv_socket_open(struct inode *inode, struct file *file) -{ - unsigned int i; - struct batadv_socket_client *socket_client; - - if (!try_module_get(THIS_MODULE)) - return -EBUSY; - - batadv_debugfs_deprecated(file, ""); - - stream_open(inode, file); - - socket_client = kmalloc(sizeof(*socket_client), GFP_KERNEL); - if (!socket_client) { - module_put(THIS_MODULE); - return -ENOMEM; - } - - for (i = 0; i < ARRAY_SIZE(batadv_socket_client_hash); i++) { - if (!batadv_socket_client_hash[i]) { - batadv_socket_client_hash[i] = socket_client; - break; - } - } - - if (i == ARRAY_SIZE(batadv_socket_client_hash)) { - pr_err("Error - can't add another packet client: maximum number of clients reached\n"); - kfree(socket_client); - module_put(THIS_MODULE); - return -EXFULL; - } - - INIT_LIST_HEAD(&socket_client->queue_list); - socket_client->queue_len = 0; - socket_client->index = i; - socket_client->bat_priv = inode->i_private; - spin_lock_init(&socket_client->lock); - init_waitqueue_head(&socket_client->queue_wait); - - file->private_data = socket_client; - - return 0; -} - -static int batadv_socket_release(struct inode *inode, struct file *file) -{ - struct batadv_socket_client *client = file->private_data; - struct batadv_socket_packet *packet, *tmp; - - spin_lock_bh(&client->lock); - - /* for all packets in the queue ... */ - list_for_each_entry_safe(packet, tmp, &client->queue_list, list) { - list_del(&packet->list); - kfree(packet); - } - - batadv_socket_client_hash[client->index] = NULL; - spin_unlock_bh(&client->lock); - - kfree(client); - module_put(THIS_MODULE); - - return 0; -} - -static ssize_t batadv_socket_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - struct batadv_socket_client *socket_client = file->private_data; - struct batadv_socket_packet *socket_packet; - size_t packet_len; - int error; - - if ((file->f_flags & O_NONBLOCK) && socket_client->queue_len == 0) - return -EAGAIN; - - if (!buf || count < sizeof(struct batadv_icmp_packet)) - return -EINVAL; - - error = wait_event_interruptible(socket_client->queue_wait, - socket_client->queue_len); - - if (error) - return error; - - spin_lock_bh(&socket_client->lock); - - socket_packet = list_first_entry(&socket_client->queue_list, - struct batadv_socket_packet, list); - list_del(&socket_packet->list); - socket_client->queue_len--; - - spin_unlock_bh(&socket_client->lock); - - packet_len = min(count, socket_packet->icmp_len); - error = copy_to_user(buf, &socket_packet->icmp_packet, packet_len); - - kfree(socket_packet); - - if (error) - return -EFAULT; - - return packet_len; -} - -static ssize_t batadv_socket_write(struct file *file, const char __user *buff, - size_t len, loff_t *off) -{ - struct batadv_socket_client *socket_client = file->private_data; - struct batadv_priv *bat_priv = socket_client->bat_priv; - struct batadv_hard_iface *primary_if = NULL; - struct sk_buff *skb; - struct batadv_icmp_packet_rr *icmp_packet_rr; - struct batadv_icmp_header *icmp_header; - struct batadv_orig_node *orig_node = NULL; - struct batadv_neigh_node *neigh_node = NULL; - size_t packet_len = sizeof(struct batadv_icmp_packet); - u8 *addr; - - if (len < sizeof(struct batadv_icmp_header)) { - batadv_dbg(BATADV_DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: invalid packet size\n"); - return -EINVAL; - } - - primary_if = batadv_primary_if_get_selected(bat_priv); - - if (!primary_if) { - len = -EFAULT; - goto out; - } - - if (len >= BATADV_ICMP_MAX_PACKET_SIZE) - packet_len = BATADV_ICMP_MAX_PACKET_SIZE; - else - packet_len = len; - - skb = netdev_alloc_skb_ip_align(NULL, packet_len + ETH_HLEN); - if (!skb) { - len = -ENOMEM; - goto out; - } - - skb->priority = TC_PRIO_CONTROL; - skb_reserve(skb, ETH_HLEN); - icmp_header = skb_put(skb, packet_len); - - if (copy_from_user(icmp_header, buff, packet_len)) { - len = -EFAULT; - goto free_skb; - } - - if (icmp_header->packet_type != BATADV_ICMP) { - batadv_dbg(BATADV_DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n"); - len = -EINVAL; - goto free_skb; - } - - switch (icmp_header->msg_type) { - case BATADV_ECHO_REQUEST: - if (len < sizeof(struct batadv_icmp_packet)) { - batadv_dbg(BATADV_DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: invalid packet size\n"); - len = -EINVAL; - goto free_skb; - } - - if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE) - goto dst_unreach; - - orig_node = batadv_orig_hash_find(bat_priv, icmp_header->dst); - if (!orig_node) - goto dst_unreach; - - neigh_node = batadv_orig_router_get(orig_node, - BATADV_IF_DEFAULT); - if (!neigh_node) - goto dst_unreach; - - if (!neigh_node->if_incoming) - goto dst_unreach; - - if (neigh_node->if_incoming->if_status != BATADV_IF_ACTIVE) - goto dst_unreach; - - icmp_packet_rr = (struct batadv_icmp_packet_rr *)icmp_header; - if (packet_len == sizeof(*icmp_packet_rr)) { - addr = neigh_node->if_incoming->net_dev->dev_addr; - ether_addr_copy(icmp_packet_rr->rr[0], addr); - } - - break; - default: - batadv_dbg(BATADV_DBG_BATMAN, bat_priv, - "Error - can't send packet from char device: got unknown message type\n"); - len = -EINVAL; - goto free_skb; - } - - icmp_header->uid = socket_client->index; - - if (icmp_header->version != BATADV_COMPAT_VERSION) { - icmp_header->msg_type = BATADV_PARAMETER_PROBLEM; - icmp_header->version = BATADV_COMPAT_VERSION; - batadv_socket_add_packet(socket_client, icmp_header, - packet_len); - goto free_skb; - } - - ether_addr_copy(icmp_header->orig, primary_if->net_dev->dev_addr); - - batadv_send_unicast_skb(skb, neigh_node); - goto out; - -dst_unreach: - icmp_header->msg_type = BATADV_DESTINATION_UNREACHABLE; - batadv_socket_add_packet(socket_client, icmp_header, packet_len); -free_skb: - kfree_skb(skb); -out: - if (primary_if) - batadv_hardif_put(primary_if); - if (neigh_node) - batadv_neigh_node_put(neigh_node); - if (orig_node) - batadv_orig_node_put(orig_node); - return len; -} - -static __poll_t batadv_socket_poll(struct file *file, poll_table *wait) -{ - struct batadv_socket_client *socket_client = file->private_data; - - poll_wait(file, &socket_client->queue_wait, wait); - - if (socket_client->queue_len > 0) - return EPOLLIN | EPOLLRDNORM; - - return 0; -} - -static const struct file_operations batadv_fops = { - .owner = THIS_MODULE, - .open = batadv_socket_open, - .release = batadv_socket_release, - .read = batadv_socket_read, - .write = batadv_socket_write, - .poll = batadv_socket_poll, - .llseek = no_llseek, -}; - -/** - * batadv_socket_setup() - Create debugfs "socket" file - * @bat_priv: the bat priv with all the soft interface information - */ -void batadv_socket_setup(struct batadv_priv *bat_priv) -{ - debugfs_create_file(BATADV_ICMP_SOCKET, 0600, bat_priv->debug_dir, - bat_priv, &batadv_fops); -} - -/** - * batadv_socket_add_packet() - schedule an icmp packet to be sent to - * userspace on an icmp socket. - * @socket_client: the socket this packet belongs to - * @icmph: pointer to the header of the icmp packet - * @icmp_len: total length of the icmp packet - */ -static void batadv_socket_add_packet(struct batadv_socket_client *socket_client, - struct batadv_icmp_header *icmph, - size_t icmp_len) -{ - struct batadv_socket_packet *socket_packet; - size_t len; - - socket_packet = kmalloc(sizeof(*socket_packet), GFP_ATOMIC); - - if (!socket_packet) - return; - - len = icmp_len; - /* check the maximum length before filling the buffer */ - if (len > sizeof(socket_packet->icmp_packet)) - len = sizeof(socket_packet->icmp_packet); - - INIT_LIST_HEAD(&socket_packet->list); - memcpy(&socket_packet->icmp_packet, icmph, len); - socket_packet->icmp_len = len; - - spin_lock_bh(&socket_client->lock); - - /* while waiting for the lock the socket_client could have been - * deleted - */ - if (!batadv_socket_client_hash[icmph->uid]) { - spin_unlock_bh(&socket_client->lock); - kfree(socket_packet); - return; - } - - list_add_tail(&socket_packet->list, &socket_client->queue_list); - socket_client->queue_len++; - - if (socket_client->queue_len > 100) { - socket_packet = list_first_entry(&socket_client->queue_list, - struct batadv_socket_packet, - list); - - list_del(&socket_packet->list); - kfree(socket_packet); - socket_client->queue_len--; - } - - spin_unlock_bh(&socket_client->lock); - - wake_up(&socket_client->queue_wait); -} - -/** - * batadv_socket_receive_packet() - schedule an icmp packet to be received - * locally and sent to userspace. - * @icmph: pointer to the header of the icmp packet - * @icmp_len: total length of the icmp packet - */ -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len) -{ - struct batadv_socket_client *hash; - - hash = batadv_socket_client_hash[icmph->uid]; - if (hash) - batadv_socket_add_packet(hash, icmph, icmp_len); -} diff --git a/net/batman-adv/icmp_socket.h b/net/batman-adv/icmp_socket.h deleted file mode 100644 index 6abd0f4742ef..000000000000 --- a/net/batman-adv/icmp_socket.h +++ /dev/null @@ -1,38 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* Copyright (C) 2007-2020 B.A.T.M.A.N. contributors: - * - * Marek Lindner - */ - -#ifndef _NET_BATMAN_ADV_ICMP_SOCKET_H_ -#define _NET_BATMAN_ADV_ICMP_SOCKET_H_ - -#include "main.h" - -#include -#include - -#define BATADV_ICMP_SOCKET "socket" - -void batadv_socket_setup(struct batadv_priv *bat_priv); - -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - -void batadv_socket_init(void); -void batadv_socket_receive_packet(struct batadv_icmp_header *icmph, - size_t icmp_len); - -#else - -static inline void batadv_socket_init(void) -{ -} - -static inline void -batadv_socket_receive_packet(struct batadv_icmp_header *icmph, size_t icmp_len) -{ -} - -#endif - -#endif /* _NET_BATMAN_ADV_ICMP_SOCKET_H_ */ diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c index c0ca5fbe5b08..b7e9923b11a2 100644 --- a/net/batman-adv/log.c +++ b/net/batman-adv/log.c @@ -7,214 +7,10 @@ #include "log.h" #include "main.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for linux/wait.h */ -#include -#include -#include -#include -#include -#include #include -#include "debugfs.h" #include "trace.h" -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - -#define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) - -static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN; - -static char *batadv_log_char_addr(struct batadv_priv_debug_log *debug_log, - size_t idx) -{ - return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK]; -} - -static void batadv_emit_log_char(struct batadv_priv_debug_log *debug_log, - char c) -{ - char *char_addr; - - char_addr = batadv_log_char_addr(debug_log, debug_log->log_end); - *char_addr = c; - debug_log->log_end++; - - if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) - debug_log->log_start = debug_log->log_end - batadv_log_buff_len; -} - -__printf(2, 3) -static int batadv_fdebug_log(struct batadv_priv_debug_log *debug_log, - const char *fmt, ...) -{ - va_list args; - static char debug_log_buf[256]; - char *p; - - if (!debug_log) - return 0; - - spin_lock_bh(&debug_log->lock); - va_start(args, fmt); - vscnprintf(debug_log_buf, sizeof(debug_log_buf), fmt, args); - va_end(args); - - for (p = debug_log_buf; *p != 0; p++) - batadv_emit_log_char(debug_log, *p); - - spin_unlock_bh(&debug_log->lock); - - wake_up(&debug_log->queue_wait); - - return 0; -} - -static int batadv_log_open(struct inode *inode, struct file *file) -{ - if (!try_module_get(THIS_MODULE)) - return -EBUSY; - - batadv_debugfs_deprecated(file, - "Use tracepoint batadv:batadv_dbg instead\n"); - - stream_open(inode, file); - file->private_data = inode->i_private; - return 0; -} - -static int batadv_log_release(struct inode *inode, struct file *file) -{ - module_put(THIS_MODULE); - return 0; -} - -static bool batadv_log_empty(struct batadv_priv_debug_log *debug_log) -{ - return !(debug_log->log_start - debug_log->log_end); -} - -static ssize_t batadv_log_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - struct batadv_priv *bat_priv = file->private_data; - struct batadv_priv_debug_log *debug_log = bat_priv->debug_log; - int error, i = 0; - char *char_addr; - char c; - - if ((file->f_flags & O_NONBLOCK) && batadv_log_empty(debug_log)) - return -EAGAIN; - - if (!buf) - return -EINVAL; - - if (count == 0) - return 0; - - if (!access_ok(buf, count)) - return -EFAULT; - - error = wait_event_interruptible(debug_log->queue_wait, - (!batadv_log_empty(debug_log))); - - if (error) - return error; - - spin_lock_bh(&debug_log->lock); - - while ((!error) && (i < count) && - (debug_log->log_start != debug_log->log_end)) { - char_addr = batadv_log_char_addr(debug_log, - debug_log->log_start); - c = *char_addr; - - debug_log->log_start++; - - spin_unlock_bh(&debug_log->lock); - - error = __put_user(c, buf); - - spin_lock_bh(&debug_log->lock); - - buf++; - i++; - } - - spin_unlock_bh(&debug_log->lock); - - if (!error) - return i; - - return error; -} - -static __poll_t batadv_log_poll(struct file *file, poll_table *wait) -{ - struct batadv_priv *bat_priv = file->private_data; - struct batadv_priv_debug_log *debug_log = bat_priv->debug_log; - - poll_wait(file, &debug_log->queue_wait, wait); - - if (!batadv_log_empty(debug_log)) - return EPOLLIN | EPOLLRDNORM; - - return 0; -} - -static const struct file_operations batadv_log_fops = { - .open = batadv_log_open, - .release = batadv_log_release, - .read = batadv_log_read, - .poll = batadv_log_poll, - .llseek = no_llseek, - .owner = THIS_MODULE, -}; - -/** - * batadv_debug_log_setup() - Initialize debug log - * @bat_priv: the bat priv with all the soft interface information - * - * Return: 0 on success or negative error number in case of failure - */ -int batadv_debug_log_setup(struct batadv_priv *bat_priv) -{ - bat_priv->debug_log = kzalloc(sizeof(*bat_priv->debug_log), GFP_ATOMIC); - if (!bat_priv->debug_log) - return -ENOMEM; - - spin_lock_init(&bat_priv->debug_log->lock); - init_waitqueue_head(&bat_priv->debug_log->queue_wait); - - debugfs_create_file("log", 0400, bat_priv->debug_dir, bat_priv, - &batadv_log_fops); - return 0; -} - -/** - * batadv_debug_log_cleanup() - Destroy debug log - * @bat_priv: the bat priv with all the soft interface information - */ -void batadv_debug_log_cleanup(struct batadv_priv *bat_priv) -{ - kfree(bat_priv->debug_log); - bat_priv->debug_log = NULL; -} - -#endif /* CONFIG_BATMAN_ADV_DEBUGFS */ - /** * batadv_debug_log() - Add debug log entry * @bat_priv: the bat priv with all the soft interface information @@ -232,11 +28,6 @@ int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...) vaf.fmt = fmt; vaf.va = &args; -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - batadv_fdebug_log(bat_priv->debug_log, "[%10u] %pV", - jiffies_to_msecs(jiffies), &vaf); -#endif - trace_batadv_dbg(bat_priv, &vaf); va_end(args); diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 293c62edd9ed..ed9d87ce3407 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -45,12 +44,10 @@ #include "bat_iv_ogm.h" #include "bat_v.h" #include "bridge_loop_avoidance.h" -#include "debugfs.h" #include "distributed-arp-table.h" #include "gateway_client.h" #include "gateway_common.h" #include "hard-interface.h" -#include "icmp_socket.h" #include "log.h" #include "multicast.h" #include "netlink.h" @@ -114,9 +111,6 @@ static int __init batadv_init(void) if (!batadv_event_workqueue) goto err_create_wq; - batadv_socket_init(); - batadv_debugfs_init(); - register_netdevice_notifier(&batadv_hard_if_notifier); rtnl_link_register(&batadv_link_ops); batadv_netlink_register(); @@ -134,7 +128,6 @@ static int __init batadv_init(void) static void __exit batadv_exit(void) { - batadv_debugfs_destroy(); batadv_netlink_unregister(); rtnl_link_unregister(&batadv_link_ops); unregister_netdevice_notifier(&batadv_hard_if_notifier); @@ -306,44 +299,6 @@ bool batadv_is_my_mac(struct batadv_priv *bat_priv, const u8 *addr) return is_my_mac; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_seq_print_text_primary_if_get() - called from debugfs table printing - * function that requires the primary interface - * @seq: debugfs table seq_file struct - * - * Return: primary interface if found or NULL otherwise. - */ -struct batadv_hard_iface * -batadv_seq_print_text_primary_if_get(struct seq_file *seq) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hard_iface *primary_if; - - primary_if = batadv_primary_if_get_selected(bat_priv); - - if (!primary_if) { - seq_printf(seq, - "BATMAN mesh %s disabled - please specify interfaces to enable it\n", - net_dev->name); - goto out; - } - - if (primary_if->if_status == BATADV_IF_ACTIVE) - goto out; - - seq_printf(seq, - "BATMAN mesh %s disabled - primary interface not active\n", - net_dev->name); - batadv_hardif_put(primary_if); - primary_if = NULL; - -out: - return primary_if; -} -#endif - /** * batadv_max_header_len() - calculate maximum encapsulation overhead for a * payload packet diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 9254c6ee0c0a..288201630ceb 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -212,7 +212,6 @@ enum batadv_uev_type { #include #include #include -#include #include #include #include @@ -243,8 +242,6 @@ extern struct workqueue_struct *batadv_event_workqueue; int batadv_mesh_init(struct net_device *soft_iface); void batadv_mesh_free(struct net_device *soft_iface); bool batadv_is_my_mac(struct batadv_priv *bat_priv, const u8 *addr); -struct batadv_hard_iface * -batadv_seq_print_text_primary_if_get(struct seq_file *seq); int batadv_max_header_len(void); void batadv_skb_set_priority(struct sk_buff *skb, int offset); int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev, diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 9af99c39b9fd..854e5ff28a3f 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -2074,116 +2073,6 @@ void batadv_mcast_init(struct batadv_priv *bat_priv) batadv_mcast_start_timer(bat_priv); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_mcast_flags_print_header() - print own mcast flags to debugfs table - * @bat_priv: the bat priv with all the soft interface information - * @seq: debugfs table seq_file struct - * - * Prints our own multicast flags including a more specific reason why - * they are set, that is prints the bridge and querier state too, to - * the debugfs table specified via @seq. - */ -static void batadv_mcast_flags_print_header(struct batadv_priv *bat_priv, - struct seq_file *seq) -{ - struct batadv_mcast_mla_flags *mla_flags = &bat_priv->mcast.mla_flags; - char querier4, querier6, shadowing4, shadowing6; - bool bridged = mla_flags->bridged; - u8 flags = mla_flags->tvlv_flags; - - if (bridged) { - querier4 = mla_flags->querier_ipv4.exists ? '.' : '4'; - querier6 = mla_flags->querier_ipv6.exists ? '.' : '6'; - shadowing4 = mla_flags->querier_ipv4.shadowing ? '4' : '.'; - shadowing6 = mla_flags->querier_ipv6.shadowing ? '6' : '.'; - } else { - querier4 = '?'; - querier6 = '?'; - shadowing4 = '?'; - shadowing6 = '?'; - } - - seq_printf(seq, "Multicast flags (own flags: [%c%c%c%s%s])\n", - (flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES) ? 'U' : '.', - (flags & BATADV_MCAST_WANT_ALL_IPV4) ? '4' : '.', - (flags & BATADV_MCAST_WANT_ALL_IPV6) ? '6' : '.', - !(flags & BATADV_MCAST_WANT_NO_RTR4) ? "R4" : ". ", - !(flags & BATADV_MCAST_WANT_NO_RTR6) ? "R6" : ". "); - seq_printf(seq, "* Bridged [U]\t\t\t\t%c\n", bridged ? 'U' : '.'); - seq_printf(seq, "* No IGMP/MLD Querier [4/6]:\t\t%c/%c\n", - querier4, querier6); - seq_printf(seq, "* Shadowing IGMP/MLD Querier [4/6]:\t%c/%c\n", - shadowing4, shadowing6); - seq_puts(seq, "-------------------------------------------\n"); - seq_printf(seq, " %-10s %s\n", "Originator", "Flags"); -} - -/** - * batadv_mcast_flags_seq_print_text() - print the mcast flags of other nodes - * @seq: seq file to print on - * @offset: not used - * - * This prints a table of (primary) originators and their according - * multicast flags, including (in the header) our own. - * - * Return: always 0 - */ -int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hard_iface *primary_if; - struct batadv_hashtable *hash = bat_priv->orig_hash; - struct batadv_orig_node *orig_node; - struct hlist_head *head; - u8 flags; - u32 i; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - return 0; - - batadv_mcast_flags_print_header(bat_priv, seq); - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, head, hash_entry) { - if (!test_bit(BATADV_ORIG_CAPA_HAS_MCAST, - &orig_node->capa_initialized)) - continue; - - if (!test_bit(BATADV_ORIG_CAPA_HAS_MCAST, - &orig_node->capabilities)) { - seq_printf(seq, "%pM -\n", orig_node->orig); - continue; - } - - flags = orig_node->mcast_flags; - - seq_printf(seq, "%pM [%c%c%c%s%s]\n", orig_node->orig, - (flags & BATADV_MCAST_WANT_ALL_UNSNOOPABLES) - ? 'U' : '.', - (flags & BATADV_MCAST_WANT_ALL_IPV4) - ? '4' : '.', - (flags & BATADV_MCAST_WANT_ALL_IPV6) - ? '6' : '.', - !(flags & BATADV_MCAST_WANT_NO_RTR4) - ? "R4" : ". ", - !(flags & BATADV_MCAST_WANT_NO_RTR6) - ? "R6" : ". "); - } - rcu_read_unlock(); - } - - batadv_hardif_put(primary_if); - - return 0; -} -#endif - /** * batadv_mcast_mesh_info_put() - put multicast info into a netlink message * @msg: buffer for the message diff --git a/net/batman-adv/multicast.h b/net/batman-adv/multicast.h index 3e114bc5ca3b..d61593d02072 100644 --- a/net/batman-adv/multicast.h +++ b/net/batman-adv/multicast.h @@ -10,7 +10,6 @@ #include "main.h" #include -#include #include /** @@ -56,8 +55,6 @@ int batadv_mcast_forw_send(struct batadv_priv *bat_priv, struct sk_buff *skb, void batadv_mcast_init(struct batadv_priv *bat_priv); -int batadv_mcast_flags_seq_print_text(struct seq_file *seq, void *offset); - int batadv_mcast_mesh_info_put(struct sk_buff *msg, struct batadv_priv *bat_priv); diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 61ddd6d709a0..0cec108b7a99 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -30,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -39,7 +37,6 @@ #include #include -#include "hard-interface.h" #include "hash.h" #include "log.h" #include "originator.h" @@ -1876,87 +1873,3 @@ void batadv_nc_mesh_free(struct batadv_priv *bat_priv) batadv_nc_purge_paths(bat_priv, bat_priv->nc.decoding_hash, NULL); batadv_hash_destroy(bat_priv->nc.decoding_hash); } - -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_nc_nodes_seq_print_text() - print the nc node information - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_nc_nodes_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hashtable *hash = bat_priv->orig_hash; - struct batadv_hard_iface *primary_if; - struct hlist_head *head; - struct batadv_orig_node *orig_node; - struct batadv_nc_node *nc_node; - int i; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - goto out; - - /* Traverse list of originators */ - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - /* For each orig_node in this bin */ - rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, head, hash_entry) { - /* no need to print the orig node if it does not have - * network coding neighbors - */ - if (list_empty(&orig_node->in_coding_list) && - list_empty(&orig_node->out_coding_list)) - continue; - - seq_printf(seq, "Node: %pM\n", orig_node->orig); - - seq_puts(seq, " Ingoing: "); - /* For each in_nc_node to this orig_node */ - list_for_each_entry_rcu(nc_node, - &orig_node->in_coding_list, - list) - seq_printf(seq, "%pM ", - nc_node->addr); - seq_puts(seq, "\n Outgoing: "); - /* For out_nc_node to this orig_node */ - list_for_each_entry_rcu(nc_node, - &orig_node->out_coding_list, - list) - seq_printf(seq, "%pM ", - nc_node->addr); - seq_puts(seq, "\n\n"); - } - rcu_read_unlock(); - } - -out: - if (primary_if) - batadv_hardif_put(primary_if); - return 0; -} - -/** - * batadv_nc_init_debugfs() - create nc folder and related files in debugfs - * @bat_priv: the bat priv with all the soft interface information - */ -void batadv_nc_init_debugfs(struct batadv_priv *bat_priv) -{ - struct dentry *nc_dir; - - nc_dir = debugfs_create_dir("nc", bat_priv->debug_dir); - - debugfs_create_u8("min_tq", 0644, nc_dir, &bat_priv->nc.min_tq); - - debugfs_create_u32("max_fwd_delay", 0644, nc_dir, - &bat_priv->nc.max_fwd_delay); - - debugfs_create_u32("max_buffer_time", 0644, nc_dir, - &bat_priv->nc.max_buffer_time); -} -#endif diff --git a/net/batman-adv/network-coding.h b/net/batman-adv/network-coding.h index 334289084127..8fb2c01e7837 100644 --- a/net/batman-adv/network-coding.h +++ b/net/batman-adv/network-coding.h @@ -10,7 +10,6 @@ #include "main.h" #include -#include #include #include #include @@ -38,8 +37,6 @@ void batadv_nc_skb_store_for_decoding(struct batadv_priv *bat_priv, struct sk_buff *skb); void batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, struct sk_buff *skb); -int batadv_nc_nodes_seq_print_text(struct seq_file *seq, void *offset); -void batadv_nc_init_debugfs(struct batadv_priv *bat_priv); #else /* ifdef CONFIG_BATMAN_ADV_NC */ @@ -104,16 +101,6 @@ batadv_nc_skb_store_sniffed_unicast(struct batadv_priv *bat_priv, { } -static inline int batadv_nc_nodes_seq_print_text(struct seq_file *seq, - void *offset) -{ - return 0; -} - -static inline void batadv_nc_init_debugfs(struct batadv_priv *bat_priv) -{ -} - #endif /* ifdef CONFIG_BATMAN_ADV_NC */ #endif /* _NET_BATMAN_ADV_NETWORK_CODING_H_ */ diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 805d8969bdfb..77431e59b228 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -733,42 +732,6 @@ batadv_neigh_node_get_or_create(struct batadv_orig_node *orig_node, return batadv_neigh_node_create(orig_node, hard_iface, neigh_addr); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_hardif_neigh_seq_print_text() - print the single hop neighbour list - * @seq: neighbour table seq_file struct - * @offset: not used - * - * Return: always 0 - */ -int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hard_iface *primary_if; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - return 0; - - seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n", - BATADV_SOURCE_VERSION, primary_if->net_dev->name, - primary_if->net_dev->dev_addr, net_dev->name, - bat_priv->algo_ops->name); - - batadv_hardif_put(primary_if); - - if (!bat_priv->algo_ops->neigh.print) { - seq_puts(seq, - "No printing function for this routing protocol\n"); - return 0; - } - - bat_priv->algo_ops->neigh.print(bat_priv, seq); - return 0; -} -#endif - /** * batadv_hardif_neigh_dump() - Dump to netlink the neighbor infos for a * specific outgoing interface @@ -1382,90 +1345,6 @@ static void batadv_purge_orig(struct work_struct *work) msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD)); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - -/** - * batadv_orig_seq_print_text() - Print the originator table in a seq file - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_orig_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hard_iface *primary_if; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - return 0; - - seq_printf(seq, "[B.A.T.M.A.N. adv %s, MainIF/MAC: %s/%pM (%s %s)]\n", - BATADV_SOURCE_VERSION, primary_if->net_dev->name, - primary_if->net_dev->dev_addr, net_dev->name, - bat_priv->algo_ops->name); - - batadv_hardif_put(primary_if); - - if (!bat_priv->algo_ops->orig.print) { - seq_puts(seq, - "No printing function for this routing protocol\n"); - return 0; - } - - bat_priv->algo_ops->orig.print(bat_priv, seq, BATADV_IF_DEFAULT); - - return 0; -} - -/** - * batadv_orig_hardif_seq_print_text() - writes originator infos for a specific - * outgoing interface - * @seq: debugfs table seq_file struct - * @offset: not used - * - * Return: 0 - */ -int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_hard_iface *hard_iface; - struct batadv_priv *bat_priv; - - hard_iface = batadv_hardif_get_by_netdev(net_dev); - - if (!hard_iface || !hard_iface->soft_iface) { - seq_puts(seq, "Interface not known to B.A.T.M.A.N.\n"); - goto out; - } - - bat_priv = netdev_priv(hard_iface->soft_iface); - if (!bat_priv->algo_ops->orig.print) { - seq_puts(seq, - "No printing function for this routing protocol\n"); - goto out; - } - - if (hard_iface->if_status != BATADV_IF_ACTIVE) { - seq_puts(seq, "Interface not active\n"); - goto out; - } - - seq_printf(seq, "[B.A.T.M.A.N. adv %s, IF/MAC: %s/%pM (%s %s)]\n", - BATADV_SOURCE_VERSION, hard_iface->net_dev->name, - hard_iface->net_dev->dev_addr, - hard_iface->soft_iface->name, bat_priv->algo_ops->name); - - bat_priv->algo_ops->orig.print(bat_priv, seq, hard_iface); - -out: - if (hard_iface) - batadv_hardif_put(hard_iface); - return 0; -} -#endif - /** * batadv_orig_dump() - Dump to netlink the originator infos for a specific * outgoing interface diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h index 7bc01c138b3a..e75d4c4d11f5 100644 --- a/net/batman-adv/originator.h +++ b/net/batman-adv/originator.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -46,7 +45,6 @@ batadv_neigh_ifinfo_get(struct batadv_neigh_node *neigh, void batadv_neigh_ifinfo_put(struct batadv_neigh_ifinfo *neigh_ifinfo); int batadv_hardif_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb); -int batadv_hardif_neigh_seq_print_text(struct seq_file *seq, void *offset); struct batadv_orig_ifinfo * batadv_orig_ifinfo_get(struct batadv_orig_node *orig_node, @@ -56,9 +54,7 @@ batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node, struct batadv_hard_iface *if_outgoing); void batadv_orig_ifinfo_put(struct batadv_orig_ifinfo *orig_ifinfo); -int batadv_orig_seq_print_text(struct seq_file *seq, void *offset); int batadv_orig_dump(struct sk_buff *msg, struct netlink_callback *cb); -int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset); struct batadv_orig_node_vlan * batadv_orig_node_vlan_new(struct batadv_orig_node *orig_node, unsigned short vid); diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 9e5c71e406ff..49cbca4aa428 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -29,7 +29,6 @@ #include "distributed-arp-table.h" #include "fragmentation.h" #include "hard-interface.h" -#include "icmp_socket.h" #include "log.h" #include "network-coding.h" #include "originator.h" @@ -227,15 +226,6 @@ static int batadv_recv_my_icmp_packet(struct batadv_priv *bat_priv, icmph = (struct batadv_icmp_header *)skb->data; switch (icmph->msg_type) { - case BATADV_ECHO_REPLY: - case BATADV_DESTINATION_UNREACHABLE: - case BATADV_TTL_EXCEEDED: - /* receive the packet */ - if (skb_linearize(skb) < 0) - break; - - batadv_socket_receive_packet(icmph, skb->len); - break; case BATADV_ECHO_REQUEST: /* answer echo request (ping) */ primary_if = batadv_primary_if_get_selected(bat_priv); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 072b76259bf7..6c6a8c6bab17 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -43,7 +43,6 @@ #include "bat_algo.h" #include "bridge_loop_avoidance.h" -#include "debugfs.h" #include "distributed-arp-table.h" #include "gateway_client.h" #include "hard-interface.h" @@ -823,18 +822,12 @@ static int batadv_softif_init_late(struct net_device *dev) goto free_bat_counters; } - ret = batadv_debugfs_add_meshif(dev); - if (ret < 0) - goto free_bat_counters; - ret = batadv_mesh_init(dev); if (ret < 0) - goto unreg_debugfs; + goto free_bat_counters; return 0; -unreg_debugfs: - batadv_debugfs_del_meshif(dev); free_bat_counters: free_percpu(bat_priv->bat_counters); bat_priv->bat_counters = NULL; @@ -1011,7 +1004,6 @@ static const struct ethtool_ops batadv_ethtool_ops = { */ static void batadv_softif_free(struct net_device *dev) { - batadv_debugfs_del_meshif(dev); batadv_mesh_free(dev); /* some scheduled RCU callbacks need the bat_priv struct to accomplish diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 98a0aaaf0d50..cd09916f97fe 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -1062,84 +1061,6 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) kfree(tt_data); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - -/** - * batadv_tt_local_seq_print_text() - Print the local tt table in a seq file - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hashtable *hash = bat_priv->tt.local_hash; - struct batadv_tt_common_entry *tt_common_entry; - struct batadv_tt_local_entry *tt_local; - struct batadv_hard_iface *primary_if; - struct hlist_head *head; - u32 i; - int last_seen_secs; - int last_seen_msecs; - unsigned long last_seen_jiffies; - bool no_purge; - u16 np_flag = BATADV_TT_CLIENT_NOPURGE; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - goto out; - - seq_printf(seq, - "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", - net_dev->name, (u8)atomic_read(&bat_priv->tt.vn)); - seq_puts(seq, - " Client VID Flags Last seen (CRC )\n"); - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(tt_common_entry, - head, hash_entry) { - tt_local = container_of(tt_common_entry, - struct batadv_tt_local_entry, - common); - last_seen_jiffies = jiffies - tt_local->last_seen; - last_seen_msecs = jiffies_to_msecs(last_seen_jiffies); - last_seen_secs = last_seen_msecs / 1000; - last_seen_msecs = last_seen_msecs % 1000; - - no_purge = tt_common_entry->flags & np_flag; - seq_printf(seq, - " * %pM %4i [%c%c%c%c%c%c] %3u.%03u (%#.8x)\n", - tt_common_entry->addr, - batadv_print_vid(tt_common_entry->vid), - ((tt_common_entry->flags & - BATADV_TT_CLIENT_ROAM) ? 'R' : '.'), - no_purge ? 'P' : '.', - ((tt_common_entry->flags & - BATADV_TT_CLIENT_NEW) ? 'N' : '.'), - ((tt_common_entry->flags & - BATADV_TT_CLIENT_PENDING) ? 'X' : '.'), - ((tt_common_entry->flags & - BATADV_TT_CLIENT_WIFI) ? 'W' : '.'), - ((tt_common_entry->flags & - BATADV_TT_CLIENT_ISOLA) ? 'I' : '.'), - no_purge ? 0 : last_seen_secs, - no_purge ? 0 : last_seen_msecs, - tt_local->vlan->tt.crc); - } - rcu_read_unlock(); - } -out: - if (primary_if) - batadv_hardif_put(primary_if); - return 0; -} -#endif - /** * batadv_tt_local_dump_entry() - Dump one TT local entry into a message * @msg :Netlink message to dump into @@ -1879,139 +1800,6 @@ batadv_transtable_best_orig(struct batadv_priv *bat_priv, return best_entry; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_tt_global_print_entry() - print all orig nodes who announce the - * address for this global entry - * @bat_priv: the bat priv with all the soft interface information - * @tt_global_entry: global translation table entry to be printed - * @seq: debugfs table seq_file struct - * - * This function assumes the caller holds rcu_read_lock(). - */ -static void -batadv_tt_global_print_entry(struct batadv_priv *bat_priv, - struct batadv_tt_global_entry *tt_global_entry, - struct seq_file *seq) -{ - struct batadv_tt_orig_list_entry *orig_entry, *best_entry; - struct batadv_tt_common_entry *tt_common_entry; - struct batadv_orig_node_vlan *vlan; - struct hlist_head *head; - u8 last_ttvn; - u16 flags; - - tt_common_entry = &tt_global_entry->common; - flags = tt_common_entry->flags; - - best_entry = batadv_transtable_best_orig(bat_priv, tt_global_entry); - if (best_entry) { - vlan = batadv_orig_node_vlan_get(best_entry->orig_node, - tt_common_entry->vid); - if (!vlan) { - seq_printf(seq, - " * Cannot retrieve VLAN %d for originator %pM\n", - batadv_print_vid(tt_common_entry->vid), - best_entry->orig_node->orig); - goto print_list; - } - - last_ttvn = atomic_read(&best_entry->orig_node->last_ttvn); - seq_printf(seq, - " %c %pM %4i (%3u) via %pM (%3u) (%#.8x) [%c%c%c%c]\n", - '*', tt_global_entry->common.addr, - batadv_print_vid(tt_global_entry->common.vid), - best_entry->ttvn, best_entry->orig_node->orig, - last_ttvn, vlan->tt.crc, - ((flags & BATADV_TT_CLIENT_ROAM) ? 'R' : '.'), - ((flags & BATADV_TT_CLIENT_WIFI) ? 'W' : '.'), - ((flags & BATADV_TT_CLIENT_ISOLA) ? 'I' : '.'), - ((flags & BATADV_TT_CLIENT_TEMP) ? 'T' : '.')); - - batadv_orig_node_vlan_put(vlan); - } - -print_list: - head = &tt_global_entry->orig_list; - - hlist_for_each_entry_rcu(orig_entry, head, list) { - if (best_entry == orig_entry) - continue; - - vlan = batadv_orig_node_vlan_get(orig_entry->orig_node, - tt_common_entry->vid); - if (!vlan) { - seq_printf(seq, - " + Cannot retrieve VLAN %d for originator %pM\n", - batadv_print_vid(tt_common_entry->vid), - orig_entry->orig_node->orig); - continue; - } - - last_ttvn = atomic_read(&orig_entry->orig_node->last_ttvn); - seq_printf(seq, - " %c %pM %4d (%3u) via %pM (%3u) (%#.8x) [%c%c%c%c]\n", - '+', tt_global_entry->common.addr, - batadv_print_vid(tt_global_entry->common.vid), - orig_entry->ttvn, orig_entry->orig_node->orig, - last_ttvn, vlan->tt.crc, - ((flags & BATADV_TT_CLIENT_ROAM) ? 'R' : '.'), - ((flags & BATADV_TT_CLIENT_WIFI) ? 'W' : '.'), - ((flags & BATADV_TT_CLIENT_ISOLA) ? 'I' : '.'), - ((flags & BATADV_TT_CLIENT_TEMP) ? 'T' : '.')); - - batadv_orig_node_vlan_put(vlan); - } -} - -/** - * batadv_tt_global_seq_print_text() - Print the global tt table in a seq file - * @seq: seq file to print on - * @offset: not used - * - * Return: always 0 - */ -int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_priv *bat_priv = netdev_priv(net_dev); - struct batadv_hashtable *hash = bat_priv->tt.global_hash; - struct batadv_tt_common_entry *tt_common_entry; - struct batadv_tt_global_entry *tt_global; - struct batadv_hard_iface *primary_if; - struct hlist_head *head; - u32 i; - - primary_if = batadv_seq_print_text_primary_if_get(seq); - if (!primary_if) - goto out; - - seq_printf(seq, - "Globally announced TT entries received via the mesh %s\n", - net_dev->name); - seq_puts(seq, - " Client VID (TTVN) Originator (Curr TTVN) (CRC ) Flags\n"); - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(tt_common_entry, - head, hash_entry) { - tt_global = container_of(tt_common_entry, - struct batadv_tt_global_entry, - common); - batadv_tt_global_print_entry(bat_priv, tt_global, seq); - } - rcu_read_unlock(); - } -out: - if (primary_if) - batadv_hardif_put(primary_if); - return 0; -} -#endif - /** * batadv_tt_global_dump_subentry() - Dump all TT local entries into a message * @msg: Netlink message to dump into diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h index b24d35b9226a..57192c817229 100644 --- a/net/batman-adv/translation-table.h +++ b/net/batman-adv/translation-table.h @@ -11,7 +11,6 @@ #include #include -#include #include #include @@ -21,8 +20,6 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr, u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr, unsigned short vid, const char *message, bool roaming); -int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset); -int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset); int batadv_tt_local_dump(struct sk_buff *msg, struct netlink_callback *cb); int batadv_tt_global_dump(struct sk_buff *msg, struct netlink_callback *cb); void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 7cfe3081039e..2f96e96a5ca4 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -21,7 +21,6 @@ #include #include #include /* for linux/wait.h */ -#include #include #include #include @@ -219,13 +218,6 @@ struct batadv_hard_iface { struct batadv_hard_iface_bat_v bat_v; #endif -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - /** - * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs - */ - struct dentry *debug_dir; -#endif - /** * @neigh_list: list of unique single hop neighbors via this interface */ @@ -1303,13 +1295,6 @@ struct batadv_priv_nc { /** @work: work queue callback item for cleanup */ struct delayed_work work; -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - /** - * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs - */ - struct dentry *debug_dir; -#endif - /** * @min_tq: only consider neighbors for encoding if neigh_tq > min_tq */ @@ -1661,11 +1646,6 @@ struct batadv_priv { /** @batman_queue_left: number of remaining OGM packet slots */ atomic_t batman_queue_left; -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - /** @debug_dir: dentry for debugfs batman-adv subdirectory */ - struct dentry *debug_dir; -#endif - /** @forw_bat_list: list of aggregated OGMs that will be forwarded */ struct hlist_head forw_bat_list; @@ -2225,11 +2205,6 @@ struct batadv_algo_neigh_ops { struct batadv_neigh_node *neigh2, struct batadv_hard_iface *if_outgoing2); -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - /** @print: print the single hop neighbor list (optional) */ - void (*print)(struct batadv_priv *priv, struct seq_file *seq); -#endif - /** @dump: dump neighbors to a netlink socket (optional) */ void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, struct batadv_priv *priv, @@ -2240,12 +2215,6 @@ struct batadv_algo_neigh_ops { * struct batadv_algo_orig_ops - mesh algorithm callbacks (originator specific) */ struct batadv_algo_orig_ops { -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - /** @print: print the originator table (optional) */ - void (*print)(struct batadv_priv *priv, struct seq_file *seq, - struct batadv_hard_iface *hard_iface); -#endif - /** @dump: dump originators to a netlink socket (optional) */ void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, struct batadv_priv *priv, @@ -2280,11 +2249,6 @@ struct batadv_algo_gw_ops { struct batadv_orig_node *curr_gw_orig, struct batadv_orig_node *orig_node); -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - /** @print: print the gateway table (optional) */ - void (*print)(struct batadv_priv *bat_priv, struct seq_file *seq); -#endif - /** @dump: dump gateways to a netlink socket (optional) */ void (*dump)(struct sk_buff *msg, struct netlink_callback *cb, struct batadv_priv *priv); From patchwork Fri Dec 4 15:46:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18239 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id 24ED182655; Fri, 4 Dec 2020 16:55:49 +0100 (CET) Received: from simonwunderlich.de (packetmixer.de [IPv6:2001:4d88:2000:24::c0de]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 170A581A84 for ; Fri, 4 Dec 2020 16:55:08 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id D47AC174066; Fri, 4 Dec 2020 16:46:35 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 7/8] batman-adv: Drop legacy code for auto deleting mesh interfaces Date: Fri, 4 Dec 2020 16:46:30 +0100 Message-Id: <20201204154631.21063-8-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aJPzlXjBYK4eAF04N+xWnJpfMf8E7pH0dI1VfVhE9IM=; b=Xz6kuaxYRk1QsJN5VXqUYLpX5W3zgqq46NkdD2BbCxvvzKthQlXAWOhlmMXUaj+4h77YZs BXatapRGOWn646it2kpoZWQ+fUs+n+gkko30D+udOZxhMD+6xZxUIraL/etN9yXMlKHULM CbGpmksN4Wk72GgOLbTPocBU9HPzyCA= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097308; a=rsa-sha256; cv=none; b=CLNNjXDsk84nzMhqD326o6tBfqHJ8J0bf8O6fotWWIR0n7Ri8wf11JlO9pv4elAf+vcyZN uyozTzASwTGMxfvTSxkIkdc4vnzPJq7EiG30kuxhEKmr2RW2yioNjg4c39EKEbK9qWXBJo eNRel1ENvmlcJiw7fPeNMEcSV7RiUpY= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 2001:4d88:2000:24::c0de as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: U4ER5T6HPP7TL2ERCPECSCAGHMHA5R3N X-Message-ID-Hash: U4ER5T6HPP7TL2ERCPECSCAGHMHA5R3N X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Sven Eckelmann The only way to automatically drop batadv mesh interfaces when all soft interfaces were removed was dropped with the sysfs support. It is no longer needed to have them handled by kernel anymore. Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/hard-interface.c | 8 ++------ net/batman-adv/hard-interface.h | 19 +------------------ net/batman-adv/soft-interface.c | 5 ++--- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index bbedb9a422c0..0f186ddc15e3 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -845,11 +845,8 @@ static size_t batadv_hardif_cnt(const struct net_device *soft_iface) /** * batadv_hardif_disable_interface() - Remove hard interface from soft interface * @hard_iface: hard interface to be removed - * @autodel: whether to delete soft interface when it doesn't contain any other - * slave interfaces */ -void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, - enum batadv_hard_if_cleanup autodel) +void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface) { struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); struct batadv_hard_iface *primary_if = NULL; @@ -953,8 +950,7 @@ static void batadv_hardif_remove_interface(struct batadv_hard_iface *hard_iface) /* first deactivate interface */ if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) - batadv_hardif_disable_interface(hard_iface, - BATADV_IF_CLEANUP_KEEP); + batadv_hardif_disable_interface(hard_iface); if (hard_iface->if_status != BATADV_IF_NOT_IN_USE) return; diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h index 1ee45b615399..f4b8e9efef19 100644 --- a/net/batman-adv/hard-interface.h +++ b/net/batman-adv/hard-interface.h @@ -67,22 +67,6 @@ enum batadv_hard_if_bcast { BATADV_HARDIF_BCAST_DUPORIG, }; -/** - * enum batadv_hard_if_cleanup - Cleanup modi for soft_iface after slave removal - */ -enum batadv_hard_if_cleanup { - /** - * @BATADV_IF_CLEANUP_KEEP: Don't automatically delete soft-interface - */ - BATADV_IF_CLEANUP_KEEP, - - /** - * @BATADV_IF_CLEANUP_AUTO: Delete soft-interface after last slave was - * removed - */ - BATADV_IF_CLEANUP_AUTO, -}; - extern struct notifier_block batadv_hard_if_notifier; struct net_device *batadv_get_real_netdev(struct net_device *net_device); @@ -92,8 +76,7 @@ struct batadv_hard_iface* batadv_hardif_get_by_netdev(const struct net_device *net_dev); int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface, struct net *net, const char *iface_name); -void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface, - enum batadv_hard_if_cleanup autodel); +void batadv_hardif_disable_interface(struct batadv_hard_iface *hard_iface); int batadv_hardif_min_mtu(struct net_device *soft_iface); void batadv_update_min_mtu(struct net_device *soft_iface); void batadv_hardif_release(struct kref *ref); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 6c6a8c6bab17..97118efbe678 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -881,7 +881,7 @@ static int batadv_softif_slave_del(struct net_device *dev, if (!hard_iface || hard_iface->soft_iface != dev) goto out; - batadv_hardif_disable_interface(hard_iface, BATADV_IF_CLEANUP_KEEP); + batadv_hardif_disable_interface(hard_iface); ret = 0; out: @@ -1139,8 +1139,7 @@ static void batadv_softif_destroy_netlink(struct net_device *soft_iface, list_for_each_entry(hard_iface, &batadv_hardif_list, list) { if (hard_iface->soft_iface == soft_iface) - batadv_hardif_disable_interface(hard_iface, - BATADV_IF_CLEANUP_KEEP); + batadv_hardif_disable_interface(hard_iface); } /* destroy the "untagged" VLAN */ From patchwork Fri Dec 4 15:46:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 18233 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from diktynna.open-mesh.org (localhost [IPv6:::1]) by diktynna.open-mesh.org (Postfix) with ESMTP id D06B78263C; Fri, 4 Dec 2020 16:55:16 +0100 (CET) Received: from simonwunderlich.de (packetmixer.de [IPv6:2001:4d88:2000:24::c0de]) by diktynna.open-mesh.org (Postfix) with ESMTPS id 8D066809F8 for ; Fri, 4 Dec 2020 16:55:07 +0100 (CET) Received: from kero.packetmixer.de (p200300c59716c1e0c1b6a3b925be22c4.dip0.t-ipconnect.de [IPv6:2003:c5:9716:c1e0:c1b6:a3b9:25be:22c4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 41B8B174067; Fri, 4 Dec 2020 16:46:36 +0100 (CET) From: Simon Wunderlich To: davem@davemloft.net, kuba@kernel.org Subject: [PATCH 8/8] batman-adv: Drop unused soft-interface.h include in fragmentation.c Date: Fri, 4 Dec 2020 16:46:31 +0100 Message-Id: <20201204154631.21063-9-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201204154631.21063-1-sw@simonwunderlich.de> References: <20201204154631.21063-1-sw@simonwunderlich.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh.org; s=20121; t=1607097307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T/ZwBxbw6TSnrnHZqgYlEL/yonj1m0BTV1EosbYghT8=; b=g8BgVKqwzmv+/+pIuX1FkLG7eU9Bz1B9PzFj+ExiMsqXXVuTFF8PGs3ERBODDTzfOVFsYw mzw8FW07HEQSVadGo2UhDZknr/UzKsUVtwi0sEiCZ09HGH7Rt5OnCQtbWRrNJNTM5flhmL a640KwTW12VVPI5WSWKP7Jl/7o9zYw0= ARC-Seal: i=1; s=20121; d=open-mesh.org; t=1607097307; a=rsa-sha256; cv=none; b=c1Si40yOTGIPshNVU2/TUrWsJG4R4N3vfYLNaBrsQ5zDEu/Mnyc7UBsR1MI2zwjzQHyEcY yVlH1CaL3jMSl/d0IZ4a557CFnkv3g739bi8yjyc+hEunYVVlnN6Uw16li10s+BXE0t0FQ mEGYRGOb96rau4ifQigbOWlAlYMHWOY= ARC-Authentication-Results: i=1; diktynna.open-mesh.org; dkim=none; spf=pass (diktynna.open-mesh.org: domain of sw@simonwunderlich.de designates 2001:4d88:2000:24::c0de as permitted sender) smtp.mailfrom=sw@simonwunderlich.de Message-ID-Hash: KUJGFVHMCYRMOI2OAUVDCRDOKQJE5F7A X-Message-ID-Hash: KUJGFVHMCYRMOI2OAUVDCRDOKQJE5F7A X-MailFrom: sw@simonwunderlich.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-b.a.t.m.a.n.lists.open-mesh.org-0; header-match-b.a.t.m.a.n.lists.open-mesh.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 3.2.1 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The commit 992b03b88e36 ("batman-adv: Don't always reallocate the fragmentation skb head") removed the last user of functions from soft-interface.h. Signed-off-by: Simon Wunderlich --- net/batman-adv/fragmentation.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index 59ebd73125bf..e522f1fcfd9a 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -27,7 +27,6 @@ #include "originator.h" #include "routing.h" #include "send.h" -#include "soft-interface.h" /** * batadv_frag_clear_chain() - delete entries in the fragment buffer chain