From patchwork Wed Oct 30 22:21:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabian Pfitzner X-Patchwork-Id: 13857267 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8A871946A0 for ; Wed, 30 Oct 2024 22:23:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730327013; cv=none; b=rKbUlbKNQpa8OtPtMwfB+71T2cDstZQE7DzJJsXzRf8KOA2Nq4kDt/DnpiaSqN7yHtEiVY7IwlIhVAjtYmgm6n9gjq8EvMd3MTjMJXhUkx2yY8/awq+LwZ4hzKhHvGhZ3copAiT99n38oBhcgEc9nJTXXHaMSD2N5hsa0MEO1/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730327013; c=relaxed/simple; bh=7X+BkPWVY3jrDds8UbTE1K7ELbI+fgW1NyOMDM+42sI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Sf/UjjO3j74V8rsbo9nxB4tsI4LY5e/jdaOO+utZWVPPWCTAF/SX7+YP8r9XW81QVvBezlKBbKXMFo6br1zWaAO4FZu2M68eqopF7+ujQBCkU2/Nb1seYcKzSkNWN7Ac2aJ974oLQDM4x5esiGykQEWQYT6hZpkL+80Kzp8RTDs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1t6H64-0007Ca-F3; Wed, 30 Oct 2024 23:23:24 +0100 Received: from dude05.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::54]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1t6H63-001GUb-3C; Wed, 30 Oct 2024 23:23:24 +0100 Received: from fpf by dude05.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1t6H63-00EFEz-32; Wed, 30 Oct 2024 23:23:23 +0100 From: Fabian Pfitzner To: netdev@vger.kernel.org Cc: entwicklung@pengutronix.de, dsahern@gmail.com, roopa@nvidia.com, razor@blackwall.org, bridge@lists.linux-foundation.org, Fabian Pfitzner Subject: [PATCH v2 iproute] bridge: dump mcast querier state Date: Wed, 30 Oct 2024 23:21:36 +0100 Message-Id: <20241030222136.3395120-1-f.pfitzner@pengutronix.de> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: fpf@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Kernel support for dumping the multicast querier state was added in this commit [1]. As some people might be interested to get this information from userspace, this commit implements the necessary changes to show it via ip -d link show [dev] The querier state shows the following information for IPv4 and IPv6 respectively: 1) The ip address of the current querier in the network. This could be ourselves or an external querier. 2) The port on which the querier was seen 3) Querier timeout in seconds [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c7fa1d9b1fb179375e889ff076a1566ecc997bfc Signed-off-by: Fabian Pfitzner --- v1->v2: refactor code ip/iplink_bridge.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c index f01ffe15..f74436d3 100644 --- a/ip/iplink_bridge.c +++ b/ip/iplink_bridge.c @@ -661,6 +661,53 @@ static void bridge_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) "mcast_querier %u ", rta_getattr_u8(tb[IFLA_BR_MCAST_QUERIER])); + if (tb[IFLA_BR_MCAST_QUERIER_STATE]) { + struct rtattr *bqtb[BRIDGE_QUERIER_MAX + 1]; + SPRINT_BUF(other_time); + + parse_rtattr_nested(bqtb, BRIDGE_QUERIER_MAX, tb[IFLA_BR_MCAST_QUERIER_STATE]); + memset(other_time, 0, sizeof(other_time)); + + open_json_object("mcast_querier_state_ipv4"); + if (bqtb[BRIDGE_QUERIER_IP_ADDRESS]) + print_string(PRINT_ANY, + "mcast_querier_ipv4_addr", + "mcast_querier_ipv4_addr %s ", + format_host_rta(AF_INET, bqtb[BRIDGE_QUERIER_IP_ADDRESS])); + if (bqtb[BRIDGE_QUERIER_IP_PORT]) + print_uint(PRINT_ANY, + "mcast_querier_ipv4_port", + "mcast_querier_ipv4_port %u ", + rta_getattr_u32(bqtb[BRIDGE_QUERIER_IP_PORT])); + if (bqtb[BRIDGE_QUERIER_IP_OTHER_TIMER]) + print_string(PRINT_ANY, + "mcast_querier_ipv4_other_timer", + "mcast_querier_ipv4_other_timer %s ", + sprint_time64( + rta_getattr_u64(bqtb[BRIDGE_QUERIER_IP_OTHER_TIMER]), + other_time)); + close_json_object(); + open_json_object("mcast_querier_state_ipv6"); + if (bqtb[BRIDGE_QUERIER_IPV6_ADDRESS]) + print_string(PRINT_ANY, + "mcast_querier_ipv6_addr", + "mcast_querier_ipv6_addr %s ", + format_host_rta(AF_INET6, bqtb[BRIDGE_QUERIER_IPV6_ADDRESS])); + if (bqtb[BRIDGE_QUERIER_IPV6_PORT]) + print_uint(PRINT_ANY, + "mcast_querier_ipv6_port", + "mcast_querier_ipv6_port %u ", + rta_getattr_u32(bqtb[BRIDGE_QUERIER_IPV6_PORT])); + if (bqtb[BRIDGE_QUERIER_IPV6_OTHER_TIMER]) + print_string(PRINT_ANY, + "mcast_querier_ipv6_other_timer", + "mcast_querier_ipv6_other_timer %s ", + sprint_time64( + rta_getattr_u64(bqtb[BRIDGE_QUERIER_IPV6_OTHER_TIMER]), + other_time)); + close_json_object(); + } + if (tb[IFLA_BR_MCAST_HASH_ELASTICITY]) print_uint(PRINT_ANY, "mcast_hash_elasticity",