From patchwork Wed Jul 7 17:54:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1501952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) 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=ieAEYF83; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 4GKnBr4byvz9sXL for ; Thu, 8 Jul 2021 03:55:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3D6E383B7B; Wed, 7 Jul 2021 17:55:13 +0000 (UTC) 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 1jPNft6ubLkY; Wed, 7 Jul 2021 17:55:12 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0AAEF83B65; Wed, 7 Jul 2021 17:55:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5A8C5C0024; Wed, 7 Jul 2021 17:55:09 +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 CD841C000E for ; Wed, 7 Jul 2021 17:55:07 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id AF92E41482 for ; Wed, 7 Jul 2021 17:55:07 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 sSMxykKhK5oi for ; Wed, 7 Jul 2021 17:55: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 smtp4.osuosl.org (Postfix) with ESMTPS id 841E940619 for ; Wed, 7 Jul 2021 17:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625680505; 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=bxil5QXyY7EtX+7CMFDF4kL+su6VdMWbwoWVEon+qF8=; b=ieAEYF831DAEb4qxk4cg8yEo7ZcnymC2wv8RRT6KBpdSkTdEvKNnM7cTB40nc5Rako1WZR +RHsOFxgkvVWytoCRWsd6yWMeVddRdT0qTJHyk/JudeaOhGX/JM1BevR9db219US8XoMpV IShff9y/CGMbhLGlDMTvBMlB0untWRo= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-VG9foDg_MA65HPOP73N3wA-1; Wed, 07 Jul 2021 13:55:03 -0400 X-MC-Unique: VG9foDg_MA65HPOP73N3wA-1 Received: by mail-ej1-f69.google.com with SMTP id ci2-20020a1709072662b02904ce09e83b00so870120ejc.23 for ; Wed, 07 Jul 2021 10:55:03 -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=bxil5QXyY7EtX+7CMFDF4kL+su6VdMWbwoWVEon+qF8=; b=gE9yhtL3N9fqrx+AS1XrxGL9qHn6T3YEYpXV5V6Hoa+QTZ+0ksJLHXuzPssfPuk7YF 1nQbyvqnJDFxkS+jUeH90V1F2zPiJn9uoUxgz5Ik7+qKFRcPFQhYxEoxaOI486KKK6q7 +xmbFUoARFv5fhDW+NLlT6AlNMdprSQbaTL+LDmyUI7sc/RqhmanrM31YqkFNpKP0hse ogbA9YpTJgc/InUboM7fL4KoXEsIJbFhanayNRJJwayLb4Db8Jf4+iBYg0TR3xCEFPAy g9lTglUX1P7bOpxkm0b3bGzvxtzMWGr5vzWX1/gnTNnR86ehC7H+I+zc0UCuJxCq8CK/ 7qjQ== X-Gm-Message-State: AOAM532zWm73zKoOwIJ0LkbUetEn9HimMxkdlTlTPT2V+dxRF59NArkL bswvE8oV+gNvMkace1Z9XpFK5mABwB8gOsoms2kXvP4ungOLHPMBj/HrIq6HrIPKlZBekAXG3Bj fqBgb74LwqMMFu40ZwdAFCyLBgDaL1A9bhkQ2mLVM/X5pbOypSDLBByRRVfEOIZHu8oGbfjEmqX g= X-Received: by 2002:a50:cdcb:: with SMTP id h11mr32077136edj.366.1625680502432; Wed, 07 Jul 2021 10:55:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuqw/TlcOJ7lsUA2fdyECwv4svCsWgcUh0JsN0va/kZ8mH7//xpohRZjrOY4VSlkQA9VwevA== X-Received: by 2002:a50:cdcb:: with SMTP id h11mr32077118edj.366.1625680502220; Wed, 07 Jul 2021 10:55:02 -0700 (PDT) Received: from lore-desk.redhat.com (net-93-71-3-244.cust.vodafonedsl.it. [93.71.3.244]) by smtp.gmail.com with ESMTPSA id j5sm7305513ejn.19.2021.07.07.10.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 10:55:01 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Wed, 7 Jul 2021 19:54:56 +0200 Message-Id: <2f9670104e1c94fe73048b1849200e9943a4f230.1625680335.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn 1/2] controller: incrementally create ipv6 prefix delegation port_binding list 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" Incrementally manage local_active_ports_ipv6_pd map for interfaces where IPv6 prefix-delegation has been enabled. This patch allows to avoid looping over all local interfaces to check if prefix-delegation is running on the current port binding. Signed-off-by: Lorenzo Bianconi --- controller/binding.c | 35 ++++++++++++ controller/binding.h | 1 + controller/ovn-controller.c | 25 ++++++++- controller/ovn-controller.h | 8 +++ controller/pinctrl.c | 109 ++++++++++++++++++------------------ controller/pinctrl.h | 3 +- 6 files changed, 124 insertions(+), 57 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index 594babc98..2cec7ea84 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -574,6 +574,33 @@ remove_related_lport(const struct sbrec_port_binding *pb, } } +static void +update_active_pb_ras_pd(const struct sbrec_port_binding *pb, + struct hmap *local_datapaths, + struct hmap *map, const char *conf) +{ + const char *ras_pd_conf = smap_get(&pb->options, conf); + if (!ras_pd_conf) { + return; + } + + struct pb_active_ra_pd *ras_pd = + get_pb_active_ras_pd(map, pb->logical_port); + if (ras_pd && !strcmp(ras_pd_conf, "false")) { + hmap_remove(map, &ras_pd->hmap_node); + return; + } + if (!ras_pd && !strcmp(ras_pd_conf, "true")) { + ras_pd = xzalloc(sizeof *ras_pd); + ras_pd->pb = pb; + hmap_insert(map, &ras_pd->hmap_node, hash_string(pb->logical_port, 0)); + } + if (ras_pd) { + ras_pd->ld = get_local_datapath(local_datapaths, + pb->datapath->tunnel_key); + } +} + /* Corresponds to each Port_Binding.type. */ enum en_lport_type { LP_UNKNOWN, @@ -1645,6 +1672,10 @@ binding_run(struct binding_ctx_in *b_ctx_in, struct binding_ctx_out *b_ctx_out) const struct sbrec_port_binding *pb; SBREC_PORT_BINDING_TABLE_FOR_EACH (pb, b_ctx_in->port_binding_table) { + update_active_pb_ras_pd(pb, b_ctx_out->local_datapaths, + b_ctx_out->local_active_ports_ipv6_pd, + "ipv6_prefix_delegation"); + enum en_lport_type lport_type = get_lport_type(pb); switch (lport_type) { @@ -2482,6 +2513,10 @@ delete_done: continue; } + update_active_pb_ras_pd(pb, b_ctx_out->local_datapaths, + b_ctx_out->local_active_ports_ipv6_pd, + "ipv6_prefix_delegation"); + enum en_lport_type lport_type = get_lport_type(pb); struct binding_lport *b_lport = diff --git a/controller/binding.h b/controller/binding.h index a08011ae2..5a6f46a14 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -72,6 +72,7 @@ void related_lports_destroy(struct related_lports *); struct binding_ctx_out { struct hmap *local_datapaths; + struct hmap *local_active_ports_ipv6_pd; struct local_binding_data *lbinding_data; /* sset of (potential) local lports. */ diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 9050380f3..a42b96ddb 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -133,6 +133,20 @@ get_local_datapath(const struct hmap *local_datapaths, uint32_t tunnel_key) : NULL); } +struct pb_active_ra_pd * +get_pb_active_ras_pd(const struct hmap *map, const char *name) +{ + uint32_t key = hash_string(name, 0); + struct hmap_node *node; + + node = hmap_first_with_hash(map, key); + if (node) { + return CONTAINER_OF(node, struct pb_active_ra_pd, hmap_node); + } + + return NULL; +} + uint32_t get_tunnel_type(const char *name) { @@ -1028,6 +1042,8 @@ struct ed_type_runtime_data { bool tracked; bool local_lports_changed; struct hmap tracked_dp_bindings; + + struct hmap local_active_ports_ipv6_pd; }; /* struct ed_type_runtime_data has the below members for tracking the @@ -1115,6 +1131,7 @@ en_runtime_data_init(struct engine_node *node OVS_UNUSED, sset_init(&data->egress_ifaces); smap_init(&data->local_iface_ids); local_binding_data_init(&data->lbinding_data); + hmap_init(&data->local_active_ports_ipv6_pd); /* Init the tracked data. */ hmap_init(&data->tracked_dp_bindings); @@ -1140,6 +1157,7 @@ en_runtime_data_cleanup(void *data) free(cur_node); } hmap_destroy(&rt_data->local_datapaths); + hmap_destroy(&rt_data->local_active_ports_ipv6_pd); local_binding_data_destroy(&rt_data->lbinding_data); } @@ -1218,6 +1236,8 @@ init_binding_ctx(struct engine_node *node, b_ctx_in->ovs_table = ovs_table; b_ctx_out->local_datapaths = &rt_data->local_datapaths; + b_ctx_out->local_active_ports_ipv6_pd = + &rt_data->local_active_ports_ipv6_pd; b_ctx_out->local_lports = &rt_data->local_lports; b_ctx_out->local_lports_changed = false; b_ctx_out->related_lports = &rt_data->related_lports; @@ -1235,6 +1255,7 @@ en_runtime_data_run(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = data; struct hmap *local_datapaths = &rt_data->local_datapaths; + struct hmap *local_active_ipv6_pd = &rt_data->local_active_ports_ipv6_pd; struct sset *local_lports = &rt_data->local_lports; struct sset *active_tunnels = &rt_data->active_tunnels; @@ -1250,6 +1271,7 @@ en_runtime_data_run(struct engine_node *node, void *data) free(cur_node); } hmap_clear(local_datapaths); + hmap_clear(local_active_ipv6_pd); local_binding_data_destroy(&rt_data->lbinding_data); sset_destroy(local_lports); related_lports_destroy(&rt_data->related_lports); @@ -3263,7 +3285,8 @@ main(int argc, char *argv[]) sbrec_bfd_table_get(ovnsb_idl_loop.idl), br_int, chassis, &runtime_data->local_datapaths, - &runtime_data->active_tunnels); + &runtime_data->active_tunnels, + &runtime_data->local_active_ports_ipv6_pd); /* Updating monitor conditions if runtime data or * logical datapath goups changed. */ if (engine_node_changed(&en_runtime_data) diff --git a/controller/ovn-controller.h b/controller/ovn-controller.h index 5d9466880..cb054109e 100644 --- a/controller/ovn-controller.h +++ b/controller/ovn-controller.h @@ -71,6 +71,8 @@ struct local_datapath { struct local_datapath *get_local_datapath(const struct hmap *, uint32_t tunnel_key); +struct pb_active_ra_pd * +get_pb_active_ras_pd(const struct hmap *map, const char *name); const struct ovsrec_bridge *get_bridge(const struct ovsrec_bridge_table *, const char *br_name); @@ -87,4 +89,10 @@ enum chassis_tunnel_type { uint32_t get_tunnel_type(const char *name); +struct pb_active_ra_pd { + const struct sbrec_port_binding *pb; + const struct local_datapath *ld; + struct hmap_node hmap_node; +}; + #endif /* controller/ovn-controller.h */ diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 78ecfed84..1a74af872 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -1249,80 +1249,77 @@ fill_ipv6_prefix_state(struct ovsdb_idl_txn *ovnsb_idl_txn, static void prepare_ipv6_prefixd(struct ovsdb_idl_txn *ovnsb_idl_txn, struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct hmap *local_datapaths, + const struct hmap *local_active_ports_ipv6_pd, const struct sbrec_chassis *chassis, const struct sset *active_tunnels) OVS_REQUIRES(pinctrl_mutex) { - const struct local_datapath *ld; + const struct pb_active_ra_pd *pb_ipv6; bool changed = false; - HMAP_FOR_EACH (ld, hmap_node, local_datapaths) { - if (datapath_is_switch(ld->datapath)) { - /* logical switch */ + HMAP_FOR_EACH (pb_ipv6, hmap_node, local_active_ports_ipv6_pd) { + const struct sbrec_port_binding *pb = pb_ipv6->pb; + int j; + + if (!smap_get_bool(&pb->options, "ipv6_prefix_delegation", + false)) { continue; } - for (size_t i = 0; i < ld->n_peer_ports; i++) { - const struct sbrec_port_binding *pb = ld->peer_ports[i].local; - int j; + if (!pb_ipv6->ld) { + continue; + } - if (!smap_get_bool(&pb->options, "ipv6_prefix_delegation", - false)) { - continue; - } + const char *peer_s = smap_get(&pb->options, "peer"); + if (!peer_s) { + continue; + } - const char *peer_s = smap_get(&pb->options, "peer"); - if (!peer_s) { - continue; - } + const struct sbrec_port_binding *peer + = lport_lookup_by_name(sbrec_port_binding_by_name, peer_s); + if (!peer) { + continue; + } - const struct sbrec_port_binding *peer - = lport_lookup_by_name(sbrec_port_binding_by_name, peer_s); - if (!peer) { - continue; - } + char *redirect_name = xasprintf("cr-%s", pb->logical_port); + bool resident = lport_is_chassis_resident( + sbrec_port_binding_by_name, chassis, active_tunnels, + redirect_name); + free(redirect_name); + if (!resident && strcmp(pb->type, "l3gateway")) { + continue; + } - char *redirect_name = xasprintf("cr-%s", pb->logical_port); - bool resident = lport_is_chassis_resident( - sbrec_port_binding_by_name, chassis, active_tunnels, - redirect_name); - free(redirect_name); - if (!resident && strcmp(pb->type, "l3gateway")) { + struct in6_addr ip6_addr; + struct eth_addr ea = eth_addr_zero; + for (j = 0; j < pb->n_mac; j++) { + struct lport_addresses laddrs; + + if (!extract_lsp_addresses(pb->mac[j], &laddrs)) { continue; } - struct in6_addr ip6_addr; - struct eth_addr ea = eth_addr_zero; - for (j = 0; j < pb->n_mac; j++) { - struct lport_addresses laddrs; - - if (!extract_lsp_addresses(pb->mac[j], &laddrs)) { - continue; - } - - ea = laddrs.ea; - if (laddrs.n_ipv6_addrs > 0) { - ip6_addr = laddrs.ipv6_addrs[0].addr; - destroy_lport_addresses(&laddrs); - break; - } + ea = laddrs.ea; + if (laddrs.n_ipv6_addrs > 0) { + ip6_addr = laddrs.ipv6_addrs[0].addr; destroy_lport_addresses(&laddrs); + break; } + destroy_lport_addresses(&laddrs); + } - if (eth_addr_is_zero(ea)) { - continue; - } - - if (j == pb->n_mac) { - in6_generate_lla(ea, &ip6_addr); - } + if (eth_addr_is_zero(ea)) { + continue; + } - changed |= fill_ipv6_prefix_state(ovnsb_idl_txn, ld, - ea, ip6_addr, - peer->tunnel_key, - peer->datapath->tunnel_key); + if (j == pb->n_mac) { + in6_generate_lla(ea, &ip6_addr); } + + changed |= fill_ipv6_prefix_state(ovnsb_idl_txn, pb_ipv6->ld, + ea, ip6_addr, + peer->tunnel_key, + peer->datapath->tunnel_key); } struct shash_node *iter, *next; @@ -3411,7 +3408,8 @@ pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, const struct ovsrec_bridge *br_int, const struct sbrec_chassis *chassis, const struct hmap *local_datapaths, - const struct sset *active_tunnels) + const struct sset *active_tunnels, + const struct hmap *local_active_ports_ipv6_pd) { ovs_mutex_lock(&pinctrl_mutex); pinctrl_set_br_int_name_(br_int->name); @@ -3426,7 +3424,8 @@ pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, local_datapaths, active_tunnels); prepare_ipv6_ras(local_datapaths); prepare_ipv6_prefixd(ovnsb_idl_txn, sbrec_port_binding_by_name, - local_datapaths, chassis, active_tunnels); + local_active_ports_ipv6_pd, chassis, + active_tunnels); sync_dns_cache(dns_table); controller_event_run(ovnsb_idl_txn, ce_table, chassis); ip_mcast_sync(ovnsb_idl_txn, chassis, local_datapaths, diff --git a/controller/pinctrl.h b/controller/pinctrl.h index cc0a51984..9d98ee72e 100644 --- a/controller/pinctrl.h +++ b/controller/pinctrl.h @@ -49,7 +49,8 @@ void pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, const struct sbrec_bfd_table *, const struct ovsrec_bridge *, const struct sbrec_chassis *, const struct hmap *local_datapaths, - const struct sset *active_tunnels); + const struct sset *active_tunnels, + const struct hmap *local_active_ports_ipv6_pd); void pinctrl_wait(struct ovsdb_idl_txn *ovnsb_idl_txn); void pinctrl_destroy(void); void pinctrl_set_br_int_name(char *br_int_name); From patchwork Wed Jul 7 17:54:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1501953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) 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=RWUwfER8; dkim-atps=neutral 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GKnBt1yFlz9sWd for ; Thu, 8 Jul 2021 03:55:18 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6CFE660AAB; Wed, 7 Jul 2021 17:55:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nCmiGYSYQUOy; Wed, 7 Jul 2021 17:55:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5BD3660AAD; Wed, 7 Jul 2021 17:55:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4DBA1C001D; Wed, 7 Jul 2021 17:55:11 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 23263C000E for ; Wed, 7 Jul 2021 17:55:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D406740613 for ; Wed, 7 Jul 2021 17:55:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 zmyLbvciv8SE for ; Wed, 7 Jul 2021 17:55:07 +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 [216.205.24.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id B0326404DF for ; Wed, 7 Jul 2021 17:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625680506; 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=mpMcfTVLAbG5MdpRZO+daxfEL5F4k6KkRgVQ4jLGUy8=; b=RWUwfER8nB3wG2NyShNBUz9P1Oc+oCjdrNRUgkWgdUQLhZHN6Lyif6MPjJAZxL7W7DDg0O X5WOk8LawQc4sfd84LHHVZLscLm+fUgVRPEaINYk9Yd4ntAr+rxEe3W6BJtqUnG8kNk9fM X42mAl+Vo1UXbl8zOuPOy+i942AzdO0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-ZVpZtMlEMUyMGRtaO6w4uw-1; Wed, 07 Jul 2021 13:55:05 -0400 X-MC-Unique: ZVpZtMlEMUyMGRtaO6w4uw-1 Received: by mail-ed1-f69.google.com with SMTP id m15-20020a056402430fb0290399da445c17so1832775edc.8 for ; Wed, 07 Jul 2021 10:55:05 -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=mpMcfTVLAbG5MdpRZO+daxfEL5F4k6KkRgVQ4jLGUy8=; b=qEcMfmI4msRpdPduZYrhbBGBNa9OTffGYtksL8b82wJbJwXjNO0e3Iu6Pvly9SbClq ZuhsoEYEFe5fzxaKCVmyDWwsL/6Hg21m50r0+rUJbPDk2x64L5XcVeCt9kwTCzTl6EOi ZtvpXpDawLa49v6LitW6W3aj7z6WW4h7glbAakkjJLSc7vZEMdEGLNlQlsa9rsWXc81S Acmm7LrCKX5tnAKZmDZyMiNVk6cDEu/z7gQjNKjSw2Fi+2/W8duqCL08jVTpalMAtjLJ fRpO9rTRbij0Tm/I4N6CSt5OcYMtxghsAeja0JFi4KmqXDJ+lnlOVKNAdKhc/Exk2Hui F94A== X-Gm-Message-State: AOAM530GYWp09QtMoK2lQghto9hUEgw/imc6AhLrcN2RigkvAvQwCbic oHkYCwvd7JgFJUIChsi4Y433MSm9p6fp9atQknJKmiVLXSux56uZMhbdR2xoWRVw35UgGpQoYtk H+gzkb2k2p17FZEbYeHDJXRcH2LXc+HGjx6MVtumBw6QM6bEaR7fucxU/65lQbVZEGxA1K4suJG c= X-Received: by 2002:a17:906:ce59:: with SMTP id se25mr8865549ejb.418.1625680503787; Wed, 07 Jul 2021 10:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhYOXY381KZshvm9SkRGhgPbRDadIqsizYewtLSBZpJspRXIE8ZwBNOl1LPn79ciXSiCzDPg== X-Received: by 2002:a17:906:ce59:: with SMTP id se25mr8865529ejb.418.1625680503464; Wed, 07 Jul 2021 10:55:03 -0700 (PDT) Received: from lore-desk.redhat.com (net-93-71-3-244.cust.vodafonedsl.it. [93.71.3.244]) by smtp.gmail.com with ESMTPSA id j5sm7305513ejn.19.2021.07.07.10.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 10:55:03 -0700 (PDT) From: Lorenzo Bianconi To: dev@openvswitch.org Date: Wed, 7 Jul 2021 19:54:57 +0200 Message-Id: <7366c766111954b8f9251ebcb97a9837ed916874.1625680335.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: dceara@redhat.com Subject: [ovs-dev] [PATCH ovn 2/2] controller: incrementally create ras port_binding list 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" Incrementally manage local_active_ports_ras map for interfaces where periodic router advertisement has been enabled. This patch allows to avoid looping over all local interfaces to check if periodic RA is running on the current port binding. Signed-off-by: Lorenzo Bianconi --- controller/binding.c | 7 +++ controller/binding.h | 1 + controller/ovn-controller.c | 10 +++- controller/pinctrl.c | 96 ++++++++++++++++++++----------------- controller/pinctrl.h | 3 +- 5 files changed, 72 insertions(+), 45 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index 2cec7ea84..8a66a867c 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1675,6 +1675,9 @@ binding_run(struct binding_ctx_in *b_ctx_in, struct binding_ctx_out *b_ctx_out) update_active_pb_ras_pd(pb, b_ctx_out->local_datapaths, b_ctx_out->local_active_ports_ipv6_pd, "ipv6_prefix_delegation"); + update_active_pb_ras_pd(pb, b_ctx_out->local_datapaths, + b_ctx_out->local_active_ports_ras, + "ipv6_ra_send_periodic"); enum en_lport_type lport_type = get_lport_type(pb); @@ -2517,6 +2520,10 @@ delete_done: b_ctx_out->local_active_ports_ipv6_pd, "ipv6_prefix_delegation"); + update_active_pb_ras_pd(pb, b_ctx_out->local_datapaths, + b_ctx_out->local_active_ports_ras, + "ipv6_ra_send_periodic"); + enum en_lport_type lport_type = get_lport_type(pb); struct binding_lport *b_lport = diff --git a/controller/binding.h b/controller/binding.h index 5a6f46a14..a0ac47dd4 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -73,6 +73,7 @@ void related_lports_destroy(struct related_lports *); struct binding_ctx_out { struct hmap *local_datapaths; struct hmap *local_active_ports_ipv6_pd; + struct hmap *local_active_ports_ras; struct local_binding_data *lbinding_data; /* sset of (potential) local lports. */ diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index a42b96ddb..b779f0c58 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1044,6 +1044,7 @@ struct ed_type_runtime_data { struct hmap tracked_dp_bindings; struct hmap local_active_ports_ipv6_pd; + struct hmap local_active_ports_ras; }; /* struct ed_type_runtime_data has the below members for tracking the @@ -1132,6 +1133,7 @@ en_runtime_data_init(struct engine_node *node OVS_UNUSED, smap_init(&data->local_iface_ids); local_binding_data_init(&data->lbinding_data); hmap_init(&data->local_active_ports_ipv6_pd); + hmap_init(&data->local_active_ports_ras); /* Init the tracked data. */ hmap_init(&data->tracked_dp_bindings); @@ -1158,6 +1160,7 @@ en_runtime_data_cleanup(void *data) } hmap_destroy(&rt_data->local_datapaths); hmap_destroy(&rt_data->local_active_ports_ipv6_pd); + hmap_destroy(&rt_data->local_active_ports_ras); local_binding_data_destroy(&rt_data->lbinding_data); } @@ -1238,6 +1241,8 @@ init_binding_ctx(struct engine_node *node, b_ctx_out->local_datapaths = &rt_data->local_datapaths; b_ctx_out->local_active_ports_ipv6_pd = &rt_data->local_active_ports_ipv6_pd; + b_ctx_out->local_active_ports_ras = + &rt_data->local_active_ports_ras; b_ctx_out->local_lports = &rt_data->local_lports; b_ctx_out->local_lports_changed = false; b_ctx_out->related_lports = &rt_data->related_lports; @@ -1256,6 +1261,7 @@ en_runtime_data_run(struct engine_node *node, void *data) struct ed_type_runtime_data *rt_data = data; struct hmap *local_datapaths = &rt_data->local_datapaths; struct hmap *local_active_ipv6_pd = &rt_data->local_active_ports_ipv6_pd; + struct hmap *local_active_ras = &rt_data->local_active_ports_ras; struct sset *local_lports = &rt_data->local_lports; struct sset *active_tunnels = &rt_data->active_tunnels; @@ -1272,6 +1278,7 @@ en_runtime_data_run(struct engine_node *node, void *data) } hmap_clear(local_datapaths); hmap_clear(local_active_ipv6_pd); + hmap_clear(local_active_ras); local_binding_data_destroy(&rt_data->lbinding_data); sset_destroy(local_lports); related_lports_destroy(&rt_data->related_lports); @@ -3286,7 +3293,8 @@ main(int argc, char *argv[]) br_int, chassis, &runtime_data->local_datapaths, &runtime_data->active_tunnels, - &runtime_data->local_active_ports_ipv6_pd); + &runtime_data->local_active_ports_ipv6_pd, + &runtime_data->local_active_ports_ras); /* Updating monitor conditions if runtime data or * logical datapath goups changed. */ if (engine_node_changed(&en_runtime_data) diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 1a74af872..199a32685 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -243,7 +243,9 @@ static void wait_controller_event(struct ovsdb_idl_txn *ovnsb_idl_txn); static void init_ipv6_ras(void); static void destroy_ipv6_ras(void); static void ipv6_ra_wait(long long int send_ipv6_ra_time); -static void prepare_ipv6_ras(const struct hmap *local_datapaths) +static void prepare_ipv6_ras( + const struct hmap *local_active_ports_ras, + struct ovsdb_idl_index *sbrec_port_binding_by_name) OVS_REQUIRES(pinctrl_mutex); static void send_ipv6_ras(struct rconn *swconn, long long int *send_ipv6_ra_time) @@ -3409,7 +3411,8 @@ pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, const struct sbrec_chassis *chassis, const struct hmap *local_datapaths, const struct sset *active_tunnels, - const struct hmap *local_active_ports_ipv6_pd) + const struct hmap *local_active_ports_ipv6_pd, + const struct hmap *local_active_ports_ras) { ovs_mutex_lock(&pinctrl_mutex); pinctrl_set_br_int_name_(br_int->name); @@ -3422,7 +3425,7 @@ pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, sbrec_port_binding_by_name, sbrec_mac_binding_by_lport_ip, br_int, chassis, local_datapaths, active_tunnels); - prepare_ipv6_ras(local_datapaths); + prepare_ipv6_ras(local_active_ports_ras, sbrec_port_binding_by_name); prepare_ipv6_prefixd(ovnsb_idl_txn, sbrec_port_binding_by_name, local_active_ports_ipv6_pd, chassis, active_tunnels); @@ -3879,7 +3882,8 @@ send_ipv6_ras(struct rconn *swconn, long long int *send_ipv6_ra_time) /* Called by pinctrl_run(). Runs with in the main ovn-controller * thread context. */ static void -prepare_ipv6_ras(const struct hmap *local_datapaths) +prepare_ipv6_ras(const struct hmap *local_active_ports_ras, + struct ovsdb_idl_index *sbrec_port_binding_by_name) OVS_REQUIRES(pinctrl_mutex) { struct shash_node *iter, *iter_next; @@ -3890,52 +3894,58 @@ prepare_ipv6_ras(const struct hmap *local_datapaths) } bool changed = false; - const struct local_datapath *ld; - HMAP_FOR_EACH (ld, hmap_node, local_datapaths) { + const struct pb_active_ra_pd *ras; + HMAP_FOR_EACH (ras, hmap_node, local_active_ports_ras) { + const struct sbrec_port_binding *pb = ras->pb; + if (!smap_get_bool(&pb->options, "ipv6_ra_send_periodic", false)) { + continue; + } - for (size_t i = 0; i < ld->n_peer_ports; i++) { - const struct sbrec_port_binding *peer = ld->peer_ports[i].remote; - const struct sbrec_port_binding *pb = ld->peer_ports[i].local; + const char *peer_s = smap_get(&pb->options, "peer"); + if (!peer_s) { + continue; + } - if (!smap_get_bool(&pb->options, "ipv6_ra_send_periodic", false)) { - continue; - } + const struct sbrec_port_binding *peer + = lport_lookup_by_name(sbrec_port_binding_by_name, peer_s); + if (!peer) { + continue; + } - struct ipv6_ra_config *config = ipv6_ra_update_config(pb); - if (!config) { - continue; - } + struct ipv6_ra_config *config = ipv6_ra_update_config(pb); + if (!config) { + continue; + } - struct ipv6_ra_state *ra - = shash_find_data(&ipv6_ras, pb->logical_port); - if (!ra) { - ra = xzalloc(sizeof *ra); - ra->config = config; + struct ipv6_ra_state *ra + = shash_find_data(&ipv6_ras, pb->logical_port); + if (!ra) { + ra = xzalloc(sizeof *ra); + ra->config = config; + ra->next_announce = ipv6_ra_calc_next_announce( + ra->config->min_interval, + ra->config->max_interval); + shash_add(&ipv6_ras, pb->logical_port, ra); + changed = true; + } else { + if (config->min_interval != ra->config->min_interval || + config->max_interval != ra->config->max_interval) ra->next_announce = ipv6_ra_calc_next_announce( - ra->config->min_interval, - ra->config->max_interval); - shash_add(&ipv6_ras, pb->logical_port, ra); - changed = true; - } else { - if (config->min_interval != ra->config->min_interval || - config->max_interval != ra->config->max_interval) - ra->next_announce = ipv6_ra_calc_next_announce( - config->min_interval, - config->max_interval); - ipv6_ra_config_delete(ra->config); - ra->config = config; - } + config->min_interval, + config->max_interval); + ipv6_ra_config_delete(ra->config); + ra->config = config; + } - /* Peer is the logical switch port that the logical - * router port is connected to. The RA is injected - * into that logical switch port. - */ - ra->port_key = peer->tunnel_key; - ra->metadata = peer->datapath->tunnel_key; - ra->delete_me = false; + /* Peer is the logical switch port that the logical + * router port is connected to. The RA is injected + * into that logical switch port. + */ + ra->port_key = peer->tunnel_key; + ra->metadata = peer->datapath->tunnel_key; + ra->delete_me = false; - /* pinctrl_handler thread will send the IPv6 RAs. */ - } + /* pinctrl_handler thread will send the IPv6 RAs. */ } /* Remove those that are no longer in the SB database */ diff --git a/controller/pinctrl.h b/controller/pinctrl.h index 9d98ee72e..5bb74d5f7 100644 --- a/controller/pinctrl.h +++ b/controller/pinctrl.h @@ -50,7 +50,8 @@ void pinctrl_run(struct ovsdb_idl_txn *ovnsb_idl_txn, const struct ovsrec_bridge *, const struct sbrec_chassis *, const struct hmap *local_datapaths, const struct sset *active_tunnels, - const struct hmap *local_active_ports_ipv6_pd); + const struct hmap *local_active_ports_ipv6_pd, + const struct hmap *local_active_ports_ras); void pinctrl_wait(struct ovsdb_idl_txn *ovnsb_idl_txn); void pinctrl_destroy(void); void pinctrl_set_br_int_name(char *br_int_name);