From patchwork Tue May 9 03:45:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nobuhiro MIKI X-Patchwork-Id: 1778739 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yahoo-corp.jp header.i=@yahoo-corp.jp header.a=rsa-sha256 header.s=selector1 header.b=Yg3UmzTZ; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QFkbV6JSgz20fl for ; Tue, 9 May 2023 13:46:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3D87541D1D; Tue, 9 May 2023 03:46:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3D87541D1D Authentication-Results: smtp2.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key, unprotected) header.d=yahoo-corp.jp header.i=@yahoo-corp.jp header.a=rsa-sha256 header.s=selector1 header.b=Yg3UmzTZ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hJHsT42PUWbE; Tue, 9 May 2023 03:46:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 2C4A141DB5; Tue, 9 May 2023 03:46:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 2C4A141DB5 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5E8C7C0092; Tue, 9 May 2023 03:46:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7BC8EC002A for ; Tue, 9 May 2023 03:46:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2B53D8450C for ; Tue, 9 May 2023 03:46:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2B53D8450C Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=yahoo-corp.jp header.i=@yahoo-corp.jp header.a=rsa-sha256 header.s=selector1 header.b=Yg3UmzTZ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iK94kYo-TZHx for ; Tue, 9 May 2023 03:45:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0875E84466 Received: from corp-ob08.yahoo-corp.jp (corp-ob08.yahoo-corp.jp [183.79.94.93]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0875E84466 for ; Tue, 9 May 2023 03:45:57 +0000 (UTC) Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01lp2107.outbound.protection.outlook.com [104.47.23.107]) by corp-ob08.yahoo-corp.jp (Postfix) with ESMTPS id 9EEFE19FB184 for ; Tue, 9 May 2023 12:45:55 +0900 (JST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bu4h/sCh5ziEaIze3GwFV5laUyn4n0A8z/kwXSScyyUl74tyy/rAjRnP1Lj8NzuTk88tbuqzlgnR3zZGpxXKLLyaEFsW4CT2i335qcNTv8L9tacDzyUbpXDDlU1qyqSMCAW8+EewMqlY4PxwFjhvqauPZLOigQmgn5wWMegHnsFEMUESUfn8g1RNw8e7pQF7A/kmklv5BnJGk7ntuSl9esHusx4i2opeYLs/lBXngkKu7uPRp+SRFYLDpOJOUQBzGAinU95nWyyWpsQhP4xc7y5ped9A5TbVd6uIT6Zm4CTZQ9D+TrjMC9pijvhrID2zc3WVvcpnScv4/3YJtzQNWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=fh5/qaR4ey/gjLej4t1Vtz4KeMSPGhm355x0VLQO7Hk=; b=PPSw4SOI8WvVZB40P4CYSYyKgWjsiTnqHBAqlb2rhGBJPMcfO3wsrIXfe97XHxS43qgR2LSayX6EJAYZfMJA7DYM0+QCUutLHB7Rs4i5XThWmSFipUx6IqBIiWlIQsU/iHN/IbdXTdI+YcB8TGzvy3Sr2+JZ/JtOL3aHOVr3X4IHsAJCakFLLHpJNNxALZP6IvhqDuqzwjjNVafGqxaVZySYAt4voHUzIzUrLdfREKGt0T+QsFBIFekP8ZOxYOoIj4DwwQr/4Pi1zNIINiheJgfF6yGGUrMgybaq+xDwkdTqaD00CFKi9SMZH1tsB9T3PqNH7j2LPIr5W5mOOJgdow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=yahoo-corp.jp; dmarc=pass action=none header.from=yahoo-corp.jp; dkim=pass header.d=yahoo-corp.jp; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo-corp.jp; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fh5/qaR4ey/gjLej4t1Vtz4KeMSPGhm355x0VLQO7Hk=; b=Yg3UmzTZcaF/WouazGjoitj/1q1kiAqVqHlPZbpJrUGe/Ljzory8Hz33rnOwtGVuJf1ZojKrtZ+xjLY4jplA4ZZTKp6WApRe3JJiTiwwofW+PKGZJi/bZe0etfbB+/FkIwyMgy5nUG8FpCA908ATiGyD9E8JqBYZTedQd5crB1w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=yahoo-corp.jp; Received: from TY2PR01MB4107.jpnprd01.prod.outlook.com (2603:1096:404:d8::23) by TYCPR01MB10118.jpnprd01.prod.outlook.com (2603:1096:400:1ee::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Tue, 9 May 2023 03:45:54 +0000 Received: from TY2PR01MB4107.jpnprd01.prod.outlook.com ([fe80::316c:fe30:7d04:4f2b]) by TY2PR01MB4107.jpnprd01.prod.outlook.com ([fe80::316c:fe30:7d04:4f2b%5]) with mapi id 15.20.6363.033; Tue, 9 May 2023 03:45:54 +0000 From: Nobuhiro MIKI To: dev@openvswitch.org Date: Tue, 9 May 2023 12:45:30 +0900 Message-Id: <20230509034530.35553-3-nmiki@yahoo-corp.jp> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230509034530.35553-1-nmiki@yahoo-corp.jp> References: <20230509034530.35553-1-nmiki@yahoo-corp.jp> X-ClientProxiedBy: TY2PR01CA0023.jpnprd01.prod.outlook.com (2603:1096:404:a::35) To TY2PR01MB4107.jpnprd01.prod.outlook.com (2603:1096:404:d8::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TY2PR01MB4107:EE_|TYCPR01MB10118:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cc8e895-004e-471a-39e5-08db503fe40e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T5qqDgX5hqhy0aQLiOE1uiwsB1tdZevluG9JD8wXvy+lM8xMN6JN0VU8iy14p5JkM+qPKW1wOeVV0bT44mEjJuXvu5BrwRLcstm4sZCgzatbJOJLX7w2GEHyuPjVlMrPvWcsAFdDxvMvmYKsnqfITJTr4S68k7SMay17apnXbz1Alok2dhHn+MT1d8Iz+DdkXQBjT6lDg4Txge/c5gh5hVFpMZoJ+/oZrlaheZEBzYvNgPFNXZ5g6rsQhnn276X1QGuXtkqNl4i+MlnT6e5r9A/fzzIB+ng9SWHegSA3P5niztM/ULXp/wzYZsiYIOp9O9vq1mu7Nju7EEyzez/LEgmnWefFkpemcemUUJiKf1igdAbRZE3G9OZWBdku9qE1nc0RkeZrC3kpmVKzxENnD3adHNkX+M2NAgTPS+DAWLpBKQSA6R5L30w+Ui5lGkXcG/tFSU7CDtIjpvXI23kzSplbEYLZh2EsJIzlwzKyh83EEx6KDiBA04BCLgLDiNHpr6roejpD4QHQEmrj4dW4YraIw13cQVVPrTd6gdr/DpcBmKevsWxVL5HMfw3bY/6CORyYyl78kTHh0Ckrtph3hR1IFjn68pcPnIS60Q34zUs0uQXViJDoyFNIARPooEgz X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TY2PR01MB4107.jpnprd01.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(136003)(396003)(346002)(376002)(366004)(39860400002)(451199021)(30864003)(2906002)(186003)(38350700002)(6512007)(26005)(6506007)(1076003)(36756003)(107886003)(38100700002)(83380400001)(2616005)(82960400001)(316002)(6486002)(6666004)(6916009)(41300700001)(66946007)(66556008)(66476007)(4326008)(966005)(86362001)(52116002)(478600001)(8676002)(8936002)(5660300002)(461764006); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NAtGxt9e7qmOMSHATp/fE1jVzOJjtwQh7Bn5RqAVM/W4/W2WbYJN/PwvNO3ll857+OkIjsdaWlQQ5tFQ6/vnQ21SjfIBEGHGhKx5P6eOHaZ8bzT1CwanrxrcJhuFZORo4PQX4eBbJljJSJb0fC2vas3uGlqUZiJGltRyLQiuIl/c9FoKOiH5V9Vx1jJsRsF4FpcsCKTBhwR6YSPfkOO/SHhFJjk5cvBVVSsVBw3pvz8f/mSmDG9EQa2LrAzZQQGxBJlZkDclnDYzfwCMDbfDwhcQTzCk3BC6BLZj+DSNwrcDh35G2mzmDurH4NV5UiI/mAMV5gEaDrNavvOEvViV5F/tXKYcDfJjj3dzGh62NM9/YaTRvhmmNcds+W2CwPG/tKYp8Q1HSCup4G+QSiT8NzDU0rAWnvju+QuIYgGu1Bj+LSwTfkLiV5n5VxUvzmqTccFc+FKCRd72E6uaB8KvRkWaE8CIEV2TdN3QWpUV2sfXeZd1Wy2cDPvZjsd19toDG68Q4VyBBV2DEUAhyguPhrIrPqH3ivaHMRTZZ603NMOxUZ3OcO3xcgbG8a3YPhM+YU5c0c0FM35Xni1E/p9AL8igEkWZSRxW1PfVGjERSDcXCnceZODfUwNHySihL1UgYRXOC/BL8X07dWzorU2N+BKOWQHTVPYIvZsZvzoBioEhpLr1PIIdaSf0A/9/glUUB0XLMW7lxLhEUHtITcDRiOu7PEEPLTNbh7glJDLk9RZ+Dg7U6H4tc7MC5zjgvmJLVXe5eCj01nYAi3+qdRe2zothJGqEYgm8rAi03OdGTp+Tn+UqVnVrspwDVM6armD6usGlfw137LZb27oPt+xCdE/8FJd45dAqvRsYouNr4QqW/9WZKjzjMZbZGi/o1rj5JIHDKviiYibKFULchrDRXHbz7j7+2LJA6sie7l0/jhVxQ7mswarGE1B38/SxWBQZ6No+li3ysv/S+cUEqyG4q5no1D/21y1rxQ6sLNNV8vhc6dbwBA+g54smQ/RMYfepj+UY8/bR9wUGHwrrVad5E3z8sp5rcgCtg4h9QOMCenoGDeo/bKEmO95Zs3B3v4ofsgHwxow7uKtOUJiWnJjyzXrqzRQMpC2TwZDGOaHZnatHhe+c02vuqOt0g0AdUTlPWTny4UFfoKgkaPkWzIJtmX61AYqmdoeXtHAOBjoMwTTi/h0OJE3Uqj/K+0ZO1oSeON2WEXhD9XggbvSRPPcHABmnH8A/Qy5SQ7mNBfuB3V54JVm7DKsxUQLdW6wA1800LrRVG/ul9lyozZ890OyKigad4VrId4XplnOfQpJtVJiGDHCzYiHeInGWxNbfjNccp+gKy5HXwxuEVPF42/bvzlT/w45l21iW6JT48wSdIRGLG9cmopt5phDR30tig6TO4zQY3BwrbOjFTFRBrsujzR22w40ig+BxTgDFCxYG/9KYmcwC2ebBrCUKumOXLVk/AaMAdh9GKPDhnDGK9HyReXHddBXWJlRAlwiVJwzty8QuwaUtuxn4gfWYqTuKPnQPyy7jCxlkNK+qkI0xetsdyM5LiMCONGVMifF9h38fdg6tn1UYJGDq1uXLu5jBfXMB X-OriginatorOrg: yahoo-corp.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 1cc8e895-004e-471a-39e5-08db503fe40e X-MS-Exchange-CrossTenant-AuthSource: TY2PR01MB4107.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 May 2023 03:45:54.4731 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a208d369-cd4e-4f87-b119-98eaf31df2c3 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wq0UuqA0xrq+tp45YzodLcm2W/DW0vr963chgDxZdQLsUjKbqBQmAZsGv6DvoByi8sce/dAlss6//iWgUc/VrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB10118 Subject: [ovs-dev] [PATCH 2/2] userspace: Add new option srv6_flowlabel in SRv6 tunnel. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" It supports flowlabel based load balancing by controlling the flowlabel of outer IPv6 header, which is already implemented in Linux kernel as seg6_flowlabel sysctl [1]. [1]: https://docs.kernel.org/networking/seg6-sysctl.html Signed-off-by: Nobuhiro MIKI --- lib/flow.c | 26 ++++++++++++ lib/flow.h | 1 + lib/netdev-native-tnl.c | 22 +++++++++- lib/netdev-vport.c | 8 ++++ lib/netdev.h | 12 ++++++ tests/tunnel-push-pop-ipv6.at | 79 +++++++++++++++++++++++++++++++++++ vswitchd/vswitch.xml | 29 +++++++++++++ 7 files changed, 176 insertions(+), 1 deletion(-) diff --git a/lib/flow.c b/lib/flow.c index 9501a259e9d4..f0bfe79b3265 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -2734,6 +2734,32 @@ flow_hash_in_wildcards(const struct flow *flow, return hash_finish(hash, 8 * FLOW_U64S); } +uint32_t +flow_hash_srv6_flowlabel(const struct flow *flow, uint32_t basis) +{ + uint32_t hash; + + if (flow->dl_type == htons(ETH_TYPE_IPV6)) { + const uint64_t *flow_u64 = (const uint64_t *) flow; + int ofs = offsetof(struct flow, ipv6_src) / 8; + int end = ofs + 2 * sizeof flow->ipv6_src / 8; + + hash = basis; + + for (;ofs < end; ofs++) { + hash = hash_add64(hash, flow_u64[ofs]); + } + + hash = hash_add(hash, flow->nw_proto); + hash = hash_add(hash, flow->ipv6_label); + } else if (flow->dl_type == htons(ETH_TYPE_IP) + || flow->dl_type == htons(ETH_TYPE_ARP)) { + hash = flow_hash_5tuple(flow, basis); + } + + return hash_finish(hash, 42) & IPV6_LABEL_MASK; /* Arbitrary number. */ +} + /* Sets the VLAN VID that 'flow' matches to 'vid', which is interpreted as an * OpenFlow 1.0 "dl_vlan" value: * diff --git a/lib/flow.h b/lib/flow.h index a9d026e1ce3b..7b8ef5164465 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -258,6 +258,7 @@ bool flow_hash_fields_valid(enum nx_hash_fields); uint32_t flow_hash_in_wildcards(const struct flow *, const struct flow_wildcards *, uint32_t basis); +uint32_t flow_hash_srv6_flowlabel(const struct flow *, uint32_t basis); bool flow_equal_except(const struct flow *a, const struct flow *b, const struct flow_wildcards *); diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c index 55e1bd567fa1..18bd9df57175 100644 --- a/lib/netdev-native-tnl.c +++ b/lib/netdev-native-tnl.c @@ -856,6 +856,7 @@ netdev_srv6_build_header(const struct netdev *netdev, struct netdev_tunnel_config *tnl_cfg; const struct in6_addr *segs; struct srv6_base_hdr *srh; + uint32_t ipv6_label = 0; struct in6_addr *s; ovs_be16 dl_type; int err = 0; @@ -882,7 +883,26 @@ netdev_srv6_build_header(const struct netdev *netdev, goto out; } - srh = netdev_tnl_ip_build_header(data, params, IPPROTO_ROUTING, 0); + switch (tnl_cfg->srv6_flowlabel) { + case SRV6_FLOWLABEL_COPY: + ipv6_label = ntohl(params->flow->ipv6_label); + break; + + case SRV6_FLOWLABEL_ZERO: + ipv6_label = 0; + break; + + case SRV6_FLOWLABEL_COMPUTE: + ipv6_label = flow_hash_srv6_flowlabel(params->flow, 0); + break; + + default: + err = EINVAL; + goto out; + } + + srh = netdev_tnl_ip_build_header(data, params, IPPROTO_ROUTING, + ipv6_label); srh->rt_hdr.segments_left = nr_segs - 1; srh->rt_hdr.type = IPV6_SRCRT_TYPE_4; srh->rt_hdr.hdrlen = 2 * nr_segs; diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 663ee8606c3b..2141621cf23e 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -792,6 +792,14 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args, char **errp) name, node->value); break; } + } else if (!strcmp(node->key, "srv6_flowlabel")) { + if (!strcmp(node->value, "zero")) { + tnl_cfg.srv6_flowlabel = SRV6_FLOWLABEL_ZERO; + } else if (!strcmp(node->value, "compute")) { + tnl_cfg.srv6_flowlabel = SRV6_FLOWLABEL_COMPUTE; + } else { + tnl_cfg.srv6_flowlabel = SRV6_FLOWLABEL_COPY; + } } else if (!strcmp(node->key, "payload_type")) { if (!strcmp(node->value, "mpls")) { tnl_cfg.payload_ethertype = htons(ETH_TYPE_MPLS); diff --git a/lib/netdev.h b/lib/netdev.h index ff207f56c28c..743a56ca1629 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -97,6 +97,17 @@ enum netdev_pt_mode { NETDEV_PT_LEGACY_L3, }; +enum netdev_srv6_flowlabel { + /* Copy the flowlabel from inner packet. */ + SRV6_FLOWLABEL_COPY, + + /* Simply set flowlabel to 0. */ + SRV6_FLOWLABEL_ZERO, + + /* Calculate a hash for some fields and set the result to flowlabel. */ + SRV6_FLOWLABEL_COMPUTE, +}; + /* Configuration specific to tunnels. */ struct netdev_tunnel_config { ovs_be64 in_key; @@ -144,6 +155,7 @@ struct netdev_tunnel_config { uint8_t srv6_num_segs; #define SRV6_MAX_SEGS 6 struct in6_addr srv6_segs[SRV6_MAX_SEGS]; + enum netdev_srv6_flowlabel srv6_flowlabel; }; void netdev_run(void); diff --git a/tests/tunnel-push-pop-ipv6.at b/tests/tunnel-push-pop-ipv6.at index e300fe3a0d26..33edc8319eed 100644 --- a/tests/tunnel-push-pop-ipv6.at +++ b/tests/tunnel-push-pop-ipv6.at @@ -1,5 +1,84 @@ AT_BANNER([tunnel_push_pop_ipv6]) +AT_SETUP([tunnel_push_pop_ipv6 - srv6]) + +OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00]) +AT_CHECK([ovs-vsctl add-br int-br1 -- set bridge int-br1 datapath_type=dummy], [0]) +AT_CHECK([ovs-vsctl add-br int-br2 -- set bridge int-br2 datapath_type=dummy], [0]) +AT_CHECK([ovs-vsctl add-br int-br3 -- set bridge int-br3 datapath_type=dummy], [0]) +AT_CHECK([ovs-vsctl add-port int-br1 t1 -- set Interface t1 type=srv6 \ + options:remote_ip=2001:cafe::91 ofport_request=2 \ + options:srv6_flowlabel=copy \ + ], [0]) +AT_CHECK([ovs-vsctl add-port int-br2 t2 -- set Interface t2 type=srv6 \ + options:remote_ip=2001:cafe::92 ofport_request=3 \ + options:srv6_flowlabel=zero \ + ], [0]) +AT_CHECK([ovs-vsctl add-port int-br3 t3 -- set Interface t3 type=srv6 \ + options:remote_ip=2001:cafe::93 ofport_request=4 \ + options:srv6_flowlabel=compute \ + ], [0]) + +dnl First setup dummy interface IP address, then add the route +dnl so that tnl-port table can get valid IP address for the device. +AT_CHECK([ovs-appctl netdev-dummy/ip6addr br0 2001:cafe::88/24], [0], [OK +]) +AT_CHECK([ovs-appctl ovs/route/add 2001:cafe::0/24 br0], [0], [OK +]) +AT_CHECK([ovs-appctl tnl/neigh/set br0 2001:cafe::91 aa:55:aa:55:00:01], [0], [OK +]) +AT_CHECK([ovs-appctl tnl/neigh/set br0 2001:cafe::92 aa:55:aa:55:00:02], [0], [OK +]) +AT_CHECK([ovs-appctl tnl/neigh/set br0 2001:cafe::93 aa:55:aa:55:00:03], [0], [OK +]) +AT_CHECK([ovs-ofctl add-flow br0 action=1]) +AT_CHECK([ovs-ofctl add-flow int-br1 action=2]) +AT_CHECK([ovs-ofctl add-flow int-br2 action=3]) +AT_CHECK([ovs-ofctl add-flow int-br3 action=4]) + +dnl Check "srv6_flowlabel=copy". +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(2),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:beef::1,dst=2001:beef::2,label=12345,proto=47,tclass=0x0,hlimit=64)'], [0], [stdout]) +cat stdout +AT_CHECK([tail -1 stdout | grep -o 'label=[[0-9]]*'], [0], [dnl +label=12345 +]) + +dnl Check "srv6_flowlabel=zero". +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(3),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:beef::1,dst=2001:beef::2,label=12345,proto=47,tclass=0x0,hlimit=64)'], [0], [stdout]) +AT_CHECK([tail -1 stdout | grep -o 'label=[[0-9]]*'], [0], [dnl +label=0 +]) + +dnl Check "srv6_flowlabel=compute" for IPv4 in IPv6 tunnels. +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(4),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=6,tos=0,ttl=64,frag=no),tcp(src=8,dst=9)'], [0], [stdout]) +AT_CHECK([tail -1 stdout | grep -o 'label=[[0-9]]*'], [0], [dnl +label=944785 +]) + +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(4),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x0800),ipv4(src=1.1.3.88,dst=1.1.3.112,proto=6,tos=0,ttl=64,frag=no),tcp(src=800,dst=900)'], [0], [stdout]) +AT_CHECK([tail -1 stdout | grep -o 'label=[[0-9]]*'], [0], [dnl +label=772289 +]) + +dnl Check "srv6_flowlabel=compute" for IPv6 in IPv6 tunnels. +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(4),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:beef::1,dst=2001:beef::2,label=0,proto=47,tclass=0x0,hlimit=64)'], [0], [stdout]) +AT_CHECK([tail -1 stdout | grep -o 'label=[[0-9]]*'], [0], [dnl +label=468935 +]) + +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(4),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:beef::1,dst=2001:beef::2,label=12345,proto=47,tclass=0x0,hlimit=64)'], [0], [stdout]) +AT_CHECK([tail -1 stdout | grep -o 'label=[[0-9]]*'], [0], [dnl +label=1012207 +]) + +AT_CHECK([ovs-appctl ofproto/trace ovs-dummy 'in_port(4),eth(src=f8:bc:12:44:34:b6,dst=aa:55:aa:55:00:00),eth_type(0x86dd),ipv6(src=2001:beef::1,dst=2001:beef::3,label=0,proto=47,tclass=0x0,hlimit=64)'], [0], [stdout]) +AT_CHECK([tail -1 stdout | grep -o 'label=[[0-9]]*'], [0], [dnl +label=629290 +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP + AT_SETUP([tunnel_push_pop_ipv6 - ip6gre]) OVS_VSWITCHD_START([add-port br0 p0 -- set Interface p0 type=dummy ofport_request=1 other-config:hwaddr=aa:55:aa:55:00:00]) diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index edb5eafa04c3..7a0682503233 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -3287,6 +3287,35 @@ .

+ +

+ Optional. + This option controls how flowlabel in outer IPv6 header is + configured. This would give you the benefit of IPv6 flow label + based load balancing, which is supported by some popular vendor + appliances. You can choose from the following three types, as + in net.ipv6.seg6_flowlabel syscall. +

+
    +
  • + By default, or if this option is copy, copy the + flowlabel of inner IPv6 header to the flowlabel of outer IPv6 + header. If inner header is not IPv6, it is set to 0. +
  • +
  • + If this option is zero, simply set flowlabel to 0. +
  • +
  • + If this option is compute, calculate a hash for + some fields in inner header and set the result to flowlabel. + If inner packet is IPv6, src_ip, dst_ip, L4 proto, and + flowlabel are the targets of hash calculation. If it is IPv4, + src_ip, dst_ip, L4 proto, src_port, and dst_port are the targets. +
  • +
+