ipv4: Pass netns to fib_table_lookup()

The next patch will report the network namespace cookie in the
fib_table_lookup tracepoint. As a preparation, pass the namespace to
fib_table_lookup() and from there to the tracepoint, like the
fib6_table_lookup tracepoint. All the callers already have the namespace
at hand.

Add the namespace as the last tracepoint argument so that the positions
of the existing arguments do not change and BPF programs that attach to
the raw tracepoint are not affected.

No functional changes intended.

Assisted-by: LLM
Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ferenc Fejes <ferenc@fejes.dev>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20261008133158.1438907-3-idosch@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Ido Schimmel authored and Paolo Abeni committed 2026-10-13 12:26:26 +02:00
1 parent ffe378c06c
commit c436a624f8
8 files changed
+27 -19

No files matched your search

+7 -5
View File
@@ -275,8 +275,9 @@ struct fib_dump_filter {
struct net_device *dev;
};
int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
struct fib_result *res, int fib_flags);
int fib_table_lookup(struct net *net, struct fib_table *tb,
const struct flowi4 *flp, struct fib_result *res,
int fib_flags);
int fib_table_insert(struct net *, struct fib_table *, struct fib_config *,
struct netlink_ext_ack *extack);
int fib_table_delete(struct net *, struct fib_table *, struct fib_config *,
@@ -323,7 +324,8 @@ static inline int fib_lookup(struct net *net, const struct flowi4 *flp,
tb = fib_get_table(net, RT_TABLE_MAIN);
if (tb)
err = fib_table_lookup(tb, flp, res, flags | FIB_LOOKUP_NOREF);
err = fib_table_lookup(net, tb, flp, res,
flags | FIB_LOOKUP_NOREF);
if (err == -EAGAIN)
err = -ENETUNREACH;
@@ -387,14 +389,14 @@ static inline int fib_lookup(struct net *net, struct flowi4 *flp,
tb = rcu_dereference_rtnl(net->ipv4.fib_main);
if (tb)
err = fib_table_lookup(tb, flp, res, flags);
err = fib_table_lookup(net, tb, flp, res, flags);
if (err != -EAGAIN)
goto out;
tb = rcu_dereference_rtnl(net->ipv4.fib_default);
if (tb)
err = fib_table_lookup(tb, flp, res, flags);
err = fib_table_lookup(net, tb, flp, res, flags);
if (err == -EAGAIN)
err = -ENETUNREACH;
+3 -2
View File
@@ -15,9 +15,10 @@
TRACE_EVENT(fib_table_lookup,
TP_PROTO(u32 tb_id, const struct flowi4 *flp,
const struct fib_nh_common *nhc, int err),
const struct fib_nh_common *nhc, int err,
const struct net *net),
TP_ARGS(tb_id, flp, nhc, err),
TP_ARGS(tb_id, flp, nhc, err, net),
TP_STRUCT__entry(
__field( u32, tb_id )
+1 -1
View File
@@ -6413,7 +6413,7 @@ static int bpf_ipv4_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
if (unlikely(!tb))
return BPF_FIB_LKUP_RET_NOT_FWDED;
err = fib_table_lookup(tb, &fl4, &res, FIB_LOOKUP_NOREF);
err = fib_table_lookup(net, tb, &fl4, &res, FIB_LOOKUP_NOREF);
} else {
if (flags & BPF_FIB_LOOKUP_MARK)
fl4.flowi4_mark = params->mark;
+2 -1
View File
@@ -157,7 +157,8 @@ struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref)
*/
local = fib_get_table(net, RT_TABLE_LOCAL);
if (local &&
!fib_table_lookup(local, &fl4, &res, FIB_LOOKUP_NOREF) &&
!fib_table_lookup(net, local, &fl4, &res,
FIB_LOOKUP_NOREF) &&
res.type == RTN_LOCAL)
result = FIB_RES_DEV(res);
} else {
+4 -2
View File
@@ -243,7 +243,8 @@ static inline unsigned int __inet_dev_addr_type(struct net *net,
table = fib_get_table(net, tb_id);
if (table) {
ret = RTN_UNICAST;
if (!fib_table_lookup(table, &fl4, &res, FIB_LOOKUP_NOREF)) {
if (!fib_table_lookup(net, table, &fl4, &res,
FIB_LOOKUP_NOREF)) {
struct fib_nh_common *nhc = fib_info_nhc(res.fi, 0);
if (!dev || dev == nhc->nhc_dev)
@@ -1400,7 +1401,8 @@ static void nl_fib_lookup(struct net *net, struct fib_result_nl *frn)
local_bh_disable();
frn->tb_id = tb->tb_id;
frn->err = fib_table_lookup(tb, &fl4, &res, FIB_LOOKUP_NOREF);
frn->err = fib_table_lookup(net, tb, &fl4, &res,
FIB_LOOKUP_NOREF);
if (!frn->err) {
frn->prefixlen = res.prefixlen;
+1 -1
View File
@@ -136,7 +136,7 @@ INDIRECT_CALLABLE_SCOPE int fib4_rule_action(struct fib_rule *rule,
tb_id = fib_rule_get_table(rule, arg);
tbl = fib_get_table(rule->fr_net, tb_id);
if (tbl)
err = fib_table_lookup(tbl, &flp->u.ip4,
err = fib_table_lookup(rule->fr_net, tbl, &flp->u.ip4,
(struct fib_result *)arg->result,
arg->flags);
+1 -1
View File
@@ -1224,7 +1224,7 @@ static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table,
tbl = fib_get_table(net, table);
if (tbl)
err = fib_table_lookup(tbl, &fl4, &res,
err = fib_table_lookup(net, tbl, &fl4, &res,
FIB_LOOKUP_IGNORE_LINKSTATE |
FIB_LOOKUP_NOREF);
+8 -6
View File
@@ -1415,8 +1415,9 @@ bool fib_lookup_good_nhc(const struct fib_nh_common *nhc, int fib_flags,
}
/* should be called with rcu_read_lock */
int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
struct fib_result *res, int fib_flags)
int fib_table_lookup(struct net *net, struct fib_table *tb,
const struct flowi4 *flp, struct fib_result *res,
int fib_flags)
{
struct trie *t = (struct trie *) tb->tb_data;
#ifdef CONFIG_IP_FIB_TRIE_STATS
@@ -1433,7 +1434,7 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
n = get_child_rcu(pn, cindex);
if (!n) {
trace_fib_table_lookup(tb->tb_id, flp, NULL, -EAGAIN);
trace_fib_table_lookup(tb->tb_id, flp, NULL, -EAGAIN, net);
return -EAGAIN;
}
@@ -1520,7 +1521,8 @@ backtrace:
*/
if (IS_TRIE(pn)) {
trace_fib_table_lookup(tb->tb_id, flp,
NULL, -EAGAIN);
NULL, -EAGAIN,
net);
return -EAGAIN;
}
#ifdef CONFIG_IP_FIB_TRIE_STATS
@@ -1567,7 +1569,7 @@ out_reject:
#ifdef CONFIG_IP_FIB_TRIE_STATS
this_cpu_inc(stats->semantic_match_passed);
#endif
trace_fib_table_lookup(tb->tb_id, flp, NULL, err);
trace_fib_table_lookup(tb->tb_id, flp, NULL, err, net);
return err;
}
if (fi->fib_flags & RTNH_F_DEAD)
@@ -1608,7 +1610,7 @@ set_result:
#ifdef CONFIG_IP_FIB_TRIE_STATS
this_cpu_inc(stats->semantic_match_passed);
#endif
trace_fib_table_lookup(tb->tb_id, flp, nhc, err);
trace_fib_table_lookup(tb->tb_id, flp, nhc, err, net);
return err;
}