Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 64121e3

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: fib: check correct rtable in vrf setups
[ Upstream commit 05ef705 ] We need to init l3mdev unconditionally, else main routing table is searched and incorrect result is returned unless strict (iif keyword) matching is requested. Next patch adds a selftest for this. Fixes: 2a8a7c0 ("netfilter: nft_fib: Fix for rpath check with VRF devices") Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1761 Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 997f67d commit 64121e3

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

net/ipv4/netfilter/nft_fib_ipv4.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
6666
.flowi4_scope = RT_SCOPE_UNIVERSE,
6767
.flowi4_iif = LOOPBACK_IFINDEX,
6868
.flowi4_uid = sock_net_uid(nft_net(pkt), NULL),
69+
.flowi4_l3mdev = l3mdev_master_ifindex_rcu(nft_in(pkt)),
6970
};
7071
const struct net_device *oif;
7172
const struct net_device *found;
@@ -84,9 +85,6 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
8485
else
8586
oif = NULL;
8687

87-
if (priv->flags & NFTA_FIB_F_IIF)
88-
fl4.flowi4_l3mdev = l3mdev_master_ifindex_rcu(oif);
89-
9088
if (nft_hook(pkt) == NF_INET_PRE_ROUTING &&
9189
nft_fib_is_loopback(pkt->skb, nft_in(pkt))) {
9290
nft_fib_store_result(dest, priv, nft_in(pkt));

net/ipv6/netfilter/nft_fib_ipv6.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
4141
if (ipv6_addr_type(&fl6->daddr) & IPV6_ADDR_LINKLOCAL) {
4242
lookup_flags |= RT6_LOOKUP_F_IFACE;
4343
fl6->flowi6_oif = get_ifindex(dev ? dev : pkt->skb->dev);
44-
} else if (priv->flags & NFTA_FIB_F_IIF) {
45-
fl6->flowi6_l3mdev = l3mdev_master_ifindex_rcu(dev);
4644
}
4745

4846
if (ipv6_addr_type(&fl6->saddr) & IPV6_ADDR_UNICAST)
@@ -75,6 +73,8 @@ static u32 __nft_fib6_eval_type(const struct nft_fib *priv,
7573
else if (priv->flags & NFTA_FIB_F_OIF)
7674
dev = nft_out(pkt);
7775

76+
fl6.flowi6_l3mdev = l3mdev_master_ifindex_rcu(dev);
77+
7878
nft_fib6_flowi_init(&fl6, priv, pkt, dev, iph);
7979

8080
if (dev && nf_ipv6_chk_addr(nft_net(pkt), &fl6.daddr, dev, true))
@@ -165,6 +165,7 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs,
165165
.flowi6_iif = LOOPBACK_IFINDEX,
166166
.flowi6_proto = pkt->tprot,
167167
.flowi6_uid = sock_net_uid(nft_net(pkt), NULL),
168+
.flowi6_l3mdev = l3mdev_master_ifindex_rcu(nft_in(pkt)),
168169
};
169170
struct rt6_info *rt;
170171
int lookup_flags;

0 commit comments

Comments
 (0)