From patchwork Tue Feb 20 19:04:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 875633 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="PI6bxYth"; 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 3zmDMS6GSQz9s4X for ; Wed, 21 Feb 2018 08:31:31 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BC6F41342; Tue, 20 Feb 2018 19:05:47 +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 778DD133F for ; Tue, 20 Feb 2018 19:05:43 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C72AD1E1 for ; Tue, 20 Feb 2018 19:05:40 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id f6so7465623pgs.10 for ; Tue, 20 Feb 2018 11:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nWPqUiI21jGgQzgI4goaOR1NwgSPDbHKc0zYq8W8zxg=; b=PI6bxYthI3KElocFnuddcRtEIzwKT9TZCuFCWWQvAA1aDOJ8PDzo8DFZceYoGR2Odz C4BoCzeva9mWL+N59WzCWXqQzw4NefrDd2GwUxC+ZdYidEtdXXv8d6GteAdUIwBYEyLG +HHwuD1g/9Ig6noQylJFzopp66K9Dchwn4bgnsR1hkFyoeF8d0RXj05FudEHNWuiMmnm yVYQk/cuio6GrnXd8dslAv5P+KTNgOCU6ebVjFH0LWWkDuAwFh1csj4iFabY8JsLsl8s Nc1eTQC4dKe8NdG19I5gZIiB3DVcaR+wo1zzpaxBD8IP11i/MNQWyoPC09Ytm8PIrVHN 8How== 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:in-reply-to :references; bh=nWPqUiI21jGgQzgI4goaOR1NwgSPDbHKc0zYq8W8zxg=; b=It2nmOUKA5rT7u4iH5myPQECn/qFtf6o708Dm2V2oH9Yre+hWgs/MzVZKn09MzI8cw xWuTylBdw4QPexJ1+EiIB1XWhh5oGu7DzrRIOF1AO3pnYKmEz1KJ6Y/lPdzA6Kcf+tRq UicXkD4ln3YhjXbDS+PX0KhxVDNv0nUN66clMBSI++Ozp/9djUBSISI58Ex+2MjWe4q8 fJvU8Sa1vOc3cEXjd20zNblU86urLvve1R9TmOpuV97c0lJcnd7lS+6iMJY9OY1Nq9hT 6dRSGsEgJhpijjtrJLip+E48ojR/YDIm82xuUBzkR8MRKnhlf7KqQe6Az5ng3/6bzcUI nj9w== X-Gm-Message-State: APf1xPCajiXA3aaYU2/90/gJs6Q/6r8MAX7WoVXjvfipo61VKnDp4t/g RuDfRm094rxp684b2mHqYDMogA== X-Google-Smtp-Source: AH8x2245ty8Gng7hb2Qj0FpYxeb3mhbCfGsPClG9unHgiFdrRjcVa02WreTOyrzCBrYhNrc9LzKPcw== X-Received: by 10.98.49.7 with SMTP id x7mr608940pfx.101.1519153540103; Tue, 20 Feb 2018 11:05:40 -0800 (PST) Received: from localhost.localdomain.localdomain ([216.113.160.71]) by smtp.gmail.com with ESMTPSA id m9sm61761846pff.59.2018.02.20.11.05.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 11:05:39 -0800 (PST) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Tue, 20 Feb 2018 11:04:44 -0800 Message-Id: <1519153484-11253-9-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1519153484-11253-1-git-send-email-hzhou8@ebay.com> References: <1519153484-11253-1-git-send-email-hzhou8@ebay.com> 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 Subject: [ovs-dev] [RFC 8/8] ovn-controller: port-binding incremental processing for physical flows 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 patch implements change handler for port-binding in flow_output for physical flows computing, so that physical flow computing will be incremental. This patch together with previous incremental processing engine related changes supports incremental processing for lflow changes and port-binding changes of lports on other HVs, which are the most common scenarios in a cloud where workloads come up and down. The CPU time of ovn-controller in ovn-scale-test for 500 lports creating and binding decreased 90% comparing with master without incremental processing engine related changes. (TODO: test case 2337 failed) Signed-off-by: Han Zhou --- ovn/controller/ovn-controller.c | 36 ++++++++++++++++++++++++++++++++++- ovn/controller/physical.c | 42 ++++++++++++++++++++++++++++++++++------- ovn/controller/physical.h | 6 ++++++ 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 31f78f1..b92dcf5 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -780,6 +780,40 @@ flow_output_sb_logical_flow_handler(struct engine_node *node) return true; } +static bool +flow_output_sb_port_binding_handler(struct engine_node *node) +{ + struct controller_ctx *ctx = (struct controller_ctx *)node->context; + struct ed_type_runtime_data *data = + (struct ed_type_runtime_data *)engine_get_input( + "runtime_data", node)->data; + struct hmap *local_datapaths = data->local_datapaths; + struct sset *active_tunnels = data->active_tunnels; + struct chassis_index *chassis_index = data->chassis_index; + const struct ovsrec_bridge *br_int = get_br_int(ctx); + + const char *chassis_id = get_chassis_id(ctx->ovs_idl); + + + const struct sbrec_chassis *chassis = NULL; + if (chassis_id) { + chassis = get_chassis(ctx->ovnsb_idl, chassis_id); + } + + ovs_assert(br_int && chassis); + + // TODO: handle port-binding for lflow processing + + enum mf_field_id mff_ovn_geneve = ofctrl_get_mf_field_id(); + physical_handle_port_binding_changes(ctx, mff_ovn_geneve, + chassis, ctx->ct_zones, + local_datapaths, + chassis_index, active_tunnels); + + node->changed = true; + return true; +} + int main(int argc, char *argv[]) { @@ -911,7 +945,7 @@ main(int argc, char *argv[]) engine_add_input(&en_flow_output, &en_sb_address_set, NULL); engine_add_input(&en_flow_output, &en_sb_multicast_group, NULL); engine_add_input(&en_flow_output, &en_sb_datapath_binding, NULL); - engine_add_input(&en_flow_output, &en_sb_port_binding, NULL); + engine_add_input(&en_flow_output, &en_sb_port_binding, flow_output_sb_port_binding_handler); engine_add_input(&en_flow_output, &en_sb_mac_binding, NULL); engine_add_input(&en_flow_output, &en_sb_logical_flow, flow_output_sb_logical_flow_handler); engine_add_input(&en_flow_output, &en_sb_dhcp_options, NULL); diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c index 41ea9fe..b14051b 100644 --- a/ovn/controller/physical.c +++ b/ovn/controller/physical.c @@ -358,7 +358,7 @@ consider_port_binding(struct controller_ctx *ctx, ofpact_finish_CLONE(ofpacts_p, &clone); ofctrl_add_flow(OFTABLE_LOG_TO_PHY, 100, 0, - &match, ofpacts_p, hc_uuid); + &match, ofpacts_p, &binding->header_.uuid); return; } @@ -426,7 +426,7 @@ consider_port_binding(struct controller_ctx *ctx, } ofctrl_add_flow(OFTABLE_LOCAL_OUTPUT, 100, 0, - &match, ofpacts_p, hc_uuid); + &match, ofpacts_p, &binding->header_.uuid); goto out; } @@ -558,7 +558,7 @@ consider_port_binding(struct controller_ctx *ctx, /* Resubmit to first logical ingress pipeline table. */ put_resubmit(OFTABLE_LOG_INGRESS_PIPELINE, ofpacts_p); ofctrl_add_flow(OFTABLE_PHY_TO_LOG, - tag ? 150 : 100, 0, &match, ofpacts_p, hc_uuid); + tag ? 150 : 100, 0, &match, ofpacts_p, &binding->header_.uuid); if (!tag && (!strcmp(binding->type, "localnet") || !strcmp(binding->type, "l2gateway"))) { @@ -568,7 +568,7 @@ consider_port_binding(struct controller_ctx *ctx, * action. */ ofpbuf_pull(ofpacts_p, ofpacts_orig_size); match_set_dl_tci_masked(&match, 0, htons(VLAN_CFI)); - ofctrl_add_flow(0, 100, 0, &match, ofpacts_p, hc_uuid); + ofctrl_add_flow(0, 100, 0, &match, ofpacts_p, &binding->header_.uuid); } /* Table 65, Priority 100. @@ -596,7 +596,7 @@ consider_port_binding(struct controller_ctx *ctx, ofpact_put_STRIP_VLAN(ofpacts_p); } ofctrl_add_flow(OFTABLE_LOG_TO_PHY, 100, 0, - &match, ofpacts_p, hc_uuid); + &match, ofpacts_p, &binding->header_.uuid); } else if (!tun && !is_ha_remote) { /* Remote port connected by localnet port */ /* Table 33, priority 100. @@ -619,7 +619,7 @@ consider_port_binding(struct controller_ctx *ctx, /* Resubmit to table 33. */ put_resubmit(OFTABLE_LOCAL_OUTPUT, ofpacts_p); ofctrl_add_flow(OFTABLE_LOCAL_OUTPUT, 100, 0, - &match, ofpacts_p, hc_uuid); + &match, ofpacts_p, &binding->header_.uuid); } else { /* Remote port connected by tunnel */ @@ -710,7 +710,7 @@ consider_port_binding(struct controller_ctx *ctx, ofpact_finish_BUNDLE(ofpacts_p, &bundle); } ofctrl_add_flow(OFTABLE_REMOTE_OUTPUT, 100, 0, - &match, ofpacts_p, hc_uuid); + &match, ofpacts_p, &binding->header_.uuid); } out: if (gateway_chassis) { @@ -857,6 +857,33 @@ update_ofports(struct simap *old, struct simap *new) } void +physical_handle_port_binding_changes(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, + const struct sbrec_chassis *chassis, + const struct simap *ct_zones, + struct hmap *local_datapaths, + struct chassis_index *chassis_index, + struct sset *active_tunnels) +{ + const struct sbrec_port_binding *binding; + struct ofpbuf ofpacts; + ofpbuf_init(&ofpacts, 0); + SBREC_PORT_BINDING_FOR_EACH_TRACKED (binding, ctx->ovnsb_idl) { + if (sbrec_port_binding_is_deleted(binding)) { + ofctrl_remove_flows(&binding->header_.uuid); + } else { + if (!sbrec_port_binding_is_new(binding)) { + ofctrl_remove_flows(&binding->header_.uuid); + } + consider_port_binding(ctx, mff_ovn_geneve, ct_zones, + chassis_index, active_tunnels, + local_datapaths, binding, chassis, + &ofpacts); + } + } + +} + +void physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, const struct ovsrec_bridge *br_int, const struct sbrec_chassis *chassis, @@ -978,6 +1005,7 @@ physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, /* Capture changed or removed openflow ports. */ physical_map_changed |= update_ofports(&localvif_to_ofport, &new_localvif_to_ofport); + // TODO: maybe this is not needed any more? if (physical_map_changed) { /* Reprocess logical flow table immediately. */ poll_immediate_wake(); diff --git a/ovn/controller/physical.h b/ovn/controller/physical.h index 4aeec04..e0b31a4 100644 --- a/ovn/controller/physical.h +++ b/ovn/controller/physical.h @@ -51,5 +51,11 @@ void physical_run(struct controller_ctx *, enum mf_field_id mff_ovn_geneve, const struct sset *local_lports, struct chassis_index *chassis_index, struct sset *active_tunnels); +void physical_handle_port_binding_changes(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve, + const struct sbrec_chassis *chassis, + const struct simap *ct_zones, + struct hmap *local_datapaths, + struct chassis_index *chassis_index, + struct sset *active_tunnels); #endif /* ovn/physical.h */