From patchwork Thu Nov 22 09:43:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: solomon X-Patchwork-Id: 1001638 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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VDkBSzng"; dkim-atps=neutral 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 430vfF65zyz9s5c for ; Thu, 22 Nov 2018 20:44:05 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 56A68CD7; Thu, 22 Nov 2018 09:43:21 +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 CEF36CCE for ; Thu, 22 Nov 2018 09:43:19 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CF20667F for ; Thu, 22 Nov 2018 09:43:18 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id b5so9027180plr.4 for ; Thu, 22 Nov 2018 01:43:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=LinPr3ldtJmkWfTKoRzm1tt2pqTolCG7eZS2Jfps2gU=; b=VDkBSzngFulFX78vv3KasdDKB/gZDK8gbm7RjwOUtkKLLjP+WTTJ/gXthVasuJDleY nmO/VhEee8VU4prv2741FAToBoiYNC2QHzpuugehszJzT08EiJCCtAhfgFX40HVAm/7T c2AzuvmGvHjlVslI54Z5PjarNFDD7il43cEj9zO1B88RACZUqij5ExB4E6Vuz3PTugOw KOsK1BINz/qwvwt3rvC6MPctkxOjwlXNwj4I+VX9iFMqGcPCDPj7rf4JWPJbhrLHSBhS /Jcbo/6rPjwlrzh8LEB5ketD+huLrAxyWU8bMsxPLk2nTNIdgmtbIKrSmdol6W/eU/8E 9dQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=LinPr3ldtJmkWfTKoRzm1tt2pqTolCG7eZS2Jfps2gU=; b=B88Re+bF5EMRatTv6fH4Py584RCbOS4XIiMCs4Dc6nkFRnWCgfyRd3e8fZIsGtfphz izxv2ZFkVPImVKZTVsIZ3HI2diOs6Hu/hEnK3k+aoa4tyUbOuTlEqR/Fcyv+n6AesY+8 /dURXku7b5sjlDse/liWMsMlGcW3zj+72yBXY1Nd5xFIWz3RV8PfLHTW2EkpkTG2Ym69 DJKfEcqFdmBP7WFEjMR+h8K2z9Wu+RFKDWSOwMfx67nSRo2CZr2KL0aNmQ1yXKNqd0gs jM3xLzEO7zC7+IG6QWoM4XmlOaW9fRuyY2brdMnOlJBD8tq2zVKDJVdpRY9+J05oSlK/ nAqQ== X-Gm-Message-State: AA+aEWZbwAsV31ubpAq8oCrc8vMd/axIA+k4wQF9AYKb+ZnQ3TXr7wDN Xau9dM4J6Fi5HJhA7cJiogDSGOWc X-Google-Smtp-Source: AFSGD/U7xX7Fb0Pv7NNaou6wBqKgwBi3GZr4bfs711tX5lAzDiNsDxH758t0A46eUe/qaanJvX2uBQ== X-Received: by 2002:a17:902:2d81:: with SMTP id p1-v6mr10290788plb.97.1542879798257; Thu, 22 Nov 2018 01:43:18 -0800 (PST) Received: from solomondeMacBook-Pro.local ([47.74.215.247]) by smtp.gmail.com with ESMTPSA id t12sm48916255pfi.45.2018.11.22.01.43.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 01:43:17 -0800 (PST) To: Ben Pfaff From: solomon Message-ID: <4f04d061-199e-185a-9c92-63532946050c@gmail.com> Date: Thu, 22 Nov 2018 17:43:09 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: dev@openvswitch.org Subject: [ovs-dev] [PATCH ] ovs:group: support to insert bucket with weight value for select type 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 After creating a group with hash select type,then we need to insert a new bucket with weight, But,it fails. Commands are as following: # ovs-ofctl -O OpenFlow15 add-group br0 "group_id=10, type=select, selection_method=hash,fields=tcp_src, bucket=bucket_id=10,weight:99,actions=output:1, bucket=bucket_id=20,weight:199,actions=output:1 " # ovs-ofctl -O OpenFlow15 insert-buckets br0 "group_id=10,type=select command_bucket_id=last,bucket=bucket_id=3,weight=100,actions=output:1" ovs-ofctl: type is not needed # ovs-ofctl -O OpenFlow15 insert-buckets br0 "group_id=10 command_bucket_id=last,bucket=bucket_id=3,weight=100,actions=output:1" ovs-ofctl: Only select groups can have bucket weights. This patch can help us. However, for other types that are not select, the check of the parameters is not strict, but it does not affect their function, because other types do not use this weight parameter. Signed-off-by: LiWei --- lib/ofp-group.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ofp-group.c b/lib/ofp-group.c index c9e95ad4c..a4677310a 100644 --- a/lib/ofp-group.c +++ b/lib/ofp-group.c @@ -1043,7 +1043,7 @@ parse_ofp_group_mod_str__(struct ofputil_group_mod *gm, int command, } ovs_list_push_back(&gm->buckets, &bucket->list_node); - if (gm->type != OFPGT11_SELECT && bucket->weight) { + if (gm->command != OFPGC15_INSERT_BUCKET && gm->type != OFPGT11_SELECT && bucket->weight) { error = xstrdup("Only select groups can have bucket weights."); goto out; } @@ -1176,7 +1176,8 @@ ofputil_put_ofp11_bucket(const struct ofputil_bucket *bucket, static void ofputil_put_ofp15_bucket(const struct ofputil_bucket *bucket, uint32_t bucket_id, enum ofp11_group_type group_type, - struct ofpbuf *openflow, enum ofp_version ofp_version) + struct ofpbuf *openflow, enum ofp_version ofp_version, + int group_command) { struct ofp15_bucket *ob; size_t start, actions_start, actions_len; @@ -1188,8 +1189,7 @@ ofputil_put_ofp15_bucket(const struct ofputil_bucket *bucket, ofpacts_put_openflow_actions(bucket->ofpacts, bucket->ofpacts_len, openflow, ofp_version); actions_len = openflow->size - actions_start; - - if (group_type == OFPGT11_SELECT) { + if (group_type == OFPGT11_SELECT || group_command == OFPGC15_INSERT_BUCKET) { ofpprop_put_u16(openflow, OFPGBPT15_WEIGHT, bucket->weight); } if (bucket->watch_port != OFPP_ANY) { @@ -1266,7 +1266,7 @@ ofputil_append_ofp15_group_desc_reply(const struct ofputil_group_desc *gds, start_buckets = reply->size; LIST_FOR_EACH (bucket, list_node, buckets) { ofputil_put_ofp15_bucket(bucket, bucket->bucket_id, - gds->type, reply, version); + gds->type, reply, version, -1); } ogds = ofpbuf_at_assert(reply, start_ogds, sizeof *ogds); ogds->type = gds->type; @@ -2066,7 +2066,7 @@ ofputil_encode_ofp15_group_mod(enum ofp_version ofp_version, bucket_id = bucket->bucket_id; } - ofputil_put_ofp15_bucket(bucket, bucket_id, gm->type, b, ofp_version); + ofputil_put_ofp15_bucket(bucket, bucket_id, gm->type, b, ofp_version, gm->command); } ogm = ofpbuf_at_assert(b, start_ogm, sizeof *ogm); ogm->command = htons(gm->command != OFPGC11_ADD_OR_MOD || group_existed < 0 @@ -2251,7 +2251,8 @@ ofputil_check_group_mod(const struct ofputil_group_mod *gm) struct ofputil_bucket *bucket; LIST_FOR_EACH (bucket, list_node, &gm->buckets) { - if (bucket->weight && gm->type != OFPGT11_SELECT) { + if (bucket->weight && gm->type != OFPGT11_SELECT && + gm->command != OFPGC15_INSERT_BUCKET) { return OFPERR_OFPGMFC_INVALID_GROUP; }