From patchwork Fri Sep 3 12:21:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Gray X-Patchwork-Id: 1524290 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=D1EB0ume; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H1H4273h2z9sSn for ; Fri, 3 Sep 2021 22:22:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5F1C7407DD; Fri, 3 Sep 2021 12:22:18 +0000 (UTC) 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 DbdUZgF39Djo; Fri, 3 Sep 2021 12:22:16 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id 73E5740809; Fri, 3 Sep 2021 12:22:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2B143C0028; Fri, 3 Sep 2021 12:22:11 +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 290B9C002D for ; Fri, 3 Sep 2021 12:22:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 09E6E83E5F for ; Fri, 3 Sep 2021 12:22:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=fail (1024-bit key) reason="fail (body has been altered)" header.d=redhat.com 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 2VcPX-uIgql7 for ; Fri, 3 Sep 2021 12:22:06 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id F295F83E64 for ; Fri, 3 Sep 2021 12:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630671723; 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=jidf38BL8G3LwLsbcRbFuEs1EJQZ6PIVvy21f+56UgY=; b=D1EB0umez+IrdWqKLG6jFDsMfk/tGutYyiFmaiffbmd+m6hJrSe9D0ilAzj2YgvMFUYmbZ eqVRiSLxEP89CWDQQImseoGBcD9EP/e7L/gWTTSSl5nF8OTZ234Mz2HJb6SWmz+uJsMrLN s1LT7vmDD4PbYKciGtjgkyJCNTSDXO8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-7h0Ue5R3MEitJiDI81Itiw-1; Fri, 03 Sep 2021 08:22:03 -0400 X-MC-Unique: 7h0Ue5R3MEitJiDI81Itiw-1 Received: by mail-wm1-f72.google.com with SMTP id u1-20020a05600c210100b002e74fc5af71so1824518wml.1 for ; Fri, 03 Sep 2021 05:22:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MVms11ABoaxLh4Ua8ADSwnxCY3hh1Jv/IEsO7la44IU=; b=BXpwJFn+Pf0Y6ci4vv9h9WNHrFScB3CvqYND79kSPiFUC0p/PNagz9ExYrhh3xXNLQ J9mNsIpfaiSQNpLWq8ii0zc+JUTYizudF3YJYWfsNyy3pS1do0AOR9mZk7lBoTRlUGmk 17fk2ZhnOdaLFqIwSO4FdUtjPfnSmc1cDXHI9+FxJG6m2icXkMgAD5N3tSXzyMt4Ix2P ijoMIobKfI39Y97ZtQQMqMUT9gDDqi5an3j8Zu/M0wn+CvxxSEfr1eSanFQDNQfUnkJF igtJ4YGYKToxM4274I05dM7M2vR0a6ab2yz0glvv6l+cmbRj7/HnsTJBSr2oI7tp5zof xC9A== X-Gm-Message-State: AOAM533Yo4A+3JdEo/3wAeZd6+VlY08Kei1np/d92xVzBPpXalDl5hwL FS185+JoGU/mN1SzmJCarkky+IyVhBezViXblf5SXxBNALHam7c68Wc1B19Fn4yxUYUBTuQjpoQ 3b1kXg1BFhWXkvW2TpeFn+TX6s4X2QZ/KDw1nQAynY9ULOCaS4PTYgZ38+TTcWlatw4NG X-Received: by 2002:adf:c3d4:: with SMTP id d20mr3849069wrg.358.1630671721646; Fri, 03 Sep 2021 05:22:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNCvqYp9PjU5llbHbHWeWXOL6nGdNx5KK4Dag/DqJDYnUtFnHBHd59cZfzBBfKF4GsqPKmuA== X-Received: by 2002:adf:c3d4:: with SMTP id d20mr3849043wrg.358.1630671721344; Fri, 03 Sep 2021 05:22:01 -0700 (PDT) Received: from wsfd-netdev91.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id a6sm4836612wrh.97.2021.09.03.05.22.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 05:22:01 -0700 (PDT) From: Mark Gray To: dev@openvswitch.org Date: Fri, 3 Sep 2021 08:21:48 -0400 Message-Id: <20210903122148.826196-8-mark.d.gray@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210903122148.826196-1-mark.d.gray@redhat.com> References: <20210903122148.826196-1-mark.d.gray@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mark.d.gray@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: numans@redhat.com Subject: [ovs-dev] [PATCH ovn v4 7/7] northd: Add functionality to runtime node 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" Update the runtime node to initialize and destroy some common data used by multiple functions in northd. Signed-off-by: Mark Gray --- northd/en-northd.c | 9 ++++++++- northd/en-runtime.c | 30 ++++++++++++++++++++++++++++-- northd/en-runtime.h | 8 ++++++++ northd/northd.c | 15 +++++---------- northd/northd.h | 5 ++++- 5 files changed, 53 insertions(+), 14 deletions(-) diff --git a/northd/en-northd.c b/northd/en-northd.c index d310fa4dd31f..2a3250f3d57a 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -19,6 +19,7 @@ #include #include "en-northd.h" +#include "en-runtime.h" #include "lib/inc-proc-eng.h" #include "northd.h" #include "openvswitch/vlog.h" @@ -29,7 +30,13 @@ void en_northd_run(struct engine_node *node, void *data OVS_UNUSED) { const struct engine_context *eng_ctx = engine_get_context(); struct northd_context *ctx = eng_ctx->client_ctx; - ovn_db_run(ctx); + + struct ed_type_runtime *runtime_data = + engine_get_input_data("runtime", node); + + ovn_db_run(ctx, &runtime_data->lr_list, + &runtime_data->datapaths, + &runtime_data->ports); engine_set_node_state(node, EN_UPDATED); diff --git a/northd/en-runtime.c b/northd/en-runtime.c index aac01cd0351f..b8e5766823bf 100644 --- a/northd/en-runtime.c +++ b/northd/en-runtime.c @@ -19,7 +19,9 @@ #include #include "en-runtime.h" +#include "openvswitch/hmap.h" #include "lib/inc-proc-eng.h" +#include "openvswitch/list.h" #include "northd.h" #include "openvswitch/vlog.h" @@ -27,14 +29,38 @@ VLOG_DEFINE_THIS_MODULE(en_runtime); void en_runtime_run(struct engine_node *node, void *data OVS_UNUSED) { + struct ed_type_runtime *runtime_data = data; + + struct ovs_list *lr_list = &runtime_data->lr_list; + struct hmap *datapaths = &runtime_data->datapaths; + struct hmap *ports = &runtime_data->ports; + + destroy_datapaths_and_ports(datapaths, ports, lr_list); + + ovs_list_init(lr_list); + hmap_init(datapaths); + hmap_init(ports); + engine_set_node_state(node, EN_UPDATED); } void *en_runtime_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg OVS_UNUSED) { - return NULL; + struct ed_type_runtime *data = xzalloc(sizeof *data); + ovs_list_init(&data->lr_list); + hmap_init(&data->datapaths); + hmap_init(&data->ports); + + return data; } -void en_runtime_cleanup(void *data OVS_UNUSED) +void en_runtime_cleanup(void *data) { + struct ed_type_runtime *runtime_data = data; + + struct ovs_list *lr_list = &runtime_data->lr_list; + struct hmap *datapaths = &runtime_data->datapaths; + struct hmap *ports = &runtime_data->ports; + + destroy_datapaths_and_ports(datapaths, ports, lr_list); } diff --git a/northd/en-runtime.h b/northd/en-runtime.h index 2547c9ec470a..7a1b2f6873e5 100644 --- a/northd/en-runtime.h +++ b/northd/en-runtime.h @@ -7,7 +7,15 @@ #include #include +#include "openvswitch/hmap.h" #include "lib/inc-proc-eng.h" +#include "openvswitch/list.h" + +struct ed_type_runtime { + struct ovs_list lr_list; + struct hmap datapaths; + struct hmap ports; +}; void en_runtime_run(struct engine_node *node, void *data); void *en_runtime_init(struct engine_node *node, diff --git a/northd/northd.c b/northd/northd.c index 829c4479f14b..43792f0d7ff7 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -13838,7 +13838,7 @@ sync_dns_entries(struct northd_context *ctx, struct hmap *datapaths) hmap_destroy(&dns_map); } -static void +void destroy_datapaths_and_ports(struct hmap *datapaths, struct hmap *ports, struct ovs_list *lr_list) { @@ -14548,13 +14548,9 @@ ovnsb_db_run(struct northd_context *ctx, } void -ovn_db_run(struct northd_context *ctx) +ovn_db_run(struct northd_context *ctx, struct ovs_list *lr_list, + struct hmap *datapaths, struct hmap *ports) { - struct hmap datapaths, ports; - struct ovs_list lr_list; - ovs_list_init(&lr_list); - hmap_init(&datapaths); - hmap_init(&ports); use_parallel_build = ctx->use_parallel_build; lflow_locks = ctx->lflow_locks; @@ -14562,12 +14558,11 @@ ovn_db_run(struct northd_context *ctx) stopwatch_start(OVNNB_DB_RUN_STOPWATCH_NAME, time_msec()); ovnnb_db_run(ctx, ctx->sbrec_chassis_by_name, ctx->ovnsb_idl_loop, - &datapaths, &ports, &lr_list, start_time, + datapaths, ports, lr_list, start_time, ctx->ovn_internal_version); stopwatch_stop(OVNNB_DB_RUN_STOPWATCH_NAME, time_msec()); stopwatch_start(OVNSB_DB_RUN_STOPWATCH_NAME, time_msec()); - ovnsb_db_run(ctx, ctx->ovnsb_idl_loop, &ports, start_time); + ovnsb_db_run(ctx, ctx->ovnsb_idl_loop, ports, start_time); stopwatch_stop(OVNSB_DB_RUN_STOPWATCH_NAME, time_msec()); - destroy_datapaths_and_ports(&datapaths, &ports, &lr_list); } diff --git a/northd/northd.h b/northd/northd.h index fa941d8ec83b..45a153ba2aa4 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -37,6 +37,9 @@ struct northd_context { const char *ovn_internal_version; }; -void ovn_db_run(struct northd_context *ctx); +void ovn_db_run(struct northd_context *ctx, struct ovs_list *, + struct hmap *, struct hmap *); +void destroy_datapaths_and_ports(struct hmap *datapaths, struct hmap *ports, + struct ovs_list *lr_list); #endif /* NORTHD_H */