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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,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 EB512C2D0B1 for ; Wed, 4 Dec 2019 18:21:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B78072073B for ; Wed, 4 Dec 2019 18:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575483690; bh=OUxMEqaedTerczHBI7WUPaEO4Ds7NoVMV/fIilPn1tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wssDbI3dVUsSQJMXNdqh0mCLLZT7+eO/4s8wBS0GlJEzAbbzYO5D8NokhccAAfH7I A43bKUpo6qDuscBg6vJfY619DDUNIp7P2PgN8QbeijHMB2h/Os5ECp3mEQNtpf32DI YZ6oOOgfYxnyTQRBkD5bD7FfUJ7liz2k0wwsXkow= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729822AbfLDSGg (ORCPT ); Wed, 4 Dec 2019 13:06:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:55064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730024AbfLDSGd (ORCPT ); Wed, 4 Dec 2019 13:06:33 -0500 Received: from localhost (unknown [217.68.49.72]) (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 7B02D20674; Wed, 4 Dec 2019 18:06:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482792; bh=OUxMEqaedTerczHBI7WUPaEO4Ds7NoVMV/fIilPn1tk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjRdYUI3pDktxWO/aXFyQcHeCIuOaxWsSnohMGjiZLuc7iFz1zbcVNo+r6gqdkOow Fz0PHarssx32tcpOwbRde0KBVfPzc6GWxud2z85SAxCgmv7TYfNZ6mixTIW1T72VJW Y3wjrcaXfaEowfNvobKTTHwD50jwGNFIP9H1kX1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, wenxu , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 134/209] ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel Date: Wed, 4 Dec 2019 18:55:46 +0100 Message-Id: <20191204175332.445673372@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175321.609072813@linuxfoundation.org> References: <20191204175321.609072813@linuxfoundation.org> User-Agent: quilt/0.66 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 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 fabc299cb875f..7a31287ff1232 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c @@ -661,13 +661,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