Skip to content

Commit f8d3e0d

Browse files
committed
Merge branch 'nexthop-nexthop-dump-fixes'
Ido Schimmel says: ==================== nexthop: Nexthop dump fixes Patches #1 and STMicroelectronics#3 fix two problems related to nexthops and nexthop buckets dump, respectively. Patch STMicroelectronics#2 is a preparation for the third patch. The pattern described in these patches of splitting the NLMSG_DONE to a separate response is prevalent in other rtnetlink dump callbacks. I don't know if it's because I'm missing something or if this was done intentionally to ensure the message is delivered to user space. After commit 0642840 ("af_netlink: ensure that NLMSG_DONE never fails in dumps") this is no longer necessary and I can improve these dump callbacks assuming this analysis is correct. No regressions in existing tests: # ./fib_nexthops.sh [...] Tests passed: 230 Tests failed: 0 ==================== Link: https://lore.kernel.org/r/20230808075233.3337922-1-idosch@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 718cb09 + 8743aef commit f8d3e0d

2 files changed

Lines changed: 17 additions & 21 deletions

File tree

net/ipv4/nexthop.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,13 +3221,9 @@ static int rtm_dump_nexthop(struct sk_buff *skb, struct netlink_callback *cb)
32213221
&rtm_dump_nexthop_cb, &filter);
32223222
if (err < 0) {
32233223
if (likely(skb->len))
3224-
goto out;
3225-
goto out_err;
3224+
err = skb->len;
32263225
}
32273226

3228-
out:
3229-
err = skb->len;
3230-
out_err:
32313227
cb->seq = net->nexthop.seq;
32323228
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
32333229
return err;
@@ -3367,25 +3363,19 @@ static int rtm_dump_nexthop_bucket_nh(struct sk_buff *skb,
33673363
dd->filter.res_bucket_nh_id != nhge->nh->id)
33683364
continue;
33693365

3366+
dd->ctx->bucket_index = bucket_index;
33703367
err = nh_fill_res_bucket(skb, nh, bucket, bucket_index,
33713368
RTM_NEWNEXTHOPBUCKET, portid,
33723369
cb->nlh->nlmsg_seq, NLM_F_MULTI,
33733370
cb->extack);
3374-
if (err < 0) {
3375-
if (likely(skb->len))
3376-
goto out;
3377-
goto out_err;
3378-
}
3371+
if (err)
3372+
return err;
33793373
}
33803374

33813375
dd->ctx->done_nh_idx = dd->ctx->nh.idx + 1;
3382-
bucket_index = 0;
3376+
dd->ctx->bucket_index = 0;
33833377

3384-
out:
3385-
err = skb->len;
3386-
out_err:
3387-
dd->ctx->bucket_index = bucket_index;
3388-
return err;
3378+
return 0;
33893379
}
33903380

33913381
static int rtm_dump_nexthop_bucket_cb(struct sk_buff *skb,
@@ -3434,13 +3424,9 @@ static int rtm_dump_nexthop_bucket(struct sk_buff *skb,
34343424

34353425
if (err < 0) {
34363426
if (likely(skb->len))
3437-
goto out;
3438-
goto out_err;
3427+
err = skb->len;
34393428
}
34403429

3441-
out:
3442-
err = skb->len;
3443-
out_err:
34443430
cb->seq = net->nexthop.seq;
34453431
nl_dump_check_consistent(cb, nlmsg_hdr(skb));
34463432
return err;

tools/testing/selftests/net/fib_nexthops.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,11 @@ basic()
19811981

19821982
run_cmd "$IP link set dev lo up"
19831983

1984+
# Dump should not loop endlessly when maximum nexthop ID is configured.
1985+
run_cmd "$IP nexthop add id $((2**32-1)) blackhole"
1986+
run_cmd "timeout 5 $IP nexthop"
1987+
log_test $? 0 "Maximum nexthop ID dump"
1988+
19841989
#
19851990
# groups
19861991
#
@@ -2201,6 +2206,11 @@ basic_res()
22012206
run_cmd "$IP nexthop bucket list fdb"
22022207
log_test $? 255 "Dump all nexthop buckets with invalid 'fdb' keyword"
22032208

2209+
# Dump should not loop endlessly when maximum nexthop ID is configured.
2210+
run_cmd "$IP nexthop add id $((2**32-1)) group 1/2 type resilient buckets 4"
2211+
run_cmd "timeout 5 $IP nexthop bucket"
2212+
log_test $? 0 "Maximum nexthop ID dump"
2213+
22042214
#
22052215
# resilient nexthop buckets get requests
22062216
#

0 commit comments

Comments
 (0)