netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] nexthop: Various cleanups
@ 2023-08-13 16:48 Ido Schimmel
  2023-08-13 16:48 ` [PATCH net-next 1/2] nexthop: Simplify nexthop bucket dump Ido Schimmel
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ido Schimmel @ 2023-08-13 16:48 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, dsahern, petrm, mlxsw,
	Ido Schimmel

Benefit from recent bug fixes and simplify the nexthop dump code.

No regressions in existing tests:

 # ./fib_nexthops.sh
 [...]
 Tests passed: 234
 Tests failed:   0

Ido Schimmel (2):
  nexthop: Simplify nexthop bucket dump
  nexthop: Do not increment dump sentinel at the end of the dump

 net/ipv4/nexthop.c | 6 ------
 1 file changed, 6 deletions(-)

-- 
2.40.1


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

* [PATCH net-next 1/2] nexthop: Simplify nexthop bucket dump
  2023-08-13 16:48 [PATCH net-next 0/2] nexthop: Various cleanups Ido Schimmel
@ 2023-08-13 16:48 ` Ido Schimmel
  2023-08-14  1:20   ` David Ahern
  2023-08-13 16:48 ` [PATCH net-next 2/2] nexthop: Do not increment dump sentinel at the end of the dump Ido Schimmel
  2023-08-16  2:00 ` [PATCH net-next 0/2] nexthop: Various cleanups patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Ido Schimmel @ 2023-08-13 16:48 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, dsahern, petrm, mlxsw,
	Ido Schimmel

Before commit f10d3d9df49d ("nexthop: Make nexthop bucket dump more
efficient"), rtm_dump_nexthop_bucket_nh() returned a non-zero return
code for each resilient nexthop group whose buckets it dumped,
regardless if it encountered an error or not.

This meant that the sentinel ('dd->ctx->nh.idx') used by the function
that walked the different nexthops could not be used as a sentinel for
the bucket dump, as otherwise buckets from the same group would be
dumped over and over again.

This was dealt with by adding another sentinel ('dd->ctx->done_nh_idx')
that was incremented by rtm_dump_nexthop_bucket_nh() after successfully
dumping all the buckets from a given group.

After the previously mentioned commit this sentinel is no longer
necessary since the function no longer returns a non-zero return code
when successfully dumping all the buckets from a given group.

Remove this sentinel and simplify the code.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
---
 net/ipv4/nexthop.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 09d36bcbd7d4..7e8bb85e9dcb 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -3337,7 +3337,6 @@ static int nh_valid_dump_bucket_req(const struct nlmsghdr *nlh,
 struct rtm_dump_res_bucket_ctx {
 	struct rtm_dump_nh_ctx nh;
 	u16 bucket_index;
-	u32 done_nh_idx; /* 1 + the index of the last fully processed NH. */
 };
 
 static struct rtm_dump_res_bucket_ctx *
@@ -3366,9 +3365,6 @@ static int rtm_dump_nexthop_bucket_nh(struct sk_buff *skb,
 	u16 bucket_index;
 	int err;
 
-	if (dd->ctx->nh.idx < dd->ctx->done_nh_idx)
-		return 0;
-
 	nhg = rtnl_dereference(nh->nh_grp);
 	res_table = rtnl_dereference(nhg->res_table);
 	for (bucket_index = dd->ctx->bucket_index;
@@ -3395,7 +3391,6 @@ static int rtm_dump_nexthop_bucket_nh(struct sk_buff *skb,
 			return err;
 	}
 
-	dd->ctx->done_nh_idx = dd->ctx->nh.idx + 1;
 	dd->ctx->bucket_index = 0;
 
 	return 0;
-- 
2.40.1


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

* [PATCH net-next 2/2] nexthop: Do not increment dump sentinel at the end of the dump
  2023-08-13 16:48 [PATCH net-next 0/2] nexthop: Various cleanups Ido Schimmel
  2023-08-13 16:48 ` [PATCH net-next 1/2] nexthop: Simplify nexthop bucket dump Ido Schimmel
@ 2023-08-13 16:48 ` Ido Schimmel
  2023-08-14  1:22   ` David Ahern
  2023-08-16  2:00 ` [PATCH net-next 0/2] nexthop: Various cleanups patchwork-bot+netdevbpf
  2 siblings, 1 reply; 6+ messages in thread
From: Ido Schimmel @ 2023-08-13 16:48 UTC (permalink / raw)
  To: netdev; +Cc: davem, kuba, pabeni, edumazet, dsahern, petrm, mlxsw,
	Ido Schimmel

The nexthop and nexthop bucket dump callbacks previously returned a
positive return code even when the dump was complete, prompting the core
netlink code to invoke the callback again, until returning zero.

Zero was only returned by these callbacks when no information was filled
in the provided skb, which was achieved by incrementing the dump
sentinel at the end of the dump beyond the ID of the last nexthop.

This is no longer necessary as when the dump is complete these callbacks
return zero.

Remove the unnecessary increment.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
---
 net/ipv4/nexthop.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 7e8bb85e9dcb..bbff68b5b5d4 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -3209,7 +3209,6 @@ static int rtm_dump_walk_nexthops(struct sk_buff *skb,
 			return err;
 	}
 
-	ctx->idx++;
 	return 0;
 }
 
-- 
2.40.1


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

* Re: [PATCH net-next 1/2] nexthop: Simplify nexthop bucket dump
  2023-08-13 16:48 ` [PATCH net-next 1/2] nexthop: Simplify nexthop bucket dump Ido Schimmel
@ 2023-08-14  1:20   ` David Ahern
  0 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2023-08-14  1:20 UTC (permalink / raw)
  To: Ido Schimmel, netdev; +Cc: davem, kuba, pabeni, edumazet, petrm, mlxsw

On 8/13/23 10:48 AM, Ido Schimmel wrote:
> Before commit f10d3d9df49d ("nexthop: Make nexthop bucket dump more
> efficient"), rtm_dump_nexthop_bucket_nh() returned a non-zero return
> code for each resilient nexthop group whose buckets it dumped,
> regardless if it encountered an error or not.
> 
> This meant that the sentinel ('dd->ctx->nh.idx') used by the function
> that walked the different nexthops could not be used as a sentinel for
> the bucket dump, as otherwise buckets from the same group would be
> dumped over and over again.
> 
> This was dealt with by adding another sentinel ('dd->ctx->done_nh_idx')
> that was incremented by rtm_dump_nexthop_bucket_nh() after successfully
> dumping all the buckets from a given group.
> 
> After the previously mentioned commit this sentinel is no longer
> necessary since the function no longer returns a non-zero return code
> when successfully dumping all the buckets from a given group.
> 
> Remove this sentinel and simplify the code.
> 
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> Reviewed-by: Petr Machata <petrm@nvidia.com>
> ---
>  net/ipv4/nexthop.c | 5 -----
>  1 file changed, 5 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>



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

* Re: [PATCH net-next 2/2] nexthop: Do not increment dump sentinel at the end of the dump
  2023-08-13 16:48 ` [PATCH net-next 2/2] nexthop: Do not increment dump sentinel at the end of the dump Ido Schimmel
@ 2023-08-14  1:22   ` David Ahern
  0 siblings, 0 replies; 6+ messages in thread
From: David Ahern @ 2023-08-14  1:22 UTC (permalink / raw)
  To: Ido Schimmel, netdev; +Cc: davem, kuba, pabeni, edumazet, petrm, mlxsw

On 8/13/23 10:48 AM, Ido Schimmel wrote:
> The nexthop and nexthop bucket dump callbacks previously returned a
> positive return code even when the dump was complete, prompting the core
> netlink code to invoke the callback again, until returning zero.
> 
> Zero was only returned by these callbacks when no information was filled
> in the provided skb, which was achieved by incrementing the dump
> sentinel at the end of the dump beyond the ID of the last nexthop.
> 
> This is no longer necessary as when the dump is complete these callbacks
> return zero.
> 
> Remove the unnecessary increment.
> 
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> Reviewed-by: Petr Machata <petrm@nvidia.com>
> ---
>  net/ipv4/nexthop.c | 1 -
>  1 file changed, 1 deletion(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>



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

* Re: [PATCH net-next 0/2] nexthop: Various cleanups
  2023-08-13 16:48 [PATCH net-next 0/2] nexthop: Various cleanups Ido Schimmel
  2023-08-13 16:48 ` [PATCH net-next 1/2] nexthop: Simplify nexthop bucket dump Ido Schimmel
  2023-08-13 16:48 ` [PATCH net-next 2/2] nexthop: Do not increment dump sentinel at the end of the dump Ido Schimmel
@ 2023-08-16  2:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-08-16  2:00 UTC (permalink / raw)
  To: Ido Schimmel; +Cc: netdev, davem, kuba, pabeni, edumazet, dsahern, petrm, mlxsw

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sun, 13 Aug 2023 19:48:54 +0300 you wrote:
> Benefit from recent bug fixes and simplify the nexthop dump code.
> 
> No regressions in existing tests:
> 
>  # ./fib_nexthops.sh
>  [...]
>  Tests passed: 234
>  Tests failed:   0
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] nexthop: Simplify nexthop bucket dump
    https://git.kernel.org/netdev/net-next/c/23ab9324fd26
  - [net-next,2/2] nexthop: Do not increment dump sentinel at the end of the dump
    https://git.kernel.org/netdev/net-next/c/db1428f66a8c

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-08-16  2:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-13 16:48 [PATCH net-next 0/2] nexthop: Various cleanups Ido Schimmel
2023-08-13 16:48 ` [PATCH net-next 1/2] nexthop: Simplify nexthop bucket dump Ido Schimmel
2023-08-14  1:20   ` David Ahern
2023-08-13 16:48 ` [PATCH net-next 2/2] nexthop: Do not increment dump sentinel at the end of the dump Ido Schimmel
2023-08-14  1:22   ` David Ahern
2023-08-16  2:00 ` [PATCH net-next 0/2] nexthop: Various cleanups patchwork-bot+netdevbpf

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).