Skip to content

Commit acc641a

Browse files
Phil SutterFlorian Westphal
authored andcommitted
netfilter: rpfilter/fib: Populate flowic_l3mdev field
Use the introduced field for correct operation with VRF devices instead of conditionally overwriting flowic_oif. This is a partial revert of commit b575b24 ("netfilter: Fix rpfilter dropping vrf packets by mistake"), implementing a simpler solution. Signed-off-by: Phil Sutter <phil@nwl.cc> Reviewed-by: David Ahern <dsahern@kernel.org> Reviewed-by: Guillaume Nault <gnault@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de>
1 parent 6e31ce8 commit acc641a

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

net/ipv4/netfilter/ipt_rpfilter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
7777
flow.flowi4_mark = info->flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0;
7878
flow.flowi4_tos = iph->tos & IPTOS_RT_MASK;
7979
flow.flowi4_scope = RT_SCOPE_UNIVERSE;
80-
flow.flowi4_oif = l3mdev_master_ifindex_rcu(xt_in(par));
80+
flow.flowi4_l3mdev = l3mdev_master_ifindex_rcu(xt_in(par));
8181

8282
return rpfilter_lookup_reverse(xt_net(par), &flow, xt_in(par), info->flags) ^ invert;
8383
}

net/ipv4/netfilter/nft_fib_ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
8484
oif = NULL;
8585

8686
if (priv->flags & NFTA_FIB_F_IIF)
87-
fl4.flowi4_oif = l3mdev_master_ifindex_rcu(oif);
87+
fl4.flowi4_l3mdev = l3mdev_master_ifindex_rcu(oif);
8888

8989
if (nft_hook(pkt) == NF_INET_PRE_ROUTING &&
9090
nft_fib_is_loopback(pkt->skb, nft_in(pkt))) {

net/ipv6/netfilter/ip6t_rpfilter.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
3737
bool ret = false;
3838
struct flowi6 fl6 = {
3939
.flowi6_iif = LOOPBACK_IFINDEX,
40+
.flowi6_l3mdev = l3mdev_master_ifindex_rcu(dev),
4041
.flowlabel = (* (__be32 *) iph) & IPV6_FLOWINFO_MASK,
4142
.flowi6_proto = iph->nexthdr,
4243
.daddr = iph->saddr,
@@ -55,9 +56,7 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
5556
if (rpfilter_addr_linklocal(&iph->saddr)) {
5657
lookup_flags |= RT6_LOOKUP_F_IFACE;
5758
fl6.flowi6_oif = dev->ifindex;
58-
/* Set flowi6_oif for vrf devices to lookup route in l3mdev domain. */
59-
} else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev) ||
60-
(flags & XT_RPFILTER_LOOSE) == 0)
59+
} else if ((flags & XT_RPFILTER_LOOSE) == 0)
6160
fl6.flowi6_oif = dev->ifindex;
6261

6362
rt = (void *)ip6_route_lookup(net, &fl6, skb, lookup_flags);
@@ -72,9 +71,7 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
7271
goto out;
7372
}
7473

75-
if (rt->rt6i_idev->dev == dev ||
76-
l3mdev_master_ifindex_rcu(rt->rt6i_idev->dev) == dev->ifindex ||
77-
(flags & XT_RPFILTER_LOOSE))
74+
if (rt->rt6i_idev->dev == dev || (flags & XT_RPFILTER_LOOSE))
7875
ret = true;
7976
out:
8077
ip6_rt_put(rt);

net/ipv6/netfilter/nft_fib_ipv6.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ 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-
(netif_is_l3_master(dev) || netif_is_l3_slave(dev))) {
46-
fl6->flowi6_oif = dev->ifindex;
44+
} else if (priv->flags & NFTA_FIB_F_IIF) {
45+
fl6->flowi6_l3mdev = l3mdev_master_ifindex_rcu(dev);
4746
}
4847

4948
if (ipv6_addr_type(&fl6->saddr) & IPV6_ADDR_UNICAST)

0 commit comments

Comments
 (0)