From nobody Wed Apr 15 07:03:31 2026 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 8B0A3C43334 for ; Sun, 24 Jul 2022 00:40:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234150AbiGXAil (ORCPT ); Sat, 23 Jul 2022 20:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbiGXAih (ORCPT ); Sat, 23 Jul 2022 20:38:37 -0400 Received: from mx08-0057a101.pphosted.com (mx08-0057a101.pphosted.com [185.183.31.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B23B13F75; Sat, 23 Jul 2022 17:38:35 -0700 (PDT) Received: from pps.filterd (m0214196.ppops.net [127.0.0.1]) by mx07-0057a101.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26O0c7YK023760; Sun, 24 Jul 2022 02:38:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=westermo.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=12052020; bh=PdsnhLuR+bExbwtgs4UB+/XN5oUBXX/fw4V7lvvdrxc=; b=W9Ji7B3gWSVACZoqWWCMmnFzEbxkG+vBZHoS948juRaeaLCiNpd8msyis2ZBTlVxmEtK C8s0qqE/1uGEvP+dQX7J998lE1f4iAJ5A1EKXabwoQFPeZLZb+R9zb2HBely3QQUScT7 FGZ02RQFMEYHlDuCmLahu9nImSlgM9qNkCfiS4xNFUZtmij/3Cvj7Tg9coEP1nDax1DD 5RUnPYhUSARnNKtsR43tLvjdlZvb0XmDZhQmy6nDHcrpoaKCFmlDmWPuSNPzU+SS/3hT V+OpuqzkOEDaKBOux4UXQLLCUYRsk2ZQt6eE7W4gQQ0wMTGiFsPx08ydMv4ibT6oVyTH Ig== Received: from mail.beijerelectronics.com ([195.67.87.131]) by mx07-0057a101.pphosted.com (PPS) with ESMTPS id 3hg5048rhw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 24 Jul 2022 02:38:07 +0200 Received: from Orpheus.nch.westermo.com (172.29.100.2) by EX01GLOBAL.beijerelectronics.com (10.101.10.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.2375.17; Sun, 24 Jul 2022 02:38:05 +0200 From: Matthias May To: CC: , , , , , , , , , Matthias May Subject: [PATCH 1/2 net-next] geneve: fix TOS inheriting for ipv4 Date: Sun, 24 Jul 2022 02:37:40 +0200 Message-ID: <20220724003741.57816-2-matthias.may@westermo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220724003741.57816-1-matthias.may@westermo.com> References: <20220724003741.57816-1-matthias.may@westermo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.29.100.2] X-ClientProxiedBy: wsevst-s0023.westermo.com (192.168.130.120) To EX01GLOBAL.beijerelectronics.com (10.101.10.25) X-Proofpoint-ORIG-GUID: DfRptbxre1p0rdf75NXy3oFeFGg9oFYv X-Proofpoint-GUID: DfRptbxre1p0rdf75NXy3oFeFGg9oFYv Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The current code retrieves the TOS field after the lookup on the ipv4 routing table. The routing process currently only allows routing based on the original 3 TOS bits, and not on the full 6 DSCP bits. As a result the retrieved TOS is cut to the 3 bits. However for inheriting purposes the full 6 bits should be used. Extract the full 6 bits before the route lookup and use that instead of the cut off 3 TOS bits. Signed-off-by: Matthias May --- drivers/net/geneve.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 2495a5719e1c..4c380c06f178 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -797,7 +797,8 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *= skb, struct geneve_sock *gs4, struct flowi4 *fl4, const struct ip_tunnel_info *info, - __be16 dport, __be16 sport) + __be16 dport, __be16 sport, + __u8 *full_tos) { bool use_cache =3D ip_tunnel_dst_cache_usable(skb, info); struct geneve_dev *geneve =3D netdev_priv(dev); @@ -822,6 +823,7 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *= skb, use_cache =3D false; } fl4->flowi4_tos =3D RT_TOS(tos); + *full_tos =3D tos; =20 dst_cache =3D (struct dst_cache *)&info->dst_cache; if (use_cache) { @@ -910,6 +912,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct = net_device *dev, const struct ip_tunnel_key *key =3D &info->key; struct rtable *rt; struct flowi4 fl4; + __u8 full_tos; __u8 tos, ttl; __be16 df =3D 0; __be16 sport; @@ -920,7 +923,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct = net_device *dev, =20 sport =3D udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); rt =3D geneve_get_v4_rt(skb, dev, gs4, &fl4, info, - geneve->cfg.info.key.tp_dst, sport); + geneve->cfg.info.key.tp_dst, sport, &full_tos); if (IS_ERR(rt)) return PTR_ERR(rt); =20 @@ -964,7 +967,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct = net_device *dev, =20 df =3D key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; } else { - tos =3D ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb); + tos =3D ip_tunnel_ecn_encap(full_tos, ip_hdr(skb), skb); if (geneve->cfg.ttl_inherit) ttl =3D ip_tunnel_get_ttl(ip_hdr(skb), skb); else @@ -1137,6 +1140,7 @@ static int geneve_fill_metadata_dst(struct net_device= *dev, struct sk_buff *skb) { struct ip_tunnel_info *info =3D skb_tunnel_info(skb); struct geneve_dev *geneve =3D netdev_priv(dev); + __u8 full_tos; __be16 sport; =20 if (ip_tunnel_info_af(info) =3D=3D AF_INET) { @@ -1148,7 +1152,8 @@ static int geneve_fill_metadata_dst(struct net_device= *dev, struct sk_buff *skb) 1, USHRT_MAX, true); =20 rt =3D geneve_get_v4_rt(skb, dev, gs4, &fl4, info, - geneve->cfg.info.key.tp_dst, sport); + geneve->cfg.info.key.tp_dst, sport, + &full_tos); if (IS_ERR(rt)) return PTR_ERR(rt); =20 --=20 2.35.1 From nobody Wed Apr 15 07:03:31 2026 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 37848C433EF for ; Sun, 24 Jul 2022 00:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236497AbiGXAs0 (ORCPT ); Sat, 23 Jul 2022 20:48:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbiGXAsY (ORCPT ); Sat, 23 Jul 2022 20:48:24 -0400 Received: from mx07-0057a101.pphosted.com (mx07-0057a101.pphosted.com [205.220.184.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86C6A646C for ; Sat, 23 Jul 2022 17:48:23 -0700 (PDT) Received: from pps.filterd (m0214197.ppops.net [127.0.0.1]) by mx07-0057a101.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26O0c8EC019842; Sun, 24 Jul 2022 02:38:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=westermo.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=12052020; bh=j83F4qCiNDaplHCmmwDEVPID1jxIjxR0J0xDijvNBm4=; b=Eh+3oSdCTBRQKIefX12C+nXLpnGq5H8XEN+UR0Y56nDfBJggfyAU4QHtQw1s5veHJVBk hnYJhJKmKS9WA2vawZ1VO89WsQMGFhfkeb1Z4wTIw1mt/8swC5BkvTnnN6EHuGh/EJav P6X9VBQ1hMtFwFTBqAoXe1jmp+aToc5axFGHjjTDW4dGN5sZfDCW3/GDkYNSw1PDtE8x blC4/t0gMtO65BQYbXGgzPJ0SUVVKqM0cBrEgFL3XUigRykIOaJM7JK3rjIRsswnxxn6 Jtgqjk1t/1HSBCFTNFPvxJRM6hJStrT/iZFZGr3di7at+ad6FpcPUaH7mHDJ9AQvA8p3 GQ== Received: from mail.beijerelectronics.com ([195.67.87.131]) by mx07-0057a101.pphosted.com (PPS) with ESMTPS id 3hg5bbgrm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 24 Jul 2022 02:38:08 +0200 Received: from Orpheus.nch.westermo.com (172.29.100.2) by EX01GLOBAL.beijerelectronics.com (10.101.10.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.2375.17; Sun, 24 Jul 2022 02:38:07 +0200 From: Matthias May To: CC: , , , , , , , , , Matthias May Subject: [PATCH 2/2 net-next] geneve: fix TOS inheriting for ipv6 Date: Sun, 24 Jul 2022 02:37:41 +0200 Message-ID: <20220724003741.57816-3-matthias.may@westermo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220724003741.57816-1-matthias.may@westermo.com> References: <20220724003741.57816-1-matthias.may@westermo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.29.100.2] X-ClientProxiedBy: wsevst-s0023.westermo.com (192.168.130.120) To EX01GLOBAL.beijerelectronics.com (10.101.10.25) X-Proofpoint-GUID: q6bX-TEiNttAZoqHP0Ap_M1dyzqYwg5M X-Proofpoint-ORIG-GUID: q6bX-TEiNttAZoqHP0Ap_M1dyzqYwg5M Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The current code uses the RT_TOS macro to cut off the 6 DSCP bits, down to the original 3 TOS bits. Do not use this macro to get the prio for inheriting purposes. Signed-off-by: Matthias May --- drivers/net/geneve.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 4c380c06f178..e1a4480e6f17 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -877,8 +877,7 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_bu= ff *skb, use_cache =3D false; } =20 - fl6->flowlabel =3D ip6_make_flowinfo(RT_TOS(prio), - info->key.label); + fl6->flowlabel =3D ip6_make_flowinfo(prio, info->key.label); dst_cache =3D (struct dst_cache *)&info->dst_cache; if (use_cache) { dst =3D dst_cache_get_ip6(dst_cache, &fl6->saddr); --=20 2.35.1