From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF187C04AA7 for ; Mon, 13 May 2019 13:25:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91E0A208C2 for ; Mon, 13 May 2019 13:25:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728960AbfEMNZw (ORCPT ); Mon, 13 May 2019 09:25:52 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7748 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728434AbfEMNZv (ORCPT ); Mon, 13 May 2019 09:25:51 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F099C31F1596DC0FA4C0; Mon, 13 May 2019 21:25:31 +0800 (CST) Received: from [127.0.0.1] (10.184.189.20) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Mon, 13 May 2019 21:25:24 +0800 Subject: Re: [PATCH v3] net: netfilter: Fix rpfilter dropping vrf packets by mistake To: Pablo Neira Ayuso CC: , , , , , , , , , , Mingfangsen References: <212e4feb-39de-2627-9948-bbb117ff4d4e@huawei.com> <20190513094203.atnko3xbim5hzb7y@salvia> From: linmiaohe Message-ID: Date: Mon, 13 May 2019 21:25:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190513094203.atnko3xbim5hzb7y@salvia> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.184.189.20] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/5/13 17:42, Pablo Neira Ayuso wrote: > On Thu, Apr 25, 2019 at 09:43:53PM +0800, linmiaohe wrote: >> From: Miaohe Lin >> >> 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 >> --- >> net/ipv4/netfilter/ipt_rpfilter.c | 1 + >> net/ipv6/netfilter/ip6t_rpfilter.c | 10 +++++++++- >> 2 files changed, 10 insertions(+), 1 deletion(-) >> > > Suggestion: Could you just call l3mdev_master_ifindex_rcu() when > invoking rpfilter_lookup_reverse6() ? > > diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c > index c3c6b09acdc4..ce64ff5d6fb6 100644 > --- a/net/ipv6/netfilter/ip6t_rpfilter.c > +++ b/net/ipv6/netfilter/ip6t_rpfilter.c > @@ -101,7 +101,8 @@ static bool rpfilter_mt(const struct sk_buff *skb, > struct xt_action_param *par) > if (unlikely(saddrtype == IPV6_ADDR_ANY)) > return true ^ invert; /* not routable: forward path will drop it */ > > - return rpfilter_lookup_reverse6(xt_net(par), skb, xt_in(par), > + return rpfilter_lookup_reverse6(xt_net(par), skb, > + l3mdev_master_ifindex_rcu(xt_in(par)), > info->flags) ^ invert; > } > > . > rpfilter_lookup_reverse6 requests struct net_device *dev as third argument, so what you really mean is this ? diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c index c3c6b09acdc4..ce64ff5d6fb6 100644 --- a/net/ipv6/netfilter/ip6t_rpfilter.c +++ b/net/ipv6/netfilter/ip6t_rpfilter.c @@ -101,7 +101,8 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) if (unlikely(saddrtype == IPV6_ADDR_ANY)) return true ^ invert; /* not routable: forward path will drop it */ - return rpfilter_lookup_reverse6(xt_net(par), skb, xt_in(par), + return rpfilter_lookup_reverse6(xt_net(par), skb, + l3mdev_master_dev_rcu(xt_in(par)) ? : xt_in(par), info->flags) ^ invert; } I'am sorry but I tested this. It doesn't work. When flags with XT_RPFILTER_LOOSE set, we need set fl6.flowi6_oif to complete fib lookup in an l3mdev domain. And we need enslaved network device to compute rpfilter rather than l3 master device. Many thanks for your suggestion. Best regards.