From patchwork Fri Nov 18 16:20:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1705695 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=140.211.166.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=EE3pEgaG; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.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 4NDMVB2VKqz23mH for ; Sat, 19 Nov 2022 03:21:22 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B71E541A52; Fri, 18 Nov 2022 16:21:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B71E541A52 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=EE3pEgaG 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 HkavRYqiUl1s; Fri, 18 Nov 2022 16:21:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1C7CC41A2B; Fri, 18 Nov 2022 16:21:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 1C7CC41A2B Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D59B9C007B; Fri, 18 Nov 2022 16:21:15 +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 C199FC0085 for ; Fri, 18 Nov 2022 16:21:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id A82CA41A00 for ; Fri, 18 Nov 2022 16:21:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A82CA41A00 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 3EXRo2jIQ7i3 for ; Fri, 18 Nov 2022 16:21:10 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9A5C2419CC Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by smtp4.osuosl.org (Postfix) with ESMTPS id 9A5C2419CC for ; Fri, 18 Nov 2022 16:21:10 +0000 (UTC) Received: by mail-lj1-x22d.google.com with SMTP id d20so7330863ljc.12 for ; Fri, 18 Nov 2022 08:21:10 -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=EE3pEgaG1Av2jODd4RklBLebvzmb4/t5WvB3g+VwwVt5juBjO3mJT0qJVEHXlKsEYx m2DIRH8+k+H7L/tmqA0AmZZz+p6Z8+w4y0WilTXKdvZY7K4ERbdFzF4XElfo5+hDefJ6 vGn/X+P0+T1nR7idZS3NtKECt1udHNTTpAWJWalEAMLoXvdWaQ3QyfM86jN8NIRyOAeP jpdniMK/5OnP4yHR9GH//LGPFULVyaSNRvTPS23Ln7yzomTsxcVl1BzRt3zeuLU0PK7R vUNPAyB+YvHQEITw2ttrLfBf8cUNQFDa5KSvS68Tefrc8GWGyrxR3mDRU8EdJjzo5aOR DC/g== 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=hCRBwJsNxxyxHaVYM3gh4NonCdbYnQBSSbsuMFKBaAhTnV2hNiBlg4j4oOI0FmUGFF ezY7t2GXeRvn7ouxSyIkPKmSTNiEK4/yuhutTIsIeJp658Tj8jFcYvjFvyGio9u1bj5B qAzwDiTpn7iFYLfqhjOpwqQTpCkPDbuMY7kW1U0CD7+S9buUXrQMry2wtH2uMeG4b3GM my4cJHQeVYPvKAqn64VRLCYzMqY5eA7x06lRpL30YdhhYCEB8RGow69R/IqnWYdrf640 kH0qnjsDJYb7U2GY/KKy181o0H8WblUbzxB0kAHgydlvG7jKHVjjRnUENXnIis4A9NOl 90Hw== X-Gm-Message-State: ANoB5pleYcTEn2kD7UtMNCMFq2JqbTJtpoOi5VIgW9LWDRv/tqx0aIk9 KuW1BiUtiRFjIhgrb4r2ITmeUpeWklLo0A== X-Google-Smtp-Source: AA0mqf4H2fM3aC5rID8OoM/uTml1+cj3RXGm9BTbNto0K9EZRgDs6CMWNuh6lRlSl+axyfNj+Aj1BA== X-Received: by 2002:a05:651c:168d:b0:277:8a07:521c with SMTP id bd13-20020a05651c168d00b002778a07521cmr2592795ljb.335.1668788468244; Fri, 18 Nov 2022 08:21:08 -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 o16-20020ac25e30000000b0049465afdd38sm717538lfg.108.2022.11.18.08.21.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 08:21:07 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Fri, 18 Nov 2022 19:20:48 +0300 Message-Id: <20221118162050.3019353-6-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221118162050.3019353-1-odivlad@gmail.com> References: <20221118162050.3019353-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [OVN RFC 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);