diff mbox series

[net-next,1/2] nexthop: Simplify nexthop bucket dump

Message ID 20230813164856.2379822-2-idosch@nvidia.com (mailing list archive)
State Accepted
Commit 23ab9324fd260277f83a07c51fdc625442e98265
Delegated to: Netdev Maintainers
Headers show
Series nexthop: Various cleanups | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1333 this patch: 1333
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1356 this patch: 1356
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ido Schimmel Aug. 13, 2023, 4:48 p.m. UTC
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(-)

Comments

David Ahern Aug. 14, 2023, 1:20 a.m. UTC | #1
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>
diff mbox series

Patch

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;