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=ham 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 37390C432C0 for ; Tue, 3 Dec 2019 22:54:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0595A20865 for ; Tue, 3 Dec 2019 22:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575413687; bh=Cfh5iaPFdbxtC3r2r5rJvmuhIpcUY0ww7bg/ux2CRcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UZP62lFwH8+eVfL/d9nVYeo85+CPcaQTdIok/4qT6XuR0/phZAYoFfl/6Zq6eNCOB oEaFOZaOx7Nukv3s4gHRdqF3mBMWskPKgU+A4+30S1jUtR0nfUBjlskvt0fqQSNWZ4 kXwObLR02ovam2QY+S8vgSW6ybS4Pt7mvyfoPWOA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730309AbfLCWyq (ORCPT ); Tue, 3 Dec 2019 17:54:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:48712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729804AbfLCWyl (ORCPT ); Tue, 3 Dec 2019 17:54:41 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 B066921555; Tue, 3 Dec 2019 22:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575413681; bh=Cfh5iaPFdbxtC3r2r5rJvmuhIpcUY0ww7bg/ux2CRcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W6dtR60mEsC+Iy2XTEw/MyebulE0bMB4KcgI5s30RhYFwYyOxfNjFoPXKx74NX0/K AYModSaTIg0/7O91PtBWkigvVlRbAE5iYFGGDB42rec/WELzxjyUw5waC57HRoDtZt HVHBl7mTflZyV5v09Mgn/h6CJ1HuThaq+m7A9Fwk= 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.19 222/321] ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel Date: Tue, 3 Dec 2019 23:34:48 +0100 Message-Id: <20191203223438.666158833@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203223427.103571230@linuxfoundation.org> References: <20191203223427.103571230@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 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