Message ID | 20241211072223.87370-1-f.pfitzner@pengutronix.de (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Stephen Hemminger |
Headers | show |
Series | [v4,iproute] bridge: dump mcast querier state | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
Forgot to mention the Acked-by from [1] in the trailer: Acked-by: Nikolay Aleksandrov <razor@blackwall.org> [1] https://lore.kernel.org/netdev/12a687d5-cc87-4993-aec2-07ea799ce334@blackwall.org/#t On 11.12.24 08:22, 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@pengutronix.de> > --- > > v1->v2 > - refactor code > - link to v1: https://lore.kernel.org/netdev/20241025142836.19946-1-f.pfitzner@pengutronix.de/ > v2->v3 > - use print_color_string for addresses > - link to v2: https://lore.kernel.org/netdev/20241030222136.3395120-1-f.pfitzner@pengutronix.de/ > v3->v4 > - drop new line between bqtb and other_time declarations > - link to v3: https://lore.kernel.org/netdev/20241101115039.2604631-1-f.pfitzner@pengutronix.de/ > > ip/iplink_bridge.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 59 insertions(+) > > diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c > index f01ffe15..1fe89551 100644 > --- a/ip/iplink_bridge.c > +++ b/ip/iplink_bridge.c > @@ -661,6 +661,65 @@ 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_FP, > + NULL, > + "%s ", > + "mcast_querier_ipv4_addr"); > + print_color_string(PRINT_ANY, > + COLOR_INET, > + "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_FP, > + NULL, > + "%s ", > + "mcast_querier_ipv6_addr"); > + print_color_string(PRINT_ANY, > + COLOR_INET6, > + "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", > -- > 2.39.5 > > >
On 12/12/24 12:46, Fabian Pfitzner wrote: > Forgot to mention the Acked-by from [1] in the trailer: > > Acked-by: Nikolay Aleksandrov <razor@blackwall.org> > > [1] https://lore.kernel.org/netdev/12a687d5-cc87-4993-aec2-07ea799ce334@blackwall.org/#t > Please don't send separate acks on behalf of other people. I was going to ack the patch again. Also please don't top post on netdev. Thanks, Acked-by: Nikolay Aleksandrov <razor@blackwall.org> > On 11.12.24 08:22, 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@pengutronix.de> >> --- >> >> v1->v2 >> - refactor code >> - link to v1: https://lore.kernel.org/netdev/20241025142836.19946-1-f.pfitzner@pengutronix.de/ >> v2->v3 >> - use print_color_string for addresses >> - link to v2: https://lore.kernel.org/netdev/20241030222136.3395120-1-f.pfitzner@pengutronix.de/ >> v3->v4 >> - drop new line between bqtb and other_time declarations >> - link to v3: https://lore.kernel.org/netdev/20241101115039.2604631-1-f.pfitzner@pengutronix.de/ >> >> ip/iplink_bridge.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 59 insertions(+) >> >> diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c >> index f01ffe15..1fe89551 100644 >> --- a/ip/iplink_bridge.c >> +++ b/ip/iplink_bridge.c >> @@ -661,6 +661,65 @@ 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_FP, >> + NULL, >> + "%s ", >> + "mcast_querier_ipv4_addr"); >> + print_color_string(PRINT_ANY, >> + COLOR_INET, >> + "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_FP, >> + NULL, >> + "%s ", >> + "mcast_querier_ipv6_addr"); >> + print_color_string(PRINT_ANY, >> + COLOR_INET6, >> + "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", >> -- >> 2.39.5 >> >> >>
diff --git a/ip/iplink_bridge.c b/ip/iplink_bridge.c index f01ffe15..1fe89551 100644 --- a/ip/iplink_bridge.c +++ b/ip/iplink_bridge.c @@ -661,6 +661,65 @@ 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_FP, + NULL, + "%s ", + "mcast_querier_ipv4_addr"); + print_color_string(PRINT_ANY, + COLOR_INET, + "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_FP, + NULL, + "%s ", + "mcast_querier_ipv6_addr"); + print_color_string(PRINT_ANY, + COLOR_INET6, + "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",
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@pengutronix.de> --- v1->v2 - refactor code - link to v1: https://lore.kernel.org/netdev/20241025142836.19946-1-f.pfitzner@pengutronix.de/ v2->v3 - use print_color_string for addresses - link to v2: https://lore.kernel.org/netdev/20241030222136.3395120-1-f.pfitzner@pengutronix.de/ v3->v4 - drop new line between bqtb and other_time declarations - link to v3: https://lore.kernel.org/netdev/20241101115039.2604631-1-f.pfitzner@pengutronix.de/ ip/iplink_bridge.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) -- 2.39.5