mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
neighbour: Skip default parms when resumed in neightbl_dump_info().
neightbl_dump_info() calls neightbl_fill_info() in each loop
to render the default parms.
If there are many devices and neightbl_fill_param_info() failed,
neightbl_fill_info() is called again when the dump resumes:
# ynl --family rt-neigh --dump getneightbl --output-json |
jq '.[] | {name: .name, ifindex: .parms.ifindex}'
...
{
"name": "ndisc_cache",
"ifindex": null
}
...
{
"name": "ndisc_cache",
"ifindex": 6
}
{
"name": "ndisc_cache",
"ifindex": null
}
{
"name": "ndisc_cache",
"ifindex": 5
}
Let's skip neightbl_fill_info() if it is already called in
neightbl_dump_info().
Note that we cannot use !neigh_skip instead of !default_skip
because default_skip == 1 && neigh_skip == 0 could be true
if the first neightbl_fill_param_info() fails.
Also, nidx must be cleared at the end of each table loop;
otherwise, if neightbl_fill_info() for a subsequent table
fails, the leftover nidx from the previous table would be
saved in cb->args[1], resulting in erroneously skipping parms
of the subsequent table in the next dump.
Fixes: c7fb64db00 ("[NETLINK]: Neighbour table configuration and statistics via rtnetlink")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20260909233143.2401847-5-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
7b430fcfc9
commit
979aabdad8
|
|
@ -2587,9 +2587,10 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
{
|
{
|
||||||
const struct nlmsghdr *nlh = cb->nlh;
|
const struct nlmsghdr *nlh = cb->nlh;
|
||||||
struct net *net = sock_net(skb->sk);
|
struct net *net = sock_net(skb->sk);
|
||||||
|
int default_skip = cb->args[2];
|
||||||
|
int neigh_skip = cb->args[1];
|
||||||
int family, tidx, nidx = 0;
|
int family, tidx, nidx = 0;
|
||||||
int tbl_skip = cb->args[0];
|
int tbl_skip = cb->args[0];
|
||||||
int neigh_skip = cb->args[1];
|
|
||||||
struct neigh_table *tbl;
|
struct neigh_table *tbl;
|
||||||
|
|
||||||
if (cb->strict_check) {
|
if (cb->strict_check) {
|
||||||
|
|
@ -2613,12 +2614,13 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
if (tidx < tbl_skip || (family && tbl->family != family))
|
if (tidx < tbl_skip || (family && tbl->family != family))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (neightbl_fill_info(skb, tbl, NETLINK_CB(cb->skb).portid,
|
if (!default_skip &&
|
||||||
|
neightbl_fill_info(skb, tbl, NETLINK_CB(cb->skb).portid,
|
||||||
nlh->nlmsg_seq, RTM_NEWNEIGHTBL,
|
nlh->nlmsg_seq, RTM_NEWNEIGHTBL,
|
||||||
NLM_F_MULTI) < 0)
|
NLM_F_MULTI) < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
nidx = 0;
|
default_skip = 1;
|
||||||
|
|
||||||
list_for_each_entry_rcu(p, &tbl->parms_list, list) {
|
list_for_each_entry_rcu(p, &tbl->parms_list, list) {
|
||||||
if (!net_eq(neigh_parms_net(p), net))
|
if (!net_eq(neigh_parms_net(p), net))
|
||||||
|
|
@ -2641,12 +2643,15 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
neigh_skip = 0;
|
neigh_skip = 0;
|
||||||
|
nidx = 0;
|
||||||
|
default_skip = 0;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
|
||||||
cb->args[0] = tidx;
|
cb->args[0] = tidx;
|
||||||
cb->args[1] = nidx;
|
cb->args[1] = nidx;
|
||||||
|
cb->args[2] = default_skip;
|
||||||
|
|
||||||
return skb->len;
|
return skb->len;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user