Skip to contentSkip to conversation

net: netfilter: Fix rpfilter dropping vrf packets by mistake

PATCH linmiaohe 3 participants 4 messages Jun 29, 2019 – Jul 1, 2019

Subsystems (3)
lore
Share & tools
lore

linmiaohe

author
#0 lore raw
Quoted 16 lines · David Ahern

net/ipv6/netfilter/ip6t_rpfilter.c static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb, · line 60

Quoted 12 lines · Miaohe Lin
net/ipv6/netfilter/ip6t_rpfilter.c +3 -0
index 6bcaf7357183..3c4a1772c15f 100644
@@ -55,6 +55,10 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
 	if (rpfilter_addr_linklocal(&iph->saddr)) {
 		lookup_flags |= RT6_LOOKUP_F_IFACE;
 		fl6.flowi6_oif = dev->ifindex;
+	/* Set flowi6_oif for vrf devices to lookup route in l3mdev domain. */
+	} else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev)) {
+		lookup_flags |= FLOWI_FLAG_SKIP_NH_OIF;

you don't need to set that flag here. It is done by the fib_rules code as needed.

You're right. Fib rules code would set FLOWI_FLAG_SKIP_NH_OIF flag. But I set it here for distinguish with the flags & XT_RPFILTER_LOOSE branch. Without this, they do the same work and maybe should be combined. I don't want to do that as that makes code confusing.
Is this code snipet below ok ? If so, I would delete this flag setting.

       } else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev)) {
               fl6.flowi6_oif = dev->ifindex;
        } else if ((flags & XT_RPFILTER_LOOSE) == 0)
                fl6.flowi6_oif = dev->ifindex;
#1 lore raw
Quoted 10 lines · linmiaohe

You're right. Fib rules code would set FLOWI_FLAG_SKIP_NH_OIF flag. But I set it here for distinguish with the flags & XT_RPFILTER_LOOSE branch. Without this, they do the same work and maybe should be combined. I don't want to do that as that makes code confusing.
Is this code snipet below ok ? If so, I would delete this flag setting.

       } else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev)) {
               fl6.flowi6_oif = dev->ifindex;
        } else if ((flags & XT_RPFILTER_LOOSE) == 0)
                fl6.flowi6_oif = dev->ifindex;

that looks fine to me, but it is up to Pablo.

author
#2 lore raw
Quoted 7 lines · David Ahern
Quoted 6 lines · linmiaohe

You're right. Fib rules code would set FLOWI_FLAG_SKIP_NH_OIF flag. But I set it here for distinguish with the flags & XT_RPFILTER_LOOSE branch. Without this, they do the same work and maybe should be combined. I don't want to do that as that makes code confusing. Is this code snipet below ok ? If so, I would delete this flag setting.

Quoted 6 lines
Quoted 4 lines
       } else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev)) {
               fl6.flowi6_oif = dev->ifindex;
        } else if ((flags & XT_RPFILTER_LOOSE) == 0)
                fl6.flowi6_oif = dev->ifindex;

that looks fine to me, but it is up to Pablo.

@David Ahern Many thanks for your valuable advice.

@ Pablo Hi, could you please tell me if this code snipet is ok? If not, which code would you prefer? It's very nice of you to figure it out for me. Thanks a lot.

Have a nice day.
Best wishes.

#3 lore raw
Quoted 13 lines · linmiaohe
Quoted 11 lines · David Ahern
Quoted 10 lines · linmiaohe

You're right. Fib rules code would set FLOWI_FLAG_SKIP_NH_OIF flag. But I set it here for distinguish with the flags & XT_RPFILTER_LOOSE branch. Without this, they do the same work and maybe should be combined. I don't want to do that as that makes code confusing. Is this code snipet below ok ? If so, I would delete this flag setting.

       } else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev)) {
               fl6.flowi6_oif = dev->ifindex;
        } else if ((flags & XT_RPFILTER_LOOSE) == 0)
                fl6.flowi6_oif = dev->ifindex;
Quoted 7 lines
Quoted 1 line

that looks fine to me, but it is up to Pablo.

@David Ahern Many thanks for your valuable advice.

@ Pablo Hi, could you please tell me if this code snipet is ok? If not, which code would you prefer? It's very nice of you to figure it out for me. Thanks a lot.

Probably this?

        } else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev) ||
                   (flags & XT_RPFILTER_LOOSE) == 0) {
                fl6.flowi6_oif = dev->ifindex;
        }

Thanks.