Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3677255pxb; Mon, 24 Jan 2022 15:07:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyY1IShO0GYa33y9MPPdbGq1hlRnUG5nz0jNT7/c4BCi2fs3YrsBu1oWv7rIyr/snF4APsV X-Received: by 2002:a17:90b:1b0b:: with SMTP id nu11mr578685pjb.246.1643065628951; Mon, 24 Jan 2022 15:07:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643065628; cv=none; d=google.com; s=arc-20160816; b=v3SkwtAK9ynN1RJgrUVOZPI1vTxUa1/S5xPIpVijJWV+alnxGL5GXjJTf92MPAaQvQ zUXNJrB0Os0lISEbFS8CeoQoFlP2ZPdDNWeicH1ZJ2iBggBMd+KlcNOMKGDrx1iROff6 ATyrBsoEvjesHuee+A3xAXhWU6RYk7pKtsGn/sMnM024yaxNZX8COreTfM1PMR8X/889 Uw9/6ZKzLWgUyZ76vQxnK3uJ4TK4RZn8fWVPXgdH5ACgnrwsIOTyuweTnRz/RAiAHyKi rkHPCgoASSJYWohqYFJPAPuyFYjHhbgTeDjHDBCfQXH0I0zcQeaGoU3bMGRuhG663E53 kWuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yr3JYQWnxOlGMZQrIGEsHzvlsi8DOqUFkfj4aj804pE=; b=KynqIV31MgkehXzfw9bufZer8vZRGG/Y1nZwwyXDuVMDM0WWy4+FDA4scULSR1zpvk NvZc04R7e1XkqdKtnaDSpkGiJwcSqJmbsdKZkrLcojpbMV6aNwqk5q+5ck/ADyxw2UiO ++5a3kNwaNThj3jYLqyCjHyPS8riPfwPy9QLHWTjcO7UFMQ3xDkftV4/hB7u87oggN82 v4NfxZP1RwH7UkOtL9lEnDR0HqO+zhJRTLj4wQjU0IlUJghK7aMzgJhoJO7ziiY6c0op Tmq+NbmBUZVz0IKoBdCix3Y6/iZ5zOWBr8PBAWffhhS/xn5zdn/LBh3Jx+YsySjIB1SD xQng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EGnyjVoi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ls3si616046pjb.177.2022.01.24.15.06.57; Mon, 24 Jan 2022 15:07:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EGnyjVoi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383666AbiAXXE2 (ORCPT + 99 others); Mon, 24 Jan 2022 18:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1580326AbiAXWJd (ORCPT ); Mon, 24 Jan 2022 17:09:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6896EC0DDDB5; Mon, 24 Jan 2022 12:43:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 06C8160B89; Mon, 24 Jan 2022 20:43:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3517C340F5; Mon, 24 Jan 2022 20:43:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056991; bh=lkrwcZs1rqswsvxiGuBq5poRVJf34efWrzR6up4nC3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EGnyjVoi4260KdJsydiO2mrPp1RkJdzJEVNCk55edPZDNFqaSTu8mgAsqu0NBH+fV u4yjRUSDgdOkxXjxgcvs3wQrWzhv+0OQyM5yirEQuYrH53ZFXZlMpjrOBMY22wOtc6 fo2UGuKCQheJd0/meYKFvgOssQu0FXyKxetYIY80= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Lunn , David Ahern , Willem de Bruijn , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 666/846] udp6: Use Segment Routing Header for dest address if present Date: Mon, 24 Jan 2022 19:43:03 +0100 Message-Id: <20220124184124.037991401@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Lunn [ Upstream commit 222a011efc839ca1f51bf89fe7a2b3705fa55ccd ] When finding the socket to report an error on, if the invoking packet is using Segment Routing, the IPv6 destination address is that of an intermediate router, not the end destination. Extract the ultimate destination address from the segment address. This change allows traceroute to function in the presence of Segment Routing. Signed-off-by: Andrew Lunn Reviewed-by: David Ahern Reviewed-by: Willem de Bruijn Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- include/net/seg6.h | 19 +++++++++++++++++++ net/ipv6/udp.c | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) --- a/include/net/seg6.h +++ b/include/net/seg6.h @@ -65,4 +65,23 @@ extern int seg6_do_srh_encap(struct sk_b extern int seg6_do_srh_inline(struct sk_buff *skb, struct ipv6_sr_hdr *osrh); extern int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, u32 tbl_id); + +/* If the packet which invoked an ICMP error contains an SRH return + * the true destination address from within the SRH, otherwise use the + * destination address in the IP header. + */ +static inline const struct in6_addr *seg6_get_daddr(struct sk_buff *skb, + struct inet6_skb_parm *opt) +{ + struct ipv6_sr_hdr *srh; + + if (opt->flags & IP6SKB_SEG6) { + srh = (struct ipv6_sr_hdr *)(skb->data + opt->srhoff); + return &srh->segments[0]; + } + + return NULL; +} + + #endif --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -561,7 +562,7 @@ int __udp6_lib_err(struct sk_buff *skb, struct ipv6_pinfo *np; const struct ipv6hdr *hdr = (const struct ipv6hdr *)skb->data; const struct in6_addr *saddr = &hdr->saddr; - const struct in6_addr *daddr = &hdr->daddr; + const struct in6_addr *daddr = seg6_get_daddr(skb, opt) ? : &hdr->daddr; struct udphdr *uh = (struct udphdr *)(skb->data+offset); bool tunnel = false; struct sock *sk;