From patchwork Fri Dec 2 17:31:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1711534 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=) 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=UHuzxP1v; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NP0Pj6lrMz23n4 for ; Sat, 3 Dec 2022 04:32:25 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 020C041D12; Fri, 2 Dec 2022 17:32:23 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 020C041D12 Authentication-Results: smtp4.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=UHuzxP1v 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 ZZ_Q7i5QVTKy; Fri, 2 Dec 2022 17:32:22 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id A7A9C41D2B; Fri, 2 Dec 2022 17:32:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A7A9C41D2B Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 79B44C0033; Fri, 2 Dec 2022 17:32:20 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 21D5CC0078 for ; Fri, 2 Dec 2022 17:32:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 55D73821C8 for ; Fri, 2 Dec 2022 17:32:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 55D73821C8 Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=UHuzxP1v 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 y6xZWl7ovPDr for ; Fri, 2 Dec 2022 17:32:11 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 7AE3682217 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by smtp1.osuosl.org (Postfix) with ESMTPS id 7AE3682217 for ; Fri, 2 Dec 2022 17:32:11 +0000 (UTC) Received: by mail-ej1-x631.google.com with SMTP id o13so13156629ejm.1 for ; Fri, 02 Dec 2022 09:32:11 -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=iPuRNWahIvsVuJ4p9i3UIqHS+U5YuEN8nNCbxqXH7F4=; b=UHuzxP1vicDOPvUP0rc1lmQatQiO110SwRBhSqWIDQJVxlpLjZvqUU1DAxdAzYCQTa z7AD6gBI9ByRtue+ZsAEPB6+ufNOuSQVjTxvj7KcNCYe8PzuarnJs/ZS6X+KkZQmWAU8 zvacZ8H5S6BiQmnVGBZarw8dcVql0aJU/NqyAOivOlM14rDPC2Npv902JTjzNB9DpJdN 581dMkttY9FZv8xEH7h93bW4a/Lpb4D2wax83XVlVHa+OFTfyPmiG2/nTybDoB0CaPEa cBxmx1Y2tNE2WstKIP+qWEFfulBopRpelPUprNV4awd8A8ekpg36+UMfpTRYfRaoJzaY +gMA== 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=iPuRNWahIvsVuJ4p9i3UIqHS+U5YuEN8nNCbxqXH7F4=; b=NaW6rM+xlabRtaUF5t2ps782gc/HBMWJV1rV6BglTRkB8Obj81UddcZN8SuwBTSSud nKR5U4bk6Obg09HNo9VAN/73DOiB5+xU8nEYpO44HOzPaBBt+l2wISVSpyLxvQllnn/8 wh2+urt7cHYUerpLPPaZ6GSiaL0EfrsyVpozPB5MCO4d8XMuuV1jo2LqZ1WGCSz699+M mnQd1FIJnun3PYiPbuzMKR7DQGy3rROkyQmljiI0unQby9tgu0drg+wwLmKz5AGM1D9k Kmc8dsATIi58+QYktk0DdGSl31GnEEgigt6EZTxaCy/f9LBeG/CedUPojMVrfPJZ3Dy1 of2w== X-Gm-Message-State: ANoB5ploes+xrlcLyEYEk0dv1qWbFzgvusDOhTYqEarFLEadEr+Fb3rg VPnMXnoPoNCEyp3F2QEo7OQEJbrQu1zTajfD X-Google-Smtp-Source: AA0mqf60BJm7m2Q56UMcBIWHoT6jK38jMGcREWrDTS6d1XQ32rR8/2QBxTcU8cZ5rKc3t1D8YSYoPg== X-Received: by 2002:a17:907:6d12:b0:7b2:bb8c:5398 with SMTP id sa18-20020a1709076d1200b007b2bb8c5398mr49072461ejc.573.1670002329403; Fri, 02 Dec 2022 09:32:09 -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.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 09:32:09 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Fri, 2 Dec 2022 20:31:45 +0300 Message-Id: <20221202173147.3032702-6-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 5/7] ic: minor code improvements 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" 1. Remove excess nbrec_logical_router variable. 2. Remove excess call to add_static_to_routes_ad(). 3. Remove double route_table check in ic_route_fin(). 4. Move variable declarations out of loop. Signed-off-by: Vladislav Odintsov --- ic/ovn-ic.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 3e02b4c98..59468545d 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -895,8 +895,7 @@ ic_route_find(struct hmap *routes, const struct in6_addr *prefix, r->plen == plen && ipv6_addr_equals(&r->nexthop, nexthop) && !strcmp(r->origin, origin) && - !strcmp(r->route_table ? r->route_table : "", route_table) && - ipv6_addr_equals(&r->nexthop, nexthop)) { + !strcmp(r->route_table ? r->route_table : "", route_table)) { return r; } } @@ -1109,17 +1108,8 @@ 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) + const struct smap *nb_options) { - if (strcmp(route_table, nb_route->route_table)) { - if (VLOG_IS_DBG_ENABLED()) { - VLOG_DBG("Skip advertising route %s -> %s as its route table %s !=" - " %s of TS port", nb_route->ip_prefix, nb_route->nexthop, - nb_route->route_table, route_table); - } - return; - } - struct in6_addr prefix, nexthop; unsigned int plen; if (!parse_route(nb_route->ip_prefix, nb_route->nexthop, @@ -1541,13 +1531,13 @@ build_ts_routes_to_adv(struct ic_context *ctx, { const struct nbrec_logical_router *lr = ic_lr->lr; + const struct nbrec_logical_router_static_route *nb_route; + struct uuid id; + /* Check static routes of the LR */ for (int i = 0; i < lr->n_static_routes; i++) { - const struct nbrec_logical_router_static_route *nb_route - = lr->static_routes[i]; - struct uuid isb_uuid; - if (smap_get_uuid(&nb_route->external_ids, "ic-learned-route", - &isb_uuid)) { + nb_route = lr->static_routes[i]; + if (smap_get_uuid(&nb_route->external_ids, "ic-learned-route", &id)) { /* It is a learned route */ if (!add_to_routes_learned(&ic_lr->routes_learned, nb_route)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); @@ -1557,10 +1547,10 @@ build_ts_routes_to_adv(struct ic_context *ctx, nbrec_logical_router_update_static_routes_delvalue(lr, nb_route); } - } else { + } else if (!strcmp(ts_route_table, nb_route->route_table)) { /* It may be a route to be advertised */ add_static_to_routes_ad(routes_ad, nb_route, ts_port_addrs, - &nb_global->options, ts_route_table); + &nb_global->options); } } @@ -1593,7 +1583,6 @@ advertise_lr_routes(struct ic_context *ctx, const struct icsbrec_port_binding *isb_pb; const char *lrp_name, *ts_name, *route_table; struct lport_addresses ts_port_addrs; - const struct nbrec_logical_router *lr = ic_lr->lr; const struct icnbrec_transit_switch *key; struct hmap routes_ad = HMAP_INITIALIZER(&routes_ad); @@ -1611,7 +1600,7 @@ advertise_lr_routes(struct ic_context *ctx, VLOG_INFO_RL(&rl, "Route sync ignores port %s on ts %s for router" " %s because the addresses are invalid.", isb_pb->logical_port, isb_pb->transit_switch, - lr->name); + ic_lr->lr->name); continue; } lrp_name = get_lrp_name_by_ts_port_name(ctx, isb_pb->logical_port);