From patchwork Thu Jan 20 10:38:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1582092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GM4Jhi7p; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JffBs5ZQ9z9sXM for ; Thu, 20 Jan 2022 21:39:17 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 04521415BC; Thu, 20 Jan 2022 10:39:15 +0000 (UTC) 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 yVHj6WFjWkLJ; Thu, 20 Jan 2022 10:39:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id E3A8D415BB; Thu, 20 Jan 2022 10:39:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B267BC0039; Thu, 20 Jan 2022 10:39:12 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9F293C002F for ; Thu, 20 Jan 2022 10:39:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 86E6E60F3D for ; Thu, 20 Jan 2022 10:39:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 Wcz8UnHXCffP for ; Thu, 20 Jan 2022 10:39:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 38E6360F3E for ; Thu, 20 Jan 2022 10:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642675149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=o7ehmX6iGwu++1L7+IHuqpFZYyXLV6FN0NEpNK2tcFE=; b=GM4Jhi7pGelwN/dQPoj0+zA+HpdkxSsYwHGxRonbg4GuT8s+UPfNm4nJ8Qp6va6+Q/nIhS V63DXiCeFDR2spi5gQKkB1a7/9Kck3fvI6W1h+g0Vrqg9uuMpkHNCPriehE3jsHtsNHgAk /QoAyy9oHnxtA9T/vU1EUX70F5amLxo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-1HNcQkrJO2eQSMdCbTzeLg-1; Thu, 20 Jan 2022 05:39:07 -0500 X-MC-Unique: 1HNcQkrJO2eQSMdCbTzeLg-1 Received: by mail-wm1-f70.google.com with SMTP id p7-20020a05600c1d8700b0034a0c77dad6so3788790wms.7 for ; Thu, 20 Jan 2022 02:39:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=o7ehmX6iGwu++1L7+IHuqpFZYyXLV6FN0NEpNK2tcFE=; b=fskF5UtLTLZTyUzI6DCAYNGfTVHQ1elvzuLuW1s4sdQYaPN+COH9EQXIaIq5Yz2kI6 0/t9iDDqX+DeSMVIJOLWcnxssH0PniPxY+OYfTrBQ7rr6EprYTlafraR8eftyn2iImYE kbcyk24Lb+rLAU4fBQ/+5ClGLMlshWm2Ur3Zf4ni3NIPYLqNHZ2hwsQ3hlIGwhSjaD/Z 2R2K+pLqTI4YoZG2KrHtKSnLWLeDgpSxRmBGnjbceGYJ0gd3MF7BxfgsuWGITwfGK7AX LFDSSeNSP1U01JZJnJpDEnFRGjZd8cO21FW8lHcDVTNp7Z/ya9LOcmw5tABZsEoefGO5 xNPw== X-Gm-Message-State: AOAM531x/+2Rh7XyCFfJ5HmDcNkgR0Wq0P1mHsK5yC4yCLwfPdDUho5c p5dybLsPLfH8cOf1SpvOjiz5EnJr5WBKX1HGv3nK2O8+V2hlDNrBCkt5HSNTvAMypiz/o+d3plM Ny5vhO7VpyVnP2Vt5Jl+KbkErkQHlPGH8uYyt9wp3NtobYSszDTaIDtQ0caK8aDU84KKtciuEdQ h4wPgX X-Received: by 2002:a5d:6a47:: with SMTP id t7mr2407212wrw.572.1642675146076; Thu, 20 Jan 2022 02:39:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJySlR70/Y0CpVgRhdIHCEx4uzbc1JbZ/h/A84nJZFDMa1yww2lT60ZMV9ybbkfZ62hjf1VTWQ== X-Received: by 2002:a5d:6a47:: with SMTP id t7mr2407183wrw.572.1642675145579; Thu, 20 Jan 2022 02:39:05 -0800 (PST) Received: from lore-desk.redhat.com (net-93-146-37-237.cust.vodafonedsl.it. [93.146.37.237]) by smtp.gmail.com with ESMTPSA id u14sm2307052wrm.58.2022.01.20.02.39.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 02:39:05 -0800 (PST) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Thu, 20 Jan 2022 11:38:59 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] ovn-nbctl: add the capability to specify CoPP UUID or CoPP name 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" Introduce the capability to specify CoPP UUID or CoPP name in order to reuse the same CoPP reference on multiple datapaths. Introduce logical_router and logical_switches columns in CoPP table in order to specify datapaths where CoPP is installed. Reported-ad: https://bugzilla.redhat.com/show_bug.cgi?id=2040852 Signed-off-by: Lorenzo Bianconi --- ovn-nb.ovsschema | 15 +++++- ovn-nb.xml | 9 ++++ tests/ovn-northd.at | 27 ++++++++++ utilities/ovn-nbctl.8.xml | 16 ++++-- utilities/ovn-nbctl.c | 103 ++++++++++++++++++++++++++++++++------ 5 files changed, 150 insertions(+), 20 deletions(-) diff --git a/ovn-nb.ovsschema b/ovn-nb.ovsschema index 55977339a..cf2947d93 100644 --- a/ovn-nb.ovsschema +++ b/ovn-nb.ovsschema @@ -1,7 +1,7 @@ { "name": "OVN_Northbound", - "version": "5.34.1", - "cksum": "2177334725 30782", + "version": "5.35.0", + "cksum": "2039436985 31434", "tables": { "NB_Global": { "columns": { @@ -32,6 +32,17 @@ "isRoot": true}, "Copp": { "columns": { + "name": {"type": "string"}, + "logical_switch": {"type": {"key": {"type": "uuid", + "refTable": "Logical_Switch", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, + "logical_router": {"type": {"key": {"type": "uuid", + "refTable": "Logical_Router", + "refType": "strong"}, + "min": 0, + "max": "unlimited"}}, "meters": { "type": {"key": "string", "value": "string", diff --git a/ovn-nb.xml b/ovn-nb.xml index 6a6972856..4d319267f 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -360,6 +360,15 @@ associate entries from table to control protocol names.

+ + CoPP name. + + + Reference to where the CoPP is installed. + + + Reference to where the CoPP is installed. + Rate limiting meter for ARP packets (request/reply) used for learning neighbors. diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 652903761..bd284c915 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -3403,6 +3403,33 @@ check ovn-nbctl lr-copp-del r0 AT_CHECK([ovn-nbctl lr-copp-list r0], [0], [dnl ]) +check ovn-nbctl ls-copp-del sw1 +AT_CHECK([ovn-nbctl ls-copp-list sw1], [0], [dnl +]) + +check ovn-nbctl --wait=hv lr-copp-add copp0 r0 arp meter0 +AT_CHECK([ovn-nbctl lr-copp-list r0], [0], [dnl +arp: meter0 +]) + +AT_CHECK([fetch_column nb:CoPP name], [0], [dnl +copp0 +]) + +lr_uuid=$(fetch_column nb:Logical_Router _uuid) +copp_lr_uuid=$(fetch_column nb:CoPP logical_router) +AT_CHECK([test "$lr_uuid" = "$copp_lr_uuid"]) + +copp_uuid=$(fetch_column nb:CoPP _uuid) +check ovn-nbctl --wait=hv ls-copp-add $copp_uuid sw1 arp meter0 + +ls_uuid=$(fetch_column nb:Logical_Switch _uuid) +copp_ls_uuid=$(fetch_column nb:CoPP logical_switch) +AT_CHECK([test "$ls_uuid" = "$copp_ls_uuid"]) + +ls_copp_uuid=$(fetch_column nb:Logical_Switch copp) +AT_CHECK([test "$ls_copp_uuid" = "$copp_uuid"]) + AT_CLEANUP ]) diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml index 80a564660..98326dcc2 100644 --- a/utilities/ovn-nbctl.8.xml +++ b/utilities/ovn-nbctl.8.xml @@ -1474,13 +1474,17 @@

-
ls-copp-add switch proto - meter
+
ls-copp-add [UUID|name] + switch proto meter
Adds the control proto to meter mapping to the switch control plane protection policy. If no policy exists yet, it creates one. If a mapping already existed for proto, this will overwrite it. + If UUID is provided, the already installed will be reused + (if not found and error will be reported). + If name is provided, CoPP name can be used for CoPP + table lookup.
ls-copp-del switch [proto]
@@ -1497,13 +1501,17 @@ switch. -
lr-copp-add router proto - meter
+
lr-copp-add [UUID|name] + router proto meter
Adds the control proto to meter mapping to the router control plane protection policy. If no policy exists yet, it creates one. If a mapping already existed for proto, this will overwrite it. + If UUID is provided, the already installed will be reused + (if not found and error will be reported). + If name is provided, CoPP name can be used for CoPP + table lookup.
lr-copp-del router [proto]
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index d67d2db65..8889f1c6b 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -437,7 +437,7 @@ chassis with mandatory PRIORITY to the HA chassis group GRP\n\ CHASSIS from the HA chassis group GRP\n\ \n\ Control Plane Protection Policy commands:\n\ - ls-copp-add SWITCH PROTO METER\n\ + ls-copp-add [UUID|NAME] SWITCH PROTO METER\n\ Add a copp policy for PROTO packets on SWITCH\n\ based on an existing METER.\n\ ls-copp-del SWITCH [PROTO]\n\ @@ -447,7 +447,7 @@ Control Plane Protection Policy commands:\n\ ls-copp-list SWITCH\n\ List all copp policies defined for control\n\ protocols on SWITCH.\n\ - lr-copp-add ROUTER PROTO METER\n\ + lr-copp-add [UUID|NAME] ROUTER PROTO METER\n\ Add a copp policy for PROTO packets on ROUTER\n\ based on an existing METER.\n\ lr-copp-del ROUTER [PROTO]\n\ @@ -6278,6 +6278,9 @@ nbctl_pre_copp(struct ctl_context *ctx) { nbctl_pre_context(ctx); ovsdb_idl_add_column(ctx->idl, &nbrec_copp_col_meters); + ovsdb_idl_add_column(ctx->idl, &nbrec_copp_col_logical_switch); + ovsdb_idl_add_column(ctx->idl, &nbrec_copp_col_logical_router); + ovsdb_idl_add_column(ctx->idl, &nbrec_copp_col_name); ovsdb_idl_add_column(ctx->idl, &nbrec_logical_switch_col_copp); ovsdb_idl_add_column(ctx->idl, &nbrec_logical_router_col_copp); } @@ -6285,9 +6288,31 @@ nbctl_pre_copp(struct ctl_context *ctx) static void nbctl_ls_copp_add(struct ctl_context *ctx) { - const char *ls_name = ctx->argv[1]; - const char *proto_name = ctx->argv[2]; - const char *meter = ctx->argv[3]; + const struct nbrec_copp *copp = NULL; + const char *copp_name = NULL; + const char *proto_name; + const char *ls_name; + const char *meter; + + if (ctx->argc == 5) { + struct uuid uuid; + if (uuid_from_string(&uuid, ctx->argv[1])) { + copp = nbrec_copp_get_for_uuid(ctx->idl, &uuid); + if (!copp) { + ctx->error = xasprintf("copp %s not found.", ctx->argv[1]); + return; + } + } else { + copp_name = ctx->argv[1]; + } + ls_name = ctx->argv[2]; + proto_name = ctx->argv[3]; + meter = ctx->argv[4]; + } else { + ls_name = ctx->argv[1]; + proto_name = ctx->argv[2]; + meter = ctx->argv[3]; + } char *error = copp_proto_validate(proto_name); if (error) { @@ -6302,9 +6327,23 @@ nbctl_ls_copp_add(struct ctl_context *ctx) return; } - const struct nbrec_copp *copp = - copp_meter_add(ctx, ls->copp, proto_name, meter); + if (!copp) { + copp = copp_meter_add(ctx, ls->copp, proto_name, meter); + } + if (copp_name) { + nbrec_copp_set_name(copp, copp_name); + } nbrec_logical_switch_set_copp(ls, copp); + + size_t n_logical_switch = copp->n_logical_switch + 1; + struct nbrec_logical_switch **ls_list = + xmalloc(n_logical_switch * sizeof *ls_list); + for (int i = 0; i < copp->n_logical_switch; i++) { + ls_list[i] = copp->logical_switch[i]; + } + ls_list[copp->n_logical_switch] = (struct nbrec_logical_switch *)ls; + nbrec_copp_set_logical_switch(copp, ls_list, n_logical_switch); + free(ls_list); } static void @@ -6351,9 +6390,31 @@ nbctl_ls_copp_list(struct ctl_context *ctx) static void nbctl_lr_copp_add(struct ctl_context *ctx) { - const char *lr_name = ctx->argv[1]; - const char *proto_name = ctx->argv[2]; - const char *meter = ctx->argv[3]; + const struct nbrec_copp *copp = NULL; + const char *copp_name = NULL; + const char *proto_name; + const char *lr_name; + const char *meter; + + if (ctx->argc == 5) { + struct uuid uuid; + if (uuid_from_string(&uuid, ctx->argv[1])) { + copp = nbrec_copp_get_for_uuid(ctx->idl, &uuid); + if (!copp) { + ctx->error = xasprintf("copp %s not found.", ctx->argv[1]); + return; + } + } else { + copp_name = ctx->argv[1]; + } + lr_name = ctx->argv[2]; + proto_name = ctx->argv[3]; + meter = ctx->argv[4]; + } else { + lr_name = ctx->argv[1]; + proto_name = ctx->argv[2]; + meter = ctx->argv[3]; + } char *error = copp_proto_validate(proto_name); if (error) { @@ -6368,9 +6429,23 @@ nbctl_lr_copp_add(struct ctl_context *ctx) return; } - const struct nbrec_copp *copp = - copp_meter_add(ctx, lr->copp, proto_name, meter); + if (!copp) { + copp = copp_meter_add(ctx, lr->copp, proto_name, meter); + } + if (copp_name) { + nbrec_copp_set_name(copp, copp_name); + } nbrec_logical_router_set_copp(lr, copp); + + size_t n_logical_router = copp->n_logical_router + 1; + struct nbrec_logical_router **lr_list = + xmalloc(n_logical_router * sizeof *lr_list); + for (int i = 0; i < copp->n_logical_router; i++) { + lr_list[i] = copp->logical_router[i]; + } + lr_list[copp->n_logical_router] = (struct nbrec_logical_router *)lr; + nbrec_copp_set_logical_router(copp, lr_list, n_logical_router); + free(lr_list); } static void @@ -7177,13 +7252,13 @@ static const struct ctl_command_syntax nbctl_commands[] = { NULL, "", RO }, /* Control plane protection commands */ - {"ls-copp-add", 3, 3, "SWITCH PROTO METER", nbctl_pre_copp, + {"ls-copp-add", 3, 4, "SWITCH PROTO METER", nbctl_pre_copp, nbctl_ls_copp_add, NULL, "", RW}, {"ls-copp-del", 1, 2, "SWITCH [PROTO]", nbctl_pre_copp, nbctl_ls_copp_del, NULL, "", RW}, {"ls-copp-list", 1, 1, "SWITCH", nbctl_pre_copp, nbctl_ls_copp_list, NULL, "", RO}, - {"lr-copp-add", 3, 3, "ROUTER PROTO METER", nbctl_pre_copp, + {"lr-copp-add", 3, 4, "ROUTER PROTO METER", nbctl_pre_copp, nbctl_lr_copp_add, NULL, "", RW}, {"lr-copp-del", 1, 2, "ROUTER [PROTO]", nbctl_pre_copp, nbctl_lr_copp_del, NULL, "", RW},