Skip to content

Commit

Permalink
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/netfilter/nf-next

Florian Westphal says:

====================
netfilter fix for net-next

This is a late bug fix for the *net-next* tree to make nftables
"fib" expression play nice with VRF devices.

This was broken since day 1 (v4.10) so I don't see a compelling reason
to push this via net at the last minute.

* 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next:
  netfilter: nft_fib: Fix for rpath check with VRF devices
====================

Link: https://lore.kernel.org/r/20220928113908.4525-1-fw@strlen.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Sep 28, 2022
2 parents b9a5cbf + 2a8a7c0 commit 929a6cd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions net/ipv4/netfilter/nft_fib_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
else
oif = NULL;

if (priv->flags & NFTA_FIB_F_IIF)
fl4.flowi4_oif = l3mdev_master_ifindex_rcu(oif);

if (nft_hook(pkt) == NF_INET_PRE_ROUTING &&
nft_fib_is_loopback(pkt->skb, nft_in(pkt))) {
nft_fib_store_result(dest, priv, nft_in(pkt));
Expand Down
6 changes: 5 additions & 1 deletion net/ipv6/netfilter/nft_fib_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
if (ipv6_addr_type(&fl6->daddr) & IPV6_ADDR_LINKLOCAL) {
lookup_flags |= RT6_LOOKUP_F_IFACE;
fl6->flowi6_oif = get_ifindex(dev ? dev : pkt->skb->dev);
} else if ((priv->flags & NFTA_FIB_F_IIF) &&
(netif_is_l3_master(dev) || netif_is_l3_slave(dev))) {
fl6->flowi6_oif = dev->ifindex;
}

if (ipv6_addr_type(&fl6->saddr) & IPV6_ADDR_UNICAST)
Expand Down Expand Up @@ -197,7 +200,8 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs,
if (rt->rt6i_flags & (RTF_REJECT | RTF_ANYCAST | RTF_LOCAL))
goto put_rt_err;

if (oif && oif != rt->rt6i_idev->dev)
if (oif && oif != rt->rt6i_idev->dev &&
l3mdev_master_ifindex_rcu(rt->rt6i_idev->dev) != oif->ifindex)
goto put_rt_err;

nft_fib_store_result(dest, priv, rt->rt6i_idev->dev);
Expand Down

0 comments on commit 929a6cd

Please sign in to comment.