Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3322926rwa; Tue, 23 Aug 2022 02:49:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR4y80D/Qwr0f0vMpiLM3DBXD9LaH2dhXY+L/8ICbFdG9B2lqCU1mPpjD07bH2pXAqtQM96j X-Received: by 2002:a17:907:6d0d:b0:73d:9983:2c12 with SMTP id sa13-20020a1709076d0d00b0073d99832c12mr2121053ejc.195.1661248197843; Tue, 23 Aug 2022 02:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248197; cv=none; d=google.com; s=arc-20160816; b=Q4gBKf2nsZrtlVDtX4YL6UPeS4oM4r5YwuoSpJWIlV6lzarpskkoo6FcT3MoaQvqaL 9+LwsOkeAPFGBLxj7UzfAahn49edCWj6dubq+X5aeoqnb3+he4zFjLyH0zVaRxCfMPHk 4SCEm3IM5bwc9IF1jHVItOp8nKadXC3Qbd16QYTKa7SCM3QM9cSgHrE2BrNGhUHljBJi BGjBmuVfwEqYBxPfvSuvB5yP3Bv7PvVD0ClaFgv+170cmX/qYA5yB8XheW2wG5ti5KhS 6LXzQ/CWB5PHqYEtayozboC6VacIP9GavcNNW3NkXxHwIa/Zku5MJR+glnvDL/bG2oPk bkyQ== 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=YVwPeJ85K3NVHDGDpDKoDNYcnyTzSKIvNucacd0Xg6Q=; b=V/KMq+99zRkc1+vAWda+n22ep53TABdAS4btzFNUsU6LvywlSKWafPuCpU7OuvXDPt tMXbCBpt1HEOktQbi9TO/3QovyPpBN/C9LJyUe1cKAugQykDZwjZj72JGlkx/TRsUpv0 Dj1fbTh/JhH4wa6NcY83B7lTjvmf5HV55Pvz9Tlsg0ULcm3WCf9L2942luCUdalzIvVI Fw0viSmz+ecUI0Vvkdj5RIBEffC0NDwCyEGWQzk6ujizUzF6CiEIURdENyV3WdUmO6FH YMUvoW9ngoG7R0WSuGwKD0T88Q4XmDjYzkOTxJljGyRE9RkDx8B1j+Ho0LCsUGeak8/3 R0Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z+9OBNHn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq42-20020a1709073f2a00b0073da56756b8si623176ejc.607.2022.08.23.02.49.32; Tue, 23 Aug 2022 02:49:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z+9OBNHn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1347158AbiHWInn (ORCPT + 99 others); Tue, 23 Aug 2022 04:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346964AbiHWIkg (ORCPT ); Tue, 23 Aug 2022 04:40:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A255242ADD; Tue, 23 Aug 2022 01:18:56 -0700 (PDT) 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 752D26132D; Tue, 23 Aug 2022 08:17:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 637C0C4347C; Tue, 23 Aug 2022 08:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242648; bh=+5grhzWxnc1TKl7dza1qwlywolTWQBQKx7cAp1Gda70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z+9OBNHnQg7SVYQNfvqTodiMAuKCyZxQtPCMY59JKSCrUsVnZTMCwvifSCPwj6owV h/TrSCW921dz1x4wFHsU1FAVK525B93hHHjPoRNJEgTr/woikTpUDHxuR6OzivZY7i p3/DUSMOEFNE7wVWK3Fo8epXM7nRSnckaGglyXKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias May , Guillaume Nault , Jakub Kicinski Subject: [PATCH 5.19 153/365] geneve: fix TOS inheriting for ipv4 Date: Tue, 23 Aug 2022 10:00:54 +0200 Message-Id: <20220823080124.625166031@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthias May commit b4ab94d6adaa5cf842b68bd28f4b50bc774496bd upstream. 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. Fixes: e305ac6cf5a1 ("geneve: Add support to collect tunnel metadata.") Signed-off-by: Matthias May Acked-by: Guillaume Nault Link: https://lore.kernel.org/r/20220805190006.8078-1-matthias.may@westermo.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/geneve.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -797,7 +797,8 @@ static struct rtable *geneve_get_v4_rt(s 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 = ip_tunnel_dst_cache_usable(skb, info); struct geneve_dev *geneve = netdev_priv(dev); @@ -823,6 +824,8 @@ static struct rtable *geneve_get_v4_rt(s use_cache = false; } fl4->flowi4_tos = RT_TOS(tos); + if (full_tos) + *full_tos = tos; dst_cache = (struct dst_cache *)&info->dst_cache; if (use_cache) { @@ -910,6 +913,7 @@ static int geneve_xmit_skb(struct sk_buf const struct ip_tunnel_key *key = &info->key; struct rtable *rt; struct flowi4 fl4; + __u8 full_tos; __u8 tos, ttl; __be16 df = 0; __be16 sport; @@ -920,7 +924,7 @@ static int geneve_xmit_skb(struct sk_buf sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); rt = 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); @@ -964,7 +968,7 @@ static int geneve_xmit_skb(struct sk_buf df = key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0; } else { - tos = ip_tunnel_ecn_encap(fl4.flowi4_tos, ip_hdr(skb), skb); + tos = ip_tunnel_ecn_encap(full_tos, ip_hdr(skb), skb); if (geneve->cfg.ttl_inherit) ttl = ip_tunnel_get_ttl(ip_hdr(skb), skb); else @@ -1148,7 +1152,7 @@ static int geneve_fill_metadata_dst(stru 1, USHRT_MAX, true); rt = geneve_get_v4_rt(skb, dev, gs4, &fl4, info, - geneve->cfg.info.key.tp_dst, sport); + geneve->cfg.info.key.tp_dst, sport, NULL); if (IS_ERR(rt)) return PTR_ERR(rt);