From patchwork Wed Jan 22 13:58:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1227297 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=hemlock.osuosl.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482n7Q6s6Wz9sNF for ; Thu, 23 Jan 2020 00:58:42 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2C50787D28; Wed, 22 Jan 2020 13:58:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z9zADDs1KHcz; Wed, 22 Jan 2020 13:58:39 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 4758087B8A; Wed, 22 Jan 2020 13:58:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 25E8EC0176; Wed, 22 Jan 2020 13:58:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id D650FC0174 for ; Wed, 22 Jan 2020 13:58:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id D2EE485FB0 for ; Wed, 22 Jan 2020 13:58:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0vhMv6UxD5y9 for ; Wed, 22 Jan 2020 13:58:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 91D2981195 for ; Wed, 22 Jan 2020 13:58:36 +0000 (UTC) X-Originating-IP: 116.75.75.144 Received: from nummac.local (unknown [116.75.75.144]) (Authenticated sender: numans@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 0EE2840008; Wed, 22 Jan 2020 13:58:32 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Wed, 22 Jan 2020 19:28:20 +0530 Message-Id: <20200122135820.1139953-1-numans@ovn.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH 1/2] Make is_switch() in lflow.c a util function X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique This patch renames is_switch() to datapath_is_switch() and moves to lib/ovn-util.c. Upcoming patch will make use of it. Signed-off-by: Numan Siddique --- controller/lflow.c | 11 ++--------- lib/ovn-util.c | 6 ++++++ lib/ovn-util.h | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/controller/lflow.c b/controller/lflow.c index 997c59662..96f2f7491 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -130,13 +130,6 @@ is_chassis_resident_cb(const void *c_aux_, const char *port_name) } } -static bool -is_switch(const struct sbrec_datapath_binding *ldp) -{ - return smap_get(&ldp->external_ids, "logical-switch") != NULL; - -} - void lflow_resource_init(struct lflow_resource_ref *lfrr) { @@ -774,7 +767,7 @@ consider_logical_flow( struct ovnact_encode_params ep = { .lookup_port = lookup_port_cb, .aux = &aux, - .is_switch = is_switch(ldp), + .is_switch = datapath_is_switch(ldp), .group_table = group_table, .meter_table = meter_table, .lflow_uuid = lflow->header_.uuid, @@ -798,7 +791,7 @@ consider_logical_flow( if (m->match.wc.masks.conj_id) { m->match.flow.conj_id += *conj_id_ofs; } - if (is_switch(ldp)) { + if (datapath_is_switch(ldp)) { unsigned int reg_index = (ingress ? MFF_LOG_INPORT : MFF_LOG_OUTPORT) - MFF_REG0; int64_t port_id = m->match.flow.regs[reg_index]; diff --git a/lib/ovn-util.c b/lib/ovn-util.c index e67c3c073..6e0bba2c5 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -423,3 +423,9 @@ ovn_logical_flow_hash(const struct uuid *logical_datapath, hash = hash_string(match, hash); return hash_string(actions, hash); } + +bool +datapath_is_switch(const struct sbrec_datapath_binding *ldp) +{ + return smap_get(&ldp->external_ids, "logical-switch") != NULL; +} diff --git a/lib/ovn-util.h b/lib/ovn-util.h index b58208e9b..422d69e5b 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -23,6 +23,7 @@ struct sbrec_logical_flow; struct uuid; struct eth_addr; struct sbrec_port_binding; +struct sbrec_datapath_binding; struct ipv4_netaddr { ovs_be32 addr; /* 192.168.10.123 */ @@ -86,5 +87,5 @@ uint32_t ovn_logical_flow_hash(const struct uuid *logical_datapath, uint8_t table_id, const char *pipeline, uint16_t priority, const char *match, const char *actions); - +bool datapath_is_switch(const struct sbrec_datapath_binding *); #endif From patchwork Wed Jan 22 13:58:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1227298 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.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 silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 482n7n0vFZz9sNF for ; Thu, 23 Jan 2020 00:59:00 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1680A2035E; Wed, 22 Jan 2020 13:58:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0QRwpm-e7IiA; Wed, 22 Jan 2020 13:58:56 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id EC0AB20368; Wed, 22 Jan 2020 13:58:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D2AAEC1D80; Wed, 22 Jan 2020 13:58:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5C235C0174 for ; Wed, 22 Jan 2020 13:58:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 58B7885FB2 for ; Wed, 22 Jan 2020 13:58:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MhJ51PFddVtk for ; Wed, 22 Jan 2020 13:58:52 +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 fraxinus.osuosl.org (Postfix) with ESMTPS id F29FA81195 for ; Wed, 22 Jan 2020 13:58:51 +0000 (UTC) Received: from nummac.local (unknown [116.75.75.144]) (Authenticated sender: numans@ovn.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id 2DF19100002; Wed, 22 Jan 2020 13:58:47 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Wed, 22 Jan 2020 19:28:41 +0530 Message-Id: <20200122135841.1140060-1-numans@ovn.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200122135820.1139953-1-numans@ovn.org> References: <20200122135820.1139953-1-numans@ovn.org> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH 2/2] ovn-controller: Remove ports from struct local_datapaths. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique struct local_datapaths stores the array of port bindings for each datapath. These ports are used only in the pinctrl module to check if a mac binding has been learnt for the buffered packets. MAC bindings are always learnt in the router pipeline and so logical_port column of MAC_Binding table will always refer to a logical router port. run_buffered_binding() of pinctrl module can use the peer ports stored in the struct local_datapaths instead. This would save many calls to mac_binding_lookup(). This patch doesn't store the array of port bindings for each local datapath as it is not required at all. Earlier, the peer ports were stored only for patch port bindings. But we can have peer ports even for l3gateway port bindings. This patch now considers l3gateway ports also for storing the peer ports in struct local_datapaths. Signed-off-by: Numan Siddique --- controller/binding.c | 9 +-------- controller/ovn-controller.c | 2 -- controller/ovn-controller.h | 4 ---- controller/pinctrl.c | 11 +++++++++-- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index 4c107c1af..8ab23203b 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -146,7 +146,7 @@ add_local_datapath__(struct ovsdb_idl_index *sbrec_datapath_binding_by_key, const struct sbrec_port_binding *pb; SBREC_PORT_BINDING_FOR_EACH_EQUAL (pb, target, sbrec_port_binding_by_datapath) { - if (!strcmp(pb->type, "patch")) { + if (!strcmp(pb->type, "patch") || !strcmp(pb->type, "l3gateway")) { const char *peer_name = smap_get(&pb->options, "peer"); if (peer_name) { const struct sbrec_port_binding *peer; @@ -172,13 +172,6 @@ add_local_datapath__(struct ovsdb_idl_index *sbrec_datapath_binding_by_key, } } } - - ld->n_ports++; - if (ld->n_ports > ld->n_allocated_ports) { - ld->ports = x2nrealloc(ld->ports, &ld->n_allocated_ports, - sizeof *ld->ports); - } - ld->ports[ld->n_ports - 1] = pb; } sbrec_port_binding_index_destroy_row(target); } diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 31ce1107c..641bfd4ce 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -965,7 +965,6 @@ en_runtime_data_cleanup(void *data) HMAP_FOR_EACH_SAFE (cur_node, next_node, hmap_node, &rt_data->local_datapaths) { free(cur_node->peer_ports); - free(cur_node->ports); hmap_remove(&rt_data->local_datapaths, &cur_node->hmap_node); free(cur_node); } @@ -989,7 +988,6 @@ en_runtime_data_run(struct engine_node *node, void *data) struct local_datapath *cur_node, *next_node; HMAP_FOR_EACH_SAFE (cur_node, next_node, hmap_node, local_datapaths) { free(cur_node->peer_ports); - free(cur_node->ports); hmap_remove(local_datapaths, &cur_node->hmap_node); free(cur_node); } diff --git a/controller/ovn-controller.h b/controller/ovn-controller.h index 86b300e44..5d9466880 100644 --- a/controller/ovn-controller.h +++ b/controller/ovn-controller.h @@ -60,10 +60,6 @@ struct local_datapath { * hypervisor. */ bool has_local_l3gateway; - const struct sbrec_port_binding **ports; - size_t n_ports; - size_t n_allocated_ports; - struct { const struct sbrec_port_binding *local; const struct sbrec_port_binding *remote; diff --git a/controller/pinctrl.c b/controller/pinctrl.c index 452ca8a1c..5825bb14b 100644 --- a/controller/pinctrl.c +++ b/controller/pinctrl.c @@ -2957,10 +2957,17 @@ run_buffered_binding(struct ovsdb_idl_index *sbrec_mac_binding_by_lport_ip, bool notify = false; HMAP_FOR_EACH (ld, hmap_node, local_datapaths) { + /* MAC_Binding.logical_port will always belong to a + * a router datapath. Hence we can skip logical switch + * datapaths. + * */ + if (datapath_is_switch(ld->datapath)) { + continue; + } - for (size_t i = 0; i < ld->n_ports; i++) { + for (size_t i = 0; i < ld->n_peer_ports; i++) { - const struct sbrec_port_binding *pb = ld->ports[i]; + const struct sbrec_port_binding *pb = ld->peer_ports[i].local; struct buffered_packets *cur_qp, *next_qp; HMAP_FOR_EACH_SAFE (cur_qp, next_qp, hmap_node, &buffered_packets_map) {