Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp704438ybc; Sat, 16 Nov 2019 07:15:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxelf6UIlIkKBXNLHIrtpd3+/icKtQpZfEiLEmK82OMT+4Tm3qCsVSzRLf2YyH551+T8UYd X-Received: by 2002:a17:906:1942:: with SMTP id b2mr10454499eje.36.1573917322902; Sat, 16 Nov 2019 07:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573917322; cv=none; d=google.com; s=arc-20160816; b=jWuP4SqB25rkuTzP3bnNnq+FOOlcc1TTtnf0f/YukJB8LNuUfetCX9oWTrjJ4Y+2nX XUieW8SVBfAmLmTgWL/QU+vBGKYC83+CyviaTGfvf7Z1CbESlypHdfpg76BnF+XUvUAu hnboj77+5ItLM5YULA0gsNIQ/e9lgeNeCeW266aRRvJt9/swLTpDaHaEL7qTFrqZSJsw KAdq2Ji6yA9J4H3fJ5BcOdTo6btYR7Im5Yj3GLeGPzazuJZU+D0WvMe60xjjv2xe7Sxb 8gede3irM6lcYo8YqmwznY9to+52OEskQVmveFlxM+EAiy9eTHL34+zaN5xa/0UIdn6u 0LgQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iLvdqyEr6YCSHJr6A79N+fG1FQnuhmlNxBBtbjqDouc=; b=bT/nSEDn0pI5/qWdIQizjOw2UGxvRTekIOjNVWPOHvH79FMVFrsYihiU6//qsaeAV1 lEnL6fHRR5vdtgQ7ueCfY2QT+E2VJitqB3ccw0YQ6LH+ACt+K781i0/Se132IGK0D3uE 8xOGwAepbuxaGa7NS+7D8l4N0YW/UNJ2jD64fm+nbF41hsPsevQ/wzv7RRZDlJOvJE3T lWZo7MdBzTUD6TMAkEOrkInfwx/qFeT+Xm15AzXUqXUdTqD3QFc/+PxNjg2e0vtDq6PH r49OSibuxCfXGiH+/VGoAtNgMvXEZSRS9O0YL8rhEqooD9xLDqIIIvnvosZwh5/c8Rg6 YTpg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uniroma2.it Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ce9si8090815ejb.213.2019.11.16.07.14.58; Sat, 16 Nov 2019 07:15:22 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uniroma2.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727825AbfKPPNz (ORCPT + 99 others); Sat, 16 Nov 2019 10:13:55 -0500 Received: from smtp.uniroma2.it ([160.80.6.23]:54166 "EHLO smtp.uniroma2.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727798AbfKPPNz (ORCPT ); Sat, 16 Nov 2019 10:13:55 -0500 Received: from localhost.localdomain ([160.80.103.126]) by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id xAGF6RdB011419 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Sat, 16 Nov 2019 16:06:29 +0100 From: Andrea Mayer To: "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , David Lebrun , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrea Mayer Subject: [net, 2/2] seg6: fix skb transport_header after decap_and_validate() Date: Sat, 16 Nov 2019 16:05:53 +0100 Message-Id: <20191116150553.17497-3-andrea.mayer@uniroma2.it> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116150553.17497-1-andrea.mayer@uniroma2.it> References: <20191116150553.17497-1-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015 X-Virus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org in the receive path (more precisely in ip6_rcv_core()) the skb->transport_header is set to skb->network_header + sizeof(*hdr). As a consequence, after routing operations, destination input expects to find skb->transport_header correctly set to the next protocol (or extension header) that follows the network protocol. However, decap behaviors (DX*, DT*) remove the outer IPv6 and SRH extension and do not set again the skb->transport_header pointer correctly. For this reason, the patch sets the skb->transport_header to the skb->network_header + sizeof(hdr) in each DX* and DT* behavior. Signed-off-by: Andrea Mayer --- net/ipv6/seg6_local.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c index 5e3d7004d431..e70567446f28 100644 --- a/net/ipv6/seg6_local.c +++ b/net/ipv6/seg6_local.c @@ -341,6 +341,8 @@ static int input_action_end_dx6(struct sk_buff *skb, if (!ipv6_addr_any(&slwt->nh6)) nhaddr = &slwt->nh6; + skb_set_transport_header(skb, sizeof(struct ipv6hdr)); + seg6_lookup_nexthop(skb, nhaddr, 0); return dst_input(skb); @@ -370,6 +372,8 @@ static int input_action_end_dx4(struct sk_buff *skb, skb_dst_drop(skb); + skb_set_transport_header(skb, sizeof(struct iphdr)); + err = ip_route_input(skb, nhaddr, iph->saddr, 0, skb->dev); if (err) goto drop; @@ -390,6 +394,8 @@ static int input_action_end_dt6(struct sk_buff *skb, if (!pskb_may_pull(skb, sizeof(struct ipv6hdr))) goto drop; + skb_set_transport_header(skb, sizeof(struct ipv6hdr)); + seg6_lookup_nexthop(skb, NULL, slwt->table); return dst_input(skb); -- 2.20.1