From patchwork Mon Sep 21 16:25:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1368498 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=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NCkYDs/7; dkim-atps=neutral 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 4Bw8vX73Frz9sVT for ; Tue, 22 Sep 2020 02:26:16 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 1F06920C45; Mon, 21 Sep 2020 16:26:15 +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 Lnn0q7HU+QBb; Mon, 21 Sep 2020 16:26:01 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id A767A2107A; Mon, 21 Sep 2020 16:26:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7BA02C0890; Mon, 21 Sep 2020 16:26:00 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id D76C7C0051 for ; Mon, 21 Sep 2020 16:25:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C31898728A for ; Mon, 21 Sep 2020 16:25:58 +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 KdEhuW4gO7YL for ; Mon, 21 Sep 2020 16:25:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by hemlock.osuosl.org (Postfix) with ESMTPS id B40F6871DB for ; Mon, 21 Sep 2020 16:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600705555; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P7eKeYdCjlAI29Yq4TUvVLYUpKpkJIkAeRpvvFf7JUY=; b=NCkYDs/77a1i2/KTCs3LlajRwSPUrjVlKQLRle15/LWbiU8iizvlrvQMiSej7+yE2lJOfp NZXXERoy+IywhTr8nHxMssK0Wmg42XUa/vFekKMs28orJET1K6NJA284fQ2f+C6j1elPpA izMH0n/liV0qFqqidaymgtO0tcRkpFY= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-142-sxqt_mEQM-Ox7Ad68Mq24w-1; Mon, 21 Sep 2020 12:25:50 -0400 X-MC-Unique: sxqt_mEQM-Ox7Ad68Mq24w-1 Received: by mail-wr1-f69.google.com with SMTP id a12so6089542wrg.13 for ; Mon, 21 Sep 2020 09:25:49 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=P7eKeYdCjlAI29Yq4TUvVLYUpKpkJIkAeRpvvFf7JUY=; b=nRO8wZ5bA9PSoZ8j7wX4f+97IM5RUH5+SJHDgykEiSaXXFtrTLcxQt2o4l+tOfWkGl 9B7Hmf0gNUDYBFdPsHA0ApBMBHv6FyPWj+nMJG5uHh8A8XSnHHUJ4NbzEddT+ZD5APhy EvVmsXunEouz0KcvPoY4AR/hxdo1kMRCJnhmRPib6EZGJ3Q1A3HpLzrL9ygni/UJGtfr GY6S9Ia3ADnTVKCHF3MT2y8MCodTBz3seTrpm8cY8Xsl4zJoXPwVs4iPjI97D8Bippm9 ihBR99Xutv1B/SM5axadFWpSaICKxIJx7Cx9Tdfwo825JnSVQc8dCemvOw7yPfhHA8Kc BYig== X-Gm-Message-State: AOAM530WYqe2uc2ymsWR7kAoa+dAYjxDdR9Tv/vzkOaBaO/Pb4+ZACVm u9b9VuoekxRxmZNQXkxT/kC4j3xWL49bdDrmgAJX4oljavoS4ZFZ4XUC0jfsJ01CIIY9LqJeA2/ IXUPMhu1OPJDn6tXzag== X-Received: by 2002:a1c:4054:: with SMTP id n81mr160180wma.81.1600705547789; Mon, 21 Sep 2020 09:25:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3KxJUlcJBJqnWAEsyteYqdoYntCJZGlOkyhJcnSLfEkMvVA1/9nZvwPskeSEtAgkBRBwvAQ== X-Received: by 2002:a1c:4054:: with SMTP id n81mr160157wma.81.1600705547499; Mon, 21 Sep 2020 09:25:47 -0700 (PDT) Received: from lore-desk.redhat.com ([151.66.80.226]) by smtp.gmail.com with ESMTPSA id s11sm21019205wrt.43.2020.09.21.09.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:25:47 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Mon, 21 Sep 2020 18:25:35 +0200 Message-Id: X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: hzhou@ovn.org Subject: [ovs-dev] [PATCH v2 ovn 1/3] controller: binding: rely on shash for local_iface_ids 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" Rely on shash for local_iface_ids instead of smap for local_iface_ids. This is a preliminary patch to properly manage ovn-egress-iface in binding I-P engine Signed-off-by: Lorenzo Bianconi --- controller/binding.c | 40 +++++++++++++++++++++++++++++-------- controller/binding.h | 6 +++++- controller/ovn-controller.c | 39 +++++++++++++++++++++++++++++------- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index 3c102dc7f..0397e145a 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1349,8 +1349,16 @@ build_local_bindings(struct binding_ctx_in *b_ctx_in, } update_local_lports(iface_id, b_ctx_out); - smap_replace(b_ctx_out->local_iface_ids, iface_rec->name, - iface_id); + + struct local_iface_node *iface_node = + xmalloc(sizeof *iface_node); + iface_node->iface_id = xstrdup(iface_id); + iface_node = shash_replace(b_ctx_out->local_ifaces, + iface_rec->name, iface_node); + if (iface_node) { + free(iface_node->iface_id); + free(iface_node); + } } /* Check if this is a tunnel interface. */ @@ -1689,7 +1697,15 @@ consider_iface_claim(const struct ovsrec_interface *iface_rec, struct hmap *qos_map) { update_local_lports(iface_id, b_ctx_out); - smap_replace(b_ctx_out->local_iface_ids, iface_rec->name, iface_id); + + struct local_iface_node *iface_node = xmalloc(sizeof *iface_node); + iface_node->iface_id = xstrdup(iface_id); + iface_node = shash_replace(b_ctx_out->local_ifaces, + iface_rec->name, iface_node); + if (iface_node) { + free(iface_node->iface_id); + free(iface_node); + } struct local_binding *lbinding = local_binding_find(b_ctx_out->local_bindings, iface_id); @@ -1783,7 +1799,13 @@ consider_iface_release(const struct ovsrec_interface *iface_rec, } remove_local_lports(iface_id, b_ctx_out); - smap_remove(b_ctx_out->local_iface_ids, iface_rec->name); + struct local_iface_node *iface_node = shash_find_and_delete( + b_ctx_out->local_ifaces, + iface_rec->name); + if (iface_node) { + free(iface_node->iface_id); + free(iface_node); + } return true; } @@ -1822,11 +1844,11 @@ binding_handle_ovs_interface_changes(struct binding_ctx_in *b_ctx_in, * 2. external_ids:iface-id is cleared in which case we need to * release the port binding corresponding to the previously set * 'old-iface-id' (which is stored in the smap - * 'b_ctx_out->local_iface_ids'). + * 'b_ctx_out->local_ifaces'). * 3. external_ids:iface-id is updated with a different value * in which case we need to release the port binding corresponding * to the previously set 'old-iface-id' (which is stored in the smap - * 'b_ctx_out->local_iface_ids'). + * 'b_ctx_out->local_ifaces'). * 4. ofport of the OVS interface is 0. * */ @@ -1842,8 +1864,10 @@ binding_handle_ovs_interface_changes(struct binding_ctx_in *b_ctx_in, } const char *iface_id = smap_get(&iface_rec->external_ids, "iface-id"); - const char *old_iface_id = smap_get(b_ctx_out->local_iface_ids, - iface_rec->name); + + struct local_iface_node *iface_node = shash_find_data( + b_ctx_out->local_ifaces, iface_rec->name); + const char *old_iface_id = iface_node ? iface_node->iface_id : NULL; const char *cleared_iface_id = NULL; if (!ovsrec_interface_is_deleted(iface_rec)) { int64_t ofport = iface_rec->n_ofport ? *iface_rec->ofport : 0; diff --git a/controller/binding.h b/controller/binding.h index c9740560f..a1e0f1ccf 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -54,6 +54,10 @@ struct binding_ctx_in { const struct ovsrec_interface_table *iface_table; }; +struct local_iface_node { + char *iface_id; +}; + struct binding_ctx_out { struct hmap *local_datapaths; struct shash *local_bindings; @@ -77,7 +81,7 @@ struct binding_ctx_out { struct sset *egress_ifaces; /* smap of OVS interface name as key and * OVS interface external_ids:iface-id as value. */ - struct smap *local_iface_ids; + struct shash *local_ifaces; /* hmap of 'struct tracked_binding_datapath' which the * callee (binding_handle_ovs_interface_changes and diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 8d8c678e5..0a6f171be 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -35,6 +35,7 @@ #include "fatal-signal.h" #include "ip-mcast.h" #include "openvswitch/hmap.h" +#include "openvswitch/shash.h" #include "lflow.h" #include "lib/vswitch-idl.h" #include "lport.h" @@ -1033,7 +1034,7 @@ struct ed_type_runtime_data { /* runtime data engine private data. */ struct sset egress_ifaces; - struct smap local_iface_ids; + struct shash local_ifaces; /* Tracked data. See below for more details and comments. */ bool tracked; @@ -1085,7 +1086,7 @@ struct ed_type_runtime_data { * | local_bindings | the @tracked_dp_bindings indirectly and hence it | * | local_lport_ids | is not tracked explicitly. | * --------------------------------------------------------------------- - * | local_iface_ids | This is used internally within the runtime data | + * | local_ifaces | This is used internally within the runtime data | * | egress_ifaces | engine (used only in binding.c) and hence there | * | | there is no need to track. | * --------------------------------------------------------------------- @@ -1124,7 +1125,7 @@ en_runtime_data_init(struct engine_node *node OVS_UNUSED, sset_init(&data->local_lport_ids); sset_init(&data->active_tunnels); sset_init(&data->egress_ifaces); - smap_init(&data->local_iface_ids); + shash_init(&data->local_ifaces); local_bindings_init(&data->local_bindings); /* Init the tracked data. */ @@ -1142,7 +1143,19 @@ en_runtime_data_cleanup(void *data) sset_destroy(&rt_data->local_lport_ids); sset_destroy(&rt_data->active_tunnels); sset_destroy(&rt_data->egress_ifaces); - smap_destroy(&rt_data->local_iface_ids); + + struct shash_node *sh_node, *sh_node_next; + SHASH_FOR_EACH_SAFE (sh_node, sh_node_next, + &rt_data->local_ifaces) { + struct local_iface_node *iface_node = sh_node->data; + hmap_remove(&rt_data->local_ifaces.map, &sh_node->node); + free(iface_node->iface_id); + free(sh_node->data); + free(sh_node->name); + free(sh_node); + } + hmap_destroy(&rt_data->local_ifaces.map); + struct local_datapath *cur_node, *next_node; HMAP_FOR_EACH_SAFE (cur_node, next_node, hmap_node, &rt_data->local_datapaths) { @@ -1234,7 +1247,7 @@ init_binding_ctx(struct engine_node *node, b_ctx_out->non_vif_ports_changed = false; b_ctx_out->egress_ifaces = &rt_data->egress_ifaces; b_ctx_out->local_bindings = &rt_data->local_bindings; - b_ctx_out->local_iface_ids = &rt_data->local_iface_ids; + b_ctx_out->local_ifaces = &rt_data->local_ifaces; b_ctx_out->tracked_dp_bindings = NULL; b_ctx_out->local_lports_changed = NULL; } @@ -1282,12 +1295,24 @@ en_runtime_data_run(struct engine_node *node, void *data) sset_destroy(local_lport_ids); sset_destroy(active_tunnels); sset_destroy(&rt_data->egress_ifaces); - smap_destroy(&rt_data->local_iface_ids); + + struct shash_node *sh_node, *sh_node_next; + SHASH_FOR_EACH_SAFE (sh_node, sh_node_next, + &rt_data->local_ifaces) { + struct local_iface_node *iface_node = sh_node->data; + hmap_remove(&rt_data->local_ifaces.map, &sh_node->node); + free(iface_node->iface_id); + free(sh_node->data); + free(sh_node->name); + free(sh_node); + } + hmap_destroy(&rt_data->local_ifaces.map); + sset_init(local_lports); sset_init(local_lport_ids); sset_init(active_tunnels); sset_init(&rt_data->egress_ifaces); - smap_init(&rt_data->local_iface_ids); + shash_init(&rt_data->local_ifaces); local_bindings_init(&rt_data->local_bindings); } From patchwork Mon Sep 21 16:25:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1368497 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.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MwZafBCJ; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bw8vC6YMtz9sWT for ; Tue, 22 Sep 2020 02:25:59 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 73110866F3; Mon, 21 Sep 2020 16:25:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JBpynzN7tqLu; Mon, 21 Sep 2020 16:25:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id A128A86679; Mon, 21 Sep 2020 16:25:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 86217C0859; Mon, 21 Sep 2020 16:25:57 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 37D21C0859 for ; Mon, 21 Sep 2020 16:25:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 1B4A6866D1 for ; Mon, 21 Sep 2020 16:25:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fX0TFqBQx8V0 for ; Mon, 21 Sep 2020 16:25:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by whitealder.osuosl.org (Postfix) with ESMTPS id 6218F866AC for ; Mon, 21 Sep 2020 16:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600705554; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DPCIzh9vkIo46yHbY2k3d8MGnaF2Neh3exwwg2mIhVQ=; b=MwZafBCJEfer6O8kTv2RpECJha7am6WRE7PtH/YL3GMkOho2r/mvxzXMAvmxr6xL/KlL8j z3tIAA0PhBc3TN1UstncrUM1vzdrhpO+n1Lil+cnaaaPF2Pzjc8vPZe7twXACtfOsnImlb Y/qjoJihUhVfAlzUsTDXB3eJT0fxXnM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-ZjgI5W5iPn-FDEVRQBQ4Sg-1; Mon, 21 Sep 2020 12:25:51 -0400 X-MC-Unique: ZjgI5W5iPn-FDEVRQBQ4Sg-1 Received: by mail-wm1-f69.google.com with SMTP id m10so30822wmf.5 for ; Mon, 21 Sep 2020 09:25:51 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=DPCIzh9vkIo46yHbY2k3d8MGnaF2Neh3exwwg2mIhVQ=; b=fEl92PgyyyhDYYC2dRZmFGi/0hLw9CFcHGmLAIlt+lzob0GEFvmhmWCNyrmMPnXvYl ti3+wFOD6ZITlRtKTyyLR819SNfo4Q9i1YatuSfT4ErPpGzy+KIv49n0S18zdQeS1AIG GwxOEDSm1wPg58xxbHd0Grwk45S/r9YNcdYmLshD565cWfGaGJODk3YQiZoZ4SirDaHw cnFLrQ7JvHVAopPPq5xw8pwjuHvQU8an0JhW8TCKKqpRdlwzJQYIHYQsZr3xblSQG/GJ twCqd4eAwhK05TF32hATtGlG/K/j7Ln4XHgVmecf1fPad2mun/wW6RRkEd47az3qgmIo s14A== X-Gm-Message-State: AOAM530ffHcAmEqFeYqXwjAvE41i5BO6ssVpno4kVVb5KhGvCAPAA2WZ uQ7bu1Wlo5gJVOJbYrMjTFQkjQtEBSkHYiVeHk2pBIGhxMLLNn8bcuBz29z4W7cV84IoZmWj+rk c6pmJvHvQm+HGS11AEw== X-Received: by 2002:a5d:4811:: with SMTP id l17mr619561wrq.252.1600705549891; Mon, 21 Sep 2020 09:25:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQUg91X/lY9qitcZHOs9WbIE1YLbRvdXMHQul5XrEC42gRCFd/gqImeMEuvL4XaD71/KHCTw== X-Received: by 2002:a5d:4811:: with SMTP id l17mr619546wrq.252.1600705549748; Mon, 21 Sep 2020 09:25:49 -0700 (PDT) Received: from lore-desk.redhat.com ([151.66.80.226]) by smtp.gmail.com with ESMTPSA id s11sm21019205wrt.43.2020.09.21.09.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:25:49 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Mon, 21 Sep 2020 18:25:36 +0200 Message-Id: <07b27739e79ed3d357328526d75aa5129aa1107f.1600704955.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: hzhou@ovn.org Subject: [ovs-dev] [PATCH v2 ovn 2/3] binding: rely on qos_map for consider_localnet_lport 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" build_local_bindings() takes care of local binding only so if the controller does not have any active tunnel egress_ifaces will be empty and qos_map map will not be populated. Rely on qos_map directly for localnet port in consider_localnet_lport() Signed-off-by: Lorenzo Bianconi --- controller/binding.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller/binding.c b/controller/binding.c index 0397e145a..107bc28a6 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1444,7 +1444,7 @@ binding_run(struct binding_ctx_in *b_ctx_in, struct binding_ctx_out *b_ctx_out) break; case LP_LOCALNET: { - consider_localnet_lport(pb, b_ctx_in, b_ctx_out, qos_map_ptr); + consider_localnet_lport(pb, b_ctx_in, b_ctx_out, &qos_map); struct localnet_lport *lnet_lport = xmalloc(sizeof *lnet_lport); lnet_lport->pb = pb; ovs_list_push_back(&localnet_lports, &lnet_lport->list_node); From patchwork Mon Sep 21 16:25:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1368499 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.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=L6BmW7vq; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bw8w21WP1z9sVT for ; Tue, 22 Sep 2020 02:26:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C853C85EA5; Mon, 21 Sep 2020 16:26:40 +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 M0szHOF48Oxb; Mon, 21 Sep 2020 16:26:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id EF1B185E93; Mon, 21 Sep 2020 16:26:39 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CF169C0890; Mon, 21 Sep 2020 16:26:39 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3D9C7C0051 for ; Mon, 21 Sep 2020 16:26:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2618920798 for ; Mon, 21 Sep 2020 16:26:38 +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 NYvLN0FdxVDn for ; Mon, 21 Sep 2020 16:26:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by silver.osuosl.org (Postfix) with ESMTPS id 23DBB21519 for ; Mon, 21 Sep 2020 16:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600705569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q8Q4mv14SzLnehcjZrnAKyHMIHU5Lm47yToX+gN8WCE=; b=L6BmW7vqUS51fObhSRnpF5vbgEj0Dm5y46KEd9FL2Wco7jrjFOpIy/Ebt3nlzdxqLx9hv0 ghrHcH/LEXnUhFGgcuHBHeKgf6WtiSRzmrfEA4Bib+4zY2KYoSN360FR0KoGcWij+Gd3IO uvvEkYsWrtcM647z3zvoVjKBc9qGkhQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-579-c0UJCsQSNLCb8v68laC1hw-1; Mon, 21 Sep 2020 12:25:53 -0400 X-MC-Unique: c0UJCsQSNLCb8v68laC1hw-1 Received: by mail-wr1-f69.google.com with SMTP id a12so6089606wrg.13 for ; Mon, 21 Sep 2020 09:25:52 -0700 (PDT) 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:mime-version:content-transfer-encoding; bh=q8Q4mv14SzLnehcjZrnAKyHMIHU5Lm47yToX+gN8WCE=; b=JxS8E5FYBhwQHI8Qa6FCAw5rAghzT4NmRAkLH8sxS6jrwGCAyeBjepdNlCmOk5L2Ou 53k3okD/Z5M6Xb+/R5uJyNhbyPVaX/LCu+im71lH07ReysKYmyOL3F+wFSZpVazh7mqy mgETUpor/6N+9ymVqrot0E+2mkGGxPGhNAWOj3/6R9qbqokuGaqJEWPczC4IwOblFhnX Bdy8qb2uV/dyDToZIwRdg31PNpsNl8YUlGZR4n41hTLqIehIsHTXi9vIieVhQMBIXp6a n39GDeW6eUFgvh7lM5bu89wHO6qfvmAZjpnU4RfvpZX5cE/K8iRPoCt/cmq3FXwfPi6J gXJg== X-Gm-Message-State: AOAM531QKRBDE6dWe6QBPZIyKIBNtVvAIMCeP1UT+/D4f9NUkU+E6GAf KWsbDiul8AhAXfM1VX0/iulrcM8Oe0qyI50HFsGnaT4WyvfPr6fk8lRX5g5CNmyMrhJIjg2JeO+ 2xVSOYCJORedfIksU9A== X-Received: by 2002:a5d:55c8:: with SMTP id i8mr558480wrw.331.1600705551417; Mon, 21 Sep 2020 09:25:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBAjkg7rK0XPEqqjt4ZpOpoPcdohfl6S0WbUsi2xO6UxucY0IzibkKjQ3CeDcVfPdz70CG+Q== X-Received: by 2002:a5d:55c8:: with SMTP id i8mr558459wrw.331.1600705551171; Mon, 21 Sep 2020 09:25:51 -0700 (PDT) Received: from lore-desk.redhat.com ([151.66.80.226]) by smtp.gmail.com with ESMTPSA id s11sm21019205wrt.43.2020.09.21.09.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 09:25:50 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Mon, 21 Sep 2020 18:25:37 +0200 Message-Id: <6554c8f94a5572b52bd7e3267b8602f4f1a8cf85.1600704955.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lorenzo.bianconi@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: hzhou@ovn.org Subject: [ovs-dev] [PATCH v2 ovn 3/3] binding: fix localnet QoS configuration after I-P 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" After the I-P has been introduced in commit 354bdba51a ("ovn-controller: I-P for SB port binding and OVS interface in runtime_data"), the QoS on localnet ports is not properly configured if the ovs interface is marked with "ovn-egress-iface" flag after the related record in the logical_switch_port table is set. The issue can be triggered with the following reproducer: $ovn-nbctl set Logical_Switch_Port ln-public options:qos_burst=1000 $ovs-vsctl set interface eth0 external-ids:ovn-egress-iface=true Fix the issue triggering a recomputation after qos is configured for ovs interface Fixes: 354bdba51abf ("ovn-controller: I-P for SB port binding and OVS interface in runtime_data") Signed-off-by: Lorenzo Bianconi --- controller/binding.c | 26 +++++++++++++++++ controller/binding.h | 1 + tests/ovn-performance.at | 13 +++++++++ tests/system-ovn.at | 60 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/controller/binding.c b/controller/binding.c index 107bc28a6..26542ae66 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1353,6 +1353,13 @@ build_local_bindings(struct binding_ctx_in *b_ctx_in, struct local_iface_node *iface_node = xmalloc(sizeof *iface_node); iface_node->iface_id = xstrdup(iface_id); + struct local_iface_node *old_iface_node = shash_find_data( + b_ctx_out->local_ifaces, + iface_rec->name); + if (old_iface_node) { + iface_node->qos_egress_iface = + old_iface_node->qos_egress_iface; + } iface_node = shash_replace(b_ctx_out->local_ifaces, iface_rec->name, iface_node); if (iface_node) { @@ -1700,6 +1707,12 @@ consider_iface_claim(const struct ovsrec_interface *iface_rec, struct local_iface_node *iface_node = xmalloc(sizeof *iface_node); iface_node->iface_id = xstrdup(iface_id); + struct local_iface_node *old_iface_node = shash_find_data( + b_ctx_out->local_ifaces, + iface_rec->name); + if (old_iface_node) { + iface_node->qos_egress_iface = old_iface_node->qos_egress_iface; + } iface_node = shash_replace(b_ctx_out->local_ifaces, iface_rec->name, iface_node); if (iface_node) { @@ -1928,6 +1941,19 @@ binding_handle_ovs_interface_changes(struct binding_ctx_in *b_ctx_in, continue; } + struct local_iface_node *node = shash_find_data( + b_ctx_out->local_ifaces, iface_rec->name); + bool old_qos_egress = node ? node->qos_egress_iface : false; + bool qos_egress = smap_get_bool(&iface_rec->external_ids, + "ovn-egress-iface", false); + if (qos_egress != old_qos_egress) { + if (node) { + node->qos_egress_iface = qos_egress; + } + handled = false; + break; + } + const char *iface_id = smap_get(&iface_rec->external_ids, "iface-id"); int64_t ofport = iface_rec->n_ofport ? *iface_rec->ofport : 0; if (iface_id && ofport > 0) { diff --git a/controller/binding.h b/controller/binding.h index a1e0f1ccf..9e3e1f512 100644 --- a/controller/binding.h +++ b/controller/binding.h @@ -56,6 +56,7 @@ struct binding_ctx_in { struct local_iface_node { char *iface_id; + bool qos_egress_iface; }; struct binding_ctx_out { diff --git a/tests/ovn-performance.at b/tests/ovn-performance.at index 3010860d5..6cc5b2174 100644 --- a/tests/ovn-performance.at +++ b/tests/ovn-performance.at @@ -247,6 +247,8 @@ for i in 1 2 3; do ovs-vsctl set open . external_ids:ovn-bridge-mappings="public:br-ex" j=$((i + 2)) ovn_attach n1 br-phys 192.168.0.$j + ip link add vgw$i type dummy + ovs-vsctl add-port br-ex vgw$i done # Wait for the tunnel ports to be created and up. @@ -477,6 +479,17 @@ OVN_CONTROLLER_EXPECT_HIT( [ovn-nbctl --wait=hv lrp-set-gateway-chassis lr1-public gw3 10 && ovn-nbctl --wait=hv sync] ) +# create QoS rule +OVN_CONTROLLER_EXPECT_NO_HIT( + [hv1 hv2 gw1 gw2 gw3], [lflow_run], + [ovn-nbctl --wait=hv set Logical_Switch_Port ln-public options:qos_burst=1000] +) + +OVN_CONTROLLER_EXPECT_HIT( + [gw1], [lflow_run], + [as gw1 ovs-vsctl set interface vgw1 external-ids:ovn-egress-iface=true] +) + # Make gw2 master. There is remote possibility that full recompute # triggers for gw2 after it becomes master. Most of the time # there will be no recompute. diff --git a/tests/system-ovn.at b/tests/system-ovn.at index 4f72754c6..f779947f4 100644 --- a/tests/system-ovn.at +++ b/tests/system-ovn.at @@ -5397,3 +5397,63 @@ as OVS_TRAFFIC_VSWITCHD_STOP(["/.*error receiving.*/d /.*terminating with signal 15.*/d"]) AT_CLEANUP + +AT_SETUP([ovn -- egress qos]) +AT_KEYWORDS([ovn-egress-qos]) + +ovn_start +OVS_TRAFFIC_VSWITCHD_START() + +ADD_BR([br-int]) +ADD_BR([br-ext]) + +ovs-ofctl add-flow br-ext action=normal +# Set external-ids in br-int needed for ovn-controller +ovs-vsctl \ + -- set Open_vSwitch . external-ids:system-id=hv1 \ + -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock \ + -- set Open_vSwitch . external-ids:ovn-encap-type=geneve \ + -- set Open_vSwitch . external-ids:ovn-encap-ip=169.0.0.1 \ + -- set bridge br-int fail-mode=secure other-config:disable-in-band=true + +# Start ovn-controller +start_daemon ovn-controller + +ovn-nbctl ls-add sw0 + +ADD_NAMESPACES(sw01) +ADD_VETH(sw01, sw01, br-int, "192.168.1.2/24", "f0:00:00:01:02:03") +ovn-nbctl lsp-add sw0 sw01 \ + -- lsp-set-addresses sw01 "f0:00:00:01:02:03 192.168.1.2" + +ADD_NAMESPACES(public) +ADD_VETH(public, public, br-ext, "192.168.2.2/24", "f0:00:00:01:02:05") + +AT_CHECK([ovs-vsctl set Open_vSwitch . external-ids:ovn-bridge-mappings=phynet:br-ext]) +ovn-nbctl lsp-add sw0 public \ + -- lsp-set-addresses public unknown \ + -- lsp-set-type public localnet \ + -- lsp-set-options public network_name=phynet + +AT_CHECK([ovn-nbctl set Logical_Switch_Port public options:qos_burst=1000]) +AT_CHECK([ovs-vsctl set interface ovs-public external-ids:ovn-egress-iface=true]) +AT_CHECK([tc qdisc show | grep -q 'htb 1: dev ovs-public']) + +AT_CHECK([ovn-nbctl remove Logical_Switch_Port public options qos_burst=1000]) +AT_CHECK([tc qdisc show | grep -q 'htb 1: dev ovs-public'],[1]) + +kill $(pidof ovn-controller) + +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +as ovn-nb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +as northd +OVS_APP_EXIT_AND_WAIT([ovn-northd]) + +as +OVS_TRAFFIC_VSWITCHD_STOP(["/.*error receiving.*/d +/.*terminating with signal 15.*/d"]) +AT_CLEANUP