From patchwork Wed Dec 1 20:25:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 12650967 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89E86C433EF for ; Wed, 1 Dec 2021 20:25:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245633AbhLAU3E (ORCPT ); Wed, 1 Dec 2021 15:29:04 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:34404 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245634AbhLAU3B (ORCPT ); Wed, 1 Dec 2021 15:29:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject:Date: Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=PDkGo42W9CyFWJ3+gCVfJVB+qAGoQmWBqGyzwCPKWaM=; b=UjSgTjzJy5qHc/gdQrgBwdW78U PuLxCJBD2X1wuam9935rzb2Ns/VsiZ61tLUJzlX+1PjmYmabwASEXLtpcbN9qfOHh0xnAyt+3VIKJ 0G6gri3RsgiajAp5aXvrCIqh2ZkqMewT0c5Z5auMStO2u214BEXBAuEek/nB5zCiVOVI=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1msWAS-00FGAG-CK; Wed, 01 Dec 2021 21:25:28 +0100 From: Andrew Lunn Cc: David Miller , Jakub Kicinski , Hideaki YOSHIFUJI , David Ahern , Willem de Bruijn , James Prestwood , Justin Iurman , Praveen Chaudhary , "Jason A . Donenfeld" , Eric Dumazet , netdev , Andrew Lunn Subject: [patch RFC net-next v2 3/3] udp6: Use Segment Routing Header for dest address if present Date: Wed, 1 Dec 2021 21:25:19 +0100 Message-Id: <20211201202519.3637005-4-andrew@lunn.ch> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211201202519.3637005-1-andrew@lunn.ch> References: <20211201202519.3637005-1-andrew@lunn.ch> MIME-Version: 1.0 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- net/ipv6/udp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 6a0e569f0bb8..6a2288e7ddda 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -563,12 +564,18 @@ int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt, const struct in6_addr *saddr = &hdr->saddr; const struct in6_addr *daddr = &hdr->daddr; struct udphdr *uh = (struct udphdr *)(skb->data+offset); + struct ipv6_sr_hdr *srh; bool tunnel = false; struct sock *sk; int harderr; int err; struct net *net = dev_net(skb->dev); + if (opt->flags & IP6SKB_SEG6) { + srh = (struct ipv6_sr_hdr *)(skb->data + opt->srhoff); + daddr = &srh->segments[0]; + } + sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source, inet6_iif(skb), inet6_sdif(skb), udptable, NULL);