From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: lorenzo@kernel.org
Subject: [PATCH nf-next 3/4] net: pass dst via net_device_path in dev_fill_forward_path()
Date: Thu, 23 Jul 2026 19:49:51 +0200 [thread overview]
Message-ID: <20260723174952.329650-4-pablo@netfilter.org> (raw)
In-Reply-To: <20260723174952.329650-1-pablo@netfilter.org>
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>
---
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;
} 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;
+ 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
next prev parent reply other threads:[~2026-07-23 17:50 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 ` Pablo Neira Ayuso [this message]
2026-07-25 10:56 ` [PATCH nf-next 3/4] net: pass dst via net_device_path in dev_fill_forward_path() Lorenzo Bianconi
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=20260723174952.329650-4-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=lorenzo@kernel.org \
--cc=netfilter-devel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.