[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8241100a-dd0d-4a74-9360-527a93282642@blackwall.org>
Date: Fri, 25 Oct 2024 17:40:28 +0300
From: Nikolay Aleksandrov <razor@...ckwall.org>
To: Fabian Pfitzner <f.pfitzner@...gutronix.de>, netdev@...r.kernel.org
Cc: entwicklung@...gutronix.de
Subject: Re: [PATCH iproute] bridge: dump mcast querier state
On 25/10/2024 17:28, Fabian Pfitzner wrote:
> 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 <f.pfitzner@...gutronix.de>
> ---
> ip/iplink_bridge.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
Please CC bridge maintainers for bridge patches.
That being said, thank you! I've had a similar patch in my tree forever
and didn't get to upstream it after I added the querier state dump. :)
A few minor nits below,
> diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c
> index f01ffe15..fb92a498 100644
> --- a/ip/iplink_bridge.c
> +++ b/ip/iplink_bridge.c
> @@ -661,6 +661,54 @@ 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]) {
> + SPRINT_BUF(other_time);
> + memset(other_time, 0, sizeof(other_time));
Move this memset below, please don't mix declarations and code.
> +
> + struct rtattr *bqtb[BRIDGE_QUERIER_MAX + 1];
Please declare the local variables at the start of the block.
> +
> + parse_rtattr_nested(bqtb, BRIDGE_QUERIER_MAX, tb[IFLA_BR_MCAST_QUERIER_STATE]);
> +
> + 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",
Powered by blists - more mailing lists