From patchwork Tue Jul 16 17:18:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 1132884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.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 45p6Yh4SyHz9s3l for ; Wed, 17 Jul 2019 03:18:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E5D87DC2; Tue, 16 Jul 2019 17:18:28 +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 3DB5DD1A for ; Tue, 16 Jul 2019 17:18:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8EF1C8BA for ; Tue, 16 Jul 2019 17:18:27 +0000 (UTC) Received: from sigill.benpfaff.org (unknown [66.170.99.95]) (Authenticated sender: blp@ovn.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id DE7DA100004; Tue, 16 Jul 2019 17:18:21 +0000 (UTC) From: Ben Pfaff To: dev@openvswitch.org Date: Tue, 16 Jul 2019 10:18:18 -0700 Message-Id: <20190716171818.26327-1-blp@ovn.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Ben Pfaff Subject: [ovs-dev] [PATCH] ofp-flow: Improve error message when cookie cannot be set. 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org The "cookie" value has two meanings in "ovs-ofctl add-flow", etc. With a mask, it indicates a match; without a mask, it indicates that the cookie should be set. In some case, the cookie cannot be set, which may mean that the user meant to indicate a match. The error message for this case was poor; this improves it. Suggested-by: "Yi Yang (杨燚)-云服务集团" Signed-off-by: Ben Pfaff Reviewed-by: Greg Rose --- lib/ofp-flow.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ofp-flow.c b/lib/ofp-flow.c index c45afd204f80..ff0396845a4e 100644 --- a/lib/ofp-flow.c +++ b/lib/ofp-flow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2017 Nicira, Inc. + * Copyright (c) 2008-2017, 2019 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1660,7 +1660,9 @@ parse_ofp_str__(struct ofputil_flow_mod *fm, int command, char *string, /* No mask means that the cookie is being set. */ if (command != OFPFC_ADD && command != OFPFC_MODIFY && command != OFPFC_MODIFY_STRICT) { - return xstrdup("cannot set cookie"); + return xasprintf("cannot set cookie (to match on a " + "cookie, specify a mask, e.g. " + "cookie=%s/-1)", value); } error = str_to_be64(value, &fm->new_cookie); fm->modify_cookie = true;