From patchwork Tue Oct 24 00:43:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1854075 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::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::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 4SDtbh6Y0mz23jn for ; Tue, 24 Oct 2023 11:44:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CB63742CA3; Tue, 24 Oct 2023 00:43:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CB63742CA3 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zjBWwGnL5wNm; Tue, 24 Oct 2023 00:43:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id C955142C86; Tue, 24 Oct 2023 00:43:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C955142C86 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 94D95C0071; Tue, 24 Oct 2023 00:43:56 +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 137A8C0032 for ; Tue, 24 Oct 2023 00:43:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 8349842C6B for ; Tue, 24 Oct 2023 00:43:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 8349842C6B X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u13qsdQoWaHB for ; Tue, 24 Oct 2023 00:43:49 +0000 (UTC) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp4.osuosl.org (Postfix) with ESMTPS id F104342C65 for ; Tue, 24 Oct 2023 00:43:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org F104342C65 Received: by mail.gandi.net (Postfix) with ESMTPSA id 53DDF40003; Tue, 24 Oct 2023 00:43:43 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Mon, 23 Oct 2023 20:43:28 -0400 Message-ID: <20231024004328.4133518-1-numans@ovn.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231024004244.4133452-1-numans@ovn.org> References: <20231024004244.4133452-1-numans@ovn.org> MIME-Version: 1.0 X-GND-Sasl: numans@ovn.org Subject: [ovs-dev] [PATCH ovn v1 02/18] northd: Track ovn_datapaths in northd engine track data. 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" From: Numan Siddique northd engine tracked data now also stores the logical switches and logical routers that got updated due to the changed load balancers. Eg 1. For this command 'ovn-nbctl ls-lb-add sw0 lb1 -- lr-lb-add lr0 lb1', northd engine tracking data will store 'sw0' and 'lr0'. Eg 2. If load balancer lb1 is already associated with 'sw0' and 'lr0' then for this command 'ovn-nbctl set load_balancer vips:10.0.0.10=20.0.0.20', northd engine tracking data will store 'sw0' and 'lr0'. An upcoming commit will make use of this tracked data. Signed-off-by: Numan Siddique --- northd/northd.c | 34 +++++++++++++++++++++++++++++++++- northd/northd.h | 12 ++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/northd/northd.c b/northd/northd.c index df22a9c658..9ce1b2cb5a 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -5146,6 +5146,8 @@ destroy_northd_data_tracked_changes(struct northd_data *nd) struct northd_tracked_data *trk_changes = &nd->trk_northd_changes; destroy_tracked_ovn_ports(&trk_changes->trk_ovn_ports); destroy_tracked_lbs(&trk_changes->trk_lbs); + hmapx_clear(&trk_changes->ls_with_changed_lbs.crupdated); + hmapx_clear(&trk_changes->lr_with_changed_lbs.crupdated); nd->change_tracked = false; } @@ -5158,6 +5160,8 @@ init_northd_tracked_data(struct northd_data *nd) hmapx_init(&trk_changes->trk_ovn_ports.deleted); hmapx_init(&trk_changes->trk_lbs.crupdated); hmapx_init(&trk_changes->trk_lbs.deleted); + hmapx_init(&trk_changes->ls_with_changed_lbs.crupdated); + hmapx_init(&trk_changes->lr_with_changed_lbs.crupdated); } static void @@ -5169,6 +5173,8 @@ destroy_northd_tracked_data(struct northd_data *nd) hmapx_destroy(&trk_changes->trk_ovn_ports.deleted); hmapx_destroy(&trk_changes->trk_lbs.crupdated); hmapx_destroy(&trk_changes->trk_lbs.deleted); + hmapx_destroy(&trk_changes->ls_with_changed_lbs.crupdated); + hmapx_destroy(&trk_changes->lr_with_changed_lbs.crupdated); } @@ -5179,7 +5185,10 @@ northd_has_tracked_data(struct northd_tracked_data *trk_nd_changes) || !hmapx_is_empty(&trk_nd_changes->trk_ovn_ports.updated) || !hmapx_is_empty(&trk_nd_changes->trk_ovn_ports.deleted) || !hmapx_is_empty(&trk_nd_changes->trk_lbs.crupdated) - || !hmapx_is_empty(&trk_nd_changes->trk_lbs.deleted)); + || !hmapx_is_empty(&trk_nd_changes->trk_lbs.deleted) + || !hmapx_is_empty(&trk_nd_changes->ls_with_changed_lbs.crupdated) + || !hmapx_is_empty(&trk_nd_changes->lr_with_changed_lbs.crupdated) + ); } bool @@ -5188,6 +5197,8 @@ northd_has_only_ports_in_tracked_data( { return (hmapx_is_empty(&trk_nd_changes->trk_lbs.crupdated) && hmapx_is_empty(&trk_nd_changes->trk_lbs.deleted) + && hmapx_is_empty(&trk_nd_changes->ls_with_changed_lbs.crupdated) + && hmapx_is_empty(&trk_nd_changes->lr_with_changed_lbs.crupdated) && (!hmapx_is_empty(&trk_nd_changes->trk_ovn_ports.created) || !hmapx_is_empty(&trk_nd_changes->trk_ovn_ports.updated) || !hmapx_is_empty(&trk_nd_changes->trk_ovn_ports.deleted))); @@ -5828,6 +5839,9 @@ northd_handle_lb_data_changes(struct tracked_lb_data *trk_lb_data, lb_dps->nb_ls_map) { od = ls_datapaths->array[index]; init_lb_for_datapath(od); + + /* Add the ls datapath to the northd tracked data. */ + hmapx_add(&nd_changes->ls_with_changed_lbs.crupdated, od); } hmap_remove(lb_datapaths_map, &lb_dps->hmap_node); @@ -5909,6 +5923,9 @@ northd_handle_lb_data_changes(struct tracked_lb_data *trk_lb_data, /* Re-evaluate 'od->has_lb_vip' */ init_lb_for_datapath(od); + + /* Add the ls datapath to the northd tracked data. */ + hmapx_add(&nd_changes->ls_with_changed_lbs.crupdated, od); } LIST_FOR_EACH (codlb, list_node, &trk_lb_data->crupdated_lr_lbs) { @@ -5954,6 +5971,9 @@ northd_handle_lb_data_changes(struct tracked_lb_data *trk_lb_data, /* Re-evaluate 'od->has_lb_vip' */ init_lb_for_datapath(od); + + /* Add the lr datapath to the northd tracked data. */ + hmapx_add(&nd_changes->lr_with_changed_lbs.crupdated, od); } HMAP_FOR_EACH (clb, hmap_node, &trk_lb_data->crupdated_lbs) { @@ -5968,6 +5988,9 @@ northd_handle_lb_data_changes(struct tracked_lb_data *trk_lb_data, od = ls_datapaths->array[index]; /* Re-evaluate 'od->has_lb_vip' */ init_lb_for_datapath(od); + + /* Add the ls datapath to the northd tracked data. */ + hmapx_add(&nd_changes->ls_with_changed_lbs.crupdated, od); } BITMAP_FOR_EACH_1 (index, ods_size(lr_datapaths), @@ -5991,6 +6014,9 @@ northd_handle_lb_data_changes(struct tracked_lb_data *trk_lb_data, add_neigh_ips_to_lrouter(od, lb->neigh_mode, &clb->inserted_vips_v4, &clb->inserted_vips_v6); + + /* Add the lr datapath to the northd tracked data. */ + hmapx_add(&nd_changes->lr_with_changed_lbs.crupdated, od); } } @@ -6018,6 +6044,9 @@ northd_handle_lb_data_changes(struct tracked_lb_data *trk_lb_data, /* Add the lb_ips of lb_dps to the od. */ build_lrouter_lb_ips(od->lb_ips, lb_dps->lb); + + /* Add the lr datapath to the northd tracked data. */ + hmapx_add(&nd_changes->lr_with_changed_lbs.crupdated, od); } for (size_t i = 0; i < lbgrp_dps->n_ls; i++) { @@ -6026,6 +6055,9 @@ northd_handle_lb_data_changes(struct tracked_lb_data *trk_lb_data, /* Re-evaluate 'od->has_lb_vip' */ init_lb_for_datapath(od); + + /* Add the ls datapath to the northd tracked data. */ + hmapx_add(&nd_changes->ls_with_changed_lbs.crupdated, od); } /* Add the lb to the northd tracked data. */ diff --git a/northd/northd.h b/northd/northd.h index 2e4f125902..0478826f0a 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -107,12 +107,24 @@ struct tracked_lbs { struct hmapx deleted; }; +/* Tracked logical switches whose load balancers have changed. */ +struct tracked_lswitches_with_changed_lbs { + struct hmapx crupdated; +}; + +/* Tracked logical routers whose load balancers have changed. */ +struct tracked_lrouters_with_changed_lbs { + struct hmapx crupdated; +}; + /* Track what's changed in the northd engine node. * Now only tracks ovn_ports (of vif type) - created, updated * and deleted. */ struct northd_tracked_data { struct tracked_ovn_ports trk_ovn_ports; struct tracked_lbs trk_lbs; + struct tracked_lswitches_with_changed_lbs ls_with_changed_lbs; + struct tracked_lrouters_with_changed_lbs lr_with_changed_lbs; }; struct northd_data {