From patchwork Mon Sep 15 13:08:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reuven Plevinsky X-Patchwork-Id: 2137188 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=LqjwDET/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4cQQMy2KD8z1y1c for ; Mon, 15 Sep 2025 23:09:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BF68761197; Mon, 15 Sep 2025 13:09:00 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5qhjN3A8Lq0S; Mon, 15 Sep 2025 13:08:59 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6940D61152 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=LqjwDET/ Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6940D61152; Mon, 15 Sep 2025 13:08:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4110DC02A6; Mon, 15 Sep 2025 13:08:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 07855C02A5 for ; Mon, 15 Sep 2025 13:08:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id F38CA61152 for ; Mon, 15 Sep 2025 13:08:57 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id HDyXYUlxCy1D for ; Mon, 15 Sep 2025 13:08:57 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a01:111:f403:c10c::1; helo=sa9pr02cu001.outbound.protection.outlook.com; envelope-from=rplevinsky@nvidia.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org E318A60B36 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E318A60B36 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazlp170130001.outbound.protection.outlook.com [IPv6:2a01:111:f403:c10c::1]) by smtp3.osuosl.org (Postfix) with ESMTPS id E318A60B36 for ; Mon, 15 Sep 2025 13:08:56 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JCtDnA1wJ+1ihq6d+WwRH5LIhwHPne7UV32Q8QX3tQZtxDczNMr6pTd5z3cp7BruCTkOracEebGN7wIHxP5Lazs4CbAUGB711fMhlXppjxqZud7IIbT5txv7QR1D8Bc+PjkpiDVvTxS/voSAjGjzGVvWMBe3O4Z6aMbo5UyAfJERxzKVYhaaOW8coHMc+kDzdbpq7Z7FWmqhMLdy83Zxxa38/aJv5SRCC2Y9EcAJwfcjOOYBn81fEA42AtKzQjsR7SEmvMemYpfY43U2rf7b3G9M7uC6f8D74kO8h3buXYiUp/fFtyhhZRMa9oHkQ3EVAngRCUxDu9bBqtSydFz1Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bZSl15Tu3cdsUnwcfHyZqfB986JxQEVInBfgDbZBUVs=; b=gZDcU17kWHm/jrXmyNlSgoCZhYFbdf9gw8sXOYpO3kp7CgJ245piyVb5oRYkpY5pPeDTNA5zmTuGeCchOj2GgqGZyKEcJUBEnyeXafB9rNTCA8KgAnANYItwQcw56VU+N3p6Pezmwr92RcGP5/ENT5P6IqiN+RGqsQTwhvselxJzQj6+vWlpelatbYWYtX5a9kKG5DUwJltB768w2FmFlARmNFrto6aIQq8epYRkwzlsEQFBXZ+tgLDKvybLgSiseFFHb4aNnhMYNfvDtcOKCUCy/YUQt9w8HwIvk7SOBAnKjgPnwLv5b9qPp2G5vyEuJh/B/JMj3yc7geuEwPsu7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bZSl15Tu3cdsUnwcfHyZqfB986JxQEVInBfgDbZBUVs=; b=LqjwDET/7m6i3N9A28yeFmJFetsOp0qmfOm2GkNczGL4eWs24mXcQIyroyHXxnFuozj8CTOLOeN88hAmR6x3uUPcCwMUFinjcSd5phBvR0BLHPkyES2C1ICXOqCQCl9cw4kOoebcFpQOnOLSrJvPdJ4gB9a7PAWWpyKL94Cjq8H4bj33tcSajcIpfsGHyyyn9oJHTjnkz7UOChggQHis6Fy75Ef7gdt37r52sQVS2Ta5mWwu84huULtJyMS7BFIGLV5X274RtRM0wf1z6x6QtZZD3x7PRS3a2KiC1+dotH4WibdT/9TmNGBzYaWoTAn2KCAsbM3Gg+nvgcnWyAkBAA== Received: from BN7PPF49208036B.namprd12.prod.outlook.com (2603:10b6:40f:fc02::6cf) by SA0PR12MB4446.namprd12.prod.outlook.com (2603:10b6:806:71::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9115.22; Mon, 15 Sep 2025 13:08:53 +0000 Received: from BN7PPF49208036B.namprd12.prod.outlook.com ([fe80::1055:1537:a7ea:aa37]) by BN7PPF49208036B.namprd12.prod.outlook.com ([fe80::1055:1537:a7ea:aa37%4]) with mapi id 15.20.9115.018; Mon, 15 Sep 2025 13:08:53 +0000 To: "dev@openvswitch.org" CC: Maor Dickman , Eli Britstein , Reuven Plevinsky Thread-Topic: [PATCH 1/1] meta-flow: Introduce tunnel eth-type field. Thread-Index: AQHcJjgeg4Ts/zFwvU6wi2st0v8kobSUN16A Date: Mon, 15 Sep 2025 13:08:53 +0000 Message-ID: <50ea95b5-5820-41d7-9da8-f44a38b1b89b@nvidia.com> References: <20250915115832.23164-1-rplevinsky@nvidia.com> In-Reply-To: <20250915115832.23164-1-rplevinsky@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN7PPF49208036B:EE_|SA0PR12MB4446:EE_ x-ms-office365-filtering-correlation-id: 7fa6f796-c3b1-4e23-f929-08ddf4590519 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|376014|366016|38070700021; x-microsoft-antispam-message-info: =?utf-8?q?z3oQfCF8jtvEjRKyfndSsOJkPboU5KH?= =?utf-8?q?8NP/nd0hEQMiDENLX4U3qe1UM/HtXVKR4sFBtg8InTnmhwH9MlLXtF3TgPJTbzT09?= =?utf-8?q?24LHNvow/L9sxq27p5cszcA7pG+5gU+CB5JDGvfaLHoKaYmDj98JTef3FS9GGUZB7?= =?utf-8?q?zGv7ckJWyKee/nnlFZh5T4U4t79RzcnOCkyaj011Cauro+i9Yr6ooqMjcC5mJjh6Z?= =?utf-8?q?dAws4F0UTpLLARt+25GKlO/hhq3f//9/p/sdCsmZuErjBhcTWegOTgX+IYUF8kCXk?= =?utf-8?q?sLRZjgaLmznROx1NsMlIM5fJK4PKwVaNKV4YgeJSTKVuFa2OUAIRfJJyw8rlx4Hhe?= =?utf-8?q?qPbYPhExJ2kz6j6QM9ZVlSTqu/fyKJMXmLXak4JOHVDsRNahbGu5FJOsp/w5k1KsI?= =?utf-8?q?lBiGW0iMgvayRG0ABEzA1rOq920dxYTXtmS7YGadDloFG5VQYnhMjrRoWwaGwJCZo?= =?utf-8?q?rv3KCtjpAZXdHDzhRhEyOLbdybdV2ZZUeTGIj7Ug2eE1g5TWMHUL+fKk2P4yeV9ej?= =?utf-8?q?wSMdjGjDI0CkeGXEo1D0zYNmxBW2Ykpja845alyAAua5MduY2U4rtLUqOcdc2XPw1?= =?utf-8?q?maH3n8MMx1DcyA3KC/dJWVBWZH7eBiGjX0z0IMZ39OZxh6LkiLA1ou0pBE9oSXAee?= =?utf-8?q?k3l2vJk6lUNU7+KqA2X642BAsHf8cg7oTVAUSPBfQd0oGB1/YEUuy1jmXVPkZRF0p?= =?utf-8?q?TC0vyHhCu/2PheNQkJneY+4PrcQBn2DtrgpX8lfj/8z+4eqUU5WCsrRLn7J2xgmUu?= =?utf-8?q?jHhk4yTT+AeBF5Wg0VDPDE2wdT120XJqQ3PmEOMGBJGgFgNqDVymPzCgkq1qLdOnG?= =?utf-8?q?Jx5l3rvDBo0TYnaElEs2T4aV7lt2AthlQPL7KujEvSzlotG5ZzZa4nRPEr5hqGuLS?= =?utf-8?q?bVARbJGkk+Je8f9LLKlcVfe24ZR//va2Sl4VsYoB8ZzMTpH4nOFmt084mZzpY7qGV?= =?utf-8?q?fQnT76Y6gjIJC+xGZPFUBlV5c6dW3cntxr9bsAYrh6SYbgZ046q/15NjIl0qiDqAb?= =?utf-8?q?4JOYC2AaZdagArXPZvilnPmbz6zZubBHbAMEzX7FyN12DDyxfrkcnaHkohn2OmB+H?= =?utf-8?q?7LWiCK1WXbSC0Sg5ALWV19ZJckZnCJPuoF1ufGFtu0ELk9doxGE47HQTNbuYSq2Fp?= =?utf-8?q?s8HUScxtiSSoN9SIqyggPnsckHGboItKRFGYbTryeTPP1aBiQFBj8i8vUbYdHW1dG?= =?utf-8?q?lp3/nol2J71m08qPTCVOt9cjpJrBo9Q9kieVdwNPuRadJxPCncUey36DS77SvT80O?= =?utf-8?q?mijKgOtdua/hS8njzn6fdQkZI6JO1bwUAblfyKAtTEN3JIfpCEN42eQ1Oaa5cGgnq?= =?utf-8?q?zW9c8dgMKz/XerzODXTLQCM0Cln5GW+C8RJ5rvjSEv/akAHoZzabgjdhFxCmTsNGA?= =?utf-8?q?+40I/aUWZh8fsY2hbCOGuiL72ioiOASwobaRFUE2emKmccyw0QLhtg=3D?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PPF49208036B.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016)(38070700021); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?MjnbKIwMlzx470WIjCS7i0iMs/Cn?= =?utf-8?q?ocK+h6aEAtn8PLISeUHAN1sTV9Y6tVCLozMvzIFyCmUGl0LTR+UsqgkZK5c7Byt9/?= =?utf-8?q?Y0TUeEdgw9qxs/M4AyIrtN123fO9iUxLAWo7cY1hNhZY45xWEHUKWR98GYnh6IYIb?= =?utf-8?q?yCSKKeJRAoGplIjzNIUi/zCUfCS/HVascSdsM0WgWoZpQQY/grdDjEW9KnnxlXmu7?= =?utf-8?q?obBbucrLBPMNlzBQ9BukPip6A+ay87CvsLm1p00juJwa0kYVZu5UBukmtW1iyTgSE?= =?utf-8?q?FcfB5PlbV1mfCdiAbTwns/f5Rb4U3ZB89da9mPPHsP5tMbVHMzR28zoTIVh6eU0w3?= =?utf-8?q?XWD3xuRvkdDXfXZ+SngmZ0qMVgsQYrW25KjS4OMjUbb7fJN+V2HLh3HRjktwkNCF4?= =?utf-8?q?p4IM5kfgHuDLtruXFb6O8KwwSRmWur1QFzaKnEIWrq/7d35EJwYEB24JP42ehQ89u?= =?utf-8?q?TMj+X5oZJmSZipXS7u5wz1WiWXodVAfikZgpa1vMbWdXISXer8bRNr7YYAaLxG6KC?= =?utf-8?q?vosEBgzoX+xork4pTDhLOkE3RnLnuomi09j6rwiY4z1kUNOiZnGGMv/FB5IXVPtMF?= =?utf-8?q?LiPHRWc5E/yqeICoK/E0TRqXBT+y8wvF4vCKHhTZy0iLWaFKrMrokalpOAqJT1bHy?= =?utf-8?q?GWgrHStqUmo13TCM6VmxLv6EMw0DdRmkq2Hi7cFTVOx0m+jbdnr9juxAqPfmMljBe?= =?utf-8?q?W7aJ4Ml5C2WTr4t2k+UIXs9r4LUQiZmKzvPCBqTyZoA3bV4ioezgQz008LXn3dRn7?= =?utf-8?q?ZkYmra4MeSsh4tHyqfH8gijd1jlw6rzrfXqaG94ynBd8SdKj2AeiHc/UNicIqFPBE?= =?utf-8?q?3Tvqe1h58POPPUEEiQzMEcb1o9RRTuopuAK5J/hxuS6HdY1VURp43CLMY7Bn2Xp3M?= =?utf-8?q?hUVub6juF2G30urFQ3qsrZS8SJ3JLDUteyanC3/c3GFf9E4ZfG3RpKlgOhoWmN+GR?= =?utf-8?q?vTlpc/dZljShw8Ymt00NJio+SR47Oh/DHFZ/r9teKhuRpLe+Wfho53GzWUYwXMDNC?= =?utf-8?q?EoE7zP/N1e2HpczK2xuwp+iTzGbFeQF3eprwu1d3k6k4oFIINyk+HtVQBm0kN0KSD?= =?utf-8?q?Lx5kyMvb2sgvqwVv6llWJ4rFMr0D6NVNglxe7uM58EeLEpokVAMyFryy7ma2iRcHm?= =?utf-8?q?QuawMpcpD3y1TXm34B19s4AgbCzjiJVM/btA1u87m+zE9YOxqCeJZebqCY+HjkF3W?= =?utf-8?q?dFkmiFKhsVerC9R3nDbzmEpLuhslaVPJopqnnN4HVeEYcgFTpyAVS7fOTN4D4idRV?= =?utf-8?q?LA++Rd7oLpQFgXfrf5th8bXXusG8sY1ic6LzATv9b/k1nUx1cSs5ND9xbBeFwIsS1?= =?utf-8?q?bjg0aJ2oZxl1u3ediTq+OctbYe/AP6b5ft5lVMQySJLs3NSpTU2YolgqyR8+kPi0B?= =?utf-8?q?nrtw0UqjLJdzBCaR3mS2tX2D6rFiLLmnFEXy4amKvf35VeqPGW4VqA+EBIxh99MSt?= =?utf-8?q?To0M5tKbP96peQyIBHx9eXBkGLhbdDDdkfzugMRq0DxnylMi7v3jMaO+9mfqHggs7?= =?utf-8?q?gQvvo8+ZbqlNjB7B1LOFtXWsCkFeBR9m1g=3D=3D?= Content-ID: <75217DDC2C12DF43A933E09168E96351@namprd12.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN7PPF49208036B.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fa6f796-c3b1-4e23-f929-08ddf4590519 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Sep 2025 13:08:53.1013 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: WveKDdL/sO8vgi6AHVqCe/NfS3HlGQptXE/04Y7NJd5cfbZnMXPsuQcAY0F0TKYfoEbC136PAHfxE+wGV4FwMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4446 Subject: [ovs-dev] [PATCH 1/1] meta-flow: Introduce tunnel eth-type field. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Reuven Plevinsky via dev From: Reuven Plevinsky Reply-To: Reuven Plevinsky Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Eli Britstein Introduce eth-type field to tunnel metadata that is internally matched for tunnels, for robust detection of the IP type. Signed-off-by: Eli Britstein --- 1. Please note this is a draft-only proposal. We didn't take care on all tunnel types, testsuite etc. 2. About backward compatibility: You mentioned that today OpenFlow allows setting both tunnel IPv4 and IPv6 fields simultaneously. While that is true technically, there is no valid use case or semantic meaning to matching both address types at once. Matching on IPv4 and IPv6 together simply does not make sense from a protocol perspective. So, in practice, I would argue that this is not a real compatibility issue, because the "dual set" case is already invalid. 3. About dependencies and pipeline design: I understand the point about dependencies and the mismatch with OpenFlow's "all fields can be set" model. But the key here is that the proposed tunnel_eth_type is an internal field. It is not exposed directly in OpenFlow as a user-visible match key. Instead, it provides internal consistency for the datapath and avoids ambiguity in cases where the tunnel IP version matters. Since it is internal, existing OpenFlow semantics remain untouched, and no user-facing behavior is broken. 4. If we go forward with this approach, more commits will follow to handle offloads and cleanups of "dual set", that as mentioned it is already invalid. include/openvswitch/match.h | 1 + include/openvswitch/meta-flow.h | 14 ++++++++++++++ include/openvswitch/packets.h | 3 ++- lib/match.c | 8 ++++++++ lib/meta-flow.c | 18 ++++++++++++++++++ lib/meta-flow.xml | 1 + lib/netdev-native-tnl.c | 15 +++++++++++++++ lib/netdev-offload-dpdk.c | 3 +++ lib/netdev-offload-tc.c | 2 ++ ofproto/tunnel.c | 1 + 10 files changed, 65 insertions(+), 1 deletion(-) diff --git a/include/openvswitch/match.h b/include/openvswitch/match.h index 2e8812048e86..b962badfcfd3 100644 --- a/include/openvswitch/match.h +++ b/include/openvswitch/match.h @@ -127,6 +127,7 @@ void match_set_tun_gtpu_flags_masked(struct match *match, uint8_t flags, void match_set_tun_gtpu_msgtype(struct match *match, uint8_t msgtype); void match_set_tun_gtpu_msgtype_masked(struct match *match, uint8_t msgtype, uint8_t mask); +void match_set_tun_eth_type(struct match *, ovs_be16); void match_set_in_port(struct match *, ofp_port_t ofp_port); void match_set_pkt_mark(struct match *, uint32_t pkt_mark); void match_set_pkt_mark_masked(struct match *, uint32_t pkt_mark, uint32_t mask); diff --git a/include/openvswitch/meta-flow.h b/include/openvswitch/meta-flow.h index fb7d17ebe736..cfdd286d8bf1 100644 --- a/include/openvswitch/meta-flow.h +++ b/include/openvswitch/meta-flow.h @@ -304,6 +304,20 @@ enum OVS_PACKED_ENUM mf_field_id { */ MFF_TUN_ID, + /* "tun_eth_type". + * + * Packet's Tunnel Ethernet type. + * + * Type: be16. + * Maskable: no. + * Formatting: decimal. + * Prerequisites: none. + * Access: read-only. + * NXM: none. + * OXM: none. + */ + MFF_TUN_ETH_TYPE, + /* "tun_src". * * The IPv4 source address in the outer IP header of a tunneled packet. diff --git a/include/openvswitch/packets.h b/include/openvswitch/packets.h index a65cb0d04e77..c9af1b6ceca6 100644 --- a/include/openvswitch/packets.h +++ b/include/openvswitch/packets.h @@ -45,7 +45,8 @@ struct flow_tnl { uint8_t erspan_hwid; uint8_t gtpu_flags; uint8_t gtpu_msgtype; - uint8_t pad1[4]; /* Pad to 64 bits. */ + ovs_be16 eth_type; + uint8_t pad1[2]; /* Pad to 64 bits. */ struct tun_metadata metadata; }; diff --git a/lib/match.c b/lib/match.c index 9b7e06e0c7f8..e6681db82a05 100644 --- a/lib/match.c +++ b/lib/match.c @@ -402,6 +402,13 @@ match_set_tun_gtpu_msgtype(struct match *match, uint8_t msgtype) match_set_tun_gtpu_msgtype_masked(match, msgtype, UINT8_MAX); } +void +match_set_tun_eth_type(struct match *match, ovs_be16 eth_type) +{ + match->wc.masks.tunnel.eth_type = OVS_BE16_MAX; + match->flow.tunnel.eth_type = eth_type; +} + void match_set_in_port(struct match *match, ofp_port_t ofp_port) { @@ -1398,6 +1405,7 @@ format_flow_tunnel(struct ds *s, const struct match *match) FLOW_TNL_F_MASK); ds_put_char(s, ','); } + ds_put_format(s, "tun_eth_type=0x%04"PRIx16",", ntohs(tnl->eth_type)); tun_metadata_match_format(s, match); } diff --git a/lib/meta-flow.c b/lib/meta-flow.c index b03fe7abf1d8..e2c870a126d4 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -211,6 +211,8 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc) return !wc->masks.packet_type; case MFF_CONJ_ID: return !wc->masks.conj_id; + case MFF_TUN_ETH_TYPE: + return !wc->masks.tunnel.eth_type; case MFF_TUN_SRC: return !wc->masks.tunnel.ip_src; case MFF_TUN_DST: @@ -522,6 +524,7 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value) case MFF_PACKET_TYPE: case MFF_CONJ_ID: case MFF_TUN_ID: + case MFF_TUN_ETH_TYPE: case MFF_TUN_SRC: case MFF_TUN_DST: case MFF_TUN_IPV6_SRC: @@ -678,6 +681,9 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow, case MFF_TUN_ID: value->be64 = flow->tunnel.tun_id; break; + case MFF_TUN_ETH_TYPE: + value->be16 = flow->tunnel.eth_type; + break; case MFF_TUN_SRC: value->be32 = flow->tunnel.ip_src; break; @@ -1015,6 +1021,9 @@ mf_set_value(const struct mf_field *mf, case MFF_TUN_ID: match_set_tun_id(match, value->be64); break; + case MFF_TUN_ETH_TYPE: + match_set_tun_eth_type(match, value->be16); + break; case MFF_TUN_SRC: match_set_tun_src(match, value->be32); break; @@ -1437,6 +1446,9 @@ mf_set_flow_value(const struct mf_field *mf, case MFF_TUN_ID: flow->tunnel.tun_id = value->be64; break; + case MFF_TUN_ETH_TYPE: + flow->tunnel.eth_type = value->be16; + break; case MFF_TUN_SRC: flow->tunnel.ip_src = value->be32; break; @@ -1821,6 +1833,7 @@ mf_is_any_metadata(const struct mf_field *mf) return true; case MFF_TUN_ID: + case MFF_TUN_ETH_TYPE: case MFF_TUN_SRC: case MFF_TUN_DST: case MFF_TUN_IPV6_SRC: @@ -1915,6 +1928,7 @@ mf_is_pipeline_field(const struct mf_field *mf) { switch (mf->id) { case MFF_TUN_ID: + case MFF_TUN_ETH_TYPE: case MFF_TUN_SRC: case MFF_TUN_DST: case MFF_TUN_IPV6_SRC: @@ -2073,6 +2087,9 @@ mf_set_wild(const struct mf_field *mf, struct match *match, char **err_str) case MFF_TUN_ID: match_set_tun_id_masked(match, htonll(0), htonll(0)); break; + case MFF_TUN_ETH_TYPE: + match->flow.tunnel.eth_type = 0; + break; case MFF_TUN_SRC: match_set_tun_src_masked(match, htonl(0), htonl(0)); break; @@ -2477,6 +2494,7 @@ mf_set(const struct mf_field *mf, case MFF_ICMPV6_CODE: case MFF_ND_RESERVED: case MFF_ND_OPTIONS_TYPE: + case MFF_TUN_ETH_TYPE: return OFPUTIL_P_NONE; case MFF_DP_HASH: diff --git a/lib/meta-flow.xml b/lib/meta-flow.xml index ac72a44bce40..45225f3ad351 100644 --- a/lib/meta-flow.xml +++ b/lib/meta-flow.xml @@ -1510,6 +1510,7 @@ ovs-ofctl add-flow br-int 'in_port=3,tun_src=192.168.1.1,tun_id=5001 actions=1' +

When a packet is received from a tunnel, this field is the diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c index e172ed72e447..5bf56f480aa0 100644 --- a/lib/netdev-native-tnl.c +++ b/lib/netdev-native-tnl.c @@ -524,6 +524,7 @@ netdev_gre_pop_header(struct dp_packet *packet) struct pkt_metadata *md = &packet->md; struct flow_tnl *tnl = &md->tunnel; int hlen = sizeof(struct eth_header) + 4; + const struct eth_header *eth; ovs_assert(data_dp); @@ -540,6 +541,10 @@ netdev_gre_pop_header(struct dp_packet *packet) goto err; } + eth = dp_packet_eth(packet); + if (eth) { + tnl->eth_type = eth->eth_type; + } dp_packet_reset_packet(packet, hlen); return packet; @@ -1097,6 +1102,7 @@ netdev_vxlan_pop_header(struct dp_packet *packet) unsigned int hlen; ovs_be32 vx_flags; enum packet_type next_pt = PT_ETH; + const struct eth_header *eth; ovs_assert(packet->l3_ofs > 0); ovs_assert(packet->l4_ofs > 0); @@ -1147,6 +1153,10 @@ netdev_vxlan_pop_header(struct dp_packet *packet) tnl->flags |= FLOW_TNL_F_KEY; packet->packet_type = htonl(next_pt); + eth = dp_packet_eth(packet); + if (eth) { + tnl->eth_type = eth->eth_type; + } dp_packet_reset_packet(packet, hlen + VXLAN_HLEN); if (next_pt != PT_ETH) { packet->l3_ofs = 0; @@ -1214,6 +1224,7 @@ netdev_geneve_pop_header(struct dp_packet *packet) struct flow_tnl *tnl = &md->tunnel; struct genevehdr *gnh; unsigned int hlen, opts_len, ulen; + const struct eth_header *eth; pkt_metadata_init_tnl(md); if (GENEVE_BASE_HLEN > dp_packet_l4_size(packet)) { @@ -1255,6 +1266,10 @@ netdev_geneve_pop_header(struct dp_packet *packet) tnl->flags |= FLOW_TNL_F_UDPIF; packet->packet_type = htonl(PT_ETH); + eth = dp_packet_eth(packet); + if (eth) { + tnl->eth_type = eth->eth_type; + } dp_packet_reset_packet(packet, hlen); return packet; diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index f963bef2280b..7ce9da21b0f3 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -1367,6 +1367,9 @@ parse_flow_tnl_match(struct netdev *tnldev, return ret; } + /* Temporary ignore. */ + match->wc.masks.tunnel.eth_type = 0; + if (!strcmp(netdev_get_type(tnldev), "vxlan")) { ret = parse_vxlan_match(patterns, match); } diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c index 66f2558ddb71..0b56b650b69f 100644 --- a/lib/netdev-offload-tc.c +++ b/lib/netdev-offload-tc.c @@ -2324,6 +2324,8 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, memset(&tnl_mask->gbp_id, 0, sizeof tnl_mask->gbp_id); memset(&tnl_mask->gbp_flags, 0, sizeof tnl_mask->gbp_flags); tnl_mask->flags &= ~FLOW_TNL_F_KEY; + /* Tunnel's eth_type is for userspace only. Ignore it here. */ + tnl_mask->eth_type = 0; /* XXX: This is wrong! We're ignoring DF and CSUM flags configuration * requested by the user. However, TC for now has no way to pass diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c index 80ddee78acf6..c63332051078 100644 --- a/ofproto/tunnel.c +++ b/ofproto/tunnel.c @@ -381,6 +381,7 @@ tnl_wc_init(struct flow *flow, struct flow_wildcards *wc) * wildcarded, not to unwildcard them here. */ wc->masks.tunnel.tp_src = 0; wc->masks.tunnel.tp_dst = 0; + wc->masks.tunnel.eth_type = OVS_BE16_MAX; if (is_ip_any(flow) && IP_ECN_is_ce(flow->tunnel.ip_tos)) {