Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3287682ybb; Tue, 31 Mar 2020 02:09:05 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsmvq8tiEW5rxOzo+QU49Cip/0jQQXVqnzzgwKUEMBD4kGi0Xgq1KbOc5dLfF/nwJIbUpsl X-Received: by 2002:aca:fcd8:: with SMTP id a207mr1469256oii.56.1585645745330; Tue, 31 Mar 2020 02:09:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645745; cv=none; d=google.com; s=arc-20160816; b=jA6V7FDC7pIe9Bn46axudr5JbdGwVcfMNzzu7mG8D3XpL8r9KUHVdEhqeNgRICC8o8 mWrljXq5o8jS51PRag+gQEWkgDjOadrE9XYSsXDa+pKMjzapIOQU7DYg4DmXitRe8yCO AykhZMR1ubO9Yl+6+367SL6BLPlAFTGbeQEKSQP6BVItugLJsZUD3e15OeThwnHOc69G e8XbphJ9T1tQwBk4Pkb0Ud+5ChnRJ5lA2RH7wUKLy90H+wY1nI+RmFCderHqCL2+BrBs WC7MZZnoYOZfrZRjacoFdfP0rk+gDoP0/cwbn0lzzBEeCTUo+5tu+hfQk5YpIV382bW3 J9Mw== 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=pc5UAJYAZwvap53wh6k3LSN5S8lTuqyZK9F3HAsmZYc=; b=PmiixJ6UqQcaLaE5BjX/OSSeclcItIovM9bgsztppoFPZcnrA6XhsjEtQqqcEWgL9a JvKySwNxBNrHJzXLqagInzixZ1/LP0FE7uyWgw3Y8VttALg6SLNnOgOREmTOS6Jn3/qz MHsX3wSY156W8nBHz8ndFydibhqIDu96lk99tpi9PopHDFfN+8bS/vqJFCAx4qp3X5Zn N6rAj5BVxeHWY6EKMuWOqqIv7XCFBWIftQF30dP1rLgzukhGu9t4sZSSiAwmoPQ4rpSS GGUBgFT0Y+SEmZKdc9AX4zO1XCwaPNFT5GLiRiZcXcnhHEqv3jaGrSINOX1ptqM8kdJG KGVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VO3f8AN9; 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 d21si7311332oof.2.2020.03.31.02.08.53; Tue, 31 Mar 2020 02:09:05 -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; dkim=pass header.i=@kernel.org header.s=default header.b=VO3f8AN9; 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 S1730548AbgCaJHj (ORCPT + 99 others); Tue, 31 Mar 2020 05:07:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:49468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731253AbgCaJHh (ORCPT ); Tue, 31 Mar 2020 05:07:37 -0400 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 234EC2137B; Tue, 31 Mar 2020 09:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645656; bh=NIxqvIwYmSHXNc7yYh3cDSevwbxvddLQ+0ZJPC75KYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VO3f8AN96FE8nlrKiwYLhyXfGJW/CMrnSJCjAdklj8ol7KUmvfRVDZgoV9k6ao4Pa Fz6eiquMo9mWiuslSjG66kCe+QPh/ly6zMbZyAVMlTLtRWGGIhE9od7eyOQemA4NC9 MFEf1/D5rPFb0MszcRIp6VOrxLunKFizFARvPwf8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Dichtel , Steffen Klassert Subject: [PATCH 5.5 123/170] vti[6]: fix packet tx through bpf_redirect() in XinY cases Date: Tue, 31 Mar 2020 10:58:57 +0200 Message-Id: <20200331085437.049155458@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@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: Nicolas Dichtel commit f1ed10264ed6b66b9cd5e8461cffce69be482356 upstream. I forgot the 4in6/6in4 cases in my previous patch. Let's fix them. Fixes: 95224166a903 ("vti[6]: fix packet tx through bpf_redirect()") Signed-off-by: Nicolas Dichtel Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/ipv4/Kconfig | 1 + net/ipv4/ip_vti.c | 36 +++++++++++++++++++++++++++++------- net/ipv6/ip6_vti.c | 32 +++++++++++++++++++++++++------- 3 files changed, 55 insertions(+), 14 deletions(-) --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -303,6 +303,7 @@ config SYN_COOKIES config NET_IPVTI tristate "Virtual (secure) IP: tunneling" + depends on IPV6 || IPV6=n select INET_TUNNEL select NET_IP_TUNNEL select XFRM --- a/net/ipv4/ip_vti.c +++ b/net/ipv4/ip_vti.c @@ -187,17 +187,39 @@ static netdev_tx_t vti_xmit(struct sk_bu int mtu; if (!dst) { - struct rtable *rt; + switch (skb->protocol) { + case htons(ETH_P_IP): { + struct rtable *rt; - fl->u.ip4.flowi4_oif = dev->ifindex; - fl->u.ip4.flowi4_flags |= FLOWI_FLAG_ANYSRC; - rt = __ip_route_output_key(dev_net(dev), &fl->u.ip4); - if (IS_ERR(rt)) { + fl->u.ip4.flowi4_oif = dev->ifindex; + fl->u.ip4.flowi4_flags |= FLOWI_FLAG_ANYSRC; + rt = __ip_route_output_key(dev_net(dev), &fl->u.ip4); + if (IS_ERR(rt)) { + dev->stats.tx_carrier_errors++; + goto tx_error_icmp; + } + dst = &rt->dst; + skb_dst_set(skb, dst); + break; + } +#if IS_ENABLED(CONFIG_IPV6) + case htons(ETH_P_IPV6): + fl->u.ip6.flowi6_oif = dev->ifindex; + fl->u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC; + dst = ip6_route_output(dev_net(dev), NULL, &fl->u.ip6); + if (dst->error) { + dst_release(dst); + dst = NULL; + dev->stats.tx_carrier_errors++; + goto tx_error_icmp; + } + skb_dst_set(skb, dst); + break; +#endif + default: dev->stats.tx_carrier_errors++; goto tx_error_icmp; } - dst = &rt->dst; - skb_dst_set(skb, dst); } dst_hold(dst); --- a/net/ipv6/ip6_vti.c +++ b/net/ipv6/ip6_vti.c @@ -450,15 +450,33 @@ vti6_xmit(struct sk_buff *skb, struct ne int mtu; if (!dst) { - fl->u.ip6.flowi6_oif = dev->ifindex; - fl->u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC; - dst = ip6_route_output(dev_net(dev), NULL, &fl->u.ip6); - if (dst->error) { - dst_release(dst); - dst = NULL; + switch (skb->protocol) { + case htons(ETH_P_IP): { + struct rtable *rt; + + fl->u.ip4.flowi4_oif = dev->ifindex; + fl->u.ip4.flowi4_flags |= FLOWI_FLAG_ANYSRC; + rt = __ip_route_output_key(dev_net(dev), &fl->u.ip4); + if (IS_ERR(rt)) + goto tx_err_link_failure; + dst = &rt->dst; + skb_dst_set(skb, dst); + break; + } + case htons(ETH_P_IPV6): + fl->u.ip6.flowi6_oif = dev->ifindex; + fl->u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC; + dst = ip6_route_output(dev_net(dev), NULL, &fl->u.ip6); + if (dst->error) { + dst_release(dst); + dst = NULL; + goto tx_err_link_failure; + } + skb_dst_set(skb, dst); + break; + default: goto tx_err_link_failure; } - skb_dst_set(skb, dst); } dst_hold(dst);