mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: alishmery18@gmail.com
Cc: netdev@vger.kernel.org, idosch@nvidia.com, kuba@kernel.org,
	pabeni@redhat.com, davem@davemloft.net, edumazet@google.com,
	andrew+netdev@lunn.ch, horms@kernel.org, razor@blackwall.org,
	roopa@nvidia.com, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 3/6] vxlan: vnifilter: bound the number of VNIs one request may touch
Date: Wed, 30 Sep 2026 03:52:20 +0000	[thread overview]
Message-ID: <179074034041.434549.3857875143564705061@kernel.org> (raw)
In-Reply-To: <20260927215209.2581830-4-alishmery18@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The changelog justifies capping delete as well as add by saying
  the two "both walk the same span and hold rtnl the same way".
- [Low] The commit message says the 4096 limit follows "the usable VLAN
  ID space".
- [Low] At this commit, the dump path can emit a VXLAN_VNIFILTER_ENTRY
  that the new request parser refuses.

--

vxlan: vnifilter: bound the number of VNIs one request may touch

This patch caps the number of VNIs that one RTM_NEWTUNNEL or RTM_DELTUNNEL
message may add or delete at 4096. The count is summed across all
VXLAN_VNIFILTER_ENTRY attributes and checked in a new
vxlan_vnifilter_check_msg() before any entry is applied. The range
extraction moves into vxlan_vni_filter_entry_range() so the check and the
dispatch path use the same range.

> That walk is the cost being bounded, not the memory: an add allocates a
> VNI node and a per-CPU stats block per VNI, a delete creates neither,
> but both walk the same span and hold rtnl the same way, so both are
> bounded.

[Severity: Low]
Is "both walk the same span" accurate for delete? vxlan_vni_del() returns
-ENOENT for a VNI that is not installed:

drivers/net/vxlan/vxlan_vnifilter.c:vxlan_vni_del() {
    ...
	vninode = rhashtable_lookup_fast(&vg->vni_hash, &v,
					 vxlan_vni_rht_params);
	if (!vninode) {
		err = -ENOENT;
		goto out;
	}
    ...
}

vxlan_vni_add_del() then stops the walk at the first error:

		if (err)
			goto out;

So an RTM_DELTUNNEL walk covers the full span only when every VNI in it is
installed. That worst case can happen after several capped adds, so there
is still a reason to bound delete. The wording could be more precise,
though.

The changelog says that installs can be split across requests and that
vxlan_vnigroup_uninit() is exempt. It does not say that a user who
installed a contiguous run of more than 4096 VNIs can no longer delete it
in one message. The same applies to re-issuing RTM_NEWTUNNEL over that run
to change the group. vxlan_vnifilter_check_msg() charges the full requested
span, whatever is actually installed.

Could the changelog spell out this user-visible narrowing?

> The limit is 4096, following the usable VLAN ID space, since vnifilter
> is mainly used on bridged devices where the VNI is derived from the
> VLAN.

[Severity: Low]
This isn't a bug, but is "usable" the right word here? The usable 802.1Q
VLAN IDs are 1..4094. br_vlan_valid_id() in net/bridge/br_private.h only
accepts:

	bool ret = vid > 0 && vid < VLAN_VID_MASK;

4096 is the size of the full 12-bit VID field, which includes the reserved
IDs 0 and 4095. The in-code comment on VXLAN_VNI_FILTER_MSG_MAX says "the
VLAN ID space", which reads fine.

> diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c
> index 9cffaf4998a98..13f4e115701ac 100644
> --- a/drivers/net/vxlan/vxlan_vnifilter.c
> +++ b/drivers/net/vxlan/vxlan_vnifilter.c

[ ... ]

> +static int vxlan_vnifilter_check_msg(const struct nlmsghdr *nlh,
> +				     struct netlink_ext_ack *extack)
> +{
> +	struct nlattr *vattrs[VXLAN_VNIFILTER_ENTRY_MAX + 1];
> +	struct nlattr *attr;
> +	u32 vnis = 0;
> +	int err, rem;
> +
> +	nlmsg_for_each_attr_type(attr, VXLAN_VNIFILTER_ENTRY, nlh,
> +				 sizeof(struct tunnel_msg), rem) {

[ ... ]

> +		vnis += vni_end - vni_start + 1;
> +		if (vnis > VXLAN_VNI_FILTER_MSG_MAX) {
> +			NL_SET_ERR_MSG_ATTR_FMT(extack, attr,
> +						"Request asks for more than %u VNIs",
> +						VXLAN_VNI_FILTER_MSG_MAX);
> +			return -EINVAL;
> +		}

[Severity: Low]
At this point in the series, can a dump emit an entry that this check then
rejects?

vxlan_vnifilter_dump_dev() merges any contiguous run of VNIs with the same
remote into a single START/END entry. It puts no bound on the span:

drivers/net/vxlan/vxlan_vnifilter.c:vxlan_vnifilter_dump_dev() {
    ...
		if (!dump_stats && vnirange(vend, v) == 1 &&
		    vxlan_addr_equal(&v->remote_ip, &vend->remote_ip)) {
			goto update_end;
    ...
}

A device can still hold more than 4096 contiguous VNIs installed over
several requests, because vxlan_vni_rht_params uses
.max_size = VXLAN_N_VID. If such a dumped entry is replayed in one
RTM_NEWTUNNEL, vxlan_vnifilter_check_msg() returns -EINVAL.

The next patch in the series, "vxlan: vnifilter: clamp the dumped VNI
range to the request limit", fixes this. It adds
vnirange(vbegin, v) < VXLAN_VNI_FILTER_MSG_MAX to the merge condition, and
the selftest commit checks the dump/replay round trip.

Would it make sense to put the clamp before this patch, or fold it in, so
dump and request stay consistent at every commit in the series?

> +	}
> +
> +	return 0;
> +}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260927215209.2581830-1-alishmery18%40gmail.com

  reply	other threads:[~2026-09-30  3:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 21:52 [PATCH net-next v3 0/6] vxlan: vnifilter: bound a single request and account per-VNI memory Ali Firas
2026-09-27 21:52 ` [PATCH net-next v3 1/6] vxlan: vnifilter: validate the VXLAN_VNIFILTER_ENTRY nest Ali Firas
2026-09-30  3:52   ` netdev-bot+sashiko
2026-09-27 21:52 ` [PATCH net-next v3 2/6] vxlan: vnifilter: reject VNIs outside the 24-bit space Ali Firas
2026-09-30  3:52   ` netdev-bot+sashiko
2026-09-27 21:52 ` [PATCH net-next v3 3/6] vxlan: vnifilter: bound the number of VNIs one request may touch Ali Firas
2026-09-30  3:52   ` netdev-bot+sashiko [this message]
2026-09-27 21:52 ` [PATCH net-next v3 4/6] vxlan: vnifilter: clamp the dumped VNI range to the request limit Ali Firas
2026-09-30  3:52   ` netdev-bot+sashiko
2026-09-27 21:52 ` [PATCH net-next v3 5/6] vxlan: vnifilter: account per-VNI memory to memcg Ali Firas
2026-09-30  3:52   ` netdev-bot+sashiko
2026-09-27 21:52 ` [PATCH net-next v3 6/6] selftests: net: test the vxlan vnifilter request limit and dump replay Ali Firas
2026-09-30  3:52   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179074034041.434549.3857875143564705061@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alishmery18@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=roopa@nvidia.com \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®