All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next] f_flower: simplify cfm dump function
@ 2023-06-29 19:57 Zahari Doychev
  2023-06-30 11:22 ` Petr Machata
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Zahari Doychev @ 2023-06-29 19:57 UTC (permalink / raw)
  To: netdev
  Cc: dsahern, stephen, hmehrtens, aleksander.lobakin, simon.horman,
	idosch, Zahari Doychev

From: Zahari Doychev <zdoychev@maxlinear.com>

The standard print function can be used to print the cfm attributes in
both standard and json use cases. In this way no string buffer is needed
which simplifies the code.

Signed-off-by: Zahari Doychev <zdoychev@maxlinear.com>
---
 tc/f_flower.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/tc/f_flower.c b/tc/f_flower.c
index 6da5028a..c71394f7 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -2816,9 +2816,6 @@ static void flower_print_arp_op(const char *name,
 static void flower_print_cfm(struct rtattr *attr)
 {
 	struct rtattr *tb[TCA_FLOWER_KEY_CFM_OPT_MAX + 1];
-	struct rtattr *v;
-	SPRINT_BUF(out);
-	size_t sz = 0;
 
 	if (!attr || !(attr->rta_type & NLA_F_NESTED))
 		return;
@@ -2830,20 +2827,15 @@ static void flower_print_cfm(struct rtattr *attr)
 	print_string(PRINT_FP, NULL, "  cfm", NULL);
 	open_json_object("cfm");
 
-	v = tb[TCA_FLOWER_KEY_CFM_MD_LEVEL];
-	if (v) {
-		sz += sprintf(out, " mdl %u", rta_getattr_u8(v));
-		print_hhu(PRINT_JSON, "mdl", NULL, rta_getattr_u8(v));
-	}
+	if (tb[TCA_FLOWER_KEY_CFM_MD_LEVEL])
+		print_hhu(PRINT_ANY, "mdl", " mdl %u",
+			  rta_getattr_u8(tb[TCA_FLOWER_KEY_CFM_MD_LEVEL]));
 
-	v = tb[TCA_FLOWER_KEY_CFM_OPCODE];
-	if (v) {
-		sprintf(out + sz, " op %u", rta_getattr_u8(v));
-		print_hhu(PRINT_JSON, "op", NULL, rta_getattr_u8(v));
-	}
+	if (tb[TCA_FLOWER_KEY_CFM_OPCODE])
+		print_hhu(PRINT_ANY, "op", " op %u",
+			  rta_getattr_u8(tb[TCA_FLOWER_KEY_CFM_OPCODE]));
 
 	close_json_object();
-	print_string(PRINT_FP, "cfm", "%s", out);
 }
 
 static int flower_print_opt(struct filter_util *qu, FILE *f,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH iproute2-next] f_flower: simplify cfm dump function
  2023-06-29 19:57 [PATCH iproute2-next] f_flower: simplify cfm dump function Zahari Doychev
@ 2023-06-30 11:22 ` Petr Machata
  2023-06-30 19:37   ` Zahari Doychev
  2023-06-30 21:17 ` Stephen Hemminger
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Petr Machata @ 2023-06-30 11:22 UTC (permalink / raw)
  To: Zahari Doychev
  Cc: netdev, dsahern, stephen, hmehrtens, aleksander.lobakin,
	simon.horman, idosch, Zahari Doychev


Zahari Doychev <zahari.doychev@linux.com> writes:

> From: Zahari Doychev <zdoychev@maxlinear.com>
>
> The standard print function can be used to print the cfm attributes in
> both standard and json use cases. In this way no string buffer is needed
> which simplifies the code.

This looks correct, but please make sure that the diff between the old
and the new way is empty in both JSON and FP mode.

> Signed-off-by: Zahari Doychev <zdoychev@maxlinear.com>

Reviewed-by: Petr Machata <me@pmachata.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH iproute2-next] f_flower: simplify cfm dump function
  2023-06-30 11:22 ` Petr Machata
@ 2023-06-30 19:37   ` Zahari Doychev
  0 siblings, 0 replies; 6+ messages in thread
From: Zahari Doychev @ 2023-06-30 19:37 UTC (permalink / raw)
  To: Petr Machata
  Cc: netdev, dsahern, stephen, hmehrtens, aleksander.lobakin,
	simon.horman, idosch, Zahari Doychev

On Fri, Jun 30, 2023 at 01:22:45PM +0200, Petr Machata wrote:
> 
> Zahari Doychev <zahari.doychev@linux.com> writes:
> 
> > From: Zahari Doychev <zdoychev@maxlinear.com>
> >
> > The standard print function can be used to print the cfm attributes in
> > both standard and json use cases. In this way no string buffer is needed
> > which simplifies the code.
> 
> This looks correct, but please make sure that the diff between the old
> and the new way is empty in both JSON and FP mode.

I have done that. The diff between the two is empty.

thanks

> 
> > Signed-off-by: Zahari Doychev <zdoychev@maxlinear.com>
> 
> Reviewed-by: Petr Machata <me@pmachata.org>
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH iproute2-next] f_flower: simplify cfm dump function
  2023-06-29 19:57 [PATCH iproute2-next] f_flower: simplify cfm dump function Zahari Doychev
  2023-06-30 11:22 ` Petr Machata
@ 2023-06-30 21:17 ` Stephen Hemminger
  2023-07-03  8:01 ` Ido Schimmel
  2023-07-03 16:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Stephen Hemminger @ 2023-06-30 21:17 UTC (permalink / raw)
  To: Zahari Doychev
  Cc: netdev, dsahern, hmehrtens, aleksander.lobakin, simon.horman,
	idosch, Zahari Doychev

On Thu, 29 Jun 2023 21:57:36 +0200
Zahari Doychev <zahari.doychev@linux.com> wrote:

> From: Zahari Doychev <zdoychev@maxlinear.com>
> 
> The standard print function can be used to print the cfm attributes in
> both standard and json use cases. In this way no string buffer is needed
> which simplifies the code.
> 
> Signed-off-by: Zahari Doychev <zdoychev@maxlinear.com>

Since this does not depend on new kernel features, will pick it up as part of
regular iproute2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH iproute2-next] f_flower: simplify cfm dump function
  2023-06-29 19:57 [PATCH iproute2-next] f_flower: simplify cfm dump function Zahari Doychev
  2023-06-30 11:22 ` Petr Machata
  2023-06-30 21:17 ` Stephen Hemminger
@ 2023-07-03  8:01 ` Ido Schimmel
  2023-07-03 16:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Ido Schimmel @ 2023-07-03  8:01 UTC (permalink / raw)
  To: Zahari Doychev
  Cc: netdev, dsahern, stephen, hmehrtens, aleksander.lobakin,
	simon.horman, Zahari Doychev

On Thu, Jun 29, 2023 at 09:57:36PM +0200, Zahari Doychev wrote:
> From: Zahari Doychev <zdoychev@maxlinear.com>
> 
> The standard print function can be used to print the cfm attributes in
> both standard and json use cases. In this way no string buffer is needed
> which simplifies the code.
> 
> Signed-off-by: Zahari Doychev <zdoychev@maxlinear.com>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH iproute2-next] f_flower: simplify cfm dump function
  2023-06-29 19:57 [PATCH iproute2-next] f_flower: simplify cfm dump function Zahari Doychev
                   ` (2 preceding siblings ...)
  2023-07-03  8:01 ` Ido Schimmel
@ 2023-07-03 16:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-07-03 16:10 UTC (permalink / raw)
  To: Zahari Doychev
  Cc: netdev, dsahern, stephen, hmehrtens, aleksander.lobakin,
	simon.horman, idosch, zdoychev

Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Thu, 29 Jun 2023 21:57:36 +0200 you wrote:
> From: Zahari Doychev <zdoychev@maxlinear.com>
> 
> The standard print function can be used to print the cfm attributes in
> both standard and json use cases. In this way no string buffer is needed
> which simplifies the code.
> 
> Signed-off-by: Zahari Doychev <zdoychev@maxlinear.com>
> 
> [...]

Here is the summary with links:
  - [iproute2-next] f_flower: simplify cfm dump function
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=19f44c06e5e2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-07-03 16:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-29 19:57 [PATCH iproute2-next] f_flower: simplify cfm dump function Zahari Doychev
2023-06-30 11:22 ` Petr Machata
2023-06-30 19:37   ` Zahari Doychev
2023-06-30 21:17 ` Stephen Hemminger
2023-07-03  8:01 ` Ido Schimmel
2023-07-03 16:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.