From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FFC2346774 for ; Tue, 23 Jun 2026 19:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782243913; cv=none; b=kEQKoJxBtRiPARx62lvKKSmBZ5UIgG4f0dVblrqsyLkiKIQcPjK92wGUIXlwiLS/1icQ0ghs/Xh6CCuSXl+0GqjRYJE0iBnLvRP0eWF/Lg2lS6NEPZSLRyIWgk2/SkHJe606nsUqI7jDTtAB94/gPMhD1GptpS9hpZAd9TBeNDY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782243913; c=relaxed/simple; bh=w0LYy/lkhOkRJ1mcPpKcBJQ8WkRX9RNPOn4dmhRbI5Q=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=QfwLrnnZhMvSH2K9wNt5CAz5058Gy2hzecw9sdh58Z62a/UoGEe0baQXH3hCuNzdJXXZdhLbb/QyCzkarWOKql9vv0lreU3rPwOlUPBsFDihWPgDy20RAh0aD2ftR1VHq7pdHhAg54CdTORW2tXMIWcNSQYKzLgkKm6EvkdM/yc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=H2wWzv3B; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=C80DDWAL; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H2wWzv3B"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="C80DDWAL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782243911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qROIoP7Ox4zuQ1KlaWsTu9O+Pw1tden3SzMg+Ihd/Yg=; b=H2wWzv3BZv/A/oZrzte7WS60CbbQ0STE4rNJq92LG2JjrFwkcOP5mx9aHfyfDtCySw3KWB tg8MMNe+EUUphNNkqwDHT5SI+kwrqJKeo9S2uuyLSZG9B4ug0yfpeSimNgQmZoG0x6RwCd Bz1V9H//fsgu/f9T3Ny+d4MduFLvZTE= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-CEmxgNeGMriExV8d6wHfgw-1; Tue, 23 Jun 2026 15:45:09 -0400 X-MC-Unique: CEmxgNeGMriExV8d6wHfgw-1 X-Mimecast-MFC-AGG-ID: CEmxgNeGMriExV8d6wHfgw_1782243909 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-c07ea058c29so19663366b.0 for ; Tue, 23 Jun 2026 12:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1782243908; x=1782848708; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qROIoP7Ox4zuQ1KlaWsTu9O+Pw1tden3SzMg+Ihd/Yg=; b=C80DDWALhw3IaHQk15oxw39d8rSpSI7WAqjthYUfBF2oToS6O3pJKXVuXEV2Mkrn54 5hJ3OftuSNNnP/Lz2OwNq7uHs8H4zL1zQ+GrGyHComQyy29ZjPY4KtyNfPLwcLKPf6cK obpUQFvNl6vsWTZmnHjbuvbmGRFXS07vrKVwCBG1WwO+rCw7EcjeXJRaqSaVYL7grw5q aXpPQoZGCE20BjyRQNd2SRhtvQP880Hp7k+G5uxTeLqkWyEyhdx1e6HLaR6mRndACkiV XuAlG/3EwQfGJk0DkAFeez2yaulfibWCzUqWxNRYLqMmnpVAgwPOBYg+SPEaP17xWL2/ 7cgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782243908; x=1782848708; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=qROIoP7Ox4zuQ1KlaWsTu9O+Pw1tden3SzMg+Ihd/Yg=; b=mMr9RXQ1znj04pWxcVDx3covGLHkfOCCINyXJEyBpVkgSnDUB9m4nIr/hU3q9nzs3E fr4ecqXt6T8PdhLllackU1ru8DPhUzAI9QRZmM3CV780118RIrfEmtnizwRh3dAdDxuS 3iwNtuPV8m6H+eNiDlIjdy6gudBj5lVHE7FHDRdE5qjvPJfZPvEuizAJO+19VCeCt/w4 eDTwNm59JpSXWTVLxPuZTJHUICwjAUkdq8hPUq5IJPqT8F3Yhqx8PwjfpFarSdjkfZYB 9MHeqASps3H/rBjtdKIZyDWnj1nei0JaK+T9V6ctIRjrZoDsE3Hk83/dwxgBs5XPuuqF fT7Q== X-Forwarded-Encrypted: i=1; AFNElJ+XZ9ue4FE/NOomx/g+TBesW56PJqN/3mRlSv1GAIbGwVTPbOJ88aQobvF7hoo2hGESEP2FFVp0i/PzQw0=@vger.kernel.org X-Gm-Message-State: AOJu0YzeqnD38Hj1+LeFeERCEJ99X/nsZElBqu5P3im4gchH/Rzr5eyu PpKx08t/WMXfahxCt0wqmcFMmygK7FBA7mPNdJt9cWrZyWgpc2j7BVetPnMNrDQU9Urrqjv9PGd Ht0rLZrwCxk6qV8Du8bdeHkU4YOqRAAjy22CNKrL46tBEi/w2yXAaJC4eREAN44NE0w== X-Gm-Gg: AfdE7cmRY29yj9OyiMc7TO1ziDzF97GtxUjU9sQnu+HvtUJ21WSJycC6ksDyDqEnbSS wv6QCEcGVdCzk/6qS/N1Y5MhH4q5k6S0q0nU80Gl6Y/lePT0/OsJVqkvHv5My9JvQYLCqc9v0SL P4CGAmdlBfMbSpzdHXZJ4nDfL9FV6rAR8ZMONSg/iqPCLgmvqFQ7vPnh9N8LLdh2QxzSke1TG4w pv4M2SV8hMWpxyaDzwrWVlSvKhWpS1jnQhPhRIzBdyMLc+yAexocM7xBH8ei/jQK2mKkH5BsxmO W7MRb7fUuduJJDzicm1WyJeBr8x3Bsy+iootffzezKRSabntTClFHSpzcI5kJ7soWU0R2o/YQQV aDfHf96Qj2w3kylqdesJnqt3OuDg71siSIxRUHw== X-Received: by 2002:a17:906:99c2:b0:bec:2d7f:fe03 with SMTP id a640c23a62f3a-c107e0dffb5mr233286966b.17.1782243908570; Tue, 23 Jun 2026 12:45:08 -0700 (PDT) X-Received: by 2002:a17:906:99c2:b0:bec:2d7f:fe03 with SMTP id a640c23a62f3a-c107e0dffb5mr233285566b.17.1782243908159; Tue, 23 Jun 2026 12:45:08 -0700 (PDT) Received: from alrua-x1.borgediget.toke.dk (alrua-x1.borgediget.toke.dk. [2a0c:4d80:42:443::2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c0c610e4c76sm563520866b.46.2026.06.23.12.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 12:45:07 -0700 (PDT) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 25089808D82; Tue, 23 Jun 2026 21:45:06 +0200 (CEST) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Avinash Duduskar , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org Cc: eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, john.fastabend@gmail.com, sdf@fomichev.me, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, hawk@kernel.org, yatsenko@meta.com, leon.hwang@linux.dev, kpsingh@kernel.org, a.s.protopopov@gmail.com, ameryhung@gmail.com, rongtao@cestc.cn, eyal.birger@gmail.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, dsahern@kernel.org Subject: Re: [PATCH bpf-next v4 1/3] bpf: Add BPF_FIB_LOOKUP_VLAN flag to bpf_fib_lookup() helper In-Reply-To: <20260623182849.2623521-1-avinash.duduskar@gmail.com> References: <20260623025147.1001664-1-avinash.duduskar@gmail.com> <20260623025147.1001664-2-avinash.duduskar@gmail.com> <877bnpeaeq.fsf@toke.dk> <20260623182849.2623521-1-avinash.duduskar@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett Date: Tue, 23 Jun 2026 21:45:06 +0200 Message-ID: <87y0g5ca7x.fsf@toke.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Avinash Duduskar writes: > Toke H=C3=B8iland-J=C3=B8rgensen writes: > >> I think it's better to just move the assignment of params->ifindex >> entirely into bpf_fib_set_fwd_params(), instead of this restore dance. >> That way this can be simplified to: >> >> err =3D bpf_fib_set_fwd_params(dev, params, flags, mtu); >> if (!err && fwd_dev) >> *fwd_dev =3D dev; >> return err; > > The caller-side restore is ungainly, agreed, but the assignment can't move > all the way into the helper. The early params->ifindex =3D dev->ifindex > sits above the neighbour lookup on purpose: that is d1c362e1dd68a > ("bpf: Always return target ifindex in bpf_fib_lookup"), which took it > out of bpf_fib_set_fwd_params() and put it there so a program still > gets the target ifindex on the BPF_FIB_LKUP_RET_NO_NEIGH path and can > bpf_redirect_neigh() on it. bpf_fib_set_fwd_params() is called only at > the set_fwd_params label, below the NO_NEIGH return (and below the IPv6 > NO_SRC_ADDR return), so an assignment living in the helper never runs > on those paths and params->ifindex falls back to the input. That would > change the reported ifindex for plain bpf_fib_lookup() callers hitting > NO_NEIGH, not only the VLAN ones. Right. Well, seems I forgot about that patch, even though I seem to have written it :) > I can still get the caller down to your form by keeping the early write > and moving just the VLAN_FAILURE rewind into the helper, with one extra > parameter, the input ifindex saved before the egress write: > > err =3D bpf_fib_set_fwd_params(dev, params, flags, mtu, in_ifindex); > if (!err && fwd_dev) > *fwd_dev =3D dev; > return err; > > and the helper owning the rewind in the unreducible branch: > > } else { > params->ifindex =3D in_ifindex; > return BPF_FIB_LKUP_RET_VLAN_FAILURE; > } OK, if we do need to restore it, I think it's better to do it there. Also, wrt the fwd_dev parameter: Do we really have a use case from using this from TC? In TC you can just redirect to the VLAN device; this is meant for XDP which can't do that. So how about we just reject the flag on the TC side, and get rid of the fwd_dev parameter entirely? If we do that we're back to just a plain 'return bpf_fib_set_fwd_params()' = :) -Toke