From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B644C432C0 for ; Fri, 22 Nov 2019 06:20:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA1392068E for ; Fri, 22 Nov 2019 06:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574403642; bh=Cfh5iaPFdbxtC3r2r5rJvmuhIpcUY0ww7bg/ux2CRcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c6wjnVWcfzHKrzqXqpE3nnUg2x0bkwU4HBtdWvuhLCPKFitfwL/Lndh9pQgIf/yZD BnlJ6Bfu8i1lam9jKtdg2hQBSbUeWOICj0WcxS4rc0YRrrFTJYcgYPkw1bQ97M4o6B 9Yx46Vg6RyrD3KE4GJWLXqUOcFSkmUoodch7J/7M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728595AbfKVFwh (ORCPT ); Fri, 22 Nov 2019 00:52:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:58394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727435AbfKVFwg (ORCPT ); Fri, 22 Nov 2019 00:52:36 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 30BC12071B; Fri, 22 Nov 2019 05:52:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401955; bh=Cfh5iaPFdbxtC3r2r5rJvmuhIpcUY0ww7bg/ux2CRcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F7o7nV+icV8Z3Pk8mU+Bv8NVsi3yoaErM4YGGUySZS23qjonRn6IMC+EmWuOF5hUE uVPjNDBExwmqnTvdN5op+lCtnhiDqRsnbsKbn0pQaopXmnmrvkpFON8wswpv6fwx0R EPUc0/EbSq5dZYDCKWW4jAiudtFuaOaDvwdOJh24= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: wenxu , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 178/219] ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel Date: Fri, 22 Nov 2019 00:48:30 -0500 Message-Id: <20191122054911.1750-171-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: wenxu [ Upstream commit d71b57532d70c03f4671dd04e84157ac6bf021b0 ] ip l add dev tun type gretap key 1000 ip a a dev tun 10.0.0.1/24 Packets with tun-id 1000 can be recived by tun dev. But packet can't be sent through dev tun for non-tunnel-dst With this patch: tunnel-dst can be get through lwtunnel like beflow: ip r a 10.0.0.7 encap ip dst 172.168.0.11 dev tun Signed-off-by: wenxu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/ip_tunnel.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index c4f5602308edc..054d01c16dc6a 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -644,13 +644,19 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, dst = tnl_params->daddr; if (dst == 0) { /* NBMA tunnel */ + struct ip_tunnel_info *tun_info; if (!skb_dst(skb)) { dev->stats.tx_fifo_errors++; goto tx_error; } - if (skb->protocol == htons(ETH_P_IP)) { + tun_info = skb_tunnel_info(skb); + if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX) && + ip_tunnel_info_af(tun_info) == AF_INET && + tun_info->key.u.ipv4.dst) + dst = tun_info->key.u.ipv4.dst; + else if (skb->protocol == htons(ETH_P_IP)) { rt = skb_rtable(skb); dst = rt_nexthop(rt, inner_iph->daddr); } -- 2.20.1