From patchwork Fri Dec 2 17:31:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1711530 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::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cWW1Bogh; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NP0PR0Yl0z23nf for ; Sat, 3 Dec 2022 04:32:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 22FCF821FE; Fri, 2 Dec 2022 17:32:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 22FCF821FE Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cWW1Bogh 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 xprqc5pghJFI; Fri, 2 Dec 2022 17:32:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2E151821DB; Fri, 2 Dec 2022 17:32:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 2E151821DB Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EAE1EC0035; Fri, 2 Dec 2022 17:32:05 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id E6E30C007B for ; Fri, 2 Dec 2022 17:32:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id B650A61152 for ; Fri, 2 Dec 2022 17:32:03 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org B650A61152 Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=cWW1Bogh 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 CfDAmjf0YnOC for ; Fri, 2 Dec 2022 17:32:02 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 3D13460B8F Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by smtp3.osuosl.org (Postfix) with ESMTPS id 3D13460B8F for ; Fri, 2 Dec 2022 17:32:02 +0000 (UTC) Received: by mail-ej1-x62f.google.com with SMTP id ml11so13140641ejb.6 for ; Fri, 02 Dec 2022 09:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C3PouHVoNiOgH0VJEMVOujiTDRvkYQ/xhMys2jO/E5Q=; b=cWW1BoghrxFhATK7/0EQE6Kx536BJOyN69Pdfq0LLA2bT2LBMNn7WfqyRA3OGMzY2T SHywddeziNUOpaagkNcjFMmKjxhxB9Xx9LDAe5Xb44DZISWhdY8jcdqvBjFfWLKmui7D ZZ5/qb6+QXFzA/O9v0lwzSNOKm7fe5nr7xQPs61Bi76vs4yrgIOaBjLCMA5SkqTQvst7 5rqheQqsY4yuCoxgwcfdyI8/1um2Qyxk7nMc1qzbJgcMA6VijKh4PEzFjZKxFAFQySKn OeZLDYYEPW6ManA6OCBstP00+ddevdp9BmNzLwfTFpCchjvv2Jl2fZ1ys81yFlkuuxgm E3Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=C3PouHVoNiOgH0VJEMVOujiTDRvkYQ/xhMys2jO/E5Q=; b=h7xAWyvEyBQxyWxjwF6YEdDsr3ps1/vM/NvsWBYX5HCnhTVcIrc+i7gL/McwYvkBfA SAT5fYh47HvttJ6ZxOf6Us4SZAyftSBqwEQv8eVI+3lXPK4sOWaf6eUdwdsJbbcgnGpL xH/fnymG/YZBn5F8dcp4sWoXW4YWutM46I94Ryck1vlAv7fYpMO3miXsPM0yTHek4RJD rAi1q784iUibcTSu3GqOM5eADp6NUtiZJ+LFHDqFf4ix5Yhtd4I6ST7ov2I7lGb2T6qh I0M+RPgUDdNj6ajNc2kjYnD/sGkS5Rs85IwmPxk1/7fdAu3PK/X3Ffno+jX+cYEaGaNI HcWA== X-Gm-Message-State: ANoB5pl17BZSwa7vLTME96zJ0AS2S1ZUZZjxj5jZbNgkPMaXRkLu0LH2 r9Pc/25G7mvz/TbVPeiBGjuS+wEGjJslstjn X-Google-Smtp-Source: AA0mqf5ArFlrAZKkjFnghTH6sj3ALS75N5imTGuaZiK8Bskcce1cKq9BAzURDDwwndagrZIffOpIwQ== X-Received: by 2002:a17:906:b51:b0:7ad:da22:c396 with SMTP id v17-20020a1709060b5100b007adda22c396mr61615316ejg.653.1670002320059; Fri, 02 Dec 2022 09:32:00 -0800 (PST) Received: from ip-10-70-112-12.vpc-1e810be1.internal (c2-178-216-98-9.elastic.cloud.croc.ru. [178.216.98.9]) by smtp.gmail.com with ESMTPSA id c9-20020a170906762900b007be3aa82543sm3235776ejn.35.2022.12.02.09.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 09:31:59 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Fri, 2 Dec 2022 20:31:41 +0300 Message-Id: <20221202173147.3032702-2-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221202173147.3032702-1-odivlad@gmail.com> References: <20221202173147.3032702-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov , dragen15051@gmail.com Subject: [ovs-dev] [PATCH ovn 1/7] ic: move routes_ad hmap insert to separate function 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" This change will be useful in next commit. Signed-off-by: Vladislav Odintsov --- ic/ovn-ic.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index e5c193d9d..50ff65a26 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -881,10 +881,12 @@ ic_route_hash(const struct in6_addr *prefix, unsigned int plen, static struct ic_route_info * ic_route_find(struct hmap *routes, const struct in6_addr *prefix, unsigned int plen, const struct in6_addr *nexthop, - const char *origin, char *route_table) + const char *origin, const char *route_table, uint32_t hash) { struct ic_route_info *r; - uint32_t hash = ic_route_hash(prefix, plen, nexthop, origin, route_table); + if (!hash) { + hash = ic_route_hash(prefix, plen, nexthop, origin, route_table); + } HMAP_FOR_EACH_WITH_HASH (r, node, hash, routes) { if (ipv6_addr_equals(&r->prefix, prefix) && r->plen == plen && @@ -942,8 +944,8 @@ add_to_routes_learned(struct hmap *routes_learned, } const char *origin = smap_get_def(&nb_route->options, "origin", ""); if (ic_route_find(routes_learned, &prefix, plen, &nexthop, origin, - nb_route->route_table)) { - /* Route is already added to learned in previous iteration. */ + nb_route->route_table, 0)) { + /* Route was added to learned on previous iteration. */ return true; } @@ -1090,10 +1092,21 @@ route_need_advertise(const char *policy, } static void -add_to_routes_ad(struct hmap *routes_ad, - const struct nbrec_logical_router_static_route *nb_route, - const struct lport_addresses *nexthop_addresses, - const struct smap *nb_options, const char *route_table) +add_to_routes_ad(struct hmap *routes_ad, struct ic_route_info *ic_route) +{ + uint hash = ic_route_hash(&ic_route->prefix, ic_route->plen, + &ic_route->nexthop, ic_route->origin, + ic_route->route_table ? ic_route->route_table + : ""); + hmap_insert(routes_ad, &ic_route->node, hash); +} + +static void +add_static_to_routes_ad( + struct hmap *routes_ad, + const struct nbrec_logical_router_static_route *nb_route, + const struct lport_addresses *nexthop_addresses, + const struct smap *nb_options, const char *route_table) { if (strcmp(route_table, nb_route->route_table)) { if (VLOG_IS_DBG_ENABLED()) { @@ -1149,9 +1162,7 @@ add_to_routes_ad(struct hmap *routes_ad, ic_route->nb_route = nb_route; ic_route->origin = ROUTE_ORIGIN_STATIC; ic_route->route_table = nb_route->route_table; - hmap_insert(routes_ad, &ic_route->node, - ic_route_hash(&prefix, plen, &nexthop, ROUTE_ORIGIN_STATIC, - nb_route->route_table)); + add_to_routes_ad(routes_ad, ic_route); } static void @@ -1204,9 +1215,7 @@ add_network_to_routes_ad(struct hmap *routes_ad, const char *network, /* directly-connected routes go to
route table */ ic_route->route_table = NULL; - hmap_insert(routes_ad, &ic_route->node, - ic_route_hash(&prefix, plen, &nexthop, - ROUTE_ORIGIN_CONNECTED, "")); + add_to_routes_ad(routes_ad, ic_route); } static bool @@ -1366,7 +1375,7 @@ sync_learned_routes(struct ic_context *ctx, struct ic_route_info *route_learned = ic_route_find(&ic_lr->routes_learned, &prefix, plen, &nexthop, isb_route->origin, - isb_route->route_table); + isb_route->route_table, 0); if (route_learned) { /* Sync external-ids */ struct uuid ext_id; @@ -1465,7 +1474,7 @@ advertise_routes(struct ic_context *ctx, } struct ic_route_info *route_adv = ic_route_find(routes_ad, &prefix, plen, &nexthop, - isb_route->origin, isb_route->route_table); + isb_route->origin, isb_route->route_table, 0); if (!route_adv) { /* Delete the extra route from IC-SB. */ VLOG_DBG("Delete route %s -> %s from IC-SB, which is not found" @@ -1547,8 +1556,8 @@ build_ts_routes_to_adv(struct ic_context *ctx, } } else { /* It may be a route to be advertised */ - add_to_routes_ad(routes_ad, nb_route, ts_port_addrs, - &nb_global->options, ts_route_table); + add_static_to_routes_ad(routes_ad, nb_route, ts_port_addrs, + &nb_global->options, ts_route_table); } }