mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
Merge branch 'neighbour-small-fixes-for-rtm_-get-set-neightbl'
Kuniyuki Iwashima says:
====================
neighbour: Small fixes for RTM_{GET,SET}NEIGHTBL.
While working on the follow-up suggested here,
https://lore.kernel.org/20260902143023.GA3966681@shredder
I found a few bugs in RTM_GETNEIGHTBL and RTM_SETNEIGHTBL,
which this series fixes.
Patch 1, 3, 4 will conflict with net-next in neightbl_dump_info()
due to removal of net_eq() below:
p = list_next_entry(&tbl->parms, list);
list_for_each_entry_from_rcu(p, &tbl->parms_list, list) {
if (!net_eq(neigh_parms_net(p), net))
continue;
Note also that currently neigh_proc_dointvec_ms_jiffies_positive()
is buggy and does not enforce min/max, and it needs this fix:
https://lore.kernel.org/20260905233819.1064529-2-kuniyu@google.com
====================
Link: https://patch.msgid.link/20260909233143.2401847-1-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
e6b6078ea1
|
|
@ -341,6 +341,9 @@ attribute-sets:
|
|||
-
|
||||
name: interval-probe-time-ms
|
||||
type: u64
|
||||
checks:
|
||||
min: 1
|
||||
max: 86400000
|
||||
|
||||
operations:
|
||||
enum-model: directional
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ neigh/default/unres_qlen - INTEGER
|
|||
|
||||
neigh/default/interval_probe_time_ms - INTEGER
|
||||
The probe interval for neighbor entries with NTF_MANAGED flag,
|
||||
the min value is 1.
|
||||
the min value is 1, and the max value is 86400000 (1 day).
|
||||
|
||||
Default: 5000
|
||||
|
||||
|
|
|
|||
|
|
@ -2359,6 +2359,13 @@ static const struct nla_policy nl_neightbl_policy[NDTA_MAX+1] = {
|
|||
[NDTA_PARMS] = { .type = NLA_NESTED },
|
||||
};
|
||||
|
||||
#define NTBL_PARM_MS_MAX (24 * 60 * 60 * MSEC_PER_SEC)
|
||||
|
||||
static const struct netlink_range_validation nl_ntbl_parm_ms_range = {
|
||||
.min = 1,
|
||||
.max = NTBL_PARM_MS_MAX,
|
||||
};
|
||||
|
||||
static const struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] = {
|
||||
[NDTPA_IFINDEX] = { .type = NLA_U32 },
|
||||
[NDTPA_QUEUE_LEN] = { .type = NLA_U32 },
|
||||
|
|
@ -2375,7 +2382,8 @@ static const struct nla_policy nl_ntbl_parm_policy[NDTPA_MAX+1] = {
|
|||
[NDTPA_ANYCAST_DELAY] = { .type = NLA_U64 },
|
||||
[NDTPA_PROXY_DELAY] = { .type = NLA_U64 },
|
||||
[NDTPA_LOCKTIME] = { .type = NLA_U64 },
|
||||
[NDTPA_INTERVAL_PROBE_TIME_MS] = { .type = NLA_U64, .min = 1 },
|
||||
[NDTPA_INTERVAL_PROBE_TIME_MS] = NLA_POLICY_FULL_RANGE(NLA_U64,
|
||||
&nl_ntbl_parm_ms_range),
|
||||
};
|
||||
|
||||
static int neightbl_set(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
|
|
@ -2579,9 +2587,10 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
|
|||
{
|
||||
const struct nlmsghdr *nlh = cb->nlh;
|
||||
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 tbl_skip = cb->args[0];
|
||||
int neigh_skip = cb->args[1];
|
||||
struct neigh_table *tbl;
|
||||
|
||||
if (cb->strict_check) {
|
||||
|
|
@ -2605,17 +2614,21 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
|
|||
if (tidx < tbl_skip || (family && tbl->family != family))
|
||||
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,
|
||||
NLM_F_MULTI) < 0)
|
||||
break;
|
||||
|
||||
nidx = 0;
|
||||
p = list_next_entry(&tbl->parms, list);
|
||||
list_for_each_entry_from_rcu(p, &tbl->parms_list, list) {
|
||||
default_skip = 1;
|
||||
|
||||
list_for_each_entry_rcu(p, &tbl->parms_list, list) {
|
||||
if (!net_eq(neigh_parms_net(p), net))
|
||||
continue;
|
||||
|
||||
if (!p->dev || p->dev == blackhole_netdev)
|
||||
continue;
|
||||
|
||||
if (nidx < neigh_skip)
|
||||
goto next;
|
||||
|
||||
|
|
@ -2630,12 +2643,15 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
|
|||
}
|
||||
|
||||
neigh_skip = 0;
|
||||
nidx = 0;
|
||||
default_skip = 0;
|
||||
}
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
|
||||
cb->args[0] = tidx;
|
||||
cb->args[1] = nidx;
|
||||
cb->args[2] = default_skip;
|
||||
|
||||
return skb->len;
|
||||
}
|
||||
|
|
@ -3669,12 +3685,13 @@ static int neigh_proc_dointvec_ms_jiffies_positive(const struct ctl_table *ctl,
|
|||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
struct ctl_table tmp = *ctl;
|
||||
int ret;
|
||||
int ret, min, max;
|
||||
|
||||
int min = msecs_to_jiffies(1);
|
||||
min = msecs_to_jiffies(1);
|
||||
max = msecs_to_jiffies(NTBL_PARM_MS_MAX);
|
||||
|
||||
tmp.extra1 = &min;
|
||||
tmp.extra2 = NULL;
|
||||
tmp.extra2 = &max;
|
||||
|
||||
ret = proc_dointvec_ms_jiffies_minmax(&tmp, write, buffer, lenp, ppos);
|
||||
neigh_proc_update(ctl, write);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user