Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4922865imc; Mon, 25 Feb 2019 13:43:12 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaa/J14YDUBkdMP83NQ0XqnodmXF8ExgvFCCs5mlHpf8j23Fh18qjNkoylLwKz4mYLamKYR X-Received: by 2002:a65:46cd:: with SMTP id n13mr20684128pgr.221.1551130992353; Mon, 25 Feb 2019 13:43:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551130992; cv=none; d=google.com; s=arc-20160816; b=BTljMN40Lm/pGzQzNw42ZQvoqOM0yIEM/QnW38QtaardupxEFSyvJl/KzD4g/oAZsm bVsq1kwxq4JmdYevBFY1V3RoSRcJh/DkVK1I29ZC5wOKUdfaDYS7fwvr4Yp/bpxbxTuA 4NfrLoieXFZc+/mDOMOhkbMLX3pk5cz875JPCE+8ki/yhCA/Ds/BaDSRli+KlrLkb8tb npV2zGp80ciJOQ/vNFzpuoM2OB7J9FUakN0i8isKWhIzZ1eqQQOeiC/l/zd+KWv2WZQP 0ardhv2p6A+W5VX/bEcblBvnBdoUEbGGCkWqQpIm6MFckHa90PnePz1KjFW0tJfqyOqL qRfg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UEVgl5pBu4T0nUIDD0pyHdw/aRHJNwnTPS1xHn841KE=; b=Ff3HTeIproEhovmM8iKffgOYfGEg/EEA4y8zlFIAQ0k15xiISHrRgTM100W142XAVD 7eQcSb0l+HaMJ8lMFzNI4fc1tWlhWV9oHlmkzNt1DHREnvw5M0Mzg/lhLZg4ECFdv1E4 ehMcEvY4dIODAFxg/nrN5rblNwWbm8MVztIQyeKznvYuP9DkjsTiIL4Kdx7+DgVwYidm xe375Vjen3cXGo6e2F18k7L3QXPeEjpR8MrdJIIdjmRBkQsk9OCTInDhohgFXfp95Kja OuQiVQsV5tSlFVXIIIILlpIRCpRa/w/LfkPMRNiU2sFikeTV3G1yl7NVsdwFCaCfGSf8 Oa1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lqaugaK9; 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 d37si10448006pgb.226.2019.02.25.13.42.57; Mon, 25 Feb 2019 13:43:12 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=lqaugaK9; 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 S1732613AbfBYVdJ (ORCPT + 99 others); Mon, 25 Feb 2019 16:33:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:39170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732595AbfBYVdF (ORCPT ); Mon, 25 Feb 2019 16:33:05 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 340D72184E; Mon, 25 Feb 2019 21:33:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551130384; bh=Gr0uKQffWkVLGe5/uHgZb9qRnYCt6sWpdNBkC3UGAu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lqaugaK9DB14I3rfqW2SQpYm/BW0RHDLIKoa0wP3G2u0ntKJGCXggkJNu9iuhhzc5 y+CDSyVeldbVPFyPToaIYfhKqdHSHoKhpX1qYspfyGuZdgWTcxUWcTyJfpiJlzkB9y +3ck6QM0+/Yk8vDwxTWoL37nyFpZAY+I0M2qdltw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, wenxu , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 4.20 067/183] netfilter: nft_flow_offload: fix interaction with vrf slave device Date: Mon, 25 Feb 2019 22:10:40 +0100 Message-Id: <20190225195105.838440028@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225195054.748060397@linuxfoundation.org> References: <20190225195054.748060397@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 10f4e765879e514e1ce7f52ed26603047af196e2 ] In the forward chain, the iif is changed from slave device to master vrf device. Thus, flow offload does not find a match on the lower slave device. This patch uses the cached route, ie. dst->dev, to update the iif and oif fields in the flow entry. After this patch, the following example works fine: # ip addr add dev eth0 1.1.1.1/24 # ip addr add dev eth1 10.0.0.1/24 # ip link add user1 type vrf table 1 # ip l set user1 up # ip l set dev eth0 master user1 # ip l set dev eth1 master user1 # nft add table firewall # nft add flowtable f fb1 { hook ingress priority 0 \; devices = { eth0, eth1 } \; } # nft add chain f ftb-all {type filter hook forward priority 0 \; policy accept \; } # nft add rule f ftb-all ct zone 1 ip protocol tcp flow offload @fb1 # nft add rule f ftb-all ct zone 1 ip protocol udp flow offload @fb1 Signed-off-by: wenxu Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- include/net/netfilter/nf_flow_table.h | 1 - net/netfilter/nf_flow_table_core.c | 5 +++-- net/netfilter/nft_flow_offload.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/netfilter/nf_flow_table.h b/include/net/netfilter/nf_flow_table.h index 77e2761d4f2f9..ff4eb9869e5ba 100644 --- a/include/net/netfilter/nf_flow_table.h +++ b/include/net/netfilter/nf_flow_table.h @@ -84,7 +84,6 @@ struct flow_offload { struct nf_flow_route { struct { struct dst_entry *dst; - int ifindex; } tuple[FLOW_OFFLOAD_DIR_MAX]; }; diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c index b7a4816add765..cc91b4d6aa22f 100644 --- a/net/netfilter/nf_flow_table_core.c +++ b/net/netfilter/nf_flow_table_core.c @@ -28,6 +28,7 @@ flow_offload_fill_dir(struct flow_offload *flow, struct nf_conn *ct, { struct flow_offload_tuple *ft = &flow->tuplehash[dir].tuple; struct nf_conntrack_tuple *ctt = &ct->tuplehash[dir].tuple; + struct dst_entry *other_dst = route->tuple[!dir].dst; struct dst_entry *dst = route->tuple[dir].dst; ft->dir = dir; @@ -50,8 +51,8 @@ flow_offload_fill_dir(struct flow_offload *flow, struct nf_conn *ct, ft->src_port = ctt->src.u.tcp.port; ft->dst_port = ctt->dst.u.tcp.port; - ft->iifidx = route->tuple[dir].ifindex; - ft->oifidx = route->tuple[!dir].ifindex; + ft->iifidx = other_dst->dev->ifindex; + ft->oifidx = dst->dev->ifindex; ft->dst_cache = dst; } diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c index ccdb8f5ababbe..188c6bbf4e165 100644 --- a/net/netfilter/nft_flow_offload.c +++ b/net/netfilter/nft_flow_offload.c @@ -30,9 +30,11 @@ static int nft_flow_route(const struct nft_pktinfo *pkt, switch (nft_pf(pkt)) { case NFPROTO_IPV4: fl.u.ip4.daddr = ct->tuplehash[dir].tuple.src.u3.ip; + fl.u.ip4.flowi4_oif = nft_in(pkt)->ifindex; break; case NFPROTO_IPV6: fl.u.ip6.daddr = ct->tuplehash[dir].tuple.src.u3.in6; + fl.u.ip6.flowi6_oif = nft_in(pkt)->ifindex; break; } @@ -41,9 +43,7 @@ static int nft_flow_route(const struct nft_pktinfo *pkt, return -ENOENT; route->tuple[dir].dst = this_dst; - route->tuple[dir].ifindex = nft_in(pkt)->ifindex; route->tuple[!dir].dst = other_dst; - route->tuple[!dir].ifindex = nft_out(pkt)->ifindex; return 0; } -- 2.19.1