Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp2072384rwb; Fri, 5 Aug 2022 12:42:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5sUQLD6o0A/PS1B0iuJGjbGEHLjtxcvoALJZ/baXSNnT7YCJdoQQQ0NtPWE1bLq8zX7kej X-Received: by 2002:a05:6402:3583:b0:43d:6943:44a with SMTP id y3-20020a056402358300b0043d6943044amr7871282edc.409.1659728541311; Fri, 05 Aug 2022 12:42:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659728541; cv=none; d=google.com; s=arc-20160816; b=pe9bfg3zV4tSvnrO4RNwxLbQ5S+4vLjSRlM05lNKEBvBnH11NErsIpF3mS9SFvndWP B2n+RNj1h1WQ/rt/wm4VS7D3aE0T3CoGhweeavfvG49FmYh4RY5SY/O0mwlWDBmJJrLd P++AMqOPG8aTtrLvsH9qCKJAXkvXMcxdwLTNTPp41ThZfNoW49QCPzVYx9wmxfo4rWYe lbRIrQ5NkVLzgEnjsDrPBfHBh5+ElsIi6I3rEvhNQngGXoevf75RyZ1V/YG+MPZr38zH 9mV+GbIdKrjyrnk5HR4O0mst9YbAuTKU1FIBJ6oIpqh3dz3QCDT97ntn4T29C9mxFeOx NjVA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=DY+k8f6xizD0E3lDErdfonPO+Yme8zArGJdWjHyUqU8=; b=TH1BSejvIIA3e0b64hmha9hSBDni1VwlJsvd+XReREtWxmFpaFaG3H7UmJPk3ZdO0K u7MqWVW/MPN+wF/frFfAIw7nhQcwXjahvl2f+PbebBuyaK8MWg4+4KIHORG8TWAK2zdg OD19I7urbnaOJDA61wpI47C/srCmOS3QZDPEoKgbIIcQEY+r3B5jtCCCiaNYAQUtSEoK CwlGqq4Eq02LFP6bOyDfTylVTm7UpH+A8wkXYSwADCdy3+N7UIenQ5JAWxIemlkH9Ioj BhTuGXFkr2EAtzkWLVmH2RkuESEU2OmngZ8Yf+O8YvySuzKeelAwzTdXe6k/pon9lm1n DgPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@westermo.com header.s=12052020 header.b=3VptLbCD; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=westermo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k22-20020a05640212d600b0043e5033412asi480143edx.189.2022.08.05.12.41.50; Fri, 05 Aug 2022 12:42:21 -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=@westermo.com header.s=12052020 header.b=3VptLbCD; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=westermo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241332AbiHETC7 (ORCPT + 99 others); Fri, 5 Aug 2022 15:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240804AbiHETC4 (ORCPT ); Fri, 5 Aug 2022 15:02:56 -0400 Received: from mx08-0057a101.pphosted.com (mx08-0057a101.pphosted.com [185.183.31.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 550551A825; Fri, 5 Aug 2022 12:02:54 -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 275IwEkG013875; Fri, 5 Aug 2022 21:00:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=westermo.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=12052020; bh=DY+k8f6xizD0E3lDErdfonPO+Yme8zArGJdWjHyUqU8=; b=3VptLbCDLonm4U2mDgkzwUEUC52OQtaEECvttjmJGO6EyOdi1IBEJtIJZS4HE+ocj+90 v8Rm5ZSoqnUJS4z3swui6gcJRXZJFE2D1JsnWSU1t6FqMVoJOY2lI2dIT0FztKh7xv3d VrKdtuPxOCwF308CQ56PQLgEnEPUx+bbqMMu619/NybVRu65fC0I7KymMDlB3BOGvvSQ UVaSrEbzvrnim4Q/wA8BLrU4Vbyv666WUHEYELrLYQIwZPYYtfpycck7h0ZsBA6w1U4T oarnPJVD2oBOdaPFiVOT4BjAhL4ukEiJB6aUElOQ2GVp0asJrijgxCAEGjhmIQJNREv9 BA== Received: from mail.beijerelectronics.com ([195.67.87.131]) by mx07-0057a101.pphosted.com (PPS) with ESMTPS id 3hr402hn6v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 05 Aug 2022 21:00:20 +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; Fri, 5 Aug 2022 21:00:17 +0200 From: Matthias May To: CC: , , , , , , , , , , , , Matthias May Subject: [PATCH v4 net] geneve: fix TOS inheriting for ipv4 Date: Fri, 5 Aug 2022 21:00:06 +0200 Message-ID: <20220805190006.8078-1-matthias.may@westermo.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: AfOFOut94Z3B6azK3CtgGuOFKlYf8rtW X-Proofpoint-ORIG-GUID: AfOFOut94Z3B6azK3CtgGuOFKlYf8rtW X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 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 --- v1 -> v2: - Fix typo in "Fixes" tag v2 -> v3: - Add missing CCs v3 -> v4: - Drop reference to IPv6 equivalent of this patch (Guillaume Nault) - Return of full_tos in geneve_get_v4_rt only when needed (David Ahern)) --- drivers/net/geneve.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 018d365f9deb..fafe7dea2227 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 = 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(struct sk_buff *skb, 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) { @@ -911,6 +914,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, 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; @@ -921,7 +925,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, 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); @@ -965,7 +969,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, 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 @@ -1149,7 +1153,7 @@ static int geneve_fill_metadata_dst(struct net_device *dev, struct sk_buff *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, NULL); if (IS_ERR(rt)) return PTR_ERR(rt); -- 2.35.1