From patchwork Fri Feb 2 02:50:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoshuai Li X-Patchwork-Id: 868495 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=) 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 3zXhLh2Mr6z9sBW for ; Fri, 2 Feb 2018 13:50:52 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 341D4F8D; Fri, 2 Feb 2018 02:50:49 +0000 (UTC) X-Original-To: ovs-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 DDFFAF88 for ; Fri, 2 Feb 2018 02:50:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtp2203-239.mail.aliyun.com (smtp2203-239.mail.aliyun.com [121.197.203.239]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 4BB27315 for ; Fri, 2 Feb 2018 02:50:45 +0000 (UTC) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07449599|-1; CH=green; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03302; MF=ligs@dtdream.com; NM=1; PH=DS; RN=2; RT=2; SR=0; TI=SMTPD_---.AgaLPVK_1517539839; Received: from localhost.localdomain(mailfrom:ligs@dtdream.com fp:222.128.6.212) by smtp.aliyun-inc.com(10.147.41.158); Fri, 02 Feb 2018 10:50:40 +0800 From: Guoshuai Li To: ovs-dev@openvswitch.org Date: Fri, 2 Feb 2018 10:50:29 +0800 Message-Id: <20180202025029.14096-1-ligs@dtdream.com> X-Mailer: git-send-email 2.13.2.windows.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham 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-controller: processing matches precedes processing action in logical flow. 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 This is to fix such a problem: When the match field has "is_chassis_resident", and the chassis has no resident, and the action has meter or group, the group/meter ID is assigned. I hope to parse match field with the first, if there is no matches field, we do not need to deal with the action field. Signed-off-by: Guoshuai Li --- ovn/controller/lflow.c | 63 +++++++++++++++++++++++++++++--------------------- tests/ovn.at | 15 +++++++++++- 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c index 1e79a5355..0d4a3d6d5 100644 --- a/ovn/controller/lflow.c +++ b/ovn/controller/lflow.c @@ -254,31 +254,6 @@ consider_logical_flow(struct controller_ctx *ctx, return; } - /* Encode OVN logical actions into OpenFlow. */ - uint64_t ofpacts_stub[1024 / 8]; - struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub); - struct lookup_port_aux aux = { - .ovnsb_idl = ctx->ovnsb_idl, - .dp = lflow->logical_datapath - }; - struct ovnact_encode_params ep = { - .lookup_port = lookup_port_cb, - .aux = &aux, - .is_switch = is_switch(ldp), - .is_gateway_router = is_gateway_router(ldp, local_datapaths), - .group_table = group_table, - .meter_table = meter_table, - - .pipeline = ingress ? OVNACT_P_INGRESS : OVNACT_P_EGRESS, - .ingress_ptable = OFTABLE_LOG_INGRESS_PIPELINE, - .egress_ptable = OFTABLE_LOG_EGRESS_PIPELINE, - .output_ptable = output_ptable, - .mac_bind_ptable = OFTABLE_MAC_BINDING, - }; - ovnacts_encode(ovnacts.data, ovnacts.size, &ep, &ofpacts); - ovnacts_free(ovnacts.data, ovnacts.size); - ofpbuf_uninit(&ovnacts); - /* Translate OVN match into table of OpenFlow matches. */ struct hmap matches; struct expr *expr; @@ -296,11 +271,16 @@ consider_logical_flow(struct controller_ctx *ctx, VLOG_WARN_RL(&rl, "error parsing match \"%s\": %s", lflow->match, error); expr_destroy(prereqs); - ofpbuf_uninit(&ofpacts); free(error); + ovnacts_free(ovnacts.data, ovnacts.size); + ofpbuf_uninit(&ovnacts); return; } + struct lookup_port_aux aux = { + .ovnsb_idl = ctx->ovnsb_idl, + .dp = lflow->logical_datapath + }; struct condition_aux cond_aux = { ctx->ovnsb_idl, chassis, active_tunnels, chassis_index}; expr = expr_simplify(expr, is_chassis_resident_cb, &cond_aux); @@ -309,6 +289,37 @@ consider_logical_flow(struct controller_ctx *ctx, &matches); expr_destroy(expr); + if (hmap_is_empty(&matches)) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_WARN_RL(&rl, " \"%s\": matches is empty", lflow->match); + free(error); + ovnacts_free(ovnacts.data, ovnacts.size); + ofpbuf_uninit(&ovnacts); + expr_matches_destroy(&matches); + return; + } + + /* Encode OVN logical actions into OpenFlow. */ + uint64_t ofpacts_stub[1024 / 8]; + struct ofpbuf ofpacts = OFPBUF_STUB_INITIALIZER(ofpacts_stub); + struct ovnact_encode_params ep = { + .lookup_port = lookup_port_cb, + .aux = &aux, + .is_switch = is_switch(ldp), + .is_gateway_router = is_gateway_router(ldp, local_datapaths), + .group_table = group_table, + .meter_table = meter_table, + + .pipeline = ingress ? OVNACT_P_INGRESS : OVNACT_P_EGRESS, + .ingress_ptable = OFTABLE_LOG_INGRESS_PIPELINE, + .egress_ptable = OFTABLE_LOG_EGRESS_PIPELINE, + .output_ptable = output_ptable, + .mac_bind_ptable = OFTABLE_MAC_BINDING, + }; + ovnacts_encode(ovnacts.data, ovnacts.size, &ep, &ofpacts); + ovnacts_free(ovnacts.data, ovnacts.size); + ofpbuf_uninit(&ovnacts); + /* Prepare the OpenFlow matches for adding to the flow table. */ struct expr_match *m; HMAP_FOR_EACH (m, hmap_node, &matches) { diff --git a/tests/ovn.at b/tests/ovn.at index 734dc6c1d..1632a981b 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -5972,8 +5972,10 @@ ovn_start ovn-nbctl ls-add lsw0 ovn-nbctl --wait=sb lsp-add lsw0 lp1 ovn-nbctl --wait=sb lsp-add lsw0 lp2 +ovn-nbctl --wait=sb lsp-add lsw0 lp3 ovn-nbctl lsp-set-addresses lp1 f0:00:00:00:00:01 ovn-nbctl lsp-set-addresses lp2 f0:00:00:00:00:02 +ovn-nbctl lsp-set-addresses lp3 f0:00:00:00:00:03 ovn-nbctl lsp-set-port-security lp1 f0:00:00:00:00:01 ovn-nbctl lsp-set-port-security lp2 f0:00:00:00:00:02 ovn-nbctl --wait=sb sync @@ -6032,7 +6034,7 @@ AT_CHECK([get_final_nw_tos], [0], [none check_tos 0 # Mark DSCP with a valid value -qos_id=$(ovn-nbctl --wait=hv -- --id=@lp1-qos create QoS priority=100 action=dscp=48 match="inport\=\=\"lp1\"" direction="from-lport" -- set Logical_Switch lsw0 qos_rules=@lp1-qos) +qos_id=$(ovn-nbctl --wait=hv -- --id=@lp1-qos create QoS priority=100 action=dscp=48 match="inport\=\=\"lp1\"\ &&\ is_chassis_resident(\"lp1\")" direction="from-lport" -- set Logical_Switch lsw0 qos_rules=@lp1-qos) AT_CHECK([as hv ovn-nbctl qos-list lsw0 | wc -l], [0], [1 ]) check_tos 48 @@ -6076,6 +6078,17 @@ check_tos 0 AT_CHECK([as hv ovs-ofctl dump-flows br-int -O OpenFlow13 | grep meter | wc -l], [0], [0 ]) +# check meter with chassis not resident +ovn-nbctl qos-add lsw0 to-lport 1001 'inport=="lp3" && is_chassis_resident("lp3")' rate=11123 burst=111230 +AT_CHECK([as hv ovn-nbctl qos-list lsw0 | wc -l], [0], [1 +]) + +# check no meter table +AT_CHECK([as hv ovs-ofctl dump-flows br-int -O OpenFlow13 | grep meter | wc -l], [0], [0 +]) +AT_CHECK([as hv ovs-ofctl dump-meters br-int -O OpenFlow13 | grep rate=11123 | wc -l], [0], [0 +]) + OVN_CLEANUP([hv]) AT_CLEANUP