From patchwork Tue Dec 6 10:19:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1712643 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::136; helo=smtp3.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=TENX3bTb; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRGdq41QRz23ys for ; Tue, 6 Dec 2022 21:20:47 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6635D60FA5; Tue, 6 Dec 2022 10:20:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6635D60FA5 Authentication-Results: smtp3.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=TENX3bTb 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 uxiod2siCjlh; Tue, 6 Dec 2022 10:20:42 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 58FE760F8F; Tue, 6 Dec 2022 10:20:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 58FE760F8F Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6CF7FC0085; Tue, 6 Dec 2022 10:20:39 +0000 (UTC) X-Original-To: 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 C8BF3C002D for ; Tue, 6 Dec 2022 10:20:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A446440150 for ; Tue, 6 Dec 2022 10:20:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A446440150 Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=TENX3bTb X-Virus-Scanned: amavisd-new at osuosl.org 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 Zre-1bBTHcUH for ; Tue, 6 Dec 2022 10:20:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 2206E4062A Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by smtp2.osuosl.org (Postfix) with ESMTPS id 2206E4062A for ; Tue, 6 Dec 2022 10:20:36 +0000 (UTC) Received: by mail-lf1-x12c.google.com with SMTP id j4so22957625lfk.0 for ; Tue, 06 Dec 2022 02:20:35 -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=zTnBmdWPe+s5tnfrgS98CYt2rvDsV5uX8qYTfp4rKug=; b=TENX3bTbnBx6sKIH3/uuVZzNOL225ByDx3lzQkGQ/0+XYHfsgJHkSBGU+NbsJp7o3O Rer8z7J93XJtzjqtJoHuIo6f0O7Sn8k7OY0Y/JUNAhKTX+bIk9a3PZ9IWQI4YDO8OOLP TCnXD0zx/M8MnoFtEqG5CpwCRyjk7DSZ4ip9fJPtrg38zMiKnHb2BdXBefOVjopK4JZM V78obNnUGOiJQE1gCVUg7NbLWtiBcIMAQFGTl67BjcpPllrawJYZHdqA91LgKACryMPq WAri/9rzseLWzPKK56fDL+rD2iZ0Ab0+WmBYtZmX6z9VuNQrgJwrAb2Pwr7eUJ2b/P3A E15A== 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=zTnBmdWPe+s5tnfrgS98CYt2rvDsV5uX8qYTfp4rKug=; b=D2a5Q4zvgEuU4h6spajn/nqfmVUHJ7kuXyhyPN50fRX/5yx9CMeBN7gpIu1QBIWYQv DNnRXEvulo47d749piKvwXBwU6LEQPJqTB90HF/sM37pBkGbQdO359Tb1qvOVir32W4I SwKy8BQxkjxuM2Zp98e5wAJ4QqOby2WEb5h/7x465lwjBJl1BIuPmTi5flMxLUOjy7bH c48aHFNg5FCuzz9lH/2Paa0ywGpqYxUAmz5B1KDGko2vuFwMx3ua9HP5ieUllxkdG2/P Ih6/1+D7Gznjuu03dm2IJN0RKQb8HsviVVohh85yYyV3t6hhNwygE9U5HOVHkd8FrdFT yXlA== X-Gm-Message-State: ANoB5plFjnLmFG2EbMWmyNmVuU/riZ/pkuJ9w5zGh4vf0Qx43oMooIju r1sNMXNuVRaxJLC5InIGaL1ddJtvPDZaiN9u X-Google-Smtp-Source: AA0mqf4fMWG/z8otEHqF36Q3tMw5dEbD6IMOjERoxBvEobIIwo+aeyWgzAUJhDsou4RGaGSKK2cDPA== X-Received: by 2002:ac2:5331:0:b0:4ab:35a8:2fa0 with SMTP id f17-20020ac25331000000b004ab35a82fa0mr28631401lfh.233.1670322033630; Tue, 06 Dec 2022 02:20:33 -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 m1-20020a056512114100b004b515f9d117sm2409614lfg.271.2022.12.06.02.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 02:20:33 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Tue, 6 Dec 2022 13:19:58 +0300 Message-Id: <20221206102001.3058710-2-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221206102001.3058710-1-odivlad@gmail.com> References: <20221206102001.3058710-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov , dragen15051@gmail.com Subject: [ovs-dev] [PATCH ovn v2 1/4] ic: remove orphan ovn interconnection routes 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" Before this patch if one deletes transit switch through which there were routes in ICSB:Route table, such routes were left forever in the DB. Now we validate that each ICSB:Route has an appropriate transit switch. Signed-off-by: Vladislav Odintsov Acked-by: Dumitru Ceara --- ic/ovn-ic.c | 40 +++++++++++++++++++++++++++ tests/ovn-ic.at | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index e5c193d9d..d3bc08761 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -71,6 +71,7 @@ struct ic_context { struct ovsdb_idl_index *icsbrec_port_binding_by_az; struct ovsdb_idl_index *icsbrec_port_binding_by_ts; struct ovsdb_idl_index *icsbrec_port_binding_by_ts_az; + struct ovsdb_idl_index *icsbrec_route_by_az; struct ovsdb_idl_index *icsbrec_route_by_ts; struct ovsdb_idl_index *icsbrec_route_by_ts_az; }; @@ -1612,6 +1613,38 @@ advertise_lr_routes(struct ic_context *ctx, hmap_destroy(&routes_ad); } +static void +delete_orphan_ic_routes(struct ic_context *ctx, + const struct icsbrec_availability_zone *az) +{ + const struct icsbrec_route *isb_route, *isb_route_key = + icsbrec_route_index_init_row(ctx->icsbrec_route_by_az); + icsbrec_route_index_set_availability_zone(isb_route_key, az); + + const struct icnbrec_transit_switch *t_sw, *t_sw_key; + + ICSBREC_ROUTE_FOR_EACH_EQUAL (isb_route, isb_route_key, + ctx->icsbrec_route_by_az) + { + t_sw_key = icnbrec_transit_switch_index_init_row( + ctx->icnbrec_transit_switch_by_name); + icnbrec_transit_switch_index_set_name(t_sw_key, + isb_route->transit_switch); + t_sw = icnbrec_transit_switch_index_find( + ctx->icnbrec_transit_switch_by_name, t_sw_key); + icnbrec_transit_switch_index_destroy_row(t_sw_key); + + if (!t_sw) { + VLOG_WARN("Deleting orphan ICDB:Route: %s->%s (%s, rtb:%s, " + "transit switch: %s)", isb_route->ip_prefix, + isb_route->nexthop, isb_route->origin, + isb_route->route_table, isb_route->transit_switch); + icsbrec_route_delete(isb_route); + } + } + icsbrec_route_index_destroy_row(isb_route_key); +} + static void route_run(struct ic_context *ctx, const struct icsbrec_availability_zone *az) @@ -1620,6 +1653,8 @@ route_run(struct ic_context *ctx, return; } + delete_orphan_ic_routes(ctx, az); + struct hmap ic_lrs = HMAP_INITIALIZER(&ic_lrs); const struct icsbrec_port_binding *isb_pb; const struct icsbrec_port_binding *isb_pb_key = @@ -1908,6 +1943,10 @@ main(int argc, char *argv[]) &icsbrec_port_binding_col_transit_switch, &icsbrec_port_binding_col_availability_zone); + struct ovsdb_idl_index *icsbrec_route_by_az + = ovsdb_idl_index_create1(ovnisb_idl_loop.idl, + &icsbrec_route_col_availability_zone); + struct ovsdb_idl_index *icsbrec_route_by_ts = ovsdb_idl_index_create1(ovnisb_idl_loop.idl, &icsbrec_route_col_transit_switch); @@ -1962,6 +2001,7 @@ main(int argc, char *argv[]) .icsbrec_port_binding_by_az = icsbrec_port_binding_by_az, .icsbrec_port_binding_by_ts = icsbrec_port_binding_by_ts, .icsbrec_port_binding_by_ts_az = icsbrec_port_binding_by_ts_az, + .icsbrec_route_by_az = icsbrec_route_by_az, .icsbrec_route_by_ts = icsbrec_route_by_ts, .icsbrec_route_by_ts_az = icsbrec_route_by_ts_az, }; diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at index 0bdfc55e6..e234b7fb9 100644 --- a/tests/ovn-ic.at +++ b/tests/ovn-ic.at @@ -121,6 +121,79 @@ OVN_CLEANUP_IC AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([ovn-ic -- route deletion upon TS deletion]) + +ovn_init_ic_db +net_add n1 + +# 1 GW per AZ +for i in 1 2; do + az=az$i + ovn_start $az + sim_add gw-$az + as gw-$az + check ovs-vsctl add-br br-phys + ovn_az_attach $az n1 br-phys 192.168.1.$i + check ovs-vsctl set open . external-ids:ovn-is-interconn=true + check ovn-nbctl set nb-global . \ + options:ic-route-adv=true \ + options:ic-route-adv-default=true \ + options:ic-route-learn=true \ + options:ic-route-learn-default=true +done + +create_ic_infra() { + az_id=$1 + ts_id=$2 + az=az$i + + lsp=lsp${az_id}-${ts_id} + lrp=lrp${az_id}-${ts_id} + ts=ts${az_id}-${ts_id} + lr=lr${az_id}-${ts_id} + + ovn_as $az + + check ovn-ic-nbctl ts-add $ts + check ovn-nbctl lr-add $lr + check ovn-nbctl lrp-add $lr $lrp 00:00:00:00:00:0$az_id 10.0.$az_id.1/24 + check ovn-nbctl lrp-set-gateway-chassis $lrp gw-$az + + check ovn-nbctl lsp-add $ts $lsp -- \ + lsp-set-addresses $lsp router -- \ + lsp-set-type $lsp router -- \ + lsp-set-options $lsp router-port=$lrp + + check ovn-nbctl lr-route-add $lr 192.168.0.0/16 10.0.$az_id.10 +} + +create_ic_infra 1 1 +create_ic_infra 1 2 +create_ic_infra 2 1 + +ovn_as az1 + +wait_row_count ic-sb:Route 3 ip_prefix=192.168.0.0/16 + +# remove transit switch 1 (from az1) and check if its route is deleted +# same route from another AZ and ts should remain, as +check ovn-ic-nbctl ts-del ts1-1 +sleep 2 +ovn-ic-sbctl list route +ovn-ic-nbctl list transit_switch +wait_row_count ic-sb:route 2 ip_prefix=192.168.0.0/16 +ovn-ic-sbctl list route + +for i in 1 2; do + az=az$i + OVN_CLEANUP_SBOX(gw-$az) + OVN_CLEANUP_AZ([$az]) +done +OVN_CLEANUP_IC +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([ovn-ic -- gateway sync]) From patchwork Tue Dec 6 10:19:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1712644 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.133; helo=smtp2.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=lHSR3Io/; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 4NRGdr1cT3z23yt for ; Tue, 6 Dec 2022 21:20:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 992A340917; Tue, 6 Dec 2022 10:20:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 992A340917 Authentication-Results: smtp2.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=lHSR3Io/ X-Virus-Scanned: amavisd-new at osuosl.org 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 xdBOtBzMHdWw; Tue, 6 Dec 2022 10:20:44 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id E95FF40904; Tue, 6 Dec 2022 10:20:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E95FF40904 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 31CB4C0089; Tue, 6 Dec 2022 10:20:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id F389CC002D for ; Tue, 6 Dec 2022 10:20:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id BFA4B81E16 for ; Tue, 6 Dec 2022 10:20:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org BFA4B81E16 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=lHSR3Io/ 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 IHNGj26Z7n1A for ; Tue, 6 Dec 2022 10:20:38 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A39B881E0F Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by smtp1.osuosl.org (Postfix) with ESMTPS id A39B881E0F for ; Tue, 6 Dec 2022 10:20:37 +0000 (UTC) Received: by mail-lj1-x22e.google.com with SMTP id n1so16687175ljg.3 for ; Tue, 06 Dec 2022 02:20:37 -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=wEk+y1SQsVB3lo4t7Zk4gQSQWzdir0T0vVb/b9ZhhnE=; b=lHSR3Io/O730vWUdTHXfzvjMkm8Ohgz9a8ivDdLszd7KDI+f2kFyleek9vHR6N5YnJ udq/KcISzGqvECnF1NOTlldYMuPo6qsuq/z6NoEGiDMbF9qcONuqQ8Cf2JEJvxBaJ7fp HIhfyXIJdinm0O76KzSicLJd/jaus+UjW4zAme3jnZK6fLxNsuZlk0RXAL2RNdQXFN+I TxzgrFn7ZN0ZSXpbjUK2o1I8p28mSfz1AElgxd2yQdzVUhmUmkvwzspdXhnouObatBwF clBayKwj5x3yZr9yX2V9fHSLdpqgLt4JZMZtDGtObfbQ6QFIFncqM1lP+YW0ZzhomJ6a 0yxw== 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=wEk+y1SQsVB3lo4t7Zk4gQSQWzdir0T0vVb/b9ZhhnE=; b=ivqrKJyLPIV7VeWinAYOR7eYb5cuF9wQTYWCDsnkeQDwb23zBEqbKwjqmmWIdjhmoM jhaVUQrucbfucBifQQAzCagFgJAqNh+/oZHLcm8S2xr13TADA0a2pyG/StN9shoUaavf /3UiyPmVWoQ58DnkJqpQF1rUaqB7/ksKYzqG2Af7pL4toWYL/0B3ZXLZt7RrLvF8QuiW S6O+p+wg1CdbKgPq6e/45z0VvPOM1vN9dyUDSfwgXTzLz5YG7xJfETHMN+TCceZC+BTU fKxiImk+Tah5wtpC3CoaOnh5E3DhrC0GJk2yPPmvsaR6dz8s2H/OixfCiHjQ97Non1NZ YKBQ== X-Gm-Message-State: ANoB5pmLkzIbrIKsSSTXptGLz7SAFDsgz5qXLngiqqeobyNm7VwjETbB EdZEe9Sn1gMEeVzfTInnnASB1sFaddMkKvfE X-Google-Smtp-Source: AA0mqf4sDgbH2TQdRRNY/EVriapC5MzAsQHNXW7E7fBjRO8kug4ZDIVWd6WuVlz/gzw4rgoPnEzoOw== X-Received: by 2002:a05:651c:4d0:b0:27a:b1d:5662 with SMTP id e16-20020a05651c04d000b0027a0b1d5662mr1216912lji.356.1670322035051; Tue, 06 Dec 2022 02:20:35 -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 m1-20020a056512114100b004b515f9d117sm2409614lfg.271.2022.12.06.02.20.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 02:20:34 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Tue, 6 Dec 2022 13:19:59 +0300 Message-Id: <20221206102001.3058710-3-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221206102001.3058710-1-odivlad@gmail.com> References: <20221206102001.3058710-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Dumitru Ceara , Vladislav Odintsov , dragen15051@gmail.com Subject: [ovs-dev] [PATCH ovn v2 2/4] ic: lookup southbound port_binding only if needed 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" Signed-off-by: Vladislav Odintsov Acked-by: Dumitru Ceara --- ic/ovn-ic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index d3bc08761..9e2369fef 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -757,6 +757,7 @@ port_binding_run(struct ic_context *ctx, } icsbrec_port_binding_index_destroy_row(isb_pb_key); + const struct sbrec_port_binding *sb_pb; const struct icnbrec_transit_switch *ts; ICNBREC_TRANSIT_SWITCH_FOR_EACH (ts, ctx->ovninb_idl) { const struct nbrec_logical_switch *ls = find_ts_in_nb(ctx, ts->name); @@ -788,9 +789,9 @@ port_binding_run(struct ic_context *ctx, for (int i = 0; i < ls->n_ports; i++) { lsp = ls->ports[i]; - const struct sbrec_port_binding *sb_pb = find_lsp_in_sb(ctx, lsp); if (!strcmp(lsp->type, "router")) { /* The port is local. */ + sb_pb = find_lsp_in_sb(ctx, lsp); if (!sb_pb) { continue; } @@ -807,6 +808,7 @@ port_binding_run(struct ic_context *ctx, if (!isb_pb) { nbrec_logical_switch_update_ports_delvalue(ls, lsp); } else { + sb_pb = find_lsp_in_sb(ctx, lsp); if (!sb_pb) { continue; } From patchwork Tue Dec 6 10:20:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1712645 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::136; helo=smtp3.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=aELjyzNj; 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRGdt4Gdtz23ys for ; Tue, 6 Dec 2022 21:20:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A77BD60FA0; Tue, 6 Dec 2022 10:20:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A77BD60FA0 Authentication-Results: smtp3.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=aELjyzNj 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 3OPdbedQWF9Q; Tue, 6 Dec 2022 10:20:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9369460FAC; Tue, 6 Dec 2022 10:20:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9369460FAC Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E27EEC0071; Tue, 6 Dec 2022 10:20:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id EF2BFC0071 for ; Tue, 6 Dec 2022 10:20:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id B269A415F4 for ; Tue, 6 Dec 2022 10:20:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B269A415F4 Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=aELjyzNj 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 hGiR69Xokzy6 for ; Tue, 6 Dec 2022 10:20:39 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 36717415DA Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by smtp4.osuosl.org (Postfix) with ESMTPS id 36717415DA for ; Tue, 6 Dec 2022 10:20:39 +0000 (UTC) Received: by mail-lj1-x233.google.com with SMTP id z4so16683476ljq.6 for ; Tue, 06 Dec 2022 02:20:39 -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=9s9b1nZsCdUoSlcybylIDAcTZmH5AhF6DtN9ksjUXMA=; b=aELjyzNji336BjEUEmStgTc0fmO7tU80MwElryUAzLt9C9sOotuCPxg/FWhDFURRgv rRI9q8wT0DTHzpazt7W/vEwxaOraDZuONf8PPuqBN6l/a0rVbO+0QQTHi0zp+YuJKDuD IeyUAbp88DoNfwTFr6xTnOIWxT8dIDpa/0XHjJ/gY+XBn1Xa/2XwBV9IaJ1c9YYX448f PxyBB8AM8ITTk1uzU7oOjJP8nI4zyIPwtU+g7NpcBkoXqeOedrsbUEubbKdlY44X+7y4 fPkpmuqE6P1SPxwzk5bKMnXLaGvvQ2HHzv7g7hhxvtbDJ/N1iPniEg60atLKnnPv+blb rZMg== 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=9s9b1nZsCdUoSlcybylIDAcTZmH5AhF6DtN9ksjUXMA=; b=B+riasQVFvBKdy9bntpwgUq9czpuCcNxqaSZCZThe8BwJyLyvw2NMFZZkAoSyIJRNY l62JBckoSNliL8gFsfCXJn7Z6pMWpOGa48dd9W9d3xU/QCUhNwiiJOsJaBKgYFOpPbTm TGCvCFAqKmgHcFoB8ZiJOJlTE1+BeV973zaCTOGIVB10uctPKY/8rOVXnthwAuDHdIRY DpzagM3v50V/01U+OWkaCdrlzx1XJt+0wvpNlyfWGSQrqx/WgrJ+uiNabGeoP0YiCyux oXZMmEzISg8svEEvlesqOs0IYCutv2LdBpN+ONypjGodiL+5WLLV2afgwl4DztuFxk0N k3nw== X-Gm-Message-State: ANoB5pk7z+KTt31ShjSqEMnE7U4JYOlT/OrwLAWhw7SZCpp4pk7lomBm wFAx7rtfBkLKX+DVCcLQOjKf5k29FQMn/pCz X-Google-Smtp-Source: AA0mqf44YCNfYcAeJuj/926wKL2kgKt4SYzoZOq9nf0+40qiveJE+I1tX/Zmd82W8WwtPuXF+51zQA== X-Received: by 2002:a05:651c:12c1:b0:277:2fd5:482 with SMTP id 1-20020a05651c12c100b002772fd50482mr23352195lje.194.1670322036445; Tue, 06 Dec 2022 02:20:36 -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 m1-20020a056512114100b004b515f9d117sm2409614lfg.271.2022.12.06.02.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 02:20:36 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Tue, 6 Dec 2022 13:20:00 +0300 Message-Id: <20221206102001.3058710-4-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221206102001.3058710-1-odivlad@gmail.com> References: <20221206102001.3058710-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov , dragen15051@gmail.com Subject: [ovs-dev] [PATCH ovn v2 3/4] ic: prevent advertising/learning multiple same routes 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" Signed-off-by: Vladislav Odintsov --- ic/ovn-ic.c | 83 +++++++++++++++++++++++++++------------------ ovn-ic-sb.ovsschema | 6 ++-- tests/ovn-ic.at | 60 ++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 35 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 9e2369fef..64307d8c4 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -884,10 +884,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 && @@ -945,8 +947,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; } @@ -1093,10 +1095,42 @@ 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, const struct in6_addr prefix, + unsigned int plen, const struct in6_addr nexthop, + const char *origin, const char *route_table, + const struct nbrec_logical_router_port *nb_lrp, + const struct nbrec_logical_router_static_route *nb_route) +{ + if (route_table == NULL) { + route_table = ""; + } + + uint hash = ic_route_hash(&prefix, plen, &nexthop, origin, route_table); + + if (!ic_route_find(routes_ad, &prefix, plen, &nexthop, origin, route_table, + hash)) { + struct ic_route_info *ic_route = xzalloc(sizeof *ic_route); + ic_route->prefix = prefix; + ic_route->plen = plen; + ic_route->nexthop = nexthop; + ic_route->nb_route = nb_route; + ic_route->origin = origin; + ic_route->route_table = route_table; + ic_route->nb_lrp = nb_lrp; + hmap_insert(routes_ad, &ic_route->node, hash); + } else { + VLOG_WARN("Duplicate route advertisement was suppressed! NB route " + "uuid: "UUID_FMT, + UUID_ARGS(&nb_route->header_.uuid)); + } +} + +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()) { @@ -1145,16 +1179,8 @@ add_to_routes_ad(struct hmap *routes_ad, ds_destroy(&msg); } - struct ic_route_info *ic_route = xzalloc(sizeof *ic_route); - ic_route->prefix = prefix; - ic_route->plen = plen; - ic_route->nexthop = nexthop; - 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, prefix, plen, nexthop, ROUTE_ORIGIN_STATIC, + nb_route->route_table, NULL, nb_route); } static void @@ -1198,18 +1224,9 @@ add_network_to_routes_ad(struct hmap *routes_ad, const char *network, ds_destroy(&msg); } - struct ic_route_info *ic_route = xzalloc(sizeof *ic_route); - ic_route->prefix = prefix; - ic_route->plen = plen; - ic_route->nexthop = nexthop; - ic_route->nb_lrp = nb_lrp; - ic_route->origin = ROUTE_ORIGIN_CONNECTED; - /* 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, prefix, plen, nexthop, ROUTE_ORIGIN_CONNECTED, + NULL, nb_lrp, NULL); } static bool @@ -1369,7 +1386,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; @@ -1468,7 +1485,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" @@ -1550,8 +1567,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); } } diff --git a/ovn-ic-sb.ovsschema b/ovn-ic-sb.ovsschema index 72c9d3f3e..1d60b36d1 100644 --- a/ovn-ic-sb.ovsschema +++ b/ovn-ic-sb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_IC_Southbound", - "version": "1.1.0", - "cksum": "2309827842 6784", + "version": "1.1.1", + "cksum": "3684563024 6914", "tables": { "IC_SB_Global": { "columns": { @@ -101,6 +101,8 @@ "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}, + "indexes": [["transit_switch", "availability_zone", "route_table", + "ip_prefix", "nexthop"]], "isRoot": true}, "Connection": { "columns": { diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at index e234b7fb9..ceee45092 100644 --- a/tests/ovn-ic.at +++ b/tests/ovn-ic.at @@ -194,6 +194,66 @@ OVN_CLEANUP_IC AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([ovn-ic -- duplicate NB route adv/learn]) + +ovn_init_ic_db +net_add n1 + +# 1 GW per AZ +for i in 1 2; do + az=az$i + ovn_start $az + sim_add gw-$az + as gw-$az + check ovs-vsctl add-br br-phys + ovn_az_attach $az n1 br-phys 192.168.1.$i + check ovs-vsctl set open . external-ids:ovn-is-interconn=true + check ovn-nbctl set nb-global . \ + options:ic-route-adv=true \ + options:ic-route-adv-default=true \ + options:ic-route-learn=true \ + options:ic-route-learn-default=true +done + +ovn_as az1 + +# create transit switch and connect to LR +check ovn-ic-nbctl ts-add ts1 +for i in 1 2; do + ovn_as az$i + + check ovn-nbctl lr-add lr1 + check ovn-nbctl lrp-add lr1 lrp$i 00:00:00:00:0$i:01 10.0.$i.1/24 + check ovn-nbctl lrp-set-gateway-chassis lrp$i gw-az$i + + check ovn-nbctl lsp-add ts1 lsp$i -- \ + lsp-set-addresses lsp$i router -- \ + lsp-set-type lsp$i router -- \ + lsp-set-options lsp$i router-port=lrp$i +done + +ovn_as az1 + +ovn-nbctl \ + --id=@id create logical-router-static-route ip_prefix=1.1.1.1/32 nexthop=10.0.1.10 -- \ + add logical-router lr1 static_routes @id +ovn-nbctl \ + --id=@id create logical-router-static-route ip_prefix=1.1.1.1/32 nexthop=10.0.1.10 -- \ + add logical-router lr1 static_routes @id + +wait_row_count ic-sb:route 1 ip_prefix=1.1.1.1/32 + +for i in 1 2; do + az=az$i + OVN_CLEANUP_SBOX(gw-$az) + OVN_CLEANUP_AZ([$az]) +done + +OVN_CLEANUP_IC +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([ovn-ic -- gateway sync]) From patchwork Tue Dec 6 10:20:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1712646 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.136; helo=smtp3.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=gIsXGyvu; dkim-atps=neutral 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRGdy0cdQz23ys for ; Tue, 6 Dec 2022 21:20:54 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 41CD360FBB; Tue, 6 Dec 2022 10:20:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 41CD360FBB Authentication-Results: smtp3.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=gIsXGyvu 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 kYCslyW7K1vh; Tue, 6 Dec 2022 10:20:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6137E60FB8; Tue, 6 Dec 2022 10:20:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 6137E60FB8 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CABF0C0083; Tue, 6 Dec 2022 10:20:43 +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 146D3C002D for ; Tue, 6 Dec 2022 10:20:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D382981E3E for ; Tue, 6 Dec 2022 10:20:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D382981E3E 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=gIsXGyvu 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 pKzLehtcDlWf for ; Tue, 6 Dec 2022 10:20:40 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 6228381E20 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by smtp1.osuosl.org (Postfix) with ESMTPS id 6228381E20 for ; Tue, 6 Dec 2022 10:20:40 +0000 (UTC) Received: by mail-lf1-x136.google.com with SMTP id 1so9291420lfz.4 for ; Tue, 06 Dec 2022 02:20:40 -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=3auUt9Lx9JNUzh7TpLNV9ba41DRcfZpn3khXR/mO+Sg=; b=gIsXGyvuuqxQpIELsSCAarQb6MABQ/gK6gfws0AS7pZ8qBk81K1RX6FQGkF+xzIX/B Ulb2sU1yKE73pWK7hHnqylpqAwvdcFjXYbWSzptkpY2K4JQTXlFQOg6SQ903R64hBIbH Hoi1RFF5NUHVges2PyqMlH9jSZ+7kuV9BbaR+5anXVrN5kiDXvJNv2SZZNRtIBsgtGOf MjUdfoAQi8auZ7AFwSHMLjddj9xgQPBEQZGxDnouiBMepPbtloAG6lp3GvltmxbnpUS5 71BzzBoIOu8Nb82Do7wOIecflRHlCToWvQsioUaUhEVvJncDtPSTW9ECTTj9XbZlMAGl Tk3w== 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=3auUt9Lx9JNUzh7TpLNV9ba41DRcfZpn3khXR/mO+Sg=; b=UCNOEDCMEc2Y+IssRzXqu8SPf3GbpySrqiCGYT0+AaqRqG/nr5Ktq/w+GUCX+zh06i Xi2HEHlpx91v8EkeSPt1a7xx8BZNgPuILvKP1lRGDyOXLV13wWeLk3FsV6mwN3yIZMFJ KSwVtkeZPhIAI1opVL3FbAUj0gsD1sEk+sRKBHdbNsojy9igA1h+LoicUY+tcXwf3lSL kFbUaiaBzpZyv3LTK44uQGk8A9WBhrNde2UcZSVVp9NVkuyZ6gcctZk+YkT+ST5wIOZb 22d59JXd61WwmIsI9AmxHB8yudqx2ENuLfABiCVNKwzkQC7LEOXxRltGJTmLWIU+BfRQ qmtg== X-Gm-Message-State: ANoB5pnIUmoeTaj7dbXiqQj/ccZQ7C71aLjfjIjHvS8WvSgBBomjsMAG VhHRFMGbXh4XVBj8CWEbB2XibJTD4+lhxDX4 X-Google-Smtp-Source: AA0mqf7YTlpAe9IQVQP1FxaIZjTBOjfHCBazDqR2nVaRB3VPIvUVgP6b3qZ1TAXSvCvFiUotC/oC3Q== X-Received: by 2002:a05:6512:693:b0:4b5:5384:aa3c with SMTP id t19-20020a056512069300b004b55384aa3cmr5606035lfe.150.1670322038133; Tue, 06 Dec 2022 02:20:38 -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 m1-20020a056512114100b004b515f9d117sm2409614lfg.271.2022.12.06.02.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 02:20:37 -0800 (PST) From: Vladislav Odintsov To: dev@openvswitch.org Date: Tue, 6 Dec 2022 13:20:01 +0300 Message-Id: <20221206102001.3058710-5-odivlad@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221206102001.3058710-1-odivlad@gmail.com> References: <20221206102001.3058710-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov , dragen15051@gmail.com Subject: [ovs-dev] [PATCH ovn v2 4/4] 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 nexthop check in ic_route_find(). Signed-off-by: Vladislav Odintsov Acked-by: Dumitru Ceara --- ic/ovn-ic.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 64307d8c4..fb6cdfad8 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; } } @@ -1130,17 +1129,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, @@ -1565,10 +1555,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); } } @@ -1601,7 +1591,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); @@ -1619,7 +1608,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);