From patchwork Wed Apr 24 09:12:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 1090004 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44pvj831CSz9s47 for ; Wed, 24 Apr 2019 19:12:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728208AbfDXJMX (ORCPT ); Wed, 24 Apr 2019 05:12:23 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:43120 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727329AbfDXJMX (ORCPT ); Wed, 24 Apr 2019 05:12:23 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 36FFDE3E64F8BAD74E9A; Wed, 24 Apr 2019 17:12:21 +0800 (CST) Received: from [127.0.0.1] (10.184.189.20) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Wed, 24 Apr 2019 17:12:15 +0800 From: linmiaohe Subject: [PATCH v2] net: netfilter: Fix ipv6 rp_filter dropping vrf packets by mistake To: , , , , , , , , , CC: Mingfangsen Message-ID: <7662b7eb-89a4-adac-1e46-2c09816641f2@huawei.com> Date: Wed, 24 Apr 2019 17:12:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [10.184.189.20] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Miaohe Lin When firewall is enabled with rp_filter, vrf ipv6 packets will be dropped because in device is vrf but out device is an enslaved device. So rt->rt6i_idev->dev != dev and maybe return false in func rpfilter_lookup_reverse6. Here is the out message when I ping the peer: ip vrf exec vrf1 ping 2013::2 -c 1 1 packets transmitted, 0 received, 100% packet loss, time 0ms The drop info in /var/log/message: Apr 24 14:59:45 localhost kernel: [81316.158259] rpfilter_DROP: IN=vrf1 OUT= MAC=52:54:00:9e:dd:c1:52:54:00:4f:81:38:86:dd SRC=2013:0000:0000:0000:0000:0000:0000:0002 DST=2013:0000:0000:0000:0000:0000:0000:0001 LEN=104 TC=0 HOPLIMIT=64 FLOWLBL=1032942 PROTO=ICMPv6 TYPE=129 CODE=0 ID=14943 SEQ=1 Signed-off-by: linmiaohe --- net/ipv6/netfilter/ip6t_rpfilter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv6/netfilter/ip6t_rpfilter.c b/net/ipv6/netfilter/ip6t_rpfilter.c index c3c6b09acdc4..cf1070ab1252 100644 --- a/net/ipv6/netfilter/ip6t_rpfilter.c +++ b/net/ipv6/netfilter/ip6t_rpfilter.c @@ -73,6 +73,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: