* [PATCH v2 iproute] bridge: dump mcast querier state
@ 2024-10-30  8:46 Fabian Pfitzner
  2024-10-30 15:23 ` Stephen Hemminger
  2024-10-30 15:29 ` Nikolay Aleksandrov
  0 siblings, 2 replies; 7+ messages in thread
From: Fabian Pfitzner @ 2024-10-30  8:46 UTC (permalink / raw)
  To: netdev; +Cc: entwicklung, bridge, Fabian Pfitzner
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
 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",
-- 
2.39.5
^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH v2 iproute] bridge: dump mcast querier state
  2024-10-30  8:46 Fabian Pfitzner
@ 2024-10-30 15:23 ` Stephen Hemminger
  2024-10-30 15:29 ` Nikolay Aleksandrov
  1 sibling, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2024-10-30 15:23 UTC (permalink / raw)
  To: Fabian Pfitzner; +Cc: netdev, entwicklung, bridge
On Wed, 30 Oct 2024 09:46:23 +0100
Fabian Pfitzner <f.pfitzner@pengutronix.de> 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
> 
>  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]))
Would be good to use print_color_string here. 
^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH v2 iproute] bridge: dump mcast querier state
  2024-10-30  8:46 Fabian Pfitzner
  2024-10-30 15:23 ` Stephen Hemminger
@ 2024-10-30 15:29 ` Nikolay Aleksandrov
  2024-10-30 22:10   ` Fabian Pfitzner
  1 sibling, 1 reply; 7+ messages in thread
From: Nikolay Aleksandrov @ 2024-10-30 15:29 UTC (permalink / raw)
  To: Fabian Pfitzner, netdev; +Cc: entwicklung, bridge
On 30/10/2024 10:46, 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
> 
>  ip/iplink_bridge.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
For the second time(!), please CC maintainers because it's very easy to
miss a patch. In addition to maintainers, please CC reviewers of previous
versions as well.
Thank you,
 Nik
^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH v2 iproute] bridge: dump mcast querier state
  2024-10-30 15:29 ` Nikolay Aleksandrov
@ 2024-10-30 22:10   ` Fabian Pfitzner
  2024-10-31  8:44     ` Nikolay Aleksandrov
  0 siblings, 1 reply; 7+ messages in thread
From: Fabian Pfitzner @ 2024-10-30 22:10 UTC (permalink / raw)
  To: Nikolay Aleksandrov, netdev; +Cc: bridge, entwicklung
> For the second time(!), please CC maintainers because it's very easy to
> miss a patch. In addition to maintainers, please CC reviewers of previous
> versions as well.
Could you please tell me at which mail addresses I should send the patch?
You said that I should send it to "the bridge maintainers" as well, so I 
put "bridge@lists.linux-foundation.org" into the CC this time.
On 10/30/24 4:29 PM, Nikolay Aleksandrov wrote:
> On 30/10/2024 10:46, 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
>>
>>   ip/iplink_bridge.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 47 insertions(+)
>>
> For the second time(!), please CC maintainers because it's very easy to
> miss a patch. In addition to maintainers, please CC reviewers of previous
> versions as well.
>
> Thank you,
>   Nik
>
>
>
^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH v2 iproute] bridge: dump mcast querier state
@ 2024-10-30 22:21 Fabian Pfitzner
  2024-10-31  0:41 ` Stephen Hemminger
  0 siblings, 1 reply; 7+ messages in thread
From: Fabian Pfitzner @ 2024-10-30 22:21 UTC (permalink / raw)
  To: netdev; +Cc: entwicklung, dsahern, roopa, razor, bridge, Fabian Pfitzner
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
 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",
-- 
2.39.5
^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH v2 iproute] bridge: dump mcast querier state
  2024-10-30 22:21 [PATCH v2 iproute] bridge: dump mcast querier state Fabian Pfitzner
@ 2024-10-31  0:41 ` Stephen Hemminger
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2024-10-31  0:41 UTC (permalink / raw)
  To: Fabian Pfitzner; +Cc: netdev, entwicklung, dsahern, roopa, razor, bridge
On Wed, 30 Oct 2024 23:21:36 +0100
Fabian Pfitzner <f.pfitzner@pengutronix.de> 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>
Use print_color_string for printing addresses; to be consistent with other code
^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH v2 iproute] bridge: dump mcast querier state
  2024-10-30 22:10   ` Fabian Pfitzner
@ 2024-10-31  8:44     ` Nikolay Aleksandrov
  0 siblings, 0 replies; 7+ messages in thread
From: Nikolay Aleksandrov @ 2024-10-31  8:44 UTC (permalink / raw)
  To: Fabian Pfitzner, netdev; +Cc: bridge, entwicklung
On 31/10/2024 00:10, Fabian Pfitzner wrote:
>> For the second time(!), please CC maintainers because it's very easy to
>> miss a patch. In addition to maintainers, please CC reviewers of previous
>> versions as well.
> Could you please tell me at which mail addresses I should send the patch?
> You said that I should send it to "the bridge maintainers" as well, so I put "bridge@lists.linux-foundation.org" into the CC this time.
> 
from iproute2/MAINTAINERS file:
 Ethernet Bridging - bridge
 M: Roopa Prabhu <roopa@nvidia.com>
 M: Nikolay Aleksandrov <razor@blackwall.org>
 L: bridge@lists.linux-foundation.org (moderated for non-subscribers)
 F: bridge/*
Unrelated - I just noticed we have to add a few more F: lines there, I'll send a patch.
In addition to maintainers, please always add reviewers of previous patch versions.
Cheers,
 Nik
> On 10/30/24 4:29 PM, Nikolay Aleksandrov wrote:
>> On 30/10/2024 10:46, 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
>>>
>>>   ip/iplink_bridge.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++
>>>   1 file changed, 47 insertions(+)
>>>
>> For the second time(!), please CC maintainers because it's very easy to
>> miss a patch. In addition to maintainers, please CC reviewers of previous
>> versions as well.
>>
>> Thank you,
>>   Nik
>>
>>
>>
^ permalink raw reply	[flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-31  8:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 22:21 [PATCH v2 iproute] bridge: dump mcast querier state Fabian Pfitzner
2024-10-31  0:41 ` Stephen Hemminger
  -- strict thread matches above, loose matches on Subject: below --
2024-10-30  8:46 Fabian Pfitzner
2024-10-30 15:23 ` Stephen Hemminger
2024-10-30 15:29 ` Nikolay Aleksandrov
2024-10-30 22:10   ` Fabian Pfitzner
2024-10-31  8:44     ` Nikolay Aleksandrov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).