From patchwork Tue Aug 20 13:36:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1974431 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=hmsrJvyJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.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 4Wp9VZ6B0nz1yXZ for ; Tue, 20 Aug 2024 23:36:54 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5594060902; Tue, 20 Aug 2024 13:36:53 +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 sGS0tJrqmMQ1; Tue, 20 Aug 2024 13:36:51 +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 66B406090B Authentication-Results: smtp3.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=hmsrJvyJ Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 66B406090B; Tue, 20 Aug 2024 13:36:51 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1A844C102B; Tue, 20 Aug 2024 13:36:51 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 10580C1029 for ; Tue, 20 Aug 2024 13:36:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0C73A40A41 for ; Tue, 20 Aug 2024 13:36:49 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 5ZcykHCC6Q_J for ; Tue, 20 Aug 2024 13:36:47 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=lorenzo.bianconi@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org B55A640A39 Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org B55A640A39 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hmsrJvyJ Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id B55A640A39 for ; Tue, 20 Aug 2024 13:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724161005; 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=5YWFi572IXTDE5pjnEX6lr5YAmWv/sGXNeKsWH5L8oA=; b=hmsrJvyJQS95qSgtcP9eAXx5erPLO9xDnxv3wpoaVdY54heT9hoy3Fem25chy6UcBps6LG thBnpfmah1KLWJqX/Py3t1/G3xSE45aQcMF75QPTv+M9EcK1Alo7DikFXtEH9nhe36ozvt Yoa2xSfyOjEOm/cuq+pZYOtaeIfv9eA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-29ZbE-DzMhOmShyqhyTZrw-1; Tue, 20 Aug 2024 09:36:44 -0400 X-MC-Unique: 29ZbE-DzMhOmShyqhyTZrw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-371a804f191so2510494f8f.3 for ; Tue, 20 Aug 2024 06:36:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724161003; x=1724765803; 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=5YWFi572IXTDE5pjnEX6lr5YAmWv/sGXNeKsWH5L8oA=; b=ipajkCaz4dmYQMb5cUeB+RCD1t7SgVflEO+VM88r0sLAwvMQFJG3tKc5r0LnaPez+T S5uFocNR8JGIJYPGJRYbxquEzZCfbbdarT61LN4+2/IGUT5/4oJIEri4Y5kmDyoPoNNT qMqf/qpy5i1NsY9e0m+TuyFE1APO6mjNePAJhVCbkg8KY7LfdB//D9dYDNAHZibctZ4L uTHvLXf/rVeZbjip22gV9RtF8hL+1tz0B+R2kzf3/CWO5zywWHkP8G1T/BtYJglOcH+G UhyskzL1efQOfTJLYOrtw+OC+VcOsq4Mv+Xh93UWiwpwvy5wiYzX5uU+jcp/Wce+j39e lDwA== X-Gm-Message-State: AOJu0YxiFbT2yz4PGtbFWn2D7oFs7KEByHueE+jXerWJVbboBRfxZnP5 QfSxV07Ish0B1JjAb794e3yC6bVFinDAivqIQLbRWfKam++9s4++ZZKGj65/j9lVVfFU1/9h2r9 La+5fWtWSD45FbD5vQrzuA+cWIgUw+9c4N0h/I1fNCsMZ7MELg1NfFPAD9FeMiUAVroQutrTL8N j7stXRZMkgd8/UwKE1aYProuS06GSM96NiFdyueaNGKZDASyxvwQ== X-Received: by 2002:adf:ce8e:0:b0:371:8e30:290 with SMTP id ffacd0b85a97d-3719443ecc1mr8055079f8f.21.1724161003137; Tue, 20 Aug 2024 06:36:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYMToDv8NS37u1B2OjoRlHhQ69vd0C86xo+KndosHJEGCJPf4TB9Glp9rXvaP1yk5C5bnIFw== X-Received: by 2002:adf:ce8e:0:b0:371:8e30:290 with SMTP id ffacd0b85a97d-3719443ecc1mr8055050f8f.21.1724161002454; Tue, 20 Aug 2024 06:36:42 -0700 (PDT) Received: from localhost (net-188-152-77-192.cust.dsl.teletu.it. [188.152.77.192]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37189896a9csm13178233f8f.79.2024.08.20.06.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 06:36:42 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Tue, 20 Aug 2024 15:36:23 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 2/4] northd: Optimize lookup in bfd_is_port_running. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dceara@redhat.com Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Optimize port lookup in bfd_is_port_running using a bfd_ports sset. Get rid of bfd_connections hmap building lflows Signed-off-by: Lorenzo Bianconi --- northd/en-lflow.c | 2 +- northd/northd.c | 68 +++++++++++++++++++++-------------------------- northd/northd.h | 2 +- 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/northd/en-lflow.c b/northd/en-lflow.c index 421fcd48c..08e5bd0a1 100644 --- a/northd/en-lflow.c +++ b/northd/en-lflow.c @@ -83,7 +83,7 @@ lflow_get_input_data(struct engine_node *node, lflow_input->meter_groups = &sync_meters_data->meter_groups; lflow_input->lb_datapaths_map = &northd_data->lb_datapaths_map; lflow_input->svc_monitor_map = &northd_data->svc_monitor_map; - lflow_input->bfd_connections = &bfd_sync_data->bfd_connections; + lflow_input->bfd_ports = &bfd_sync_data->bfd_ports; lflow_input->parsed_routes = &static_routes_data->parsed_routes; lflow_input->route_tables = &static_routes_data->route_tables; lflow_input->route_policies = &route_policies_data->route_policies; diff --git a/northd/northd.c b/northd/northd.c index 2009da3d0..413b17830 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -10442,18 +10442,11 @@ bfd_port_lookup(const struct hmap *bfd_map, const char *logical_port, } static bool -bfd_is_port_running(const struct hmap *bfd_map, const char *port) +bfd_is_port_running(const struct sset *bfd_ports, const char *port) { - struct bfd_entry *bfd_e; - HMAP_FOR_EACH (bfd_e, hmap_node, bfd_map) { - if (!strcmp(bfd_e->logical_port, port)) { - return true; - } - } - return false; + return !!sset_find(bfd_ports, port); } - #define BFD_DEF_MINTX 1000 /* 1s */ #define BFD_DEF_MINRX 1000 /* 1s */ #define BFD_DEF_DETECT_MULT 5 @@ -11711,7 +11704,7 @@ add_route(struct lflow_table *lflows, struct ovn_datapath *od, const struct ovn_port *op, const char *lrp_addr_s, const char *network_s, int plen, const char *gateway, bool is_src_route, const uint32_t rtb_id, - const struct hmap *bfd_connections, + const struct sset *bfd_ports, const struct ovsdb_idl_row *stage_hint, bool is_discard_route, int ofs, struct lflow_ref *lflow_ref) { @@ -11760,7 +11753,7 @@ add_route(struct lflow_table *lflows, struct ovn_datapath *od, priority, ds_cstr(&match), ds_cstr(&actions), stage_hint, lflow_ref); - if (op && bfd_is_port_running(bfd_connections, op->key)) { + if (op && bfd_is_port_running(bfd_ports, op->key)) { ds_put_format(&match, " && udp.dst == 3784"); ovn_lflow_add_with_hint(lflows, op->od, S_ROUTER_IN_IP_ROUTING, @@ -11777,7 +11770,7 @@ static void build_static_route_flow(struct lflow_table *lflows, struct ovn_datapath *od, const struct hmap *lr_ports, const struct parsed_route *route_, - const struct hmap *bfd_connections, + const struct sset *bfd_ports, struct lflow_ref *lflow_ref) { const char *lrp_addr_s = NULL; @@ -11802,7 +11795,7 @@ build_static_route_flow(struct lflow_table *lflows, struct ovn_datapath *od, add_route(lflows, route_->is_discard_route ? od : out_port->od, out_port, lrp_addr_s, prefix_s, route_->plen, route->nexthop, route_->is_src_route, route_->route_table_id, - bfd_connections, &route->header_, route_->is_discard_route, + bfd_ports, &route->header_, route_->is_discard_route, ofs, lflow_ref); free(prefix_s); @@ -12954,10 +12947,10 @@ build_lrouter_force_snat_flows_op(struct ovn_port *op, static void build_lrouter_bfd_flows(struct lflow_table *lflows, struct ovn_port *op, const struct shash *meter_groups, - const struct hmap *bfd_connections, + const struct sset *bfd_ports, struct lflow_ref *lflow_ref) { - if (!bfd_is_port_running(bfd_connections, op->key)) { + if (!bfd_is_port_running(bfd_ports, op->key)) { return; } @@ -13553,7 +13546,7 @@ build_ip_routing_pre_flows_for_lrouter(struct ovn_datapath *od, */ static void build_ip_routing_flows_for_lrp(struct ovn_port *op, - const struct hmap *bfd_connections, + const struct sset *bfd_ports, struct lflow_table *lflows, struct lflow_ref *lflow_ref) { @@ -13562,7 +13555,7 @@ build_ip_routing_flows_for_lrp(struct ovn_port *op, add_route(lflows, op->od, op, op->lrp_networks.ipv4_addrs[i].addr_s, op->lrp_networks.ipv4_addrs[i].network_s, op->lrp_networks.ipv4_addrs[i].plen, NULL, false, 0, - bfd_connections, &op->nbrp->header_, false, + bfd_ports, &op->nbrp->header_, false, ROUTE_PRIO_OFFSET_CONNECTED, lflow_ref); } @@ -13570,7 +13563,7 @@ build_ip_routing_flows_for_lrp(struct ovn_port *op, add_route(lflows, op->od, op, op->lrp_networks.ipv6_addrs[i].addr_s, op->lrp_networks.ipv6_addrs[i].network_s, op->lrp_networks.ipv6_addrs[i].plen, NULL, false, 0, - bfd_connections, &op->nbrp->header_, false, + bfd_ports, &op->nbrp->header_, false, ROUTE_PRIO_OFFSET_CONNECTED, lflow_ref); } } @@ -13579,7 +13572,7 @@ static void build_static_route_flows_for_lrouter( struct ovn_datapath *od, struct lflow_table *lflows, const struct hmap *lr_ports, struct hmap *parsed_routes, - struct simap *route_tables, const struct hmap *bfd_connections, + struct simap *route_tables, const struct sset *bfd_ports, struct lflow_ref *lflow_ref, struct simap *nexthops_table) { ovs_assert(od->nbr); @@ -13628,7 +13621,7 @@ build_static_route_flows_for_lrouter( const struct unique_routes_node *ur; HMAP_FOR_EACH (ur, hmap_node, &unique_routes) { build_static_route_flow(lflows, od, lr_ports, ur->route, - bfd_connections, lflow_ref); + bfd_ports, lflow_ref); } ecmp_groups_destroy(&ecmp_groups); unique_routes_destroy(&unique_routes); @@ -15330,7 +15323,7 @@ build_lrouter_ipv4_ip_input(struct ovn_port *op, struct lflow_table *lflows, struct ds *match, struct ds *actions, const struct shash *meter_groups, - const struct hmap *bfd_connections, + const struct sset *bfd_ports, struct lflow_ref *lflow_ref) { ovs_assert(op->nbrp); @@ -15372,8 +15365,7 @@ build_lrouter_ipv4_ip_input(struct ovn_port *op, } /* BFD msg handling */ - build_lrouter_bfd_flows(lflows, op, meter_groups, bfd_connections, - lflow_ref); + build_lrouter_bfd_flows(lflows, op, meter_groups, bfd_ports, lflow_ref); /* ICMP time exceeded */ struct ds ip_ds = DS_EMPTY_INITIALIZER; @@ -16826,7 +16818,7 @@ build_lsp_lflows_for_lbnats(struct ovn_port *lsp, static void build_routable_flows_for_router_port( struct ovn_port *lrp, const struct lr_stateful_record *lr_stateful_rec, - const struct hmap *bfd_connections, + const struct sset *bfd_ports, struct lflow_table *lflows, struct ds *match, struct ds *actions) @@ -16863,7 +16855,7 @@ build_routable_flows_for_router_port( router_port->lrp_networks.ipv4_addrs[0].addr_s, laddrs->ipv4_addrs[k].network_s, laddrs->ipv4_addrs[k].plen, NULL, false, 0, - bfd_connections, &router_port->nbrp->header_, + bfd_ports, &router_port->nbrp->header_, false, ROUTE_PRIO_OFFSET_CONNECTED, lrp->stateful_lflow_ref); } @@ -16974,7 +16966,7 @@ build_lrp_lflows_for_lbnats(struct ovn_port *op, static void build_lbnat_lflows_iterate_by_lrp( struct ovn_port *op, const struct lr_stateful_table *lr_stateful_table, - const struct shash *meter_groups, const struct hmap *bfd_connections, + const struct shash *meter_groups, const struct sset *bfd_ports, struct ds *match, struct ds *actions, struct lflow_table *lflows) { ovs_assert(op->nbrp); @@ -16987,7 +16979,7 @@ build_lbnat_lflows_iterate_by_lrp( build_lrp_lflows_for_lbnats(op, lr_stateful_rec, meter_groups, match, actions, lflows); - build_routable_flows_for_router_port(op, lr_stateful_rec, bfd_connections, + build_routable_flows_for_router_port(op, lr_stateful_rec, bfd_ports, lflows, match, actions); } @@ -17051,7 +17043,7 @@ struct lswitch_flow_build_info { const struct shash *meter_groups; const struct hmap *lb_dps_map; const struct hmap *svc_monitor_map; - const struct hmap *bfd_connections; + const struct sset *bfd_ports; const struct chassis_features *features; char *svc_check_match; struct ds match; @@ -17109,7 +17101,7 @@ build_lswitch_and_lrouter_iterate_by_lr(struct ovn_datapath *od, build_ip_routing_pre_flows_for_lrouter(od, lsi->lflows, NULL); build_static_route_flows_for_lrouter(od, lsi->lflows, lsi->lr_ports, lsi->parsed_routes, lsi->route_tables, - lsi->bfd_connections, NULL, + lsi->bfd_ports, NULL, lsi->nexthops_table); build_mcast_lookup_flows_for_lrouter(od, lsi->lflows, &lsi->match, &lsi->actions, NULL); @@ -17181,7 +17173,7 @@ build_lswitch_and_lrouter_iterate_by_lrp(struct ovn_port *op, &lsi->actions, op->lflow_ref); build_neigh_learning_flows_for_lrouter_port(op, lsi->lflows, &lsi->match, &lsi->actions, op->lflow_ref); - build_ip_routing_flows_for_lrp(op, lsi->bfd_connections, + build_ip_routing_flows_for_lrp(op, lsi->bfd_ports, lsi->lflows, op->lflow_ref); build_ND_RA_flows_for_lrouter_port(op, lsi->lflows, &lsi->match, &lsi->actions, lsi->meter_groups, @@ -17200,7 +17192,7 @@ build_lswitch_and_lrouter_iterate_by_lrp(struct ovn_port *op, lsi->meter_groups, op->lflow_ref); build_lrouter_ipv4_ip_input(op, lsi->lflows, &lsi->match, &lsi->actions, - lsi->meter_groups, lsi->bfd_connections, + lsi->meter_groups, lsi->bfd_ports, op->lflow_ref); build_lrouter_icmp_packet_toobig_admin_flows(op, lsi->lflows, &lsi->match, &lsi->actions, op->lflow_ref); @@ -17293,7 +17285,7 @@ build_lflows_thread(void *arg) build_lswitch_and_lrouter_iterate_by_lrp(op, lsi); build_lbnat_lflows_iterate_by_lrp( op, lsi->lr_stateful_table, lsi->meter_groups, - lsi->bfd_connections, &lsi->match, &lsi->actions, + lsi->bfd_ports, &lsi->match, &lsi->actions, lsi->lflows); } } @@ -17434,7 +17426,7 @@ build_lswitch_and_lrouter_flows( const struct shash *meter_groups, const struct hmap *lb_dps_map, const struct hmap *svc_monitor_map, - const struct hmap *bfd_connections, + const struct sset *bfd_ports, const struct chassis_features *features, const char *svc_monitor_mac, const struct sampling_app_table *sampling_apps, @@ -17470,7 +17462,7 @@ build_lswitch_and_lrouter_flows( lsiv[index].meter_groups = meter_groups; lsiv[index].lb_dps_map = lb_dps_map; lsiv[index].svc_monitor_map = svc_monitor_map; - lsiv[index].bfd_connections = bfd_connections; + lsiv[index].bfd_ports = bfd_ports; lsiv[index].features = features; lsiv[index].svc_check_match = svc_check_match; lsiv[index].thread_lflow_counter = 0; @@ -17516,7 +17508,7 @@ build_lswitch_and_lrouter_flows( .meter_groups = meter_groups, .lb_dps_map = lb_dps_map, .svc_monitor_map = svc_monitor_map, - .bfd_connections = bfd_connections, + .bfd_ports = bfd_ports, .features = features, .svc_check_match = svc_check_match, .svc_monitor_mac = svc_monitor_mac, @@ -17556,7 +17548,7 @@ build_lswitch_and_lrouter_flows( build_lswitch_and_lrouter_iterate_by_lrp(op, &lsi); build_lbnat_lflows_iterate_by_lrp(op, lsi.lr_stateful_table, lsi.meter_groups, - lsi.bfd_connections, + lsi.bfd_ports, &lsi.match, &lsi.actions, lsi.lflows); @@ -17687,7 +17679,7 @@ void build_lflows(struct ovsdb_idl_txn *ovnsb_txn, input_data->meter_groups, input_data->lb_datapaths_map, input_data->svc_monitor_map, - input_data->bfd_connections, + input_data->bfd_ports, input_data->features, input_data->svc_monitor_mac, input_data->sampling_apps, @@ -18056,7 +18048,7 @@ lflow_handle_lr_stateful_changes(struct ovsdb_idl_txn *ovnsb_txn, build_lbnat_lflows_iterate_by_lrp(op, lflow_input->lr_stateful_table, lflow_input->meter_groups, - lflow_input->bfd_connections, + lflow_input->bfd_ports, &match, &actions, lflows); diff --git a/northd/northd.h b/northd/northd.h index 39a16c092..560e1bfe5 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -225,7 +225,7 @@ struct lflow_input { const struct ls_stateful_table *ls_stateful_table; const struct shash *meter_groups; const struct hmap *lb_datapaths_map; - const struct hmap *bfd_connections; + const struct sset *bfd_ports; const struct chassis_features *features; const struct hmap *svc_monitor_map; bool ovn_internal_version_changed;