Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp932378imi; Thu, 21 Jul 2022 13:52:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tg4j7buVFXO4JTnSR0n54V52LLqKKrAf0j017uaAABcvblpxnRmR960jryUzMVvK3L7d9V X-Received: by 2002:a17:90a:9b03:b0:1f1:85b2:c52b with SMTP id f3-20020a17090a9b0300b001f185b2c52bmr13538921pjp.159.1658436747528; Thu, 21 Jul 2022 13:52:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658436747; cv=none; d=google.com; s=arc-20160816; b=zsZHwTLVwoUinQDA8cKotTJz3Si6JK+VSKz8CUq2/DiTPCYraMUKMr+eWkj1g0MMu8 FxMqJzA1lG2Lumxr2cYCv59ngFL5T+btywuA+NQ4NRpoxad6pJEap9cHTKxoNovQaNFt sXekBgRgLikPsPIzH+9r3LHAeUoLjojUFJUASDzG22QISQhEhML0LPO9LHTkOMovaZxl QCwBnTq7MtjyBJjHDZvX5W+EerZMTID/n/DT/n5fa4E8OYzoYp3zY8Ra++1zD9fxz0T+ tmrUDKpxPRcYwZCjNKV/W2pBxDE737gOQtGjRsgZE9DhCYCQcrqFsAt9h2EfrtNn/Glb 1ruQ== 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=oOcCUTVsGNBleOSh/FjP99rUsWnolJ+a+d9HVll019Y=; b=wkarw+xIfVy6wEQg1JZHACaRDjRLho4JxVtisuyRRMhCmhfs2/CBbh4crWdnZGGYQX 1KbA13v2YyKRhcy7XUKXxdUwLPLExEGFg6ZWFgTFhSuPAD9qd2aqkapQIDFQH3L31xDl nBwywDaCFrrVVOUk8Csdgoi520JlVLmIv3PMtO3Yo6sLh/Wfo668xKhDDaFfNSSdWBjx FuqPbmD1/1AW6cxzCAsYMAbVBoGfRdd0uruwXNjCVOjOHQidyTPfhcD8QjYPwLexoRth FoAqSv+lN9p2APoxxSSR0Rp9hzF4tD326jgFgaqgFEEqZe2RAXJqe418dqm7yJc9MHMU 8wSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@westermo.com header.s=12052020 header.b=gRaEJP9a; 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 z4-20020a170902d54400b0016d31bb7d11si3035652plf.473.2022.07.21.13.51.51; Thu, 21 Jul 2022 13:52:27 -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=gRaEJP9a; 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 S231670AbiGUU2S (ORCPT + 99 others); Thu, 21 Jul 2022 16:28:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiGUU2Q (ORCPT ); Thu, 21 Jul 2022 16:28:16 -0400 Received: from mx08-0057a101.pphosted.com (mx08-0057a101.pphosted.com [185.183.31.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB8C2193FA; Thu, 21 Jul 2022 13:28:14 -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 26LK2QRQ017955; Thu, 21 Jul 2022 22:27:41 +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=oOcCUTVsGNBleOSh/FjP99rUsWnolJ+a+d9HVll019Y=; b=gRaEJP9aRe/GN11TyfB6kT7fUBGH7xAO4loAT4E6WD6Eh3OdfpytEg3dnb3h6sgTguin AqN1Eo0aPum2s0u7NMB3U3tqbn0gqsxdi+Kebr/Jg8jbyuo5inPX4DPUvXKbrn1F1HQM yUfYfCboZ8Q00ak6dB3LifvDtSlKPIj4YqTDhz4gF/dU90ZEs+J5GYHkWCErQsUb42ie 3TgV0wzgEdUF7U0S5dc4hpLbrA6rpHZjDgP3RNviqYHQbsdccXc3eK62eIgJhKycqb1D bUUv4xmfAv7FfuDuREIXZWzIn0kuxef94y5+8WmSvFpdLKOtwF08sGKhl4CjBiwq+Dmm LQ== Received: from mail.beijerelectronics.com ([195.67.87.131]) by mx07-0057a101.pphosted.com (PPS) with ESMTPS id 3hbhb5d6c2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 21 Jul 2022 22:27:41 +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; Thu, 21 Jul 2022 22:27:40 +0200 From: Matthias May To: CC: , , , , , , , , , Matthias May Subject: [PATCH net-next] ip_tunnels: allow VXLAN/GENEVE to inherit TOS/TTL from VLAN Date: Thu, 21 Jul 2022 22:27:19 +0200 Message-ID: <20220721202718.10092-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-ORIG-GUID: 5yHu0hAYP6Nh7wSHsFLeuODHOXm4-pz2 X-Proofpoint-GUID: 5yHu0hAYP6Nh7wSHsFLeuODHOXm4-pz2 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 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 allows for VXLAN and GENEVE to inherit the TOS respective the TTL when skb-protocol is ETH_P_IP or ETH_P_IPV6. However when the payload is VLAN encapsulated, then this inheriting does not work, because the visible skb-protocol is of type ETH_P_8021Q or ETH_P_8021AD. Instead of skb->protocol use skb_protocol(). Signed-off-by: Matthias May --- include/net/ip_tunnels.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index c24fa934221d..d76c3f6a1f3f 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -387,9 +387,11 @@ static inline int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t, static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph, const struct sk_buff *skb) { - if (skb->protocol == htons(ETH_P_IP)) + __be16 payload_protocol = skb_protocol(skb, true); + + if (payload_protocol == htons(ETH_P_IP)) return iph->tos; - else if (skb->protocol == htons(ETH_P_IPV6)) + else if (payload_protocol == htons(ETH_P_IPV6)) return ipv6_get_dsfield((const struct ipv6hdr *)iph); else return 0; @@ -398,9 +400,11 @@ static inline u8 ip_tunnel_get_dsfield(const struct iphdr *iph, static inline u8 ip_tunnel_get_ttl(const struct iphdr *iph, const struct sk_buff *skb) { - if (skb->protocol == htons(ETH_P_IP)) + __be16 payload_protocol = skb_protocol(skb, true); + + if (payload_protocol == htons(ETH_P_IP)) return iph->ttl; - else if (skb->protocol == htons(ETH_P_IPV6)) + else if (payload_protocol == htons(ETH_P_IPV6)) return ((const struct ipv6hdr *)iph)->hop_limit; else return 0; -- 2.35.1