Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp195402ybi; Tue, 2 Jul 2019 19:00:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIcTtk/uIF0puZv0Yn3lCj9h+7r50kNSSXbzeb3ZtaWb4wWES/KaDkD9gQeIV1cppto83J X-Received: by 2002:a17:902:3283:: with SMTP id z3mr7358047plb.176.1562119230081; Tue, 02 Jul 2019 19:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562119230; cv=none; d=google.com; s=arc-20160816; b=ky7RWikDqWp5D63hQVkwijqoco5h/aZHm6ql9T8F/umZFK9fP84nKngm56wjdHTVRF 1+9UHxFZSByVRAnObYYMNDMe7y4j6DgYPL85L5qtJf2L261wBb6XbO8y3XWeZ6TkNu2F hV6WReM5qA8fU414QDN/4A2GmwnP6TGJuM4zOGs57fbJs4sZH+6Rw0Aso9Y9ddHCIrG4 g188svz4+PikgJADveBxw+ZBC/KaAxT07JyumE3o50Zwcv92CtkeXkA1v7boCWWM6rij IjMMyWtKzdlnwZriWGfZV71DEuaNU9tl47QeKAMqVtYYn6da5Qp4hl+6PqaShg4mniI7 HDrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=sH5+v/6su31roDRwKe6HsoWfD5fTJGohdmg/EJv1CQk=; b=Jx8akG5m9kobF5d26GQxg/eMjtzp0WJpgQceSjTf86B+WQ/C4lJMoDcrmlmFls4NJO 6DXBJEpJC9xpWVEE0trnhJiHjEsxsc5pTTeH6mZVxNNtajDp4XHkGrVYrgQkidOAp60+ SCaSqLG0nbVEQRsdoZ6KXvMRmHm2JC/1JgkuLIp2C/ikn4YYQOSVDKmCrKqcgjbkUlqP X7IJtClQFgkeH6SrsvArTAfOK0F9I6EeWjUdxwgH/nw3WPMXEXxPM0ZbS4Q56B/yrqne Fqe1An+m782X6UyfIworZt1HaI8ObpFaZtwqWWQ7+eWkXccBwv6hqSQxHv8yRQZwNoIa 6qLA== 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 c16si358347pjq.20.2019.07.02.19.00.13; Tue, 02 Jul 2019 19:00:30 -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 S1727124AbfGCB7x convert rfc822-to-8bit (ORCPT + 99 others); Tue, 2 Jul 2019 21:59:53 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:3017 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726329AbfGCB7x (ORCPT ); Tue, 2 Jul 2019 21:59:53 -0400 Received: from DGGEMM401-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 90A18A470A45D8703D9A; Wed, 3 Jul 2019 09:59:48 +0800 (CST) Received: from dggeme715-chm.china.huawei.com (10.1.199.111) by DGGEMM401-HUB.china.huawei.com (10.3.20.209) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 3 Jul 2019 09:59:48 +0800 Received: from dggeme763-chm.china.huawei.com (10.3.19.109) by dggeme715-chm.china.huawei.com (10.1.199.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Wed, 3 Jul 2019 09:59:48 +0800 Received: from dggeme763-chm.china.huawei.com ([10.6.66.36]) by dggeme763-chm.china.huawei.com ([10.6.66.36]) with mapi id 15.01.1591.008; Wed, 3 Jul 2019 09:59:47 +0800 From: linmiaohe To: David Ahern CC: "pablo@netfilter.org" , "kadlec@blackhole.kfki.hu" , "fw@strlen.de" , "davem@davemloft.net" , "kuznet@ms2.inr.ac.ru" , "yoshfuji@linux-ipv6.org" , "netfilter-devel@vger.kernel.org" , "coreteam@netfilter.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Mingfangsen Subject: Re: [PATCH v5] net: netfilter: Fix rpfilter dropping vrf packets by mistake Thread-Topic: [PATCH v5] net: netfilter: Fix rpfilter dropping vrf packets by mistake Thread-Index: AdUxQkGnwofogVcmQkqkZWrkNMYBtA== Date: Wed, 3 Jul 2019 01:59:47 +0000 Message-ID: <4b5cc7929a83472e9b2e64d84397eccc@huawei.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.184.189.20] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add David Ahern. @David Ahern I'am so sorry but I rerun scripts/get_maintainer.pl . You are not in the list , so I forgot to add you to the email-to list. I'am sorry again. Have a good day. Best wishes. When firewalld is enabled with ipv4/ipv6 rpfilter, vrf ipv4/ipv6 packets will be dropped. Vrf device will pass through netfilter hook twice. One with enslaved device and another one with l3 master device. So in device may dismatch witch out device because out device is always enslaved device.So failed with the check of the rpfilter and drop the packets by mistake. Signed-off-by: Miaohe Lin --- net/ipv4/netfilter/ipt_rpfilter.c | 1 + net/ipv6/netfilter/ip6t_rpfilter.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c index 59031670b16a..cc23f1ce239c 100644 --- a/net/ipv4/netfilter/ipt_rpfilter.c +++ b/net/ipv4/netfilter/ipt_rpfilter.c @@ -78,6 +78,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 6bcaf7357183..d800801a5dd2 100644 --- a/net/ipv6/netfilter/ip6t_rpfilter.c +++ b/net/ipv6/netfilter/ip6t_rpfilter.c @@ -55,7 +55,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) + /* Set flowi6_oif for vrf devices to lookup route in l3mdev domain. */ + } else if (netif_is_l3_master(dev) || netif_is_l3_slave(dev) || + (flags & XT_RPFILTER_LOOSE) == 0) fl6.flowi6_oif = dev->ifindex; rt = (void *)ip6_route_lookup(net, &fl6, skb, lookup_flags); @@ -70,7 +72,9 @@ static bool rpfilter_lookup_reverse6(struct net *net, const struct sk_buff *skb, goto out; } - if (rt->rt6i_idev->dev == dev || (flags & XT_RPFILTER_LOOSE)) + if (rt->rt6i_idev->dev == dev || + l3mdev_master_ifindex_rcu(rt->rt6i_idev->dev) == dev->ifindex || + (flags & XT_RPFILTER_LOOSE)) ret = true; out: ip6_rt_put(rt); -- 2.21.GIT