get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1554071/
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1554071,
    "url": "http://patchwork.ozlabs.org/api/patches/1554071/",
    "web_url": "http://patchwork.ozlabs.org/project/ovn/patch/20211111191306.6369-6-odivlad@gmail.com/",
    "project": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/projects/68/",
        "name": "Open Virtual Network development",
        "link_name": "ovn",
        "list_id": "ovs-dev.openvswitch.org",
        "list_email": "ovs-dev@openvswitch.org",
        "web_url": "http://openvswitch.org/",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20211111191306.6369-6-odivlad@gmail.com>",
    "list_archive_url": null,
    "date": "2021-11-11T19:13:06",
    "name": "[ovs-dev,v7,5/5] ic: don't learn routes which have local GW",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "70eb109b51d03e813e6ca2050de133734319cf4f",
    "submitter": {
        "id": 80943,
        "url": "http://patchwork.ozlabs.org/api/people/80943/",
        "name": "Vladislav Odintsov",
        "email": "odivlad@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/ovn/patch/20211111191306.6369-6-odivlad@gmail.com/mbox/",
    "series": [
        {
            "id": 271600,
            "url": "http://patchwork.ozlabs.org/api/series/271600/",
            "web_url": "http://patchwork.ozlabs.org/project/ovn/list/?series=271600",
            "date": "2021-11-11T19:13:01",
            "name": "Add multiple routing tables support to Logical Routers",
            "version": 7,
            "mbox": "http://patchwork.ozlabs.org/series/271600/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1554071/comments/",
    "check": "success",
    "checks": "http://patchwork.ozlabs.org/api/patches/1554071/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<ovs-dev-bounces@openvswitch.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "dev@openvswitch.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "ovs-dev@lists.linuxfoundation.org"
        ],
        "Authentication-Results": [
            "bilbo.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20210112 header.b=mRLCiUJH;\n\tdkim-atps=neutral",
            "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=140.211.166.138; helo=smtp1.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)",
            "smtp2.osuosl.org (amavisd-new);\n dkim=pass (2048-bit key) header.d=gmail.com"
        ],
        "Received": [
            "from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4HqrwS4hbVz9s1l\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 12 Nov 2021 06:13:28 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby smtp1.osuosl.org (Postfix) with ESMTP id 9103B81C38;\n\tThu, 11 Nov 2021 19:13:24 +0000 (UTC)",
            "from smtp1.osuosl.org ([127.0.0.1])\n\tby localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id qMGcCdV9HbLh; Thu, 11 Nov 2021 19:13:23 +0000 (UTC)",
            "from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp1.osuosl.org (Postfix) with ESMTPS id A0C8081CAD;\n\tThu, 11 Nov 2021 19:13:22 +0000 (UTC)",
            "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 71D69C0019;\n\tThu, 11 Nov 2021 19:13:22 +0000 (UTC)",
            "from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])\n by lists.linuxfoundation.org (Postfix) with ESMTP id 3449AC000E\n for <dev@openvswitch.org>; Thu, 11 Nov 2021 19:13:21 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n by smtp2.osuosl.org (Postfix) with ESMTP id F1D6B4046D\n for <dev@openvswitch.org>; Thu, 11 Nov 2021 19:13:20 +0000 (UTC)",
            "from smtp2.osuosl.org ([127.0.0.1])\n by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id dvkmEi-n7c81 for <dev@openvswitch.org>;\n Thu, 11 Nov 2021 19:13:18 +0000 (UTC)",
            "from mail-lf1-x135.google.com (mail-lf1-x135.google.com\n [IPv6:2a00:1450:4864:20::135])\n by smtp2.osuosl.org (Postfix) with ESMTPS id B14F340472\n for <dev@openvswitch.org>; Thu, 11 Nov 2021 19:13:17 +0000 (UTC)",
            "by mail-lf1-x135.google.com with SMTP id b40so16452140lfv.10\n for <dev@openvswitch.org>; Thu, 11 Nov 2021 11:13:17 -0800 (PST)",
            "from localhost.localdomain (109-252-131-59.dynamic.spd-mgts.ru.\n [109.252.131.59])\n by smtp.gmail.com with ESMTPSA id p26sm106915ljj.70.2021.11.11.11.13.15\n (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);\n Thu, 11 Nov 2021 11:13:15 -0800 (PST)"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "whitelisted by SQLgrey-1.8.0",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=cJbZqFLaZMmzrFduHtkVFI2V8YXTQ66GTeGA3jZYlVo=;\n b=mRLCiUJHKVfezkKtNxzbMKB7nP5tTAegeBiY8Fdg2udbZKQ/qyya1kwLGha+n7mWkS\n nW6LiSpa4DjRMQ+cLQoxiRK3+CMy7UMmUGj0Asbnrjw1B7znygebbEi2qRfFwg4ShCgx\n ovuo2WUw9/G38a6idFGoczygzpAqOz5EanM+PJdmt6r8ur2Q0c+EYZ9NIdEKQ2ZyacZP\n YljoQ58CsgkYWqiASe9sIJlUr9HRS4vrbW8bgDIS9YUov827fn43x95UoEjw67OpkRLx\n J1HBKBy/gWJmQYx5jeVrCTu3V5HR6g9BYdCCAA2V+5B93G09kQyIaEmkHrKZbWgdvkjq\n FxlQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20210112;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=cJbZqFLaZMmzrFduHtkVFI2V8YXTQ66GTeGA3jZYlVo=;\n b=wqcAV+gh5/NrXvgP7FQmFT4RxryKpEb7AQmO73f8lMY2I3G58AExATDSYrvrSgA3YP\n AchfdW4HFY9glNPd0J+AlS1PjnLN2NILuFs7w2E8KdwxYbdl/dUpRkUx4UAHa4HuUpdc\n XeMb9k12afPr/AH7WgObUi/HAS2PAJ6g0fn0LrSuXV83Tw8qkkDTcjBihu+pGbnDAW/z\n kq28VdkH/Tg1wfR7PDt8aSabAzVVmPDVbeX2311xiCZVA45Z/1J+Xg340y7KITcNubfN\n ensOPFqFpDq55AY4htYYfY+c+fsVALIIVj+Xo/inyjBbPvAOBwf/qihL69IBB/Qanotb\n uyzA==",
        "X-Gm-Message-State": "AOAM5321t+DGqz/5nOuANpdoJFqD/gXHmpgFgU7jdmhuDNSonSX2Uh3z\n umNbFP3NgSxJzjRfA/Du7C79L73si0+PlA==",
        "X-Google-Smtp-Source": "\n ABdhPJxRPsqPgZGtJQzWfstMcaloF2b0r7QOJiNEEBYqB8Oy2lFpv5RjGAqqKvJEZturpXp4igqNWw==",
        "X-Received": "by 2002:a05:6512:108a:: with SMTP id\n j10mr8378038lfg.557.1636657995444;\n Thu, 11 Nov 2021 11:13:15 -0800 (PST)",
        "From": "Vladislav Odintsov <odivlad@gmail.com>",
        "To": "dev@openvswitch.org",
        "Date": "Thu, 11 Nov 2021 22:13:06 +0300",
        "Message-Id": "<20211111191306.6369-6-odivlad@gmail.com>",
        "X-Mailer": "git-send-email 2.30.0",
        "In-Reply-To": "<20211111191306.6369-1-odivlad@gmail.com>",
        "References": "<20211111191306.6369-1-odivlad@gmail.com>",
        "MIME-Version": "1.0",
        "Cc": "Vladislav Odintsov <odivlad@gmail.com>",
        "Subject": "[ovs-dev] [PATCH ovn v7 5/5] ic: don't learn routes which have\n\tlocal GW",
        "X-BeenThere": "ovs-dev@openvswitch.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "<ovs-dev.openvswitch.org>",
        "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>",
        "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>",
        "List-Post": "<mailto:ovs-dev@openvswitch.org>",
        "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>",
        "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "ovs-dev-bounces@openvswitch.org",
        "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>"
    },
    "content": "In case we have ovn-ic-interconnected Logical_Routers\nand install same ip_prefix route with GW in local AZ\nin each LR in each AZ, this route would be learned in\nother AZs and L3 loop is possible.\nThere could be next routes output:\n\n[az1 ~]$ ovn-nbctl lr-route-list lr0\nIPv4 Routes\nRoute Table global:\n              128.0.0.0/1               169.254.1.1 dst-ip ecmp\n              128.0.0.0/1             169.254.100.2 dst-ip (learned) ecmp\n\n[az2 ~]$ ovn-nbctl lr-route-list lr0\nIPv4 Routes\nRoute Table global:\n              128.0.0.0/1               169.254.2.1 dst-ip ecmp\n              128.0.0.0/1             169.254.100.1 dst-ip (learned) ecmp\n\nSo, there is a possible routing loop. Packets going\nto 128.0.0.0/1 could go from AZ1 to AZ2 and on AZ2\nthey can be routed back.\n\nThis commit adds check for installed local (non-learned)\nroutes. If OVN IC route's ip_prefix, route_table are\nthe same with already installed non-learned NB route, such\nroute wouldn't be learned.\n\nSigned-off-by: Vladislav Odintsov <odivlad@gmail.com>\n---\n ic/ovn-ic.c           | 30 ++++++++++++++++++++++++--\n tests/ovn-ic.at       | 49 +++++++++++++++++++++++++++++++++++++++++++\n utilities/ovn-nbctl.c |  4 +++-\n 3 files changed, 80 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c\nindex f40468e92..a9b797af2 100644\n--- a/ic/ovn-ic.c\n+++ b/ic/ovn-ic.c\n@@ -1209,7 +1209,25 @@ add_network_to_routes_ad(struct hmap *routes_ad, const char *network,\n }\n \n static bool\n-route_need_learn(struct in6_addr *prefix, unsigned int plen,\n+route_has_local_gw(const struct nbrec_logical_router *lr,\n+                   const char *route_table, const char *ip_prefix) {\n+\n+    const struct nbrec_logical_router_static_route *route;\n+    for (int i = 0; i < lr->n_static_routes; i++) {\n+        route = lr->static_routes[i];\n+        if (!smap_get(&route->external_ids, \"ic-learned-route\") &&\n+            !strcmp(route->route_table, route_table) &&\n+            !strcmp(route->ip_prefix, ip_prefix)) {\n+            return true;\n+        }\n+    }\n+    return false;\n+}\n+\n+static bool\n+route_need_learn(const struct nbrec_logical_router *lr,\n+                 const struct icsbrec_route *isb_route,\n+                 struct in6_addr *prefix, unsigned int plen,\n                  const struct smap *nb_options)\n {\n     if (!smap_get_bool(nb_options, \"ic-route-learn\", false)) {\n@@ -1229,6 +1247,12 @@ route_need_learn(struct in6_addr *prefix, unsigned int plen,\n         return false;\n     }\n \n+    if (route_has_local_gw(lr, isb_route->route_table, isb_route->ip_prefix)) {\n+        VLOG_DBG(\"Skip learning %s (rtb:%s) route, as we've got one with \"\n+                 \"local GW\", isb_route->ip_prefix, isb_route->route_table);\n+        return false;\n+    }\n+\n     return true;\n }\n \n@@ -1333,9 +1357,11 @@ sync_learned_routes(struct ic_context *ctx,\n                              isb_route->nexthop);\n                 continue;\n             }\n-            if (!route_need_learn(&prefix, plen, &nb_global->options)) {\n+            if (!route_need_learn(ic_lr->lr, isb_route, &prefix, plen,\n+                                  &nb_global->options)) {\n                 continue;\n             }\n+\n             struct ic_route_info *route_learned\n                 = ic_route_find(&ic_lr->routes_learned, &prefix, plen,\n                                 &nexthop, isb_route->origin,\ndiff --git a/tests/ovn-ic.at b/tests/ovn-ic.at\nindex 1340874d5..a189a8fed 100644\n--- a/tests/ovn-ic.at\n+++ b/tests/ovn-ic.at\n@@ -928,3 +928,52 @@ OVN_CLEANUP_IC([az1], [az2])\n \n AT_CLEANUP\n ])\n+\n+OVN_FOR_EACH_NORTHD([\n+AT_SETUP([ovn-ic -- same routes destination])\n+\n+ovn_init_ic_db\n+ovn-ic-nbctl ts-add ts1\n+\n+for i in 1 2; do\n+    ovn_start az$i\n+    ovn_as az$i\n+\n+    # Enable route learning at AZ level\n+    ovn-nbctl set nb_global . options:ic-route-learn=true\n+    ovn-nbctl set nb_global . options:ic-route-learn-default=true\n+    # Enable route advertising at AZ level\n+    ovn-nbctl set nb_global . options:ic-route-adv=true\n+    ovn-nbctl set nb_global . options:ic-route-adv-default=true\n+\n+    lr=lr1$i\n+    ovn-nbctl lr-add $lr\n+\n+    lrp=lrp-$lr-ts1\n+    lsp=lsp-ts1-$lr\n+    # Create LRP and connect to TS\n+    ovn-nbctl lrp-add $lr $lrp aa:aa:aa:aa:aa:0$i 169.254.100.$i/24\n+    ovn-nbctl lsp-add ts1 $lsp \\\n+        -- lsp-set-addresses $lsp router \\\n+        -- lsp-set-type $lsp router \\\n+        -- lsp-set-options $lsp router-port=$lrp\n+    ovn-nbctl lrp-add $lr lrp-local-subnet 00:00:00:00:00:0$i 192.168.$i.1/24\n+    ovn-nbctl list logical-router-static-route\n+    check ovn-nbctl lr-route-add $lr 10.0.0.0/24 192.168.$i.10\n+    check ovn-nbctl lr-route-add $lr 0.0.0.0/0 192.168.$i.11\n+done\n+\n+AT_CHECK([ovn_as az1 ovn-nbctl lr-route-list lr11 | grep dst-ip | sort], [0], [dnl\n+                0.0.0.0/0              192.168.1.11 dst-ip\n+              10.0.0.0/24              192.168.1.10 dst-ip\n+           192.168.2.0/24             169.254.100.2 dst-ip (learned)\n+])\n+\n+AT_CHECK([ovn_as az2 ovn-nbctl lr-route-list lr12 | grep dst-ip | sort], [0], [dnl\n+                0.0.0.0/0              192.168.2.11 dst-ip\n+              10.0.0.0/24              192.168.2.10 dst-ip\n+           192.168.1.0/24             169.254.100.1 dst-ip (learned)\n+])\n+\n+AT_CLEANUP\n+])\ndiff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c\nindex 8bdcb19a3..17bb5d41d 100644\n--- a/utilities/ovn-nbctl.c\n+++ b/utilities/ovn-nbctl.c\n@@ -4104,6 +4104,8 @@ nbctl_pre_lr_route_add(struct ctl_context *ctx)\n                          &nbrec_logical_router_static_route_col_options);\n     ovsdb_idl_add_column(ctx->idl,\n                          &nbrec_logical_router_static_route_col_route_table);\n+    ovsdb_idl_add_column(ctx->idl,\n+                         &nbrec_logical_router_static_route_col_external_ids);\n }\n \n static char * OVS_WARN_UNUSED_RESULT\n@@ -4233,7 +4235,7 @@ nbctl_lr_route_add(struct ctl_context *ctx)\n     }\n \n     if (!ecmp) {\n-        if (route) {\n+        if (route && !smap_get(&route->external_ids, \"ic-learned-route\")) {\n             if (!may_exist) {\n                 ctl_error(ctx, \"duplicate prefix: %s (policy: %s). Use option\"\n                           \" --ecmp to allow this for ECMP routing.\",\n",
    "prefixes": [
        "ovs-dev",
        "v7",
        "5/5"
    ]
}