From patchwork Mon Apr 22 07:36:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1926019 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" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Quf7Xbw5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (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 4VNH9t2LK4z1yZP for ; Mon, 22 Apr 2024 17:36:18 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 83408407DE; Mon, 22 Apr 2024 07:36:16 +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 X-4iTd-JY-JD; Mon, 22 Apr 2024 07:36:14 +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 smtp4.osuosl.org 47B0D40737 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Quf7Xbw5 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 47B0D40737; Mon, 22 Apr 2024 07:36:14 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 12456C0077; Mon, 22 Apr 2024 07:36:14 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 03464C0DCF for ; Mon, 22 Apr 2024 07:36:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7D03981DAB for ; Mon, 22 Apr 2024 07:36:11 +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 vrigBlIQ4x4Z for ; Mon, 22 Apr 2024 07:36:10 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=amusil@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org ED3BA81E1A Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org ED3BA81E1A Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Quf7Xbw5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id ED3BA81E1A for ; Mon, 22 Apr 2024 07:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713771369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BbkKLpnMepldOSkH7qhpdfWedUcwPUyd0/eLh2IfOnY=; b=Quf7Xbw52TLHf4t/MJdRgtum1ZX0r7QmMSC6fUgFMFgonPqNiwtl3+aCDz+4azjktDgJUU nAkwbZLZPnSewbmJK7/3PrfMHZLRjsLFF9AsiC9I4uvvsbdKGFaTzPHqFfp7R3a0Y+eBGD 6mXPTU88g/HPQ78VDIsJsGvXRawTC8o= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-91LNUDeRNoa-8cmXnfkoqw-1; Mon, 22 Apr 2024 03:36:07 -0400 X-MC-Unique: 91LNUDeRNoa-8cmXnfkoqw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DE3B338000A1 for ; Mon, 22 Apr 2024 07:36:06 +0000 (UTC) Received: from amusil.brq.redhat.com (unknown [10.43.17.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D67E49F1F; Mon, 22 Apr 2024 07:36:06 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Mon, 22 Apr 2024 09:36:02 +0200 Message-ID: <20240422073602.258855-5-amusil@redhat.com> In-Reply-To: <20240422073602.258855-1-amusil@redhat.com> References: <20240422073602.258855-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 4/4] controller: Use datapath key for the mac cache thresholds. 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" Use datapath tunnel key instead of UUID for the mac cache threshold handling. At the same time simplify the thresholds into single hmap. The tunnel key is unique so there shouldn't be any overlap. Having two thresholds per datapath is currently invalid configuration anyway. The switch to datapath's tunnel key requires somehow costly synchronization when the tunnel key changes. However this is fine as the key shouldn't change very often in some cases it won't change at all. Also fix wrong check in the aging tests that would ignore failure. Signed-off-by: Ales Musil --- controller/mac-cache.c | 132 ++++++++++++++++++------------------ controller/mac-cache.h | 29 ++++---- controller/ovn-controller.c | 105 +++++++++++++--------------- tests/ovn.at | 4 +- 4 files changed, 128 insertions(+), 142 deletions(-) diff --git a/controller/mac-cache.c b/controller/mac-cache.c index c52f913ce..d8c4e2aed 100644 --- a/controller/mac-cache.c +++ b/controller/mac-cache.c @@ -16,6 +16,7 @@ #include #include +#include "local_data.h" #include "lport.h" #include "mac-cache.h" #include "openvswitch/hmap.h" @@ -39,11 +40,8 @@ static uint32_t fdb_data_hash(const struct fdb_data *fdb_data); static inline bool fdb_data_equals(const struct fdb_data *a, const struct fdb_data *b); -static struct mac_cache_threshold * -mac_cache_threshold_find(struct hmap *thresholds, const struct uuid *uuid); static uint64_t -mac_cache_threshold_get_value_ms(const struct sbrec_datapath_binding *dp, - enum mac_cache_type type); +mac_cache_threshold_get_value_ms(const struct sbrec_datapath_binding *dp); static void mac_cache_threshold_remove(struct hmap *thresholds, struct mac_cache_threshold *threshold); @@ -67,60 +65,82 @@ buffered_packets_db_lookup(struct buffered_packets *bp, struct ovsdb_idl_index *sbrec_mb_by_lport_ip); /* Thresholds. */ -bool +void mac_cache_threshold_add(struct mac_cache_data *data, - const struct sbrec_datapath_binding *dp, - enum mac_cache_type type) + const struct sbrec_datapath_binding *dp) { - struct hmap *thresholds = &data->thresholds[type]; struct mac_cache_threshold *threshold = - mac_cache_threshold_find(thresholds, &dp->header_.uuid); + mac_cache_threshold_find(data, dp->tunnel_key); if (threshold) { - return true; + return; } - uint64_t value = mac_cache_threshold_get_value_ms(dp, type); + uint64_t value = mac_cache_threshold_get_value_ms(dp); if (!value) { - return false; + return; } threshold = xmalloc(sizeof *threshold); - threshold->uuid = dp->header_.uuid; + threshold->dp_key = dp->tunnel_key; threshold->value = value; threshold->dump_period = (3 * value) / 4; - hmap_insert(thresholds, &threshold->hmap_node, - uuid_hash(&dp->header_.uuid)); - - return true; + hmap_insert(&data->thresholds, &threshold->hmap_node, dp->tunnel_key); } -bool +void mac_cache_threshold_replace(struct mac_cache_data *data, const struct sbrec_datapath_binding *dp, - enum mac_cache_type type) + const struct hmap *local_datapaths) { - struct hmap *thresholds = &data->thresholds[type]; struct mac_cache_threshold *threshold = - mac_cache_threshold_find(thresholds, &dp->header_.uuid); + mac_cache_threshold_find(data, dp->tunnel_key); if (threshold) { - mac_cache_threshold_remove(thresholds, threshold); + mac_cache_threshold_remove(&data->thresholds, threshold); + } + + if (!get_local_datapath(local_datapaths, dp->tunnel_key)) { + return; } - return mac_cache_threshold_add(data, dp, type); + mac_cache_threshold_add(data, dp); +} + + +struct mac_cache_threshold * +mac_cache_threshold_find(struct mac_cache_data *data, uint32_t dp_key) +{ + struct mac_cache_threshold *threshold; + HMAP_FOR_EACH_WITH_HASH (threshold, hmap_node, dp_key, &data->thresholds) { + if (threshold->dp_key == dp_key) { + return threshold; + } + } + + return NULL; } void -mac_cache_thresholds_clear(struct mac_cache_data *data) +mac_cache_thresholds_sync(struct mac_cache_data *data, + const struct hmap *local_datapaths) { - for (size_t i = 0; i < MAC_CACHE_MAX; i++) { - struct mac_cache_threshold *threshold; - HMAP_FOR_EACH_POP (threshold, hmap_node, &data->thresholds[i]) { - free(threshold); + struct mac_cache_threshold *threshold; + HMAP_FOR_EACH_SAFE (threshold, hmap_node, &data->thresholds) { + if (!get_local_datapath(local_datapaths, threshold->dp_key)) { + mac_cache_threshold_remove(&data->thresholds, threshold); } } } +void +mac_cache_thresholds_clear(struct mac_cache_data *data) +{ + struct mac_cache_threshold *threshold; + HMAP_FOR_EACH_POP (threshold, hmap_node, &data->thresholds) { + free(threshold); + } +} + /* MAC binding. */ struct mac_binding * mac_binding_add(struct hmap *map, struct mac_binding_data mb_data, @@ -231,7 +251,6 @@ fdb_add(struct hmap *map, struct fdb_data fdb_data) { if (!fdb) { fdb = xmalloc(sizeof *fdb); fdb->sbrec_fdb = NULL; - fdb->dp_uuid = UUID_ZERO; hmap_insert(map, &fdb->hmap_node, fdb_data_hash(&fdb_data)); } @@ -343,7 +362,6 @@ mac_binding_stats_run(struct ovs_list *stats_list, uint64_t *req_delay, void *data) { struct mac_cache_data *cache_data = data; - struct hmap *thresholds = &cache_data->thresholds[MAC_CACHE_MAC_BINDING]; long long timewall_now = time_wall_msec(); struct mac_cache_stats *stats; @@ -355,9 +373,8 @@ mac_binding_stats_run(struct ovs_list *stats_list, uint64_t *req_delay, continue; } - struct uuid *dp_uuid = &mb->sbrec_mb->datapath->header_.uuid; struct mac_cache_threshold *threshold = - mac_cache_threshold_find(thresholds, dp_uuid); + mac_cache_threshold_find(cache_data, mb->data.dp_key); /* If "idle_age" is under threshold it means that the mac binding is * used on this chassis. Also make sure that we don't update the @@ -371,7 +388,7 @@ mac_binding_stats_run(struct ovs_list *stats_list, uint64_t *req_delay, free(stats); } - mac_cache_update_req_delay(thresholds, req_delay); + mac_cache_update_req_delay(&cache_data->thresholds, req_delay); } /* FDB stat processing. */ @@ -396,7 +413,6 @@ fdb_stats_run(struct ovs_list *stats_list, uint64_t *req_delay, void *data) { struct mac_cache_data *cache_data = data; - struct hmap *thresholds = &cache_data->thresholds[MAC_CACHE_FDB]; long long timewall_now = time_wall_msec(); struct mac_cache_stats *stats; @@ -409,7 +425,8 @@ fdb_stats_run(struct ovs_list *stats_list, uint64_t *req_delay, } struct mac_cache_threshold *threshold = - mac_cache_threshold_find(thresholds, &fdb->dp_uuid); + mac_cache_threshold_find(cache_data, fdb->data.dp_key); + /* If "idle_age" is under threshold it means that the mac binding is * used on this chassis. Also make sure that we don't update the * timestamp more than once during the dump period. */ @@ -422,7 +439,7 @@ fdb_stats_run(struct ovs_list *stats_list, uint64_t *req_delay, free(stats); } - mac_cache_update_req_delay(thresholds, req_delay); + mac_cache_update_req_delay(&cache_data->thresholds, req_delay); } /* Packet buffering. */ @@ -625,41 +642,22 @@ fdb_data_equals(const struct fdb_data *a, const struct fdb_data *b) eth_addr_equals(a->mac, b->mac); } - -static struct mac_cache_threshold * -mac_cache_threshold_find(struct hmap *thresholds, const struct uuid *uuid) +static uint64_t +mac_cache_threshold_get_value_ms(const struct sbrec_datapath_binding *dp) { - uint32_t hash = uuid_hash(uuid); + uint64_t mb_value = + smap_get_uint(&dp->external_ids, "mac_binding_age_threshold", 0); + uint64_t fdb_value = + smap_get_uint(&dp->external_ids, "fdb_age_threshold", 0); - struct mac_cache_threshold *threshold; - HMAP_FOR_EACH_WITH_HASH (threshold, hmap_node, hash, thresholds) { - if (uuid_equals(&threshold->uuid, uuid)) { - return threshold; - } + if (mb_value && fdb_value) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); + VLOG_WARN_RL(&rl, "Invalid aging threshold configuration for datapath:" + " "UUID_FMT, UUID_ARGS(&dp->header_.uuid)); + return 0; } - return NULL; -} - -static uint64_t -mac_cache_threshold_get_value_ms(const struct sbrec_datapath_binding *dp, - enum mac_cache_type type) -{ - uint64_t value = 0; - switch (type) { - case MAC_CACHE_MAC_BINDING: - value = smap_get_uint(&dp->external_ids, "mac_binding_age_threshold", - 0); - break; - case MAC_CACHE_FDB: - value = smap_get_uint(&dp->external_ids, "fdb_age_threshold", 0); - break; - case MAC_CACHE_MAX: - default: - break; - } - - return value * 1000; + return mb_value ? mb_value * 1000 : fdb_value * 1000; } static void diff --git a/controller/mac-cache.h b/controller/mac-cache.h index 932f6cfd4..3c78f9440 100644 --- a/controller/mac-cache.h +++ b/controller/mac-cache.h @@ -29,15 +29,9 @@ struct ovsdb_idl_index; -enum mac_cache_type { - MAC_CACHE_MAC_BINDING, - MAC_CACHE_FDB, - MAC_CACHE_MAX -}; - struct mac_cache_data { - /* 'struct mac_cache_threshold' by datapath UUID. */ - struct hmap thresholds[MAC_CACHE_MAX]; + /* 'struct mac_cache_threshold' by datapath's tunnel_key. */ + struct hmap thresholds; /* 'struct mac_cache_mac_binding' by 'struct mac_cache_mb_data' that are * local and have threshold > 0. */ struct hmap mac_bindings; @@ -48,8 +42,8 @@ struct mac_cache_data { struct mac_cache_threshold { struct hmap_node hmap_node; - /* Datapath UUID. */ - struct uuid uuid; + /* Datapath tunnel key. */ + uint32_t dp_key; /* Aging threshold in ms. */ uint64_t value; /* Statistics dump period. */ @@ -89,8 +83,6 @@ struct fdb { struct fdb_data data; /* Reference to the SB FDB record. */ const struct sbrec_fdb *sbrec_fdb; - /* UUID of datapath for this FDB record. */ - struct uuid dp_uuid; }; struct bp_packet_data { @@ -123,12 +115,15 @@ struct buffered_packets_ctx { }; /* Thresholds. */ -bool mac_cache_threshold_add(struct mac_cache_data *data, - const struct sbrec_datapath_binding *dp, - enum mac_cache_type type); -bool mac_cache_threshold_replace(struct mac_cache_data *data, +void mac_cache_threshold_add(struct mac_cache_data *data, + const struct sbrec_datapath_binding *dp); +void mac_cache_threshold_replace(struct mac_cache_data *data, const struct sbrec_datapath_binding *dp, - enum mac_cache_type type); + const struct hmap *local_datapaths); +struct mac_cache_threshold * +mac_cache_threshold_find(struct mac_cache_data *data, uint32_t dp_key); +void mac_cache_thresholds_sync(struct mac_cache_data *data, + const struct hmap *local_datapaths); void mac_cache_thresholds_clear(struct mac_cache_data *data); /* MAC binding. */ diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index cd50db823..453dc62fd 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -3309,8 +3309,7 @@ mac_binding_remove_sb(struct mac_cache_data *data, } static void -fdb_add_sb(struct mac_cache_data *data, const struct sbrec_fdb *sfdb, - struct uuid dp_uuid) +fdb_add_sb(struct mac_cache_data *data, const struct sbrec_fdb *sfdb) { struct fdb_data fdb_data; if (!fdb_data_from_sbrec(&fdb_data, sfdb)) { @@ -3320,7 +3319,6 @@ fdb_add_sb(struct mac_cache_data *data, const struct sbrec_fdb *sfdb, struct fdb *fdb = fdb_add(&data->fdbs, fdb_data); fdb->sbrec_fdb = sfdb; - fdb->dp_uuid = dp_uuid; } static void @@ -3345,8 +3343,7 @@ mac_cache_mb_handle_for_datapath(struct mac_cache_data *data, struct ovsdb_idl_index *sbrec_mb_by_dp, struct ovsdb_idl_index *sbrec_pb_by_name) { - bool has_threshold = - mac_cache_threshold_replace(data, dp, MAC_CACHE_MAC_BINDING); + bool has_threshold = mac_cache_threshold_find(data, dp->tunnel_key); struct sbrec_mac_binding *mb_index_row = sbrec_mac_binding_index_init_row(sbrec_mb_by_dp); @@ -3369,7 +3366,7 @@ mac_cache_fdb_handle_for_datapath(struct mac_cache_data *data, const struct sbrec_datapath_binding *dp, struct ovsdb_idl_index *sbrec_fdb_by_dp_key) { - bool has_threshold = mac_cache_threshold_replace(data, dp, MAC_CACHE_FDB); + bool has_threshold = mac_cache_threshold_find(data, dp->tunnel_key); struct sbrec_fdb *fdb_index_row = sbrec_fdb_index_init_row(sbrec_fdb_by_dp_key); @@ -3378,7 +3375,7 @@ mac_cache_fdb_handle_for_datapath(struct mac_cache_data *data, const struct sbrec_fdb *fdb; SBREC_FDB_FOR_EACH_EQUAL (fdb, fdb_index_row, sbrec_fdb_by_dp_key) { if (has_threshold) { - fdb_add_sb(data, fdb, dp->header_.uuid); + fdb_add_sb(data, fdb); } else { fdb_remove_sb(data, fdb); } @@ -3393,9 +3390,7 @@ en_mac_cache_init(struct engine_node *node OVS_UNUSED, { struct mac_cache_data *cache_data = xzalloc(sizeof *cache_data); - for (size_t i = 0; i < MAC_CACHE_MAX; i++) { - hmap_init(&cache_data->thresholds[i]); - } + hmap_init(&cache_data->thresholds); hmap_init(&cache_data->mac_bindings); hmap_init(&cache_data->fdbs); @@ -3408,47 +3403,37 @@ en_mac_cache_run(struct engine_node *node, void *data) struct mac_cache_data *cache_data = data; struct ed_type_runtime_data *rt_data = engine_get_input_data("runtime_data", node); - const struct sbrec_mac_binding_table *mb_table = - EN_OVSDB_GET(engine_get_input("SB_mac_binding", node)); - const struct sbrec_fdb_table *fdb_table = - EN_OVSDB_GET(engine_get_input("SB_fdb", node)); + const struct sbrec_datapath_binding_table *dp_table = + EN_OVSDB_GET(engine_get_input("SB_datapath_binding", node)); + struct ovsdb_idl_index *sbrec_mb_by_dp = + engine_ovsdb_node_get_index( + engine_get_input("SB_mac_binding", node), + "datapath"); struct ovsdb_idl_index *sbrec_pb_by_name = engine_ovsdb_node_get_index( engine_get_input("SB_port_binding", node), "name"); + struct ovsdb_idl_index *sbrec_fdb_by_dp_key = + engine_ovsdb_node_get_index( + engine_get_input("SB_fdb", node), + "dp_key"); mac_cache_thresholds_clear(cache_data); mac_bindings_clear(&cache_data->mac_bindings); fdbs_clear(&cache_data->fdbs); - const struct sbrec_mac_binding *sbrec_mb; - SBREC_MAC_BINDING_TABLE_FOR_EACH (sbrec_mb, mb_table) { + const struct sbrec_datapath_binding *sbrec_dp; + SBREC_DATAPATH_BINDING_TABLE_FOR_EACH (sbrec_dp, dp_table) { if (!get_local_datapath(&rt_data->local_datapaths, - sbrec_mb->datapath->tunnel_key)) { - continue; - } - - if (mac_cache_threshold_add(cache_data, sbrec_mb->datapath, - MAC_CACHE_MAC_BINDING)) { - mac_binding_add_sb(cache_data, sbrec_mb, - sbrec_pb_by_name); - } - } - - struct local_datapath *local_dp; - const struct sbrec_fdb *sbrec_fdb; - SBREC_FDB_TABLE_FOR_EACH (sbrec_fdb, fdb_table) { - local_dp = get_local_datapath(&rt_data->local_datapaths, - sbrec_fdb->dp_key); - if (!local_dp) { + sbrec_dp->tunnel_key)) { continue; } - if (mac_cache_threshold_add(cache_data, local_dp->datapath, - MAC_CACHE_FDB)) { - fdb_add_sb(cache_data, sbrec_fdb, - local_dp->datapath->header_.uuid); - } + mac_cache_threshold_add(cache_data, sbrec_dp); + mac_cache_mb_handle_for_datapath(cache_data, sbrec_dp, + sbrec_mb_by_dp, sbrec_pb_by_name); + mac_cache_fdb_handle_for_datapath(cache_data, sbrec_dp, + sbrec_fdb_by_dp_key); } engine_set_node_state(node, EN_UPDATED); @@ -3486,10 +3471,9 @@ mac_cache_sb_mac_binding_handler(struct engine_node *node, void *data) continue; } - if (mac_cache_threshold_add(cache_data, sbrec_mb->datapath, - MAC_CACHE_MAC_BINDING)) { - mac_binding_add_sb(cache_data, sbrec_mb, - sbrec_pb_by_name); + if (mac_cache_threshold_find(cache_data, + sbrec_mb->datapath->tunnel_key)) { + mac_binding_add_sb(cache_data, sbrec_mb, sbrec_pb_by_name); } } @@ -3528,10 +3512,8 @@ mac_cache_sb_fdb_handler(struct engine_node *node, void *data) continue; } - if (mac_cache_threshold_add(cache_data, local_dp->datapath, - MAC_CACHE_FDB)) { - fdb_add_sb(cache_data, sbrec_fdb, - local_dp->datapath->header_.uuid); + if (mac_cache_threshold_find(cache_data, sbrec_fdb->dp_key)) { + fdb_add_sb(cache_data, sbrec_fdb); } } @@ -3571,10 +3553,14 @@ mac_cache_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) struct tracked_datapath *tdp; HMAP_FOR_EACH (tdp, node, &rt_data->tracked_dp_bindings) { - if (tdp->tracked_type != TRACKED_RESOURCE_NEW) { + if (tdp->tracked_type == TRACKED_RESOURCE_UPDATED) { continue; } + mac_cache_threshold_replace(cache_data, tdp->dp, + &rt_data->local_datapaths); + } + HMAP_FOR_EACH (tdp, node, &rt_data->tracked_dp_bindings) { mac_cache_mb_handle_for_datapath(cache_data, tdp->dp, sbrec_mb_by_dp, sbrec_pb_by_name); @@ -3613,16 +3599,25 @@ mac_cache_sb_datapath_binding_handler(struct engine_node *node, void *data) size_t previous_mb_size = hmap_count(&cache_data->mac_bindings); size_t previous_fdb_size = hmap_count(&cache_data->fdbs); + bool sync_needed = false; const struct sbrec_datapath_binding *sbrec_dp; - SBREC_DATAPATH_BINDING_TABLE_FOR_EACH (sbrec_dp, dp_table) { - if (sbrec_datapath_binding_is_new(sbrec_dp) || - sbrec_datapath_binding_is_deleted(sbrec_dp) || - !get_local_datapath(&rt_data->local_datapaths, - sbrec_dp->tunnel_key)) { - continue; + SBREC_DATAPATH_BINDING_TABLE_FOR_EACH_TRACKED (sbrec_dp, dp_table) { + if (!sbrec_datapath_binding_is_new(sbrec_dp) && + sbrec_datapath_binding_is_updated( + sbrec_dp, SBREC_DATAPATH_BINDING_COL_TUNNEL_KEY)) { + sync_needed = true; } + mac_cache_threshold_replace(cache_data, sbrec_dp, + &rt_data->local_datapaths); + } + + if (sync_needed) { + mac_cache_thresholds_sync(cache_data, &rt_data->local_datapaths); + } + + SBREC_DATAPATH_BINDING_TABLE_FOR_EACH_TRACKED (sbrec_dp, dp_table) { mac_cache_mb_handle_for_datapath(cache_data, sbrec_dp, sbrec_mb_by_dp, sbrec_pb_by_name); @@ -3645,9 +3640,7 @@ en_mac_cache_cleanup(void *data) struct mac_cache_data *cache_data = data; mac_cache_thresholds_clear(cache_data); - for (size_t i = 0; i < MAC_CACHE_MAX; i++) { - hmap_destroy(&cache_data->thresholds[i]); - } + hmap_destroy(&cache_data->thresholds); mac_bindings_clear(&cache_data->mac_bindings); hmap_destroy(&cache_data->mac_bindings); fdbs_clear(&cache_data->fdbs); diff --git a/tests/ovn.at b/tests/ovn.at index 9825870eb..c5baa4db4 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -34490,7 +34490,7 @@ OVS_CTL_TIMEOUT=10 OVS_WAIT_UNTIL([ test "$timestamp" != "$(fetch_column mac_binding timestamp ip='192.168.10.20')" ]) -check $(test "$(fetch_column mac_binding timestamp ip='192.168.10.20')" != "") +check test "$(fetch_column mac_binding timestamp ip='192.168.10.20')" != "" # Check if the records are removed after some inactivity OVS_WAIT_UNTIL([ @@ -36395,7 +36395,7 @@ OVS_WAIT_UNTIL([ test "$timestamp" != "$curr_timestamp" ]) timestamp=$(fetch_column fdb timestamp mac='"00:00:00:00:10:20"') -check $(test "$timestamp" != "") +check test "$timestamp" != "" # Check if the records are removed after some inactivity wait_row_count fdb 0 mac='"00:00:00:00:10:20"'