From patchwork Fri Mar 31 23:46:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 745845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vvyp45vl9z9rvt for ; Sat, 1 Apr 2017 10:46:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oueW0bqB"; dkim-atps=neutral Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E5BACB7F; Fri, 31 Mar 2017 23:46:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 9795CA67 for ; Fri, 31 Mar 2017 23:46:47 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 59C7F86 for ; Fri, 31 Mar 2017 23:46:47 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id g2so20352673pge.2 for ; Fri, 31 Mar 2017 16:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=B9dRiR2kWJSVUOkLYJqhD7bQ/xfvrYBTUr/Bfus9mTk=; b=oueW0bqBloihd0JySG03nEV6xlIVOU7zXiC363vcq6WYtAJl1jvr/yYbe+0FYig5Px ZnKniB6RvEsl0mjEvnxvQxE/irmRsqf/ABpAv0gTI8jlMGjhqoPZ/IsYRSvJ5bPO0bRI tWfVlqZaTr4xYRaKMz90Bw8AAUp1xQRWfs4DvxYNXUKq+r1ff5ISPo3+m4iDvs1GY89Y 6DqE+flgmRe1HrfueIx1cIfygRcIkdJHJ9sqyv9d4KrnFkRSzylb06lDuVVBE64J1gl2 bnlo8/V1zBSMWbVWEvEsC+p1fC059PM67q0eRVu9Tn06oF0W2jwKd5TjsyGz7tLL8Dtw fuGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=B9dRiR2kWJSVUOkLYJqhD7bQ/xfvrYBTUr/Bfus9mTk=; b=OoADjuc0hyiC9WrW8ktqausAGGQjczbF44PLKcAc7q1R0tbp7lbvIS8bsmTs8cHALU gQqxG8MBwOJbntWZyP5cwN/L6g+MdIzy/BWfS6Fdzs5QQoLANK8e/2c9NAuTivPngSvG yRbiVMevp7vC28Mv04dD3O0KbLK8kl75RGEQdFpgv834IVDtb+gjdCn6VA0EEqlJ6lsx +AsIGfAR13zZkM21J4vdIUJhBGNV4iwpTuWWuwMFuzfEGpuXhxwZ3hShma+3GnNFlYjs 5bfj7RENUxBFQPi6E+HcIc/Wip4VKO55S8XRK3DDpajvkP+2y1L58aWY5NHvoV6GAG8Z N27A== X-Gm-Message-State: AFeK/H1+xPPu7bfhMFCLeDN9vUoQxWO1Y32uwOAUfoWS9LiLixyyrOd9YZPL03Mz/g+hsg== X-Received: by 10.84.230.131 with SMTP id e3mr6082513plk.100.1491004006983; Fri, 31 Mar 2017 16:46:46 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.70]) by smtp.gmail.com with ESMTPSA id y83sm12478563pff.83.2017.03.31.16.46.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 16:46:46 -0700 (PDT) From: Han Zhou To: dev@openvswitch.org Date: Fri, 31 Mar 2017 16:46:22 -0700 Message-Id: <1491003982-44081-1-git-send-email-zhouhan@gmail.com> X-Mailer: git-send-email 2.1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovn-sbctl: fix lflow-list when uuid has leading 0s. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When uuid starts with 0s, lflow-list will fail if leading 0s are not included in command argument. This leads to unexpected results considering that leading 0s are usually not shown up in cookies of OpenFlow outputs of tools such as ovs-ofctl dump-flows and ovs-appctl ofproto/trace. E.g. lflow uuid: 0c16ceb4-0409-484b-8297-a6e7f264ac2d $ ovn-nbctl lflow-list 0c16ceb4 # works fine $ ovn-nbctl lflow-list c16ceb4 # doesn't work This patch fixes the problem. Signed-off-by: Han Zhou --- ovn/utilities/ovn-sbctl.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ovn/utilities/ovn-sbctl.c b/ovn/utilities/ovn-sbctl.c index 4e3cbad..612456a 100644 --- a/ovn/utilities/ovn-sbctl.c +++ b/ovn/utilities/ovn-sbctl.c @@ -714,13 +714,24 @@ parse_partial_uuid(char *s) return NULL; } +static const char * +strip_leading_zero(const char *s) +{ + size_t i = 0; + while (s[i++] == '0'); + return s + i; +} + static bool is_partial_uuid_match(const struct uuid *uuid, const char *match) { char uuid_s[UUID_LEN + 1]; snprintf(uuid_s, sizeof uuid_s, UUID_FMT, UUID_ARGS(uuid)); - return !strncmp(uuid_s, match, strlen(match)); + const char *s1 = strip_leading_zero(uuid_s); + const char *s2 = strip_leading_zero(match); + + return !strncmp(s1, s2, strlen(s2)); } static const struct sbrec_datapath_binding *