From patchwork Thu May 2 09:51:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1930570 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=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fvAUuUgL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::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 4VVTjP3XW7z20fb for ; Thu, 2 May 2024 19:51:37 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BB99B60E83; Thu, 2 May 2024 09:51:33 +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 kRl-tYK5fJVJ; Thu, 2 May 2024 09:51:32 +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 F045260E70 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fvAUuUgL Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id F045260E70; Thu, 2 May 2024 09:51:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C3245C0DCF; Thu, 2 May 2024 09:51:31 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id C9C7EC0037 for ; Thu, 2 May 2024 09:51:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A66B2415EF for ; Thu, 2 May 2024 09:51:30 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id QmvRnmYvWmXQ for ; Thu, 2 May 2024 09:51:29 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::12d; helo=mail-lf1-x12d.google.com; envelope-from=odivlad@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org D3553415EC Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D3553415EC Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fvAUuUgL Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by smtp4.osuosl.org (Postfix) with ESMTPS id D3553415EC for ; Thu, 2 May 2024 09:51:28 +0000 (UTC) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-51aa6a8e49aso9527894e87.3 for ; Thu, 02 May 2024 02:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714643486; x=1715248286; darn=openvswitch.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nCB0MxhRooY6n4NEpn23undhnDGt4pVrRIH1Lky0uXY=; b=fvAUuUgLg1byCfnHJanRPd7M7xiKCNDF7E0OzzWhwY8xumwVRXtNfD4G0p0lY2cc1Y Fgc422AlzLfuhJciZ2yaop7T63q2cXIER7GVq1M46Akgt0F9qU3swmsbhMxZG7EQRfv6 9v5orTacMECq1nMPF9MSUHoihf1zezCZ+XO6ds+Awawh/KIXsQpHbHQwzlUVEBViBAmZ OalpJ7jCpk0I5IQx3POAYKLCRDOWSFFIB00UVlPAeyLExdLorkprMG26YFS4rAa/9jBA ytBmeoPLEEmDyoFj1WJPClFFvdp4++KA9jr6YHimcYBvzdcKsCyK+CPzQMa4kPHL+Uhs u61A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714643486; x=1715248286; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nCB0MxhRooY6n4NEpn23undhnDGt4pVrRIH1Lky0uXY=; b=j6rIwrNDLea9QUjLHjLwkVPokQnc3+fgANUP7H+Op5Clpi/ZWRDim93RSzDNAz9kjc jZ0sq2M+t3WfZZF2JXfBvP1nsa9YmSF2KDsf3sYNp1bJl1LGptmRYI0eYQ7oHubeaEYg K5VEprOB7VmuGRw98bOYtmPUefYXkDyxaqpJVc28q9kDRb+zxyT2qjph1UHus5Mp+nfI +qyIgJntCwW1V+tnD3A5WIuXtHj7tCWO247tWqunGv9preqrWb09E6AXehgTlXntjPjc QqHR7O+xOGIe0l9bZbIml0f7Q310h72PyPrG+wVSBjhWPcxKjWNlSNeoWTq/vQjNQ6Fl 1jDQ== X-Gm-Message-State: AOJu0Yzm6pWR1a+9fHWZUAcgbMTA+nXbmgrT9SYG2HCfuVmqSs7fW63U h2zCjqwUHQveYDfeslidPfRD6zqlKKfZkkFam6S/sVRTtBN4sL0ajy2plw== X-Google-Smtp-Source: AGHT+IEeI6dH+H8hLQANhkPfgN9YQI613qXsQYa2tyAoYrejc+T2wp2rGNqPGQB7GM/HmH9/DXgovA== X-Received: by 2002:a19:2d1c:0:b0:51f:463c:c577 with SMTP id k28-20020a192d1c000000b0051f463cc577mr479966lfj.4.1714643486141; Thu, 02 May 2024 02:51:26 -0700 (PDT) Received: from ip-10-70-112-12.vpc-1e810be1.internal (c2-185-102-122-48.elastic.cloud.croc.ru. [185.102.122.48]) by smtp.gmail.com with ESMTPSA id i7-20020a198c47000000b0051d5756018asm116205lfj.219.2024.05.02.02.51.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 02:51:25 -0700 (PDT) From: Vladislav Odintsov To: dev@openvswitch.org Date: Thu, 2 May 2024 12:51:01 +0300 Message-ID: <20240502095104.169103-2-odivlad@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502095104.169103-1-odivlad@gmail.com> References: <20240502095104.169103-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v4 1/2] northd: Make `vxlan_mode` a global variable. 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" This simplifies code and subsequent commit to explicitely disable vxlan mode is based on these changes. Also `vxlan mode` term is introduced in ovn-architecture man page. Signed-off-by: Vladislav Odintsov --- northd/en-global-config.c | 4 +- northd/northd.c | 94 ++++++++++++++++----------------------- northd/northd.h | 5 ++- ovn-architecture.7.xml | 11 +++-- 4 files changed, 50 insertions(+), 64 deletions(-) diff --git a/northd/en-global-config.c b/northd/en-global-config.c index 28c78a12c..873649a89 100644 --- a/northd/en-global-config.c +++ b/northd/en-global-config.c @@ -115,8 +115,8 @@ en_global_config_run(struct engine_node *node , void *data) config_data->svc_monitor_mac); } - char *max_tunid = xasprintf("%d", - get_ovn_max_dp_key_local(sbrec_chassis_table)); + init_vxlan_mode(sbrec_chassis_table); + char *max_tunid = xasprintf("%d", get_ovn_max_dp_key_local()); smap_replace(options, "max_tunid", max_tunid); free(max_tunid); diff --git a/northd/northd.c b/northd/northd.c index 5e12fd1e8..b54219a85 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -90,6 +90,10 @@ static bool use_ct_inv_match = true; */ static bool default_acl_drop; +/* If this option is 'true' northd will use limited 24-bit space for datapath + * and ports tunnel key allocation (12 bits for each instead of default 16). */ +static bool vxlan_mode; + #define MAX_OVN_TAGS 4096 @@ -881,24 +885,25 @@ join_datapaths(const struct nbrec_logical_switch_table *nbrec_ls_table, } } -static bool -is_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table) +void +init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table) { const struct sbrec_chassis *chassis; SBREC_CHASSIS_TABLE_FOR_EACH (chassis, sbrec_chassis_table) { for (int i = 0; i < chassis->n_encaps; i++) { if (!strcmp(chassis->encaps[i]->type, "vxlan")) { - return true; + vxlan_mode = true; + return; } } } - return false; + vxlan_mode = false; } uint32_t -get_ovn_max_dp_key_local(const struct sbrec_chassis_table *sbrec_chassis_table) +get_ovn_max_dp_key_local(void) { - if (is_vxlan_mode(sbrec_chassis_table)) { + if (vxlan_mode) { /* OVN_MAX_DP_GLOBAL_NUM doesn't apply for vxlan mode. */ return OVN_MAX_DP_VXLAN_KEY; } @@ -906,15 +911,14 @@ get_ovn_max_dp_key_local(const struct sbrec_chassis_table *sbrec_chassis_table) } static void -ovn_datapath_allocate_key(const struct sbrec_chassis_table *sbrec_ch_table, - struct hmap *datapaths, struct hmap *dp_tnlids, +ovn_datapath_allocate_key(struct hmap *datapaths, struct hmap *dp_tnlids, struct ovn_datapath *od, uint32_t *hint) { if (!od->tunnel_key) { od->tunnel_key = ovn_allocate_tnlid(dp_tnlids, "datapath", - OVN_MIN_DP_KEY_LOCAL, - get_ovn_max_dp_key_local(sbrec_ch_table), - hint); + OVN_MIN_DP_KEY_LOCAL, + get_ovn_max_dp_key_local(), + hint); if (!od->tunnel_key) { if (od->sb) { sbrec_datapath_binding_delete(od->sb); @@ -927,7 +931,6 @@ ovn_datapath_allocate_key(const struct sbrec_chassis_table *sbrec_ch_table, static void ovn_datapath_assign_requested_tnl_id( - const struct sbrec_chassis_table *sbrec_chassis_table, struct hmap *dp_tnlids, struct ovn_datapath *od) { const struct smap *other_config = (od->nbs @@ -936,8 +939,7 @@ ovn_datapath_assign_requested_tnl_id( uint32_t tunnel_key = smap_get_int(other_config, "requested-tnl-key", 0); if (tunnel_key) { const char *interconn_ts = smap_get(other_config, "interconn-ts"); - if (!interconn_ts && is_vxlan_mode(sbrec_chassis_table) && - tunnel_key >= 1 << 12) { + if (!interconn_ts && vxlan_mode && tunnel_key >= 1 << 12) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); VLOG_WARN_RL(&rl, "Tunnel key %"PRIu32" for datapath %s is " "incompatible with VXLAN", tunnel_key, @@ -985,7 +987,6 @@ build_datapaths(struct ovsdb_idl_txn *ovnsb_txn, const struct nbrec_logical_switch_table *nbrec_ls_table, const struct nbrec_logical_router_table *nbrec_lr_table, const struct sbrec_datapath_binding_table *sbrec_dp_table, - const struct sbrec_chassis_table *sbrec_chassis_table, struct ovn_datapaths *ls_datapaths, struct ovn_datapaths *lr_datapaths, struct ovs_list *lr_list) @@ -1000,12 +1001,11 @@ build_datapaths(struct ovsdb_idl_txn *ovnsb_txn, struct hmap dp_tnlids = HMAP_INITIALIZER(&dp_tnlids); struct ovn_datapath *od; LIST_FOR_EACH (od, list, &both) { - ovn_datapath_assign_requested_tnl_id(sbrec_chassis_table, &dp_tnlids, - od); + ovn_datapath_assign_requested_tnl_id(&dp_tnlids, od); } LIST_FOR_EACH (od, list, &nb_only) { - ovn_datapath_assign_requested_tnl_id(sbrec_chassis_table, &dp_tnlids, - od); } + ovn_datapath_assign_requested_tnl_id(&dp_tnlids, od); + } /* Keep nonconflicting tunnel IDs that are already assigned. */ LIST_FOR_EACH (od, list, &both) { @@ -1017,12 +1017,10 @@ build_datapaths(struct ovsdb_idl_txn *ovnsb_txn, /* Assign new tunnel ids where needed. */ uint32_t hint = 0; LIST_FOR_EACH_SAFE (od, list, &both) { - ovn_datapath_allocate_key(sbrec_chassis_table, - datapaths, &dp_tnlids, od, &hint); + ovn_datapath_allocate_key(datapaths, &dp_tnlids, od, &hint); } LIST_FOR_EACH_SAFE (od, list, &nb_only) { - ovn_datapath_allocate_key(sbrec_chassis_table, - datapaths, &dp_tnlids, od, &hint); + ovn_datapath_allocate_key(datapaths, &dp_tnlids, od, &hint); } /* Sync tunnel ids from nb to sb. */ @@ -3982,16 +3980,14 @@ ovn_port_add_tnlid(struct ovn_port *op, uint32_t tunnel_key) * that the I-P engine can fallback to recompute if needed; otherwise return * true (even if the key is not allocated). */ static bool -ovn_port_assign_requested_tnl_id( - const struct sbrec_chassis_table *sbrec_chassis_table, struct ovn_port *op) +ovn_port_assign_requested_tnl_id(struct ovn_port *op) { const struct smap *options = (op->nbsp ? &op->nbsp->options : &op->nbrp->options); uint32_t tunnel_key = smap_get_int(options, "requested-tnl-key", 0); if (tunnel_key) { - if (is_vxlan_mode(sbrec_chassis_table) && - tunnel_key >= OVN_VXLAN_MIN_MULTICAST) { + if (vxlan_mode && tunnel_key >= OVN_VXLAN_MIN_MULTICAST) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); VLOG_WARN_RL(&rl, "Tunnel key %"PRIu32" for port %s " "is incompatible with VXLAN", @@ -4011,11 +4007,10 @@ ovn_port_assign_requested_tnl_id( } static bool -ovn_port_allocate_key(const struct sbrec_chassis_table *sbrec_chassis_table, - struct ovn_port *op) +ovn_port_allocate_key(struct ovn_port *op) { if (!op->tunnel_key) { - uint8_t key_bits = is_vxlan_mode(sbrec_chassis_table)? 12 : 16; + uint8_t key_bits = vxlan_mode ? 12 : 16; op->tunnel_key = ovn_allocate_tnlid(&op->od->port_tnlids, "port", 1, (1u << (key_bits - 1)) - 1, &op->od->port_key_hint); @@ -4035,7 +4030,6 @@ ovn_port_allocate_key(const struct sbrec_chassis_table *sbrec_chassis_table, static void build_ports(struct ovsdb_idl_txn *ovnsb_txn, const struct sbrec_port_binding_table *sbrec_port_binding_table, - const struct sbrec_chassis_table *sbrec_chassis_table, const struct sbrec_mirror_table *sbrec_mirror_table, const struct sbrec_mac_binding_table *sbrec_mac_binding_table, const struct sbrec_ha_chassis_group_table *sbrec_ha_chassis_group_table, @@ -4069,10 +4063,10 @@ build_ports(struct ovsdb_idl_txn *ovnsb_txn, /* Assign explicitly requested tunnel ids first. */ struct ovn_port *op; LIST_FOR_EACH (op, list, &both) { - ovn_port_assign_requested_tnl_id(sbrec_chassis_table, op); + ovn_port_assign_requested_tnl_id(op); } LIST_FOR_EACH (op, list, &nb_only) { - ovn_port_assign_requested_tnl_id(sbrec_chassis_table, op); + ovn_port_assign_requested_tnl_id(op); } /* Keep nonconflicting tunnel IDs that are already assigned. */ @@ -4084,17 +4078,10 @@ build_ports(struct ovsdb_idl_txn *ovnsb_txn, /* Assign new tunnel ids where needed. */ LIST_FOR_EACH_SAFE (op, list, &both) { - if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { - sbrec_port_binding_delete(op->sb); - ovs_list_remove(&op->list); - ovn_port_destroy(ports, op); - } + ovn_port_allocate_key(op); } LIST_FOR_EACH_SAFE (op, list, &nb_only) { - if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { - ovs_list_remove(&op->list); - ovn_port_destroy(ports, op); - } + ovn_port_allocate_key(op); } /* For logical ports that are in both databases, update the southbound @@ -4303,14 +4290,13 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, struct ovn_datapath *od, const struct sbrec_port_binding *sb, const struct sbrec_mirror_table *sbrec_mirror_table, - const struct sbrec_chassis_table *sbrec_chassis_table, struct ovsdb_idl_index *sbrec_chassis_by_name, struct ovsdb_idl_index *sbrec_chassis_by_hostname) { op->od = od; parse_lsp_addrs(op); /* Assign explicitly requested tunnel ids first. */ - if (!ovn_port_assign_requested_tnl_id(sbrec_chassis_table, op)) { + if (!ovn_port_assign_requested_tnl_id(op)) { return false; } /* Keep nonconflicting tunnel IDs that are already assigned. */ @@ -4320,7 +4306,7 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, } } /* Assign new tunnel ids where needed. */ - if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { + if (!ovn_port_allocate_key(op)) { return false; } /* Create new binding, if needed. */ @@ -4333,6 +4319,10 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, op->sb = sbrec_port_binding_insert(ovnsb_txn); sbrec_port_binding_set_logical_port(op->sb, op->key); } + /* Assign new tunnel ids where needed. */ + if (!ovn_port_allocate_key(op)) { + return false; + } ovn_port_update_sbrec(ovnsb_txn, sbrec_chassis_by_name, sbrec_chassis_by_hostname, NULL, sbrec_mirror_table, op, NULL, NULL); @@ -4344,15 +4334,13 @@ ls_port_create(struct ovsdb_idl_txn *ovnsb_txn, struct hmap *ls_ports, const char *key, const struct nbrec_logical_switch_port *nbsp, struct ovn_datapath *od, const struct sbrec_mirror_table *sbrec_mirror_table, - const struct sbrec_chassis_table *sbrec_chassis_table, struct ovsdb_idl_index *sbrec_chassis_by_name, struct ovsdb_idl_index *sbrec_chassis_by_hostname) { struct ovn_port *op = ovn_port_create(ls_ports, key, nbsp, NULL, NULL); hmap_insert(&od->ports, &op->dp_node, hmap_node_hash(&op->key_node)); - if (!ls_port_init(op, ovnsb_txn, od, NULL, - sbrec_mirror_table, sbrec_chassis_table, + if (!ls_port_init(op, ovnsb_txn, od, NULL, sbrec_mirror_table, sbrec_chassis_by_name, sbrec_chassis_by_hostname)) { ovn_port_destroy(ls_ports, op); return NULL; @@ -4367,7 +4355,6 @@ ls_port_reinit(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, struct ovn_datapath *od, const struct sbrec_port_binding *sb, const struct sbrec_mirror_table *sbrec_mirror_table, - const struct sbrec_chassis_table *sbrec_chassis_table, struct ovsdb_idl_index *sbrec_chassis_by_name, struct ovsdb_idl_index *sbrec_chassis_by_hostname) { @@ -4375,8 +4362,7 @@ ls_port_reinit(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, op->sb = sb; ovn_port_set_nb(op, nbsp, NULL); op->l3dgw_port = op->cr_port = NULL; - return ls_port_init(op, ovnsb_txn, od, sb, - sbrec_mirror_table, sbrec_chassis_table, + return ls_port_init(op, ovnsb_txn, od, sb, sbrec_mirror_table, sbrec_chassis_by_name, sbrec_chassis_by_hostname); } @@ -4521,7 +4507,6 @@ ls_handle_lsp_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, op = ls_port_create(ovnsb_idl_txn, &nd->ls_ports, new_nbsp->name, new_nbsp, od, ni->sbrec_mirror_table, - ni->sbrec_chassis_table, ni->sbrec_chassis_by_name, ni->sbrec_chassis_by_hostname); if (!op) { @@ -4553,7 +4538,6 @@ ls_handle_lsp_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, if (!ls_port_reinit(op, ovnsb_idl_txn, new_nbsp, od, sb, ni->sbrec_mirror_table, - ni->sbrec_chassis_table, ni->sbrec_chassis_by_name, ni->sbrec_chassis_by_hostname)) { if (sb) { @@ -17609,11 +17593,12 @@ ovnnb_db_run(struct northd_input *input_data, use_common_zone = smap_get_bool(input_data->nb_options, "use_common_zone", false); + init_vxlan_mode(input_data->sbrec_chassis_table); + build_datapaths(ovnsb_txn, input_data->nbrec_logical_switch_table, input_data->nbrec_logical_router_table, input_data->sbrec_datapath_binding_table, - input_data->sbrec_chassis_table, &data->ls_datapaths, &data->lr_datapaths, &data->lr_list); build_lb_datapaths(input_data->lbs, input_data->lbgrps, @@ -17621,7 +17606,6 @@ ovnnb_db_run(struct northd_input *input_data, &data->lb_datapaths_map, &data->lb_group_datapaths_map); build_ports(ovnsb_txn, input_data->sbrec_port_binding_table, - input_data->sbrec_chassis_table, input_data->sbrec_mirror_table, input_data->sbrec_mac_binding_table, input_data->sbrec_ha_chassis_group_table, diff --git a/northd/northd.h b/northd/northd.h index 940926945..be480003e 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -791,6 +791,9 @@ lr_has_multiple_gw_ports(const struct ovn_datapath *od) return od->n_l3dgw_ports > 1 && !od->is_gw_router; } -uint32_t get_ovn_max_dp_key_local(const struct sbrec_chassis_table *); +void +init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table); + +uint32_t get_ovn_max_dp_key_local(void); #endif /* NORTHD_H */ diff --git a/ovn-architecture.7.xml b/ovn-architecture.7.xml index bfd8680ce..7abb1fa83 100644 --- a/ovn-architecture.7.xml +++ b/ovn-architecture.7.xml @@ -2809,13 +2809,12 @@

- When VXLAN is enabled on any hypervisor in a cluster, datapath and egress - port identifier ranges are reduced to 12-bits. This is done because only - STT and Geneve provide the large space for metadata (over 32 bits per - packet). To accommodate for VXLAN, 24 bits available are split as - follows: + When VXLAN is enabled on any hypervisor in a cluster, datapath and egress + port identifier ranges are reduced to 12-bits. This is done because only + STT and Geneve provide the large space for metadata (over 32 bits per + packet). Such mode is a vxlan mode. To accommodate for + VXLAN, 24 bits available are split as follows:

-
  • 12-bit logical datapath identifier, derived from the From patchwork Thu May 2 09:51:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1930571 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=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=lEsZlVPp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (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 4VVTjP6f6qz23hd for ; Thu, 2 May 2024 19:51:37 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 2360082531; Thu, 2 May 2024 09:51:36 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 1KeNbzxWeMHh; Thu, 2 May 2024 09:51:34 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 8CC1882560 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=lEsZlVPp Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 8CC1882560; Thu, 2 May 2024 09:51:33 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E2AFFC0DD4; Thu, 2 May 2024 09:51:32 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id B4285C0037 for ; Thu, 2 May 2024 09:51:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9778B415EF for ; Thu, 2 May 2024 09:51:31 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Sr0P8_aLdXng for ; Thu, 2 May 2024 09:51:30 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::130; helo=mail-lf1-x130.google.com; envelope-from=odivlad@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org 268BC415E7 Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 268BC415E7 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=lEsZlVPp Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by smtp4.osuosl.org (Postfix) with ESMTPS id 268BC415E7 for ; Thu, 2 May 2024 09:51:30 +0000 (UTC) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-51f4d2676d1so206641e87.3 for ; Thu, 02 May 2024 02:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714643487; x=1715248287; darn=openvswitch.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8pn6Ei8MFVuCTYJ9NG9rmZWHp/uq4ofBSTuM07em/Ms=; b=lEsZlVPp2ASThd27cDzCNAKvjkih+MH67keb5X/NhYSvVAkq4AybQUZnCDzhtAdO08 JeeprvKtXGGII7d8jhVdG1lmu1IqFvRJQDH5cbkmBJ5bkhoMUuWbATzBfzqIzktY3rXB 9Rt2IiIEdTomsRE0r6fO5VlP1fZq67tvsO6bSd6FVR49gY+Rf123jaQo0E8rSzxQZvAn qWOfxXlcnPQFYtCht0U4FzP6RQSGNTf5QQltPvoEi026mHa12bhcbloRNOzMJJlIvAtn 2uE0E9+yTc789kU1a60Nje2ghD2uAK390eDxtSDoBrAkISg6jzpSFPbUzgudw4sd+juH EIqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714643487; x=1715248287; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8pn6Ei8MFVuCTYJ9NG9rmZWHp/uq4ofBSTuM07em/Ms=; b=FPJ2+Twc6SWUnbN4cDC6mUh4kVTzBssBXnonbh4nfA+wC3BEsQ9xaZ8o+gI+gRQlLm zeyn0mS0gQHoRgFCe+Q2UXO+XWps1xMvr6UVDQGW2KHmoTRRawakEWLbK7hr+kjnJGzu sVEFLPnRUkfzY4PA13zFy1uDyzXXQS3A4n5clT0OvWwPl2HmSVVzVxPbvUg718xgzRqK uwZusiidd0Zr9WdQxjaIypQ6g9bbUT6VHRJr9f3d1jy5qXC/BJ8puPAqLxOx07L5ZcLF UWD9EcW17EnuZKNMVJ1nKWAQVsfv5p4FDTu/EvaiHeU9vd8bmkv7hd8sFJRGtqczh4OJ dNhA== X-Gm-Message-State: AOJu0Yx0fgQ2pS7PEe8X9nMWGSt0s//17Pc6pLu56ZGYQ7uLGcy1M+Yq D4ro6mIoOwRlckYzYVI1L86B4aSpCvMfobd7BmLnIAtPugDBE6ClEh4Fng== X-Google-Smtp-Source: AGHT+IGJ6/ygouW3Pstnx8rLjly6Naf5EGVRQrjslhwP/ecoqiNvzRSudOpHt5wTZBuHis9MbpFoNg== X-Received: by 2002:a19:ac48:0:b0:51e:2a1d:6654 with SMTP id r8-20020a19ac48000000b0051e2a1d6654mr857534lfc.31.1714643487398; Thu, 02 May 2024 02:51:27 -0700 (PDT) Received: from ip-10-70-112-12.vpc-1e810be1.internal (c2-185-102-122-48.elastic.cloud.croc.ru. [185.102.122.48]) by smtp.gmail.com with ESMTPSA id i7-20020a198c47000000b0051d5756018asm116205lfj.219.2024.05.02.02.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 02:51:27 -0700 (PDT) From: Vladislav Odintsov To: dev@openvswitch.org Date: Thu, 2 May 2024 12:51:02 +0300 Message-ID: <20240502095104.169103-3-odivlad@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240502095104.169103-1-odivlad@gmail.com> References: <20240502095104.169103-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v4 2/2] northd: Add support for disabling vxlan mode. 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" Commit [1] introduced a "vxlan mode" concept. It brought a limitation for available tunnel IDs because of lack of space in VXLAN VNI. In vxlan mode OVN is limited by 4095 datapaths (LRs or non-transit LSs) and 2047 logical switch ports per datapath. Prior to this patch vxlan mode was enabled automatically if at least one chassis had encap of vxlan type. In scenarios where one want to use VXLAN only for HW VTEP (RAMP) switch, such limitation makes no sence. This patch adds support for explicit disabling of vxlan mode via Northbound database. 1: https://github.com/ovn-org/ovn/commit/b07f1bc3d068 CC: Ihar Hrachyshka Fixes: b07f1bc3d068 ("Add VXLAN support for non-VTEP datapath bindings") Signed-off-by: Vladislav Odintsov Acked-By: Ihar Hrachyshka --- NEWS | 3 +++ northd/en-global-config.c | 7 ++++++- northd/northd.c | 10 ++++++++-- northd/northd.h | 3 ++- ovn-architecture.7.xml | 6 ++++++ ovn-nb.xml | 10 ++++++++++ tests/ovn-northd.at | 29 +++++++++++++++++++++++++++++ 7 files changed, 64 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 3b5e93dc9..43ab05a68 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,9 @@ Post v24.03.0 external-ids, the option is no longer needed as it became effectively "true" for all scenarios. - Added DHCPv4 relay support. + - Added new global config option NB_Global:options:disable_vxlan_mode to + extend available tunnel IDs space for datapaths from 4095 to 16711680. + For more details see man ovn-nb(5) for mentioned option. OVN v24.03.0 - 01 Mar 2024 -------------------------- diff --git a/northd/en-global-config.c b/northd/en-global-config.c index 873649a89..f5e2a8154 100644 --- a/northd/en-global-config.c +++ b/northd/en-global-config.c @@ -115,7 +115,7 @@ en_global_config_run(struct engine_node *node , void *data) config_data->svc_monitor_mac); } - init_vxlan_mode(sbrec_chassis_table); + init_vxlan_mode(&nb->options, sbrec_chassis_table); char *max_tunid = xasprintf("%d", get_ovn_max_dp_key_local()); smap_replace(options, "max_tunid", max_tunid); free(max_tunid); @@ -533,6 +533,11 @@ check_nb_options_out_of_sync(const struct nbrec_nb_global *nb, return true; } + if (config_out_of_sync(&nb->options, &config_data->nb_options, + "disable_vxlan_mode", false)) { + return true; + } + return false; } diff --git a/northd/northd.c b/northd/northd.c index b54219a85..d1535172e 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -886,8 +886,14 @@ join_datapaths(const struct nbrec_logical_switch_table *nbrec_ls_table, } void -init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table) +init_vxlan_mode(const struct smap *nb_options, + const struct sbrec_chassis_table *sbrec_chassis_table) { + if (smap_get_bool(nb_options, "disable_vxlan_mode", false)) { + vxlan_mode = false; + return; + } + const struct sbrec_chassis *chassis; SBREC_CHASSIS_TABLE_FOR_EACH (chassis, sbrec_chassis_table) { for (int i = 0; i < chassis->n_encaps; i++) { @@ -17593,7 +17599,7 @@ ovnnb_db_run(struct northd_input *input_data, use_common_zone = smap_get_bool(input_data->nb_options, "use_common_zone", false); - init_vxlan_mode(input_data->sbrec_chassis_table); + init_vxlan_mode(input_data->nb_options, input_data->sbrec_chassis_table); build_datapaths(ovnsb_txn, input_data->nbrec_logical_switch_table, diff --git a/northd/northd.h b/northd/northd.h index be480003e..d0322e621 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -792,7 +792,8 @@ lr_has_multiple_gw_ports(const struct ovn_datapath *od) } void -init_vxlan_mode(const struct sbrec_chassis_table *sbrec_chassis_table); +init_vxlan_mode(const struct smap *nb_options, + const struct sbrec_chassis_table *sbrec_chassis_table); uint32_t get_ovn_max_dp_key_local(void); diff --git a/ovn-architecture.7.xml b/ovn-architecture.7.xml index 7abb1fa83..251c9c514 100644 --- a/ovn-architecture.7.xml +++ b/ovn-architecture.7.xml @@ -2919,4 +2919,10 @@ the future, gateways that do not support encapsulations with large amounts of metadata may continue to have a reduced feature set.

    +

    + vxlan mode is recommended to be disabled if VXLAN encap at + hypervisors is needed only to support HW VTEP L2 Gateway functionality. + See man ovn-nb(5) for table NB_Global column + options key disable_vxlan_mode for more details. +

    diff --git a/ovn-nb.xml b/ovn-nb.xml index 5cb6ba640..a99e663e5 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -381,6 +381,16 @@ of SB changes would be very noticeable. + + By default if at least one chassis in OVN cluster has VXLAN encap, + northd will run in a vxlan mode. See man + ovn-architecture(7) Tunnel Encapsulations paragraph for + more details. In case VXLAN encaps are needed on chassis only to + support HW VTEP functionality and main encap type is GENEVE or STT, set + this option to `false` to use default non-`vxlan mode` tunnel IDs + allocation logic. + +

    These options control how routes are advertised between OVN diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 680d96675..549a28b57 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -2847,6 +2847,35 @@ AT_CHECK( get_tunnel_keys AT_CHECK([test $lsp02 = 3 && test $ls1 = 123]) +AT_CLEANUP +]) +OVN_FOR_EACH_NORTHD_NO_HV([ +AT_SETUP([check vxlan mode disabling]) +ovn_start + +# Create a fake chassis with vxlan encap to implicitly enable vxlan mode. +ovn-sbctl \ + --id=@e create encap chassis_name=hv1 ip="192.168.0.1" type="vxlan" \ + -- --id=@c create chassis name=hv1 encaps=@e + +cmd="ovn-nbctl --wait=sb" +for i in {1..4097..1}; do + cmd="${cmd} -- ls-add lsw-${i}" +done + +check $cmd + +check_row_count nb:Logical_Switch 4097 +wait_row_count sb:Datapath_Binding 4095 + +OVS_WAIT_UNTIL([grep "all datapath tunnel ids exhausted" northd/ovn-northd.log]) + +# Explicitly disable vxlan mode and check that two remaining datapaths were created. +check ovn-nbctl set NB_Global . options:disable_vxlan_mode=true + +check_row_count nb:Logical_Switch 4097 +wait_row_count sb:Datapath_Binding 4097 + AT_CLEANUP ])