From patchwork Tue May 12 09:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: taoyunxiang X-Patchwork-Id: 1288319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49Lssp3t94z9sRf for ; Tue, 12 May 2020 19:27:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3296A87008; Tue, 12 May 2020 09:27:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xe6MlLrmVE1v; Tue, 12 May 2020 09:27:53 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7CFFD86F54; Tue, 12 May 2020 09:27:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 53659C088A; Tue, 12 May 2020 09:27:53 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 652F6C016F for ; Tue, 12 May 2020 09:27:50 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 537EA88B88 for ; Tue, 12 May 2020 09:27:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D3PVaRWh746Q for ; Tue, 12 May 2020 09:27:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from cmccmta3.chinamobile.com (cmccmta3.chinamobile.com [221.176.66.81]) by hemlock.osuosl.org (Postfix) with ESMTP id D21A088B79 for ; Tue, 12 May 2020 09:27:47 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.17]) by rmmx-syy-dmz-app10-12010 (RichMail) with SMTP id 2eea5eba6bf1dce-b23ac; Tue, 12 May 2020 17:27:14 +0800 (CST) X-RM-TRANSID: 2eea5eba6bf1dce-b23ac X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from yun.localdomain (unknown[112.25.154.146]) by rmsmtp-syy-appsvr09-12009 (RichMail) with SMTP id 2ee95eba6bf01de-ea75e; Tue, 12 May 2020 17:27:13 +0800 (CST) X-RM-TRANSID: 2ee95eba6bf01de-ea75e From: Tao YunXiang To: dev@openvswitch.org Date: Tue, 12 May 2020 17:27:00 +0800 Message-Id: <20200512092700.122906-1-taoyunxiang@cmss.chinamobile.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <8> References: <8> Cc: Liu Chang , Rong Yin , Tao YunXiang Subject: [ovs-dev] [PATCH OVN, v8] ovn-nbctl.c: Add an optional way to delete QoS by uuid 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" We can delete qos by specify ls and more parameters. If CMS want to delete it exactly, it must specify detailed "match" field. It's not an easy way, also maybe deleted by mistake. This change adds a way to specify ls and uuid, which is optional. You can still use the previous method to delete. usage: ovn-nbctl qos-del ls0 [UUID0] Author: Tao YunXiang Co-authored-by: Liu Chang Co-authored-by: Rong Yin Signed-off-by: Tao YunXiang Signed-off-by: Liu Chang Signed-off-by: Rong Yin --- v7: ovn-nbctl.c: Add an optional way to delete QoS by uuid v6: ovn-nbctl.c: Add an optional way to delete QoS by uuid v5: ovn-nbctl.c: Add an optional way to delete QoS by uuid v4: Add a way to delete QoS by its name or uuid v3: ovn-nbctl.c: Add a way to delete QoS by its name or uuid --- tests/ovn-nbctl.at | 7 +++++-- utilities/ovn-nbctl.8.xml | 19 +++++++++++------ utilities/ovn-nbctl.c | 43 +++++++++++++++++++++++++++++---------- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/tests/ovn-nbctl.at b/tests/ovn-nbctl.at index 1187fe3e1..14de1a8bf 100644 --- a/tests/ovn-nbctl.at +++ b/tests/ovn-nbctl.at @@ -308,13 +308,16 @@ AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip rate=1000101]) AT_CHECK([ovn-nbctl qos-add ls0 from-lport 400 tcp dscp=44]) -AT_CHECK([ovn-nbctl qos-add ls0 from-lport 200 ip burst=1000102 rate=301 dscp=19]) dnl Delete a single flow. AT_CHECK([ovn-nbctl qos-del ls0 from-lport 400 tcp]) AT_CHECK([ovn-nbctl qos-list ls0], [0], [dnl from-lport 600 (ip) rate=1000101 -from-lport 200 (ip) rate=301 burst=1000102 dscp=19 +]) + +dnl Delete QoS rule by specified uuid +AT_CHECK([ovn-nbctl qos-del ls0 $(ovn-nbctl --bare --column _uuid list qos)]) +AT_CHECK([ovn-nbctl list qos], [0], [dnl ]) AT_CHECK([ovn-nbctl qos-add ls0 from-lport 600 ip rate=100010111111], [1], [], diff --git a/utilities/ovn-nbctl.8.xml b/utilities/ovn-nbctl.8.xml index 9c624d40c..d265c7fcc 100644 --- a/utilities/ovn-nbctl.8.xml +++ b/utilities/ovn-nbctl.8.xml @@ -160,12 +160,19 @@
qos-del switch [direction [priority match]]
- Deletes QoS rules from switch. If only - switch is supplied, all the QoS rules from the logical - switch are deleted. If direction is also specified, - then all the flows in that direction will be deleted from the - logical switch. If all the fields are supplied, then a single - flow that matches the given fields will be deleted. +

+ Deletes QoS rules from switch. If only + switch is supplied, all the QoS rules from the logical + switch are deleted. If direction is also specified, + then all the flows in that direction will be deleted from the + logical switch. If all the fields are supplied, then a single + flow that matches the given fields will be deleted. +

+ +

+ If switch and uuid are supplied, then the + QoS rule with sepcified uuid is deleted. +

qos-list switch
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c index 02fc10c9e..960f156c4 100644 --- a/utilities/ovn-nbctl.c +++ b/utilities/ovn-nbctl.c @@ -604,7 +604,7 @@ ACL commands:\n\ QoS commands:\n\ qos-add SWITCH DIRECTION PRIORITY MATCH [rate=RATE [burst=BURST]] [dscp=DSCP]\n\ add an QoS rule to SWITCH\n\ - qos-del SWITCH [DIRECTION [PRIORITY MATCH]]\n\ + qos-del SWITCH [{DIRECTION | UUID} [PRIORITY MATCH]]\n\ remove QoS rules from SWITCH\n\ qos-list SWITCH print QoS rules for SWITCH\n\ \n\ @@ -2526,22 +2526,43 @@ nbctl_qos_del(struct ctl_context *ctx) } const char *direction; - error = parse_direction(ctx->argv[2], &direction); - if (error) { - ctx->error = error; - return; + const struct uuid *qos_rule_uuid = NULL; + struct uuid uuid_from_cmd; + if (uuid_from_string(&uuid_from_cmd, ctx->argv[2])) { + qos_rule_uuid = &uuid_from_cmd; + } else { + error = parse_direction(ctx->argv[2], &direction); + if (error) { + ctx->error = error; + return; + } } - /* If priority and match are not specified, delete all qos_rules with the - * specified direction. */ + /* If uuid was specified, delete qos_rule with the + * specified uuid. */ if (ctx->argc == 3) { struct nbrec_qos **new_qos_rules = xmalloc(sizeof *new_qos_rules * ls->n_qos_rules); int n_qos_rules = 0; - for (size_t i = 0; i < ls->n_qos_rules; i++) { - if (strcmp(direction, ls->qos_rules[i]->direction)) { - new_qos_rules[n_qos_rules++] = ls->qos_rules[i]; + if (qos_rule_uuid) { + for (size_t i = 0; i < ls->n_qos_rules; i++) { + if (!uuid_equals(qos_rule_uuid, + &(ls->qos_rules[i]->header_.uuid))) { + new_qos_rules[n_qos_rules++] = ls->qos_rules[i]; + } + } + if (n_qos_rules == ls->n_qos_rules) { + ctl_error(ctx, "uuid is not found"); + } + + /* If priority and match are not specified, delete all qos_rules + * with the specified direction. */ + } else { + for (size_t i = 0; i < ls->n_qos_rules; i++) { + if (strcmp(direction, ls->qos_rules[i]->direction)) { + new_qos_rules[n_qos_rules++] = ls->qos_rules[i]; + } } } @@ -6149,7 +6170,7 @@ static const struct ctl_command_syntax nbctl_commands[] = { { "qos-add", 5, 7, "SWITCH DIRECTION PRIORITY MATCH [rate=RATE [burst=BURST]] [dscp=DSCP]", NULL, nbctl_qos_add, NULL, "--may-exist", RW }, - { "qos-del", 1, 4, "SWITCH [DIRECTION [PRIORITY MATCH]]", NULL, + { "qos-del", 1, 4, "SWITCH [{DIRECTION | UUID} [PRIORITY MATCH]]", NULL, nbctl_qos_del, NULL, "", RW }, { "qos-list", 1, 1, "SWITCH", NULL, nbctl_qos_list, NULL, "", RO },