From nobody Fri Sep 25 04:08:10 2026 Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BA6A49A3C4 for ; Wed, 16 Sep 2026 19:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587475; cv=none; b=hOlOWGuCxjHIdpJdKMtz9jSVXA+z8Op17179EtEBSnKpr/yKI1iqAMpUz3H3azyZzGMg6kH88mmAuu2r21TL04Im9op6RckBvspQu83DLpL0ngobtCjI4mR/mOoFJ1qGNr5rtRHEyaqphRyb/gCYScN+x34EmS0yqkbNJ2rpS8o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587475; c=relaxed/simple; bh=ddPCkLG/mZMQG7Ygxj4GAeNW18W2hB6ed3Wan91fRWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AY/lTYMNmOsiob3EBnqg0L3GwTBi6PdN87BqDthupLeqi08YsRXEqot36479/F9cVkhVEFtL2dtZKqrtq1pOD6Yf9XPy7nraqSAKCmvnMAEBizPXpt4fivAnN/OXWNz3W0lX/qUXFwCvzcOEwjSC4XMNcmTDAhMjQXioiPe4ejE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TJ2DNBIB; arc=none smtp.client-ip=74.125.225.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TJ2DNBIB" Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-49b912e4b11so639275e9.3 for ; Wed, 16 Sep 2026 12:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789587458; x=1790192258; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=tk+LZk++Zz9blrRTZ2t/G1JXrIPeHycnebwimkzWD3M=; b=TJ2DNBIBPFygk0HXRfK48t20WSD+fb8RBQBdKix/Ri5I2qjREEAnMzs8rLuW0/Z7CR v+8VChYmdK/A3bskV6drcvVAX/XNUTOjHcoraeW9ce9adi3FRMBHWX/YugPbtfq1MbSV lIfkAj/sMWmnWkhekZ/s1whtVcSfeHUwvsgYVOUiFFc45bllMhqpguBJyMjK+/HcQhbN /pvFFdTE6KKizrNr4/fb22eErkph6qycYk1ILKiLq/JANgnc86m5Lw87J127SwgXhW2j X6GnOmDBybJGBXXepsVfkjDU0RKuS9cc2YpamEvHmHMWIfEDEomv+H36Im9dBoyvk+N/ 5vEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789587458; x=1790192258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=tk+LZk++Zz9blrRTZ2t/G1JXrIPeHycnebwimkzWD3M=; b=uqMcu3CZJnm1niYAHhgHuXbGkD/vRHXCaTj1MoCaNHlElvYeS5riRZcasedaPOXPHV 86k3rqieTyhVVSacwFk7FqE6QFCyAVdTGIEHaPx7gBs/M2sHlNX97yT/NACQlClP/Jpd kXaz9lkJD3xhozFD49kb3Q4UQGuN08rh67v8J1XgTSXWngYOnlzY8U7p5iUewCbHeBvK /HUbARdFQNe73ri3CWIxj8jEpWRkXY9pEvCwwIFKhqEmOuAuJiAVA9cGW8ATCgaTLO/U sKf1uUbxp9jumpT901COSVEqxRcmh3+M3F3/IG5W7D2sYfz3yvbn6rf2gf5kf67Yf/nx v4mQ== X-Forwarded-Encrypted: i=1; AKwUvBxCQdCuAEzElQCmJIr61Crl3+xdlUcJUj+aSpGtsRfeyMPAY+ZnskVO77JQjcUWY0iIQnvWgVtqG3dVHGo=@vger.kernel.org X-Gm-Message-State: AFuF++k5s9a/sHxR7O54dpt9xXEO9zi2zVpvGdyIovvUmNoBBc45rMQl pxYnKMccB2v7D50q8ppovJphmmzAiCkDICUvXOu+hE1z2gQCj6mvvGWS X-Gm-Gg: AYBFou0UNZ/AxNlkzPNoVdt2mCJdqsBx2IIYLhi9GWzN2OL6HPfw8ppS33OGjW2iXtz Mx9X7P5+z42+nnbI+7BKjlxqu8Nl3YsQnIKSbCqHkyhQhdjVvt1bjP1jXNjqw/K95jKU0TY4NZV 4N3HS9gPs+qg3136mInVFtrDHyUL7piNtCyhyT9+scWgRjYRgYhwE5MqKdwRZ5GEBxtLlcJxV3v 2b2MSHbOJkW+xnnq9JnH621mpoxC4EqF4+EMSZSuyw4/myNwZ8ih5+THxbW2H6v7Y/dNk/VvLGk fhmOfnDpfKkddy6FwDwWHaagHYewC4B6aTKyVPDU7nWbG1+DI+CgQEcZ/TOwGnYa4hTl3hsbNc5 WnogXZKOa4jQreGKyfBdES1Ce6lExgusEkIYa5pmA5OOa3icxJ8c6toeXaAm2XrIf8PabT4GzDL 2xDXJKjyqFV7zkGS1hpuJuke/HwLYppKq3Ag8wb9aE364UNdpYRtp3KR0LpA8xYiY= X-Received: by 2002:a05:600c:8b30:b0:49e:7862:c09e with SMTP id 5b1f17b1804b1-49eb72fd676mr47695055e9.14.1789587457746; Wed, 16 Sep 2026 12:37:37 -0700 (PDT) Received: from kali ([169.224.126.44]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fbd23ac75sm12936105e9.13.2026.09.16.12.37.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 12:37:37 -0700 (PDT) From: Ali Firas To: netdev@vger.kernel.org, idosch@nvidia.com Cc: 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, linux-kernel@vger.kernel.org, Ali Firas Subject: [PATCH net-next v2 1/5] vxlan: vnifilter: reject VNIs outside the 24-bit space Date: Wed, 16 Sep 2026 22:34:45 +0300 Message-ID: <20260916193449.2552039-2-alishmery18@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916193449.2552039-1-alishmery18@gmail.com> References: <20260916193449.2552039-1-alishmery18@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" VXLAN_VNIFILTER_ENTRY_START and VXLAN_VNIFILTER_ENTRY_END are declared as bare NLA_U32, so neither is bounded before vxlan_process_vni_filter() hands them to vxlan_vni_add_del(): int v, err =3D 0; ... for (v =3D start_vni; v <=3D end_vni; v++) { v is int and end_vni is __u32, so the comparison is done unsigned. A request carrying only START=3D0xffffffff gives vni_start =3D=3D vni_end =3D= =3D 0xffffffff, which looks like a single-VNI request. v is then -1, "v <=3D end_vni" converts it to 0xffffffff and passes, v++ makes v 0, and the loop walks the whole space upwards from there, allocating a VNI node and a per-CPU stats block per iteration under rtnl_lock. Any range ending at 0xffffffff behaves the same way, including narrow ones such as START=3D0xfffff001 END=3D0xffffffff. Separately, a VNI at or above VXLAN_N_VID is accepted and stored even though the VXLAN header carries only 24 bits: vxlan_vni_field() shifts without masking, so such an entry occupies its own rhashtable slot while being truncated on the wire. Range-validate both attributes against the 24-bit VNI space, which is what vxlan_mdb.c already does for its own VNI attributes. The request is then rejected during netlink policy validation, before vxlan_process_vni_filter() is reached, and nothing is allocated. Make the loop counter u32 while touching this: that is not what terminates the loop, the policy check is, but it removes the signed overflow past INT_MAX and matches the u32 vni parameter vxlan_vni_add() already takes. Assisted-by: LLM Signed-off-by: Ali Firas --- v1: https://lore.kernel.org/netdev/20260909092645.3105263-1-alishmery18@gma= il.com/ drivers/net/vxlan/vxlan_vnifilter.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_= vnifilter.c index dd94085e0886..5aaaaeee8110 100644 --- a/drivers/net/vxlan/vxlan_vnifilter.c +++ b/drivers/net/vxlan/vxlan_vnifilter.c @@ -459,9 +459,15 @@ static int vxlan_vnifilter_dump(struct sk_buff *skb, s= truct netlink_callback *cb return err; } =20 +static const struct netlink_range_validation vni_filter_vni_range =3D { + .max =3D VXLAN_N_VID - 1, +}; + static const struct nla_policy vni_filter_entry_policy[VXLAN_VNIFILTER_ENT= RY_MAX + 1] =3D { - [VXLAN_VNIFILTER_ENTRY_START] =3D { .type =3D NLA_U32 }, - [VXLAN_VNIFILTER_ENTRY_END] =3D { .type =3D NLA_U32 }, + [VXLAN_VNIFILTER_ENTRY_START] =3D NLA_POLICY_FULL_RANGE(NLA_U32, + &vni_filter_vni_range), + [VXLAN_VNIFILTER_ENTRY_END] =3D NLA_POLICY_FULL_RANGE(NLA_U32, + &vni_filter_vni_range), [VXLAN_VNIFILTER_ENTRY_GROUP] =3D NLA_POLICY_EXACT_LEN(sizeof_field(struc= t iphdr, daddr)), [VXLAN_VNIFILTER_ENTRY_GROUP6] =3D NLA_POLICY_EXACT_LEN(sizeof(struct in6= _addr)), }; @@ -814,7 +820,8 @@ static int vxlan_vni_add_del(struct vxlan_dev *vxlan, _= _u32 start_vni, int cmd, struct netlink_ext_ack *extack) { struct vxlan_vni_group *vg; - int v, err =3D 0; + int err =3D 0; + u32 v; =20 vg =3D rtnl_dereference(vxlan->vnigrp); =20 --=20 2.53.0 From nobody Fri Sep 25 04:08:10 2026 Received: from mail-wm2-f12.google.com (mail-wm2-f12.google.com [74.125.225.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 160974B1D1E for ; Wed, 16 Sep 2026 19:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587490; cv=none; b=EQWF0EACJ07G2xyvWPt18HUMBOyZj6LV+GrqNEq88/y2MkGcfbqfYVqL0/hSDXhD7hv/I6EZNalYcDcgyiwdKUGUv0SBgL0Fs2HOtObgfLisKspDvo93kswzBX6rDk+roZsnPa9NvOE2DZ4dDzJuoR2z/UKuCGQSngMOMcWyAyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587490; c=relaxed/simple; bh=yplVFRAFa94y/k5PPMn8uE7M5AkSzATAdqIoyN/qNAk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vCgvXgggbaj8GX7hngsAdHwTCn/Bv37mEfp4itkf+dRiXbGU/KZLlSXNtGQKL8o4/PD4iFinxDU+clQYxpBHxvQsIdazrcdvl2r23SeLX7SvtYKqdPEBD7hS5rWdm5SwszHnx/12cxvvgbVIOOUQ1RPjwg4yrAGywtrqrMKmm+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gq9ffwJJ; arc=none smtp.client-ip=74.125.225.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gq9ffwJJ" Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49b912df756so726045e9.3 for ; Wed, 16 Sep 2026 12:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789587460; x=1790192260; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hqBEDTU8nPSvf5UYETgqnWhTRAs3DpHURSqSqutOD2E=; b=gq9ffwJJl6pEQ8M+WG6WhaRBoYUyDWrVhP5pCnqASFXSqoGAXtw8uBYJ5hBj/ouHzP /hpiHIok08F7S12ru01kmthT0r1UvIJMqITYRQyO/enKll2V0PoTex+m9vll/gShZ0P3 fm756zp7Khk7INV/v8gZ9dMHKSnHASZrRYv2fy4I8ofPb4BHi1TntM6SOI5ypfiHh/pE 9BXvz+VKmxePazRyha1+tykXFz23CwIDPUjCNqUWKVowO/NVF4kE97tM5oE36Utxh910 kiOev7wG8L1AX1nX3p+FSDAn0fNuNm5tamjuO+66ZQD+mtO42dohOMZlKXh7rFkVPOW1 2D4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789587460; x=1790192260; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=hqBEDTU8nPSvf5UYETgqnWhTRAs3DpHURSqSqutOD2E=; b=y32NzC2zrq8TadgmTyEDuZ8t7dfIYkj7mE0MM8RZyPI9X3d+5GhklWIXbALOOXzItP Jb8erbiaXTNv0UIfeai7WKjsYdf7Sd83anBB21ABEqeTEUQQnbnOKo5WW9M4Z6X8JyqT fYfETbRmPWLAXojAcNd05KzvuE/YfpKq0/ATCSc/4aMkmAeXKUZN4n7gJzYDM0mUKmk6 u2ohkryhHZ3M/cGVxx1iVKCFOf3Apc6mgcTsKohueyzbQmED0zcm46aTrWTJbUYYhblP acJvL9ctfbiFQmoqGLxy7iapk2giANreQoD40C5jKkP9oPtcJLiwaivghfbZMZG5JSoT fUnA== X-Forwarded-Encrypted: i=1; AKwUvBzfDI4yts0GoQ0VLOCO/DgXVpbev/lBn4mZu5656ZANFwLY9gVA7i7V++DWRyNroj2YMEIYlRC+W2WeM90=@vger.kernel.org X-Gm-Message-State: AFuF++n/rUqgZMceM6tSoAZjCDc6Iuz83ISKNFjx1I8CE8DkvcZrE0Wg 1eC5DkREjouS8UVozE4xVV5Y1FQkRYGvn0MatEIroTvX3Aipfscv4B/P X-Gm-Gg: AYBFou3OGiv2r2v4MwCzcaAqxMct6ezMitvVxVqGSFsx9iw3tD529CvUIK+kCgt0RJF jLDhT+6y4wccuuPngx04KXzsXHlp8PtNy71DsDMwNiH882GQXYWFTS+EWUIPm/fuO2KHBS763CX UHnMhN08ybMZOl8FAzTiLK6YneUNk46aexccYyj1gSy9loVm0LfyOTuZQQnQcVaiYaec4JI5ERk 6AYR7q9sCAshwI/uDW3dMX7LqoiIFFYvybQpsemnT2x1Oo3NN+HIVhblaAg7EBU71JyIdWtlL44 sF2vxS2h85A1m/C3IItR9AkC5/WKdaZ9c766MkU/hatNospOy0t9XUfcQ8qGBrmDoec2qxBtUKw zipOz9dCgqS6iBpgyfJoguYXnhzPgL0tgd/3/YYIrqMGQDIiJMKXUojtAowbAWLsl1kDIp8/ToZ 67H0kOR0DmOqa8Q4d4gSsuojC/sKTADBQW8TjSDSgYHKtUgIZ8dXYZUykmoSwAKZ4= X-Received: by 2002:a05:600c:4505:b0:49c:fc6e:8cae with SMTP id 5b1f17b1804b1-49eb73475efmr47512675e9.18.1789587460386; Wed, 16 Sep 2026 12:37:40 -0700 (PDT) Received: from kali ([169.224.126.44]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fbd23ac75sm12936105e9.13.2026.09.16.12.37.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 12:37:39 -0700 (PDT) From: Ali Firas To: netdev@vger.kernel.org, idosch@nvidia.com Cc: 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, linux-kernel@vger.kernel.org, Ali Firas Subject: [PATCH net-next v2 2/5] vxlan: vnifilter: bound the number of VNIs one request may touch Date: Wed, 16 Sep 2026 22:34:46 +0300 Message-ID: <20260916193449.2552039-3-alishmery18@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916193449.2552039-1-alishmery18@gmail.com> References: <20260916193449.2552039-1-alishmery18@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With both endpoints bounded to the 24-bit space, a single RTM_NEWTUNNEL or RTM_DELTUNNEL message can still ask for all of it. vxlan_vni_add_del() loops over the span creating one VNI node and one per-CPU stats block per iteration, all under rtnl_lock. The span of one VXLAN_VNIFILTER_ENTRY is not the quantity to bound. vxlan_vnifilter_process() calls vxlan_process_vni_filter() once per entry, vni_filter_policy places no limit on how many entries the nest may carry, and an entry carrying just START and END is 20 bytes on the wire, so bounding each entry on its own would still let one message ask for thousands of times the bound. Sum the spans of every entry and reject the message as a whole in vxlan_vnifilter_check_msg(), before the dispatch loop rather than inside it: entries are applied and notified one at a time, so a limit enforced during dispatch would return -EINVAL only after every preceding entry had already created its VNIs and sent its notifications. The limit is 4096, which follows from how the interface is used on bridged VXLAN devices where the VNI is derived from the VLAN and so cannot exceed the usable VLAN ID space. It bounds one message, not how many VNIs a device may hold: a device can still be populated with the whole space, it just takes more than one message. It is a driver-local constant rather than VLAN_N_VID because a bound on a VXLAN netlink request is not a count of VLAN IDs. One asymmetry is deliberate: vxlan_vnifilter_dump_dev() merges a contiguous run sharing a remote into a single entry with no clamp, so a device populated by several accepted requests can dump as one entry this check refuses on replay. Chunking the dump would not remove that, since the same run split into capped entries still exceeds the limit when they arrive in one message. Assisted-by: LLM Signed-off-by: Ali Firas --- v1: https://lore.kernel.org/netdev/20260909092645.3105263-1-alishmery18@gma= il.com/ drivers/net/vxlan/vxlan_vnifilter.c | 88 ++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_= vnifilter.c index 5aaaaeee8110..9a1baca39d8b 100644 --- a/drivers/net/vxlan/vxlan_vnifilter.c +++ b/drivers/net/vxlan/vxlan_vnifilter.c @@ -17,6 +17,15 @@ =20 #include "vxlan_private.h" =20 +/* Maximum number of VNIs one RTM_NEWTUNNEL or RTM_DELTUNNEL message may a= dd or + * delete, summed over all of its VXLAN_VNIFILTER_ENTRY attributes. VNI + * filtering is mainly used on bridged VXLAN devices where the VNI is deri= ved + * from the VLAN, so a message touching more VNIs than the VLAN ID space h= as no + * practical use, while an unbounded message can walk the whole 24-bit spa= ce + * under rtnl_lock. + */ +#define VXLAN_VNI_FILTER_MSG_MAX 4096 + static inline int vxlan_vni_cmp(struct rhashtable_compare_arg *arg, const void *ptr) { @@ -846,12 +855,77 @@ static int vxlan_vni_add_del(struct vxlan_dev *vxlan,= __u32 start_vni, return err; } =20 +/* Derive the VNI range one VXLAN_VNIFILTER_ENTRY selects. Shared so that = the + * count taken by vxlan_vnifilter_check_msg() cannot drift from the range + * vxlan_process_vni_filter() then acts on. + */ +static void vxlan_vni_filter_entry_range(struct nlattr **vattrs, u32 *vni_= start, + u32 *vni_end) +{ + *vni_start =3D 0; + *vni_end =3D 0; + + if (vattrs[VXLAN_VNIFILTER_ENTRY_START]) { + *vni_start =3D nla_get_u32(vattrs[VXLAN_VNIFILTER_ENTRY_START]); + *vni_end =3D *vni_start; + } + + if (vattrs[VXLAN_VNIFILTER_ENTRY_END]) + *vni_end =3D nla_get_u32(vattrs[VXLAN_VNIFILTER_ENTRY_END]); +} + +/* Reject a message asking for more than VXLAN_VNI_FILTER_MSG_MAX VNIs bef= ore + * any of its entries is acted on. Entries are applied one at a time and e= ach + * one notifies as it goes, so a limit checked inside the dispatch loop wo= uld + * leave the entries ahead of the offending one already applied. + */ +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 =3D 0; + int err, rem; + + nlmsg_for_each_attr_type(attr, VXLAN_VNIFILTER_ENTRY, nlh, + sizeof(struct tunnel_msg), rem) { + u32 vni_start, vni_end; + + err =3D nla_parse_nested(vattrs, VXLAN_VNIFILTER_ENTRY_MAX, attr, + vni_filter_entry_policy, extack); + if (err) + return err; + + vxlan_vni_filter_entry_range(vattrs, &vni_start, &vni_end); + + /* A start above the end selects no VNI at all and costs + * nothing; leave it behaving as it does today. + */ + if (vni_end < vni_start) + continue; + + /* vni_filter_entry_policy has already bounded both endpoints + * to below VXLAN_N_VID, so one entry adds at most VXLAN_N_VID + * and vnis cannot wrap before the test below rejects it. + */ + vnis +=3D 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; + } + } + + return 0; +} + static int vxlan_process_vni_filter(struct vxlan_dev *vxlan, struct nlattr *nlvnifilter, int cmd, struct netlink_ext_ack *extack) { struct nlattr *vattrs[VXLAN_VNIFILTER_ENTRY_MAX + 1]; - u32 vni_start =3D 0, vni_end =3D 0; + u32 vni_start, vni_end; union vxlan_addr group; int err; =20 @@ -862,13 +936,7 @@ static int vxlan_process_vni_filter(struct vxlan_dev *= vxlan, if (err) return err; =20 - if (vattrs[VXLAN_VNIFILTER_ENTRY_START]) { - vni_start =3D nla_get_u32(vattrs[VXLAN_VNIFILTER_ENTRY_START]); - vni_end =3D vni_start; - } - - if (vattrs[VXLAN_VNIFILTER_ENTRY_END]) - vni_end =3D nla_get_u32(vattrs[VXLAN_VNIFILTER_ENTRY_END]); + vxlan_vni_filter_entry_range(vattrs, &vni_start, &vni_end); =20 if (!vni_start && !vni_end) { NL_SET_ERR_MSG_ATTR(extack, nlvnifilter, @@ -975,6 +1043,10 @@ static int vxlan_vnifilter_process(struct sk_buff *sk= b, struct nlmsghdr *nlh, if (!(vxlan->cfg.flags & VXLAN_F_VNIFILTER)) return -EOPNOTSUPP; =20 + err =3D vxlan_vnifilter_check_msg(nlh, extack); + if (err) + return err; + nlmsg_for_each_attr_type(attr, VXLAN_VNIFILTER_ENTRY, nlh, sizeof(*tmsg), rem) { err =3D vxlan_process_vni_filter(vxlan, attr, nlh->nlmsg_type, --=20 2.53.0 From nobody Fri Sep 25 04:08:10 2026 Received: from mail-wm2-f12.google.com (mail-wm2-f12.google.com [74.125.225.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC984495AE3 for ; Wed, 16 Sep 2026 19:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587492; cv=none; b=O7IWBsSv41uIKVbCWbQEhKRRcZpclwx7nVMlqmnM7jg5ooyUYD6FGEWNTx6QNQdh0oz2f56UYL+tDDn01Epk/lOCWJxHjphhTuOy8d0LOObcc6pGlmRrXvolaVECPwlvenm+3mLsJgC0WE1M6rlCnGJSfyb3EG5iR/jdEATssUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587492; c=relaxed/simple; bh=B4CPVh+5rWhlU/pXoDIh36pS5SijulILYduOtOart7M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VKOahXLQF67ThjhsuOOo9umNBDCU+i/m9sF4TTZRSqWvM0LcMnucCLVKYnxxGjY5ludaBGZFnhVQtGu8iRu2oR3aze2SC/uWX6qhvo926t7V0m474JymP8Vp6VVYkp3CFdM+FU9aPA4wGHC2JPmuNXbJI5XmjRj7x8IDKNT9dHY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=n/2PxljE; arc=none smtp.client-ip=74.125.225.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n/2PxljE" Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49b91369d18so949235e9.0 for ; Wed, 16 Sep 2026 12:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789587463; x=1790192263; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5SzyobERMhWoAi0wsAy/lTdmDWo3eJYL4BsZertPOTA=; b=n/2PxljEjS/Md4Ser2yRH9lhE9iKMhttyqFaMU3TFqeZl4lcLqR24rkIHkGQtAonVS tBqZvRAkAhBYTANhqAb8nlUPwJJHLLSz9cb2ZI/baUJVp3GRXPGOqxbRw4HUTZHO+42T vAXZMagjN+qlONZM5TrGKYmgyaBA66e8vSWDjXTeCjDsiUT4UYn7XUrNavNFjI58kD4P rio+W/NCTNH0NEYpyjgFqQP/v27UnI78A1dl9GLi/8bl7ppRxas3EAxKgdHWlasQca16 wAf8uKikRAfb5PMpiXB+E3DelG15WtPKU78G+GUd7dgtWPrdQkw/lKhOjS6SBp2gM5oQ 71Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789587463; x=1790192263; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=5SzyobERMhWoAi0wsAy/lTdmDWo3eJYL4BsZertPOTA=; b=B22pLrZdmMQEh6DHXASlhWPnya9Tt2sbEzBhtKg+5f38S0NcaKccgT/I4yIm7hD5ct KxrYUqf2hibmyc06lQV7p6D9MXP5wtOWqYnUdwIAkRt4mFyW9Rtt7NLalM+aZHPOlObr I8/djHTtj77mWQ58x5aKqgcBOIZ+4ebTUpQ7gld+vZjRkXyBzodWaVMYII5MaRIO57DX CqWAncvDE6ToZ4QZsx4+eNNwPPCkVlX2z9ja6aHkRB9eZSoz4Wr2Oq9mOEDeF614gkBT NU95IrK93/quAN4o52WOp56wsJyLU1+a458XSgMKGs4L/+uaP0lvkByby3Vdj26Sb9VH y8OQ== X-Forwarded-Encrypted: i=1; AKwUvBw0jKW6g+WngHyalp9JXdY1B+kmGhkM+WAioK/3xEUCi0ltJE0211VSTbaWDGnZhtJujHtIF366k7L91kk=@vger.kernel.org X-Gm-Message-State: AFuF++kM7RZ9rxoIQHypMzKPKUdXkoFrmNspmFp+OYR580jYafIij4Pe lF9d8u+Y9xgJSsp2xV9y2FhtWiEHPnVaj4bhhijUVwuQFk0qaSaQGr0N X-Gm-Gg: AYBFou28oWFx/ATz7ZVfA1ZXkkyOlg8z1dwn2H3GYz2atJk9DyvTUaCOAfOuWQrXM96 pgt3YRAbp/idc9TCIZIONQfizWo5axi1A2RvoMZ9Pz4Xxq4mM9p/+7Jo5oUu72rJnD4f0okd/G2 qL3ghVdslZvFRosuzaGA83Uc2wy+xsHL9ycbp5IgCljbZKr81HA/91xlnTTHz704oxeRTsacG+4 PyUVqMhLi6cdOt9IEdscAHBHzmeq/dvLqRT9XL0GR5ik5UTXDR+21ixYPuPqWuwvI+XL7J+jqmK LLWw6spSiNB9Ay+LK4G4vneZHYvhWqjdFuHooM7RpFjaNK+TMYUyNDOl8Lgnhu+4cbD5CoONiov Tm5gE84muciBJLPoS3f426FPRRhj3EQ8+bEQJrtKyvHZjA4AHNn/R7v9iL8Q9U6MJovTfX35f1P yqRtgF0fnYu+4W7hwg/D+oOeUxGcl+Y+bwXbnP8ebQ8oFMU+8ZVkTEJVFt4dg+YzA= X-Received: by 2002:a05:600c:4e86:b0:49d:15b9:2a2a with SMTP id 5b1f17b1804b1-49eb72f3d08mr47340035e9.10.1789587462833; Wed, 16 Sep 2026 12:37:42 -0700 (PDT) Received: from kali ([169.224.126.44]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fbd23ac75sm12936105e9.13.2026.09.16.12.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 12:37:42 -0700 (PDT) From: Ali Firas To: netdev@vger.kernel.org, idosch@nvidia.com Cc: 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, linux-kernel@vger.kernel.org, Ali Firas Subject: [PATCH net-next v2 3/5] net: account per-CPU netdev stats to memcg Date: Wed, 16 Sep 2026 22:34:47 +0300 Message-ID: <20260916193449.2552039-4-alishmery18@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916193449.2552039-1-alishmery18@gmail.com> References: <20260916193449.2552039-1-alishmery18@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" netdev_alloc_pcpu_stats() allocates a per-CPU stats block with plain GFP_KERNEL, so it is not charged to the cgroup of the process that created the object it belongs to. The netdev's own queue arrays, ethtool state and NAPI config are already allocated with GFP_KERNEL_ACCOUNT in alloc_netdev_mqs(), which leaves the stats block allocated alongside them as the unaccounted part of the same device. Make the macro use GFP_KERNEL_ACCOUNT. This affects 34 call sites in 25 files; all of them already test the return value and propagate -ENOMEM, so none of them has to be excluded. __GFP_ACCOUNT only charges an allocation made from a task in a non-root memcg, so callers that run at boot or from a driver probe are unaffected in practice. The devm_ and explicit-gfp forms of the macro are left alone. Suggested-by: Jakub Kicinski Assisted-by: LLM Signed-off-by: Ali Firas --- v1: https://lore.kernel.org/netdev/20260909092645.3105263-1-alishmery18@gma= il.com/ include/linux/netdevice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 1f0710eef185..7c659012355d 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3171,7 +3171,7 @@ static inline void dev_dstats_tx_dropped(struct net_d= evice *dev) }) =20 #define netdev_alloc_pcpu_stats(type) \ - __netdev_alloc_pcpu_stats(type, GFP_KERNEL) + __netdev_alloc_pcpu_stats(type, GFP_KERNEL_ACCOUNT) =20 #define devm_netdev_alloc_pcpu_stats(dev, type) \ ({ \ --=20 2.53.0 From nobody Fri Sep 25 04:08:10 2026 Received: from mail-wm2-f12.google.com (mail-wm2-f12.google.com [74.125.225.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C275448FF7E for ; Wed, 16 Sep 2026 19:37:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.140 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587511; cv=none; b=L0XNnysgSdS/uCuV/6rArTN/i7fSOUO/9zq7ekT6SrtUEhF4S1auBHwxixrW/tpk3wxQTuGuaOQk2M3ysL0mLlvlLsGrcp5UBfQXnsoR9+ts5kLMWlH1o1aI70pyTVtKRMyu0UkPKc6mk7EEb5Pn0Thgg7b9nZsOZhPdmk7Z3yQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587511; c=relaxed/simple; bh=GUUQbRt1zMfb+eBg5VoDPbwqdt+9wQD7eh4Y4Ha+Vco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZgGv4ym7gqsy4o/4RlKdBdSpWcgBpdTrl3JtZaYzRNu3jm85ovtf5x3Oy6RmBGAsitzTtsQqtMW1yJ2LUyog+dxjS+p06kGyRkCLmjGmRpwdaQUs3AGhzHHAOhG8JdVZq1E59MmD7zFHSvOZHSQjp0We/t33hdriDBg3wpNSELU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lhxKBbVo; arc=none smtp.client-ip=74.125.225.140 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lhxKBbVo" Received: by mail-wm2-f12.google.com with SMTP id 5b1f17b1804b1-49e620fa473so614585e9.1 for ; Wed, 16 Sep 2026 12:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789587465; x=1790192265; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hqmFViQO1iqqbGZZzEcy3ok+zdPAZK2tv24+QLSxd2g=; b=lhxKBbVojw5DhqleSjJ4N39W4YbSbbTIwV3CUz1D20d84WfvOGJT16k9SIB5cIkJTZ DDI2qYa2gCBmeu26/5PHlT3Mj61C/YAtjARS48Yt9iD2Gz1105+uV6N74hKo7CMi1r/L xpVrze4QT/I7ZjHWrkJ79WeabbVRgQjHiEYOPaFWiXOdwJkFfKdjteP7hKgBIVOUM5Y8 z1GGksblsVD3EL72cyBl4HBZKxNoEyB5vT1xNoYXCehyeFCF8g4IeLyTdmRKynW/j/Jh 8GdPILsk+EHMOkJt+o+juNEIp1tkv7x8U2cd8w7/xcVQ1z48AauncTHbqeQ02gkkbNVM IXEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789587465; x=1790192265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=hqmFViQO1iqqbGZZzEcy3ok+zdPAZK2tv24+QLSxd2g=; b=IoVJpCUV6pLv+WaoWwRTD9EGlqYhYmnKcrOuUjAKJNg4mAdR8aZ1+6++dr+yNwzPz3 MnYYoycw3qIjyaWcq9NC5VPkRliUPdkeZ76ZzK7IUrkBMAkE5N3vOnISUe3dN+xWU59T Zkg0ji33D7/0RqMq9U/xVhFk9JY9UNxtSzTJ0aJzD+QdKYRR4oR9n70QNr8876Z8qj4H 4cNiCWKxj1OGxEB0xtmE6XbZXFOqfUp8by+Cra0roCBw5U7NkSUzH699wyT6rvjHGPuf iMNbeM37a3+rzUAzy39pFThUd67R5cV2umYoZ89RazvVB+ThjSQbb3obGd8oW2y/PrFy 8YaQ== X-Forwarded-Encrypted: i=1; AKwUvBxKeT+JBFnho5mDKmWJaRlTnvyVVhtdMYhaxkGBMJ+Qf8Tcphyy3Beh+ypN5bZ1LDKJkUTL4c3ZzjP+GdI=@vger.kernel.org X-Gm-Message-State: AFuF++nrSbVeHr7kgyvM0kHdrM98rGQNdCEYnrnqoVZi5qNTFsvfQ9HX rVk3jNigWlPKWrwTTS1ut3Pq6j4fkDsTENw2TbLs3VOvvCvOzOiRaseZbvvig1SC0aQ= X-Gm-Gg: AYBFou1TU/9XVle4qINGfxn3IXpLulwDbga8ER0WvOy7THbrl0n0lk2wh1OJUJgDSrW H5qaOQ0KNSNxEpberl3Awl2olIRBLmxwLfLOJhP2kSVyiJwnKt270tVcg5NSuXe2lFQiRXl0ZvC fX5SYER6eoJ3+TpX/q5PO98Aj81M/RdrvC8E2i6UVTr1X+ViCHPcBU6L6hMlAMNvxAKeB3M4QzM D++eONdLHndKRfarrmElrnM7zVeJUN7WKKT11nBCBRvjIGptXN7g7jl5U+qZL41xYrUo96RBJ1E +3skZoCnbJFkJsEL4Ok/i/mmToZ1BAPJ1VIl2PPeQX52JpUCILrWixU/PJIgkXlwT4T5AxI6e9w 4hZUwAdqDu2Km82nPgooXmlLa0P0/XqURRYsiVm/x8pHdLpu9q0Ip572W0Dbm4RA6o4RjzvOWnv muOMp7W+/+iN5xXQeoD70XazXD1or9mNazBAedz0e/bDqrJ6Nak82wKBlh8+CpZP5Lr52fY+aIU g== X-Received: by 2002:a05:600d:8485:10b0:49f:bc43:9e96 with SMTP id 5b1f17b1804b1-49fbc43a0a0mr19318395e9.8.1789587465257; Wed, 16 Sep 2026 12:37:45 -0700 (PDT) Received: from kali ([169.224.126.44]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fbd23ac75sm12936105e9.13.2026.09.16.12.37.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 12:37:44 -0700 (PDT) From: Ali Firas To: netdev@vger.kernel.org, idosch@nvidia.com Cc: 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, linux-kernel@vger.kernel.org, Ali Firas Subject: [PATCH net-next v2 4/5] vxlan: vnifilter: account the VNI node to memcg Date: Wed, 16 Sep 2026 22:34:48 +0300 Message-ID: <20260916193449.2552039-5-alishmery18@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916193449.2552039-1-alishmery18@gmail.com> References: <20260916193449.2552039-1-alishmery18@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" vxlan_vni_alloc() allocates a struct vxlan_vni_node for every VNI with plain GFP_KERNEL. The per-CPU stats block it allocates next is now charged to the caller's cgroup, but the node itself is not. Use GFP_KERNEL_ACCOUNT. The only caller already handles a NULL return. Assisted-by: LLM Signed-off-by: Ali Firas --- v1: https://lore.kernel.org/netdev/20260909092645.3105263-1-alishmery18@gma= il.com/ drivers/net/vxlan/vxlan_vnifilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_= vnifilter.c index 9a1baca39d8b..fbff52c450c0 100644 --- a/drivers/net/vxlan/vxlan_vnifilter.c +++ b/drivers/net/vxlan/vxlan_vnifilter.c @@ -710,7 +710,7 @@ static struct vxlan_vni_node *vxlan_vni_alloc(struct vx= lan_dev *vxlan, { struct vxlan_vni_node *vninode; =20 - vninode =3D kzalloc_obj(*vninode); + vninode =3D kzalloc_obj(*vninode, GFP_KERNEL_ACCOUNT); if (!vninode) return NULL; vninode->stats =3D netdev_alloc_pcpu_stats(struct vxlan_vni_stats_pcpu); --=20 2.53.0 From nobody Fri Sep 25 04:08:10 2026 Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B6CB4BF954 for ; Wed, 16 Sep 2026 19:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.141 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587476; cv=none; b=LSqTKFPQ9pvIk0qyIBbL3CNhzAWU1W01ouj/wL9r+EJJYV4J+5oeVC4jnNYrq4xuYM1+3i2nSbxp+2Z7JfHuKYnG1uoDMlBL3+xtPTuz681Jusbd0DQ9yJsA31C24lgYg/H1fRle0JbYGIXH50ZHMjr6wGNnVXJqNYLnQrIj7m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789587476; c=relaxed/simple; bh=y6xXqWOvYSXsLSEuNcKM2L/zBtXrSEYd2AuG3tsZsqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PIM6M9S3cQ/tWFFyWtD3VdVQoQtAAUG+Ns8foGVAq/v0t/P4HOdargqssAPPUCbeZLsvZm9MPjxu3ctsnUIryaIdKnzwhZSmTHRtDLU7D6MwQ0YJO19zssf7buSzlBdvas2PS4/9cF4jgrVfyp/lIrMQLRQi60K+xMd0Iheq57c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pyRyd8Qo; arc=none smtp.client-ip=74.125.225.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pyRyd8Qo" Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-49e721b5503so931105e9.0 for ; Wed, 16 Sep 2026 12:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789587468; x=1790192268; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IZ21S6r7mSJbbzYfZEaWtwaGPB2HSj6XAkt8M6MDS6g=; b=pyRyd8QouDmyqUDG32jyyPxTlpWB8RNL1kuPHBsj/QUqbvuHNkLZlN3RGPxTH7D3FX rJFWLsG/NoReafY7p/zQtdJRWEaAdaYUV75vEX/CZ4QCHpls8hyih/EdGJZ3MWwH5BEc ug88mU3lucEG+2K1nagOAp1PWtJwwSnk6hgczsoAkKkgS9YIpWutH84jKViOfz9pbUOD fSRVFvovkFnOk6TGSAF1hftN5ki0t0FoIWtBiR7UVLcti4yqckrCrReKzwBQ1S6206b5 V9asB8Rn/oJh2kVpKiEKJQqTlR7BUOF0/y8F0A/hhlGWaISCpBKGMACIoRsfgyePKe0L sWDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789587468; x=1790192268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=IZ21S6r7mSJbbzYfZEaWtwaGPB2HSj6XAkt8M6MDS6g=; b=A+KjFKILWkwOlD60LzhYjcLF4M73iSqbuis8U9/5G/BeZY9gki0WdWb/g4NQs1lfZ5 4343al7jQfJ7r6AnsuJC3GlCpz9vCw37LWdITj7iSKjcfHSyIP1RM1sJ0SzHUV6I1kBr 1cbaG92zE4OjvWjdhGGnAfoqTZf1pSKFKrb5lAl3qEABVnQ8ovWPaDcTNUsUNTAlV+A7 4WBvG5CjnJYWgB9iD24ytEEtMIYAPB84LscBk1WMC7SDr+7wthDP6Rp51DBVQdIIlXi3 NPaSTlcS6dHHIshlYyhht5bGw/gcsmURlumapbWRJcSTiak47YtzxuUlB+pmvOS4XsJM wsww== X-Forwarded-Encrypted: i=1; AKwUvBy1QplWnXd7mjUA94GQ8kKA09nOHP8km3eImUfdJiRjaW4xzayzq7OOjRMeGyYxGFI/HMuwrIUIvLklPNE=@vger.kernel.org X-Gm-Message-State: AFuF++lSOCTtzD42OMdQOCSn5+COwL2ApvwFZsOx+bCXs+cpDk2s9jt6 ZZV3W1NOGvNU9iGfjiFOxi8Zl/ArqC6mmKC7zMMtbOzSQhC+sOHmgKev X-Gm-Gg: AYBFou0IAIwExaxmf4D4hUYUCajg4348OV73xT4kWkreGC7o11aeBRkGV0sdT0uswGA ZuEMlhIIJYx1Cl0ZRKk3NG4i40noCGDYnEsK3M1JkhRAIipGPIyPtGjkXsTZUscMgCUViqhoe/w t4dJVpVRq5sDl7wQBAvz6fsBBkjv/poV1e7WskT9gO/2czD8r4uYTwLoAtjVziYcXRE6DQUdkmt 1S8UZT2mWf5JqQrainnc7QUCAYtkCNPcrSc9CDTPmRh83h7N55F17YiorFsOijHxxxKHACPMFfj G2eCXnPpqPao59DCJgkcJwAfw9GalWdbkt7JUAJyqnTteY8LmBCTJUN0Dt/t3a9CL3LvGM5UMst STpk3HmQAYA1pT/GuW8U6jVL/108V/slWOJEtjzfqMaf/kvlB7yGOWizJWXd7Iz900If1jz6UJh yHFdvC6CjHt2WHwQ8PsQaFkH+eh7NPCge8EzXG8cKQQ9sKyUwiiWrCdnShwe2F+ew= X-Received: by 2002:a05:600c:83c8:b0:49d:28c4:b304 with SMTP id 5b1f17b1804b1-49eb7341406mr42101875e9.29.1789587467669; Wed, 16 Sep 2026 12:37:47 -0700 (PDT) Received: from kali ([169.224.126.44]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fbd23ac75sm12936105e9.13.2026.09.16.12.37.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2026 12:37:47 -0700 (PDT) From: Ali Firas To: netdev@vger.kernel.org, idosch@nvidia.com Cc: 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, linux-kernel@vger.kernel.org, Ali Firas Subject: [PATCH net-next v2 5/5] selftests: net: test the vxlan vnifilter VNI limit Date: Wed, 16 Sep 2026 22:34:49 +0300 Message-ID: <20260916193449.2552039-6-alishmery18@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260916193449.2552039-1-alishmery18@gmail.com> References: <20260916193449.2552039-1-alishmery18@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Extend the vnifilter API test with the largest accepted range and one VNI more rejected, for both add and delete, and with the 24-bit boundary the first patch enforces. The oversized delete is written so that it can only fail on the limit. If it covered VNIs that were never installed, a kernel without the limit would reach vxlan_vni_del(), fail with -ENOENT on the first missing VNI, and iproute2 would map that to the same exit status the test expects, so the case would pass while the limit was gone. Installing the range first makes every VNI of the oversized delete exist, leaving the limit as the only reason for it to fail. bridge(8) sends one VXLAN_VNIFILTER_ENTRY per message, so these cases exercise the single-entry path only; the per-message total across several entries is not reachable from iproute2. Assisted-by: LLM Signed-off-by: Ali Firas --- v1: https://lore.kernel.org/netdev/20260909092645.3105263-1-alishmery18@gma= il.com/ .../selftests/net/test_vxlan_vnifiltering.sh | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/testing/selftests/net/test_vxlan_vnifiltering.sh b/tools= /testing/selftests/net/test_vxlan_vnifiltering.sh index 8deacc565afa..7cd4acc76ed6 100755 --- a/tools/testing/selftests/net/test_vxlan_vnifiltering.sh +++ b/tools/testing/selftests/net/test_vxlan_vnifiltering.sh @@ -371,6 +371,40 @@ vxlan_vnifilter_api() # change vxlan vnifilter flag run_cmd "ip -netns $testns link set dev vxlan-ext1 type vxlan external no= vnifilter" log_test $? 2 "Cannot unset vnifilter flag on a device" + + # a single request may touch at most 4096 vnis in total. bridge(8) + # sends one range per message, so these cover the one-entry case; the + # total across several entries of one message is not reachable from + # iproute2. + run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 10000-14095" + log_test $? 0 "Add vni range of maximum size" + + run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 10000-14096" + log_test $? 255 "Cannot add vni range larger than maximum" + + # install the one vni past that range as well, so that the oversized + # delete below can only fail on the limit and not on a missing vni + run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 14096" + log_test $? 0 "Add the vni past the maximum range" + + run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 10000-14096" + log_test $? 255 "Cannot delete vni range larger than maximum" + + run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 10000-14095" + log_test $? 0 "Delete vni range of maximum size" + + run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 14096" + log_test $? 0 "Delete the vni past the maximum range" + + # the vxlan header carries 24 bits, so a vni above that is rejected + run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 16777215" + log_test $? 0 "Add the highest vni the vxlan header can carry" + + run_cmd "bridge -netns $testns vni del dev vxlan-ext1 vni 16777215" + log_test $? 0 "Delete the highest vni the vxlan header can carry" + + run_cmd "bridge -netns $testns vni add dev vxlan-ext1 vni 16777216" + log_test $? 255 "Cannot add a vni the vxlan header cannot carry" } =20 # Sanity test vnifilter datapath --=20 2.53.0