From patchwork Wed Apr 24 07:27:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 1089987 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 44psNQ3VJxz9s4Y for ; Wed, 24 Apr 2019 17:27:50 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730167AbfDXH1p (ORCPT ); Wed, 24 Apr 2019 03:27:45 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:58600 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727054AbfDXH1o (ORCPT ); Wed, 24 Apr 2019 03:27:44 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0045E9AB8D0764E22B91; Wed, 24 Apr 2019 15:27:39 +0800 (CST) Received: from [127.0.0.1] (10.184.189.20) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Wed, 24 Apr 2019 15:27:33 +0800 To: , , , , , , , , , CC: Mingfangsen From: linmiaohe Subject: [PATCH] net: netfilter: Fix ipv6 rp_filter dropping vrf packets by mistake Message-ID: <094b7376-f796-71b6-7a81-28866b0f882b@huawei.com> Date: Wed, 24 Apr 2019 15:27:30 +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: Miaohe Lin --- 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..5cbc91f53736 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(dev_net(dev), IP6CB(skb)->iif); + if (!dev) + goto out; + } + if (rt->rt6i_idev->dev == dev || (flags & XT_RPFILTER_LOOSE)) ret = true; out: