[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b943dcae6dc447f4ba72d632736b5b4f@huawei.com>
Date: Tue, 11 Jun 2019 08:56:57 +0000
From: linmiaohe <linmiaohe@...wei.com>
To: "pablo@...filter.org" <pablo@...filter.org>,
"kadlec@...ckhole.kfki.hu" <kadlec@...ckhole.kfki.hu>,
"fw@...len.de" <fw@...len.de>,
"davem@...emloft.net" <davem@...emloft.net>,
"kuznet@....inr.ac.ru" <kuznet@....inr.ac.ru>,
"yoshfuji@...ux-ipv6.org" <yoshfuji@...ux-ipv6.org>,
"netfilter-devel@...r.kernel.org" <netfilter-devel@...r.kernel.org>,
"coreteam@...filter.org" <coreteam@...filter.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"dsahern@...il.com" <dsahern@...il.com>
CC: Mingfangsen <mingfangsen@...wei.com>
Subject: 答复: [PATCH v3] net: netfilter: Fix rpfilter dropping vrf packets by mistake
Friendly ping.
-----邮件原件-----
发件人: linux-kernel-owner@...r.kernel.org [mailto:linux-kernel-owner@...r.kernel.org] 代表 linmiaohe
发送时间: 2019年4月25日 21:44
收件人: pablo@...filter.org; kadlec@...ckhole.kfki.hu; fw@...len.de; davem@...emloft.net; kuznet@....inr.ac.ru; yoshfuji@...ux-ipv6.org; netfilter-devel@...r.kernel.org; coreteam@...filter.org; netdev@...r.kernel.org; linux-kernel@...r.kernel.org; dsahern@...il.com
抄送: Mingfangsen <mingfangsen@...wei.com>
主题: [PATCH v3] net: netfilter: Fix rpfilter dropping vrf packets by mistake
From: Miaohe Lin <linmiaohe@...wei.com>
When firewalld is enabled with ipv4/ipv6 rpfilter, vrf
ipv4/ipv6 packets will be dropped because in device is vrf but out device is an enslaved device. So failed with the check of the rpfilter.
Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
---
net/ipv4/netfilter/ipt_rpfilter.c | 1 + net/ipv6/netfilter/ip6t_rpfilter.c | 10 +++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index 0b10d8812828..6e07cd0ecbec 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -81,6 +81,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
flow.flowi4_mark = info->flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0;
flow.flowi4_tos = RT_TOS(iph->tos);
flow.flowi4_scope = RT_SCOPE_UNIVERSE;
+ flow.flowi4_oif = l3mdev_master_ifindex_rcu(xt_in(par));
return rpfilter_lookup_reverse(xt_net(par), &flow, xt_in(par), info->flags) ^ invert; } diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c
index c3c6b09acdc4..a28c81322148 100644
--- a/net/ipv6/netfilter/ip6t_rpfilter.c
+++ b/net/ipv6/netfilter/ip6t_rpfilter.c
@@ -58,7 +58,9 @@ 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;
- } else if ((flags & XT_RPFILTER_LOOSE) == 0)
+ } else if (((flags & XT_RPFILTER_LOOSE) == 0) ||
+ (netif_is_l3_master(dev)) ||
+ (netif_is_l3_slave(dev)))
fl6.flowi6_oif = dev->ifindex;
rt = (void *)ip6_route_lookup(net, &fl6, skb, lookup_flags); @@ -73,6 +75,12 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb,
goto out;
}
+ if (netif_is_l3_master(dev)) {
+ dev = dev_get_by_index_rcu(dev_net(dev), IP6CB(skb)->iif);
+ if (!dev)
+ goto out;
+ }
+
if (rt->rt6i_idev->dev == dev || (flags & XT_RPFILTER_LOOSE))
ret = true;
out:
--
2.19.1
Powered by blists - more mailing lists