Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/788419/?format=api
{ "id": 788419, "url": "http://patchwork.ozlabs.org/api/patches/788419/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170714121408.12434-1-vkommadi@redhat.com/", "project": { "id": 47, "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api", "name": "Open vSwitch", "link_name": "openvswitch", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "git@github.com:openvswitch/ovs.git", "webscm_url": "https://github.com/openvswitch/ovs", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170714121408.12434-1-vkommadi@redhat.com>", "list_archive_url": null, "date": "2017-07-14T12:14:08", "name": "[ovs-dev,v5,1/1] ovn: l3ha, CLI for logical router port gateway chassis", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "0b0255222b6c977e7d835a8dc51c491d032fd55a", "submitter": { "id": 67383, "url": "http://patchwork.ozlabs.org/api/people/67383/?format=api", "name": "Venkata Anil", "email": "vkommadi@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170714121408.12434-1-vkommadi@redhat.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/788419/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/788419/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@mail.linuxfoundation.org" ], "Received": [ "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3x8BSX54b6z9s4s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 14 Jul 2017 22:14:20 +1000 (AEST)", "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 3002DB55;\n\tFri, 14 Jul 2017 12:14:19 +0000 (UTC)", "from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id 68D34B4C\n\tfor <dev@openvswitch.org>; Fri, 14 Jul 2017 12:14:18 +0000 (UTC)", "from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTPS id AD26B1D6\n\tfor <dev@openvswitch.org>; Fri, 14 Jul 2017 12:14:17 +0000 (UTC)", "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 05D4BC04B321\n\tfor <dev@openvswitch.org>; Fri, 14 Jul 2017 12:14:17 +0000 (UTC)", "from vkommadi.redhat.com (ovpn-116-115.sin2.redhat.com\n\t[10.67.116.115])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 7B30360607;\n\tFri, 14 Jul 2017 12:14:15 +0000 (UTC)" ], "X-Greylist": [ "domain auto-whitelisted by SQLgrey-1.7.6", "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tFri, 14 Jul 2017 12:14:17 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 05D4BC04B321", "Authentication-Results": [ "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=pass smtp.mailfrom=vkommadi@redhat.com" ], "DKIM-Filter": "OpenDKIM Filter v2.11.0 mx1.redhat.com 05D4BC04B321", "From": "Venkata Anil Kommaddi <vkommadi@redhat.com>", "To": "dev@openvswitch.org", "Date": "Fri, 14 Jul 2017 17:44:08 +0530", "Message-Id": "<20170714121408.12434-1-vkommadi@redhat.com>", "In-Reply-To": "<1499965361-32021-1-git-send-email-majopela@redhat.com>", "References": "<1499965361-32021-1-git-send-email-majopela@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13", "X-Spam-Status": "No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, \n\tRP_MATCHES_RCVD autolearn=ham version=3.3.1", "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp1.linux-foundation.org", "Subject": "[ovs-dev] [PATCH v5 1/1] ovn: l3ha,\n\tCLI for logical router port gateway chassis", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.12", "Precedence": "list", "List-Id": "<ovs-dev.openvswitch.org>", "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<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\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "ovs-dev-bounces@openvswitch.org", "Errors-To": "ovs-dev-bounces@openvswitch.org" }, "content": "This change adds commands to set, get and delete gateway chassis\nfor logical router port.\n\nSigned-off-by: Venkata Anil <vkommadi@redhat.com>\n---\n ovn/utilities/ovn-nbctl.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++\n tests/ovn-nbctl.at | 52 ++++++++++++++\n 2 files changed, 224 insertions(+)", "diff": "diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c\nindex 0488318..7cf826f 100644\n--- a/ovn/utilities/ovn-nbctl.c\n+++ b/ovn/utilities/ovn-nbctl.c\n@@ -376,6 +376,13 @@ Logical router commands:\\n\\\n Logical router port commands:\\n\\\n lrp-add ROUTER PORT MAC NETWORK... [peer=PEER]\\n\\\n add logical port PORT on ROUTER\\n\\\n+ lrp-set-gateway-chassis PORT CHASSIS [PRIORITY]\\n\\\n+ set gateway chassis for port PORT\\n\\\n+ lrp-del-gateway-chassis PORT CHASSIS\\n\\\n+ delete gateway chassis from port PORT\\n\\\n+ lrp-get-gateway-chassis PORT\\n\\\n+ print the names of all gateway chassis on PORT\\n\\\n+ with PRIORITY\\n\\\n lrp-del PORT delete PORT from its attached router\\n\\\n lrp-list ROUTER print the names of all ports on ROUTER\\n\\\n lrp-set-enabled PORT STATE\\n\\\n@@ -2528,6 +2535,164 @@ lr_get_name(const struct nbrec_logical_router *lr, char uuid_s[UUID_LEN + 1],\n return uuid_s;\n }\n \n+static const struct nbrec_gateway_chassis*\n+gc_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist)\n+{\n+ const struct nbrec_gateway_chassis *gc = NULL;\n+\n+ struct uuid gc_uuid;\n+ bool is_uuid = uuid_from_string(&gc_uuid, id);\n+ if (is_uuid) {\n+ gc = nbrec_gateway_chassis_get_for_uuid(ctx->idl, &gc_uuid);\n+ }\n+\n+ if (!gc) {\n+ NBREC_GATEWAY_CHASSIS_FOR_EACH (gc, ctx->idl) {\n+ if (!strcmp(gc->name, id)) {\n+ break;\n+ }\n+ }\n+ }\n+\n+ if (!gc && must_exist) {\n+ ctl_fatal(\"%s: gateway chassis %s not found\", id,\n+ is_uuid ? \"UUID\" : \"name\");\n+ }\n+\n+ return gc;\n+}\n+\n+static void\n+nbctl_lrp_set_gateway_chassis(struct ctl_context *ctx)\n+{\n+ const char *gc_name;\n+ int64_t priority = 0;\n+ const char *lrp_name = ctx->argv[1];\n+ const struct nbrec_logical_router_port *lrp;\n+ lrp = lrp_by_name_or_uuid(ctx, lrp_name, true);\n+ if (!lrp) {\n+ ctl_fatal(\"router port %s is required\", lrp_name);\n+ return;\n+ }\n+\n+ const char *chassis_name = ctx->argv[2];\n+ if (ctx->argv[3]) {\n+ priority = parse_priority(ctx->argv[3]);\n+ }\n+\n+ gc_name = xasprintf(\"%s-%s\", lrp_name, chassis_name);\n+ const struct nbrec_gateway_chassis *gc;\n+ gc = gc_by_name_or_uuid(ctx, gc_name, false);\n+ if (gc) {\n+ nbrec_gateway_chassis_set_priority(gc, priority);\n+ return;\n+ }\n+\n+ /* Create the logical gateway chassis. */\n+ gc = nbrec_gateway_chassis_insert(ctx->txn);\n+ nbrec_gateway_chassis_set_name(gc, gc_name);\n+ nbrec_gateway_chassis_set_chassis_name(gc, chassis_name);\n+ nbrec_gateway_chassis_set_priority(gc, priority);\n+\n+ /* Insert the logical gateway chassis into the logical router port. */\n+ nbrec_logical_router_port_verify_gateway_chassis(lrp);\n+ struct nbrec_gateway_chassis **new_gc = xmalloc(\n+ sizeof *new_gc * (lrp->n_gateway_chassis + 1));\n+ nullable_memcpy(new_gc, lrp->gateway_chassis,\n+ sizeof *new_gc * lrp->n_gateway_chassis);\n+ new_gc[lrp->n_gateway_chassis] = CONST_CAST(\n+ struct nbrec_gateway_chassis *, gc);\n+ nbrec_logical_router_port_set_gateway_chassis(\n+ lrp, new_gc, lrp->n_gateway_chassis + 1);\n+ free(new_gc);\n+}\n+\n+/* Removes logical router port 'lrp->gateway_chassis[idx]'. */\n+static void\n+remove_gc(const struct nbrec_logical_router_port *lrp, size_t idx)\n+{\n+ const struct nbrec_gateway_chassis *gc = lrp->gateway_chassis[idx];\n+ /* First remove 'gc' from the array of gateway_chassis. This is what will\n+ * actually cause the gateway chassis to be deleted when the transaction is\n+ * sent to the database server (due to garbage collection). */\n+ struct nbrec_gateway_chassis **new_gc\n+ = xmemdup(lrp->gateway_chassis,\n+ sizeof *new_gc * lrp->n_gateway_chassis);\n+ new_gc[idx] = new_gc[lrp->n_gateway_chassis - 1];\n+ nbrec_logical_router_port_verify_gateway_chassis(lrp);\n+ nbrec_logical_router_port_set_gateway_chassis(\n+ lrp, new_gc, lrp->n_gateway_chassis - 1);\n+ free(new_gc);\n+\n+ /* Delete 'gc' from the IDL. This won't have a real effect on\n+ * the database server (the IDL will suppress it in fact) but it\n+ * means that it won't show up when we iterate with\n+ * NBREC_GATEWAY_CHASSIS_FOR_EACH later. */\n+ nbrec_gateway_chassis_delete(gc);\n+}\n+\n+static void\n+nbctl_lrp_del_gateway_chassis(struct ctl_context *ctx)\n+{\n+ const struct nbrec_logical_router_port *lrp;\n+ lrp = lrp_by_name_or_uuid(ctx, ctx->argv[1], true);\n+ if (!lrp) {\n+ return;\n+ }\n+ /* Find the lrp that contains 'gc', then delete it. */\n+ const char *chassis_name = ctx->argv[2];\n+ for (size_t i = 0; i < lrp->n_gateway_chassis; i++) {\n+ if (!strncmp(lrp->gateway_chassis[i]->chassis_name,\n+ chassis_name,\n+ strlen(lrp->gateway_chassis[i]->chassis_name))) {\n+ remove_gc(lrp, i);\n+ return;\n+ }\n+ }\n+\n+ /* Can't happen because of the database schema. */\n+ ctl_fatal(\"chassis %s is not added to logical port %s\",\n+ chassis_name, ctx->argv[1]);\n+}\n+\n+static int\n+gateway_chassis_cmp(const void *gc1_, const void *gc2_)\n+{\n+ const struct nbrec_gateway_chassis *const *gc1p = gc1_;\n+ const struct nbrec_gateway_chassis *const *gc2p = gc2_;\n+ const struct nbrec_gateway_chassis *gc1 = *gc1p;\n+ const struct nbrec_gateway_chassis *gc2 = *gc2p;\n+\n+ return strcmp(gc1->name, gc2->name);\n+}\n+\n+/* Print a list of gateway chassis. */\n+static void\n+nbctl_lrp_get_gateway_chassis(struct ctl_context *ctx)\n+{\n+ const char *id = ctx->argv[1];\n+ const struct nbrec_logical_router_port *lrp;\n+ const struct nbrec_gateway_chassis **gcs;\n+ size_t i;\n+\n+ lrp = lrp_by_name_or_uuid(ctx, id, true);\n+\n+ gcs = xmalloc(sizeof *gcs * lrp->n_gateway_chassis);\n+ for (i = 0; i < lrp->n_gateway_chassis; i++) {\n+ gcs[i] = lrp->gateway_chassis[i];\n+ }\n+\n+ qsort(gcs, lrp->n_gateway_chassis, sizeof *gcs, gateway_chassis_cmp);\n+\n+ for (i = 0; i < lrp->n_gateway_chassis; i++) {\n+ const struct nbrec_gateway_chassis *gc = gcs[i];\n+ ds_put_format(&ctx->output, \"%s %5\"PRId64\"\\n\",\n+ gc->name, gc->priority);\n+ }\n+\n+ free(gcs);\n+}\n+\n static void\n nbctl_lrp_add(struct ctl_context *ctx)\n {\n@@ -3413,6 +3578,13 @@ static const struct ctl_command_syntax nbctl_commands[] = {\n { \"lrp-add\", 4, INT_MAX,\n \"ROUTER PORT MAC NETWORK... [COLUMN[:KEY]=VALUE]...\",\n NULL, nbctl_lrp_add, NULL, \"--may-exist\", RW },\n+ { \"lrp-set-gateway-chassis\", 2, 3,\n+ \"PORT CHASSIS [PRIORITY]\",\n+ NULL, nbctl_lrp_set_gateway_chassis, NULL, \"--may-exist\", RW },\n+ { \"lrp-del-gateway-chassis\", 2, 2, \"PORT CHASSIS\", NULL,\n+ nbctl_lrp_del_gateway_chassis, NULL, \"\", RW },\n+ { \"lrp-get-gateway-chassis\", 1, 1, \"PORT\", NULL,\n+ nbctl_lrp_get_gateway_chassis, NULL, \"\", RO },\n { \"lrp-del\", 1, 1, \"PORT\", NULL, nbctl_lrp_del, NULL, \"--if-exists\", RW },\n { \"lrp-list\", 1, 1, \"ROUTER\", NULL, nbctl_lrp_list, NULL, \"\", RO },\n { \"lrp-set-enabled\", 2, 2, \"PORT STATE\", NULL, nbctl_lrp_set_enabled,\ndiff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at\nindex 975d702..ded21fc 100644\n--- a/tests/ovn-nbctl.at\n+++ b/tests/ovn-nbctl.at\n@@ -756,6 +756,58 @@ AT_CLEANUP\n \n dnl ---------------------------------------------------------------------\n \n+AT_SETUP([ovn-nbctl - logical router port gateway chassis])\n+OVN_NBCTL_TEST_START\n+AT_CHECK([ovn-nbctl lr-add lr0])\n+AT_CHECK([ovn-nbctl lrp-add lr0 lrp0 00:00:00:01:02:03 192.168.1.1/24])\n+AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [])\n+\n+AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lp0 chassis1], [1], [],\n+[ovn-nbctl: lp0: port name not found\n+])\n+\n+AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lp0], [1], [],\n+[ovn-nbctl: lp0: port name not found\n+])\n+\n+AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lp0 chassis1], [1], [],\n+[ovn-nbctl: lp0: port name not found\n+])\n+\n+AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1], [1], [],\n+[ovn-nbctl: chassis chassis1 is not added to logical port lrp0\n+])\n+AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1])\n+\n+AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl\n+lrp0-chassis1 0\n+])\n+AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 10])\n+\n+AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl\n+lrp0-chassis1 10\n+])\n+AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis1 20])\n+\n+AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl\n+lrp0-chassis1 20\n+])\n+AT_CHECK([ovn-nbctl lrp-set-gateway-chassis lrp0 chassis2 5])\n+AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl\n+lrp0-chassis1 20\n+lrp0-chassis2 5\n+])\n+\n+AT_CHECK([ovn-nbctl lrp-del-gateway-chassis lrp0 chassis1])\n+AT_CHECK([ovn-nbctl lrp-get-gateway-chassis lrp0], [0], [dnl\n+lrp0-chassis2 5\n+])\n+\n+OVN_NBCTL_TEST_STOP\n+AT_CLEANUP\n+\n+dnl ---------------------------------------------------------------------\n+\n AT_SETUP([ovn-nbctl - logical router port enable and disable])\n OVN_NBCTL_TEST_START\n \n", "prefixes": [ "ovs-dev", "v5", "1/1" ] }