Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5308801yba; Mon, 13 May 2019 08:43:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyI8RJi6PrCvbFWnUmPKZ+bw087fi3UmRmmDA+u4Pa0T+N31VYzTQbnA8tfvssH60Kvk8yH X-Received: by 2002:a63:ee0a:: with SMTP id e10mr18605170pgi.28.1557762216620; Mon, 13 May 2019 08:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557762216; cv=none; d=google.com; s=arc-20160816; b=IQybDFiammCR1V3x3clOgyvLrcTqBYEqwKTFFzi+lqJ0KdTQKMV1JOJQWLOBNtQNbG hl5r2TZ9KwHMfyjHdz3s5XmzNTxXgTNkFYCc1rBPNkxn0iif2Iacg5r0swFA2Ze3VRoM 4njrF/PhPCu5EPSNsuVaCpI8Qi6gbNdDBTL3ZmnP6oA3Br7PX91gknU4QNefanh+hxoR 4xVnpTSKokSw0xrJALRJYEKFyla2rSLLF216mkAcqSpzDMKYX0AECiu8AFMe7symcd6x 7dFTbpBuibj71EwbrgkQsiZNSQlgG5Llk8Jsb01OZuO7z3nSDNyZK7kPzlT+gaE3MGfF 6Rhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=8Gk6jxl9uQkrqxc8jjvrlj7EywdDn+J4LORJAGaJ8tU=; b=V+F544Rv9a6acQYz806nyrCD3Nq6YWug1v0VAcsVq09C2uc2JR6FUywfpxa8cvNYT7 EI6fR93hFZfYPaQBoTulR0oXmIkkN2znTLbgGjnNIBK8QfIyb0DdycLJBI4/8eAhyhCi zZnbpB2cut9oIabQYNkMfW3OKezHlpjQo+z326Nb8uoF8nW2j6SEQXCTinJxf6jVpiT8 BkcAJegMufq7XzyNBA+uqUKVMDVM963DZZbgqTy1xLliL4oaDZKbUb8+rDUfAIEShN+m HFRbpUQfq1tKBetJA+b4bNR7xhRjCDBQfq0TA2TtNy03sCkXONnN6l5KjbFFuU0yR+V5 mksg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si15965487pgq.39.2019.05.13.08.43.19; Mon, 13 May 2019 08:43:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728871AbfEMNZw (ORCPT + 99 others); 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.