🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17467

Re: [PATCH net-next v4 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop

#17467
From: Jamal Hadi Salim
Date: Mon, 16 Nov 2026 22:06
78 lines
14864 bytes
On Mon, Nov 16, 2026 at 3:46 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Mon, Nov 16, 2026 at 11:01 AM Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> > The release goes through skb_dst_drop_keep_metadata(), so encapsulation
> > parameters a route carries are handed over to a metadata dst instead of
> > being lost, and a metadata dst already on the packet is left in place. Both
> > wrappers take their existing drop path when that copy cannot be allocated,
> > so a packet is never sent with the stale route.
>
> Just briefly looked at it. skb_dst_drop_keep_metadata() with kmalloc()
> in the fast path is really no go.
>
> Why not do something like this instead of patches 2, 3 and 4 ?
>
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 946b07a..13f2d57 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2470,6 +2470,10 @@ static int __bpf_redirect_neigh(struct sk_buff *skb, struct net_device *dev,
>         skb_unset_mac_header(skb);
>         skb_reset_network_header(skb);
>
> +       /* The route is for the old skb->dev. Keep the tunnel key. */
> +       if (skb_valid_dst(skb))
> +               skb_dst_drop(skb);
> +
>         if (skb->protocol == htons(ETH_P_IP))
>                 return __bpf_redirect_neigh_v4(skb, dev, nh);
>         else if (skb->protocol == htons(ETH_P_IPV6))
> diff --git a/net/netfilter/nft_fwd_netdev.c b/net/netfilter/nft_fwd_netdev.c
> index 7447da9..d1ac4eb 100644
> --- a/net/netfilter/nft_fwd_netdev.c
> +++ b/net/netfilter/nft_fwd_netdev.c
> @@ -15,6 +15,7 @@
>  #include <net/netfilter/nf_tables_offload.h>
>  #include <net/netfilter/nf_dup_netdev.h>
>  #include <net/netfilter/nf_recursion.h>
> +#include <net/dst_metadata.h>
>  #include <net/neighbour.h>
>  #include <net/ip.h>
>
> @@ -176,6 +177,9 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,
>                 }
>         }
>
> +       /* The route is for the old skb->dev. Keep the tunnel template. */
> +       if (skb_valid_dst(skb))
> +               skb_dst_drop(skb);
>         skb->dev = dev;
>         skb_clear_tstamp(skb);
>

Agreed on the alloc cost (and i will send v5 to resolve that). Having said that:
skb_valid_dst() is  essentially  "a dst is present and it is not
DST_METADATA", so it is true for a route (skb_dst_drop() then releases
that route) and true for keys built with bpf_skb_set_tunnel_key(); for
encap ip/ip6 or encap xfrm template the tunnel template lives in
dst->lwtstate  that wont work (packet reaches the tunnel or xfrm
device with no encapsulation).
For that reason we cant drop 3 and 4. I see the change in 2/4 (I see
1/4 not changing either) .  The change is not that small because it
will have to touch multiple core files (although just small mechanical
surgeries). Summary it will still be 4 patches..

cheers,
jamal

> pw-bot: cr
Technical Details
Message-ID: <CAM0EoMk10vCoAKZq0P=8A_jed=Z3SudLEUV8uvXO5F=ewNjnGQ@mail.gmail.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feeder4.usenet.farm!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364745-linux-kernel-netdev=dewy.ru
References: <CORE-9NOG.v4.r0.20261116135311@mojatatu.com> <CORE-9NOG.v4.r0.20261116135311-4@mojatatu.com> <DMWXH28YQDYH.1SI4Y5WQ7EPSR@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feeder4.usenet.farm!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364745-linux-kernel-netdev=dewy.ru
From: jhs@mojatatu.com (Jamal Hadi Salim)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 4/4] bpf: drop the stale dst when redirecting to an explicit nexthop
Date: Mon, 16 Nov 2026 17:06:05 -0500
Organization: Usenet Network
Message-ID: <CAM0EoMk10vCoAKZq0P=8A_jed=Z3SudLEUV8uvXO5F=ewNjnGQ@mail.gmail.com>
References: <CORE-9NOG.v4.r0.20261116135311@mojatatu.com> <CORE-9NOG.v4.r0.20261116135311-4@mojatatu.com> <DMWXH28YQDYH.1SI4Y5WQ7EPSR@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network; logging-data="2177924"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:o218+W5NaoSJv5ZVz0C1+TQ+yhU= sha256:u8n2wMUw7zcw4YDX+7DO3bGt7R7MuFPTArMZ8TjOJwE= sha1:bl1Y+hXlJDMvhBrlBKc/+E6/Q9E= sha256:5PLbQFe0ods270ME1yH0hk6Bu5zXh2tFNEZ7mw/A2Yc=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B9B75114D81; Tue, 17 Nov 2026 01:06:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=mojatatu.com
X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M6VJRPYNWxjT; Tue, 17 Nov 2026 01:06:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-364745-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id C9B2D114D74; Tue, 17 Nov 2026 01:06:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 7DF2827EB4; Mon, 16 Nov 2026 22:06:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794866779; b=Wey7oC5BCjoRbm6ky2uZ/6A2+75SdX9Pf3QUSBja7tSmwTvysRNkaTb37gIfqxIMQSDI i7cYmhvr5RfoViUWC9n5FXq4C4UEwQAr3NvOXK4vWDjUU56fu0erciz01fKufJcJeRu3c 8rAaR/iuJuc9rHXx/TfDupfBZcE5ySkmRNY+/sTHVtSFlN2WMmn7e4n2+6nCMTJjlDZ93 WuZppBLrsl0jjYPj0iARzOGfA5nf3IgT+z5Eorr11JdEGGQ2zrEq1q4R0v9+C6jvbl4dE +4YIEyCTEfbqOjnCSgHuHvNEZ1FEgu6t2f1Mr354UJgDIAb3sXJ8RuWc/RhlyyTADtA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794866779; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:References: In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; bh=vMqdrlWyOAmekXsQEG1itPY1dEWj1QOm8mYmjBsq/aM=; b=T71QOpDcK6OyrE2SILPgE6ndoavNpbEiwvg0bMw6p1Y32a8aaCGndKk7i+8zp4p0g4Zs vdhB4qYvfxxooq8tRTv6ePp8kg51VMBVAS1QLCurIMR3pvCPCDom2HWc3H/VAnzDMQiRV EXJ06/qT75xNbb1Z4gCnIqf3AGkPT3UFZ4LzViWdYatvF1k6QHUfiR/jSqcGMCzhlfEa7 8GwiJOJ6v4jge6aSLj7P4gvJZnhCX0q+xvM2q1RxCeNPfjHcMNI0pOJo40DnnXwgY006R AvMZGLIrv2orbGTbx4MBaAQJy16PE4/Bn8V4rVxBLMVt959s+7TFX0s1ywblFtk2gCw==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=AbgF2ZqY; dmarc=none header.from=mojatatu.com; spf=none smtp.mailfrom=mojatatu.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAEF2606A335; Mon, 16 Nov 2026 22:06:19 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=AbgF2ZqY
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.210.169
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794866778; b=K5ePzTYM/0irY1U/RlW1KmfFHPoKw4lYz36tucvRJtBoxsBq48fjUThYr72F4PDtL8xQ vZmGxXHOjs2myNkvckMR/CJ7Ky23adMCDPH668B0pi0xVyz4iRtxaYDsG4nAFuI3q3koi VDGwXvufKcLYdmi6/Px5yuAF3mVeDGja1htiCAIIH8K81WikeiyNqEUQOvMbKMeH1AzdN Q2AUChzeKYWaY6dKvbtfTFdwQJ6cG0ITAgj6Wz6UNeHawO0dWtXnTj0KVNUjhE5hqsTdt qHUg/Fq8mf72nojfW+EHDoCOF+QJ+8V+hiIvvVgW5vaPhSvlwmNjxVXpqJ148Csq6qw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794866778; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:MIME-Version:References: In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:Cc: Content-Type:Content-Transfer-Encoding; bh=vMqdrlWyOAmekXsQEG1itPY1dEWj1QOm8mYmjBsq/aM=; b=a59Uo1P8U2smYsyyWPFdiOOkDcv/yti8WIpVhRdpXTwpwz2EU8i0f6SKTeVuDJxAtSCe x+Ey8Qe1Qn1J8pxtBRuzMhhGRG1YnlnOj4FWy6TQ6JLdOrznFFTiVxl4pxdPvZf2Je891 qaSqEq+5g99AQDyD4N+Rjh9HifGSk2wgKN1A9LUT6I+B38tJ6tGmHtxRGsZJ0eiMDVOVT 5KGh20u5EWLbgY4PO/c4z4jHP4QnEJqL4YGnnwHpVcB68mhBqzJiLnOlbH1mV4GBcYsZX 9i+tumlUbU4sMhU5g+wgigp1axE2blgHeYahKm4wAIzui0YTyc1Tck+KX9Z9dgBay/Q==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=mojatatu.com; spf=none smtp.mailfrom=mojatatu.com; dkim=pass header.d=mojatatu.com header.i=@mojatatu.com header.a=rsa-sha256 header.s=google header.b=AbgF2ZqY; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.210.169
X-Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34194606A329 for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 22:06:17 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 34194606A329
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com
X-Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-8b32bc605d9so1787496b3a.2 for <netdev@vger.kernel.org>; Mon, 16 Nov 2026 14:06:17 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1794866777; cv=none; d=google.com; s=arc-20260327; b=JxNxpqJebElL3jKTgvwbVO5zFQdJ3y3cdpvTGZEZIDB+XNnufUDbqPWUd4LcfrsDiO lV0KSAO0BmRZ/3TlUcNcVHcHyQTkCkpidOH1/o32qobetJLHHhsbnA9NmjVkI8w6AOMH Qg6pFIyAcJbYWgEKbwucF9cv0ecBlkooCDbbKsJ1/dykC8bGTZeRAiNYdt+Bf7y+6z7x ya4x82KCU/qIrJ7vd7sTXgK+8Nom7um6aHy1i9GjGBa4VdDCQMH1PGijEbiv5VqwuMZU OQhY8qDiMT/ZMsIOkZseO96f1PS9S8cokA1jK5HtGFe/mKDPMTC+5YAyXdBLGELveawd vFwA==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vMqdrlWyOAmekXsQEG1itPY1dEWj1QOm8mYmjBsq/aM=; fh=aLZqss/aq+NuTNBfJo217weQC9LPEdnaursDMXULNeU=; b=iv8mdX22hkUDSKZMF/u43oGNtxXOo/bqvfN4bLh2sYtnxrQPdyl34+sWM5FkAGkH+6 cY/IB60A8MpPxhp777EOU4RMuqOXodcCr7L9WnaxmH4eh3XEz7yBco/J237KjQ+WI6OK Fz2nvL8HWMT3CXJbponSl1wAYx2cooezc37/f9nWBxgNCqkf22BUKGsjbBM0QjFVmiZS PsQWRLt5LHJzaLVmK9WSdRZznnaEHeM6AOw2//mz+j5nnW6rqRYTR0yPElGvOSjMMJNC +Do5NoC/TPN9uoByHbx8Wh/ZCeaiicKQdnhqNPigxznv4RABAnyD3b6wuR86/H2VhQw0 +lhA==; darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu.com; s=google; t=1794866777; x=1795471577; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=vMqdrlWyOAmekXsQEG1itPY1dEWj1QOm8mYmjBsq/aM=; b=AbgF2ZqY1HyslMGUCiQ6uP1x99OLZqVAaM1OrrEO4CH7mo1PNmgSxN1NhAOMMml7hr Kr8qpUxep5DYauQZpKDrctjJMaD0lup8nL+WN5Te0X1Xue+6X0iQFWdV1SB7ugAHYnu2 4VERBbMxZnEKly8N6oAZzau77kTBfePEM5NYE=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794866777; x=1795471577; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vMqdrlWyO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6a00:4ac7:b0:885:e2eb:23b6 with SMTP id d2e1a72fcca58-8beb53d9d07mr10583427b3a.11.1794866777097; Mon, 16 Nov 2026 14:06:17 -0800 (PST)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <DMWXH28YQDYH.1SI4Y5WQ7EPSR@gmail.com>
X-Gm-Features: AclHuK9n7C752nA4wdQHdLQTklh2YsDwp5Gv59-pY4fMu60xseoLBKlaRL5BDRk
X-Cc: netdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>, John Fastabend <john.fastabend@gmail.com>, Stanislav Fomichev <sdf@fomichev.me>, Martin KaFai Lau <martin.lau@linux.dev>, Andrii Nakryiko <andrii@kernel.org>, Eduard Zingerman <eddyz87@gmail.com>, Kumar Kartikeya Dwivedi <memxor@gmail.com>, Song Liu <song@kernel.org>, Yonghong Song <yonghong.song@linux.dev>, Jiri Olsa <jolsa@kernel.org>, Emil Tsalapatis <emil@etsalapatis.com>, Ihor Solodrai <ihor.solodrai@linux.dev>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, bpf@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>, Victor Nogueira <victor@mojatatu.com>, Sashiko <sashiko-bot@kernel.org>