From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next 3/4] net: pass dst via net_device_path in dev_fill_forward_path()
Date: Sat, 25 Jul 2026 12:56:16 +0200 [thread overview]
Message-ID: <amSWUNHbPGVGlqBK@lore-desk> (raw)
In-Reply-To: <20260723174952.329650-4-pablo@netfilter.org>
[-- Attachment #1: Type: text/plain, Size: 3189 bytes --]
> Add dst_entry to tunnel device path, this will allow us to remove
> a duplicated route lookup.
>
> This is a preparation patch to retrieve the tunnel route directly
> from the .fill_forward_path. This new dst_entry in the tunnel will be
> used by a follow up patch.
>
> Since dst_release() works fine on NULL interface, this is still
> noop until the flowtable starts using this.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
just few nits inline. Fixing them:
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> include/linux/netdevice.h | 1 +
> net/core/dev.c | 45 +++++++++++++++++++++++++++++++--------
> 2 files changed, 37 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 8db25b79573e..30dc78b4f1a3 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -902,6 +902,7 @@ struct net_device_path {
> };
>
> u8 l3_proto;
> + struct dst_entry *dst;
nit: I guess if you move dst_entry pointer at the beginning of the tun struct
we avoid 7 bytes compiler padding.
> } tun;
> struct {
> enum {
> diff --git a/net/core/dev.c b/net/core/dev.c
> index c1c1be1a6962..fed101f54a8a 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -750,6 +750,23 @@ static struct net_device_path *dev_fwd_path(struct net_device_path_stack *stack)
> return &stack->path[k];
> }
>
> +static void dev_fill_forward_path_release(struct net_device_path_stack *stack)
> +{
> + struct net_device_path *path;
> + int k;
> +
> + for (k = stack->num_paths; k >= 0; k--) {
> + path = &stack->path[k];
> + switch (path->type) {
> + case DEV_PATH_TUN:
> + dst_release(path->tun.dst);
> + break;
> + default:
> + break;
> + }
> + }
> +}
> +
> int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,
> struct net_device_path_stack *stack)
> {
> @@ -765,28 +782,38 @@ int dev_fill_forward_path(const struct net_device *dev, const u8 *daddr,
> while (ctx.dev && ctx.dev->netdev_ops->ndo_fill_forward_path) {
> last_dev = ctx.dev;
> path = dev_fwd_path(stack);
> - if (!path)
> - return -1;
> + if (!path) {
> + ret = -1;
nit: I guess we can drop ret variable now since we do not use it in the return
path.
> + goto err_out;
> + }
>
> memset(path, 0, sizeof(struct net_device_path));
> ret = ctx.dev->netdev_ops->ndo_fill_forward_path(&ctx, path);
> if (ret < 0)
> - return -1;
> + goto err_out;
>
> - if (WARN_ON_ONCE(last_dev == ctx.dev))
> - return -1;
> + if (WARN_ON_ONCE(last_dev == ctx.dev)) {
> + ret = -1;
> + goto err_out;
> + }
> }
>
> if (!ctx.dev)
> - return ret;
> + goto err_out;
>
> path = dev_fwd_path(stack);
> - if (!path)
> - return -1;
> + if (!path) {
> + ret = -1;
> + goto err_out;
> + }
> path->type = DEV_PATH_ETHERNET;
> path->dev = ctx.dev;
>
> - return ret;
> + return 0;
> +err_out:
> + dev_fill_forward_path_release(stack);
> +
> + return -1;
> }
> EXPORT_SYMBOL_GPL(dev_fill_forward_path);
>
> --
> 2.47.3
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-07-25 10:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 17:49 [PATCH nf-next 0/4] flowtable: pass dst_entry from ipip tunnel Pablo Neira Ayuso
2026-07-23 17:49 ` [PATCH nf-next 1/4] netfilter: flowtable: consolidate net_device field in nft_forward_info struct Pablo Neira Ayuso
2026-07-25 10:20 ` Lorenzo Bianconi
2026-07-23 17:49 ` [PATCH nf-next 2/4] netfilter: flowtable: consolidate flowtable device check Pablo Neira Ayuso
2026-07-25 10:25 ` Lorenzo Bianconi
2026-07-23 17:49 ` [PATCH nf-next 3/4] net: pass dst via net_device_path in dev_fill_forward_path() Pablo Neira Ayuso
2026-07-25 10:56 ` Lorenzo Bianconi [this message]
2026-07-23 17:49 ` [PATCH nf-next 4/4] netfilter: flowtable: release tunnel route on error when building forward path Pablo Neira Ayuso
2026-07-25 11:05 ` Lorenzo Bianconi
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=amSWUNHbPGVGlqBK@lore-desk \
--to=lorenzo@kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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