From patchwork Tue Apr 5 10:16:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Li X-Patchwork-Id: 1613356 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=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KXk996kTbz9sFk for ; Tue, 5 Apr 2022 20:17:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E3BBA40A35; Tue, 5 Apr 2022 10:17:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yZWhOTs-JmiZ; Tue, 5 Apr 2022 10:17:27 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id C5E5440A1B; Tue, 5 Apr 2022 10:17:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AA645C0085; Tue, 5 Apr 2022 10:17:24 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id CC344C001D for ; Tue, 5 Apr 2022 10:17:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9945260E47 for ; Tue, 5 Apr 2022 10:17:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Dg35lNBwSfgp for ; Tue, 5 Apr 2022 10:17:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.227]) by smtp3.osuosl.org (Postfix) with ESMTP id 0FFED60D76 for ; Tue, 5 Apr 2022 10:17:19 +0000 (UTC) HMM_SOURCE_IP: 172.18.0.188:44128.524426405 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-110.188.55.93 (unknown [172.18.0.188]) by chinatelecom.cn (HERMES) with SMTP id B85C028008E; Tue, 5 Apr 2022 18:17:14 +0800 (CST) X-189-SAVE-TO-SEND: +lic121@chinatelecom.cn Received: from ([172.18.0.188]) by app0023 with ESMTP id c6293743001949739b41e3a27e983d17 for dev@openvswitch.org; Tue, 05 Apr 2022 18:17:16 CST X-Transaction-ID: c6293743001949739b41e3a27e983d17 X-Real-From: lic121@chinatelecom.cn X-Receive-IP: 172.18.0.188 X-MEDUSA-Status: 0 From: lic121 To: dev Date: Tue, 5 Apr 2022 10:16:58 +0000 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Subject: [ovs-dev] [PATCH 1/2] ofproto-dpif: trigger revalidate if ct tp changes 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Once ct_zone timeout policy changes, revalidator is supposed to be triggered. Fixes: 993cae678bca ("ofproto-dpif: Consume CT_Zone, and CT_Timeout_Policy tables") Signed-off-by: lic121 Acked-by: Eelco Chaudron --- ofproto/ofproto-dpif.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 6601f23..7a1bb0d 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5597,6 +5597,7 @@ ct_set_zone_timeout_policy(const char *datapath_type, uint16_t zone_id, ct_timeout_policy_unref(backer, ct_zone->ct_tp); ct_zone->ct_tp = ct_tp; ct_tp->ref_count++; + backer->need_revalidate = REV_RECONFIGURE; } } else { struct ct_zone *new_ct_zone = ct_zone_alloc(zone_id); @@ -5604,6 +5605,7 @@ ct_set_zone_timeout_policy(const char *datapath_type, uint16_t zone_id, cmap_insert(&backer->ct_zones, &new_ct_zone->node, hash_int(zone_id, 0)); ct_tp->ref_count++; + backer->need_revalidate = REV_RECONFIGURE; } } @@ -5620,6 +5622,7 @@ ct_del_zone_timeout_policy(const char *datapath_type, uint16_t zone_id) if (ct_zone) { ct_timeout_policy_unref(backer, ct_zone->ct_tp); ct_zone_remove_and_destroy(backer, ct_zone); + backer->need_revalidate = REV_RECONFIGURE; } } From patchwork Tue Apr 5 10:16:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Li X-Patchwork-Id: 1613357 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=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KXk9D4PP9z9sCD for ; Tue, 5 Apr 2022 20:17:36 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3909D826C8; Tue, 5 Apr 2022 10:17:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3yACKuD4x4XS; Tue, 5 Apr 2022 10:17:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2EC5682521; Tue, 5 Apr 2022 10:17:28 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 422EEC008A; Tue, 5 Apr 2022 10:17:26 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id B6E05C0012 for ; Tue, 5 Apr 2022 10:17:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A75BD8247F for ; Tue, 5 Apr 2022 10:17:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Pec8hkAVBV6Z for ; Tue, 5 Apr 2022 10:17:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.227]) by smtp1.osuosl.org (Postfix) with ESMTP id CB99E82468 for ; Tue, 5 Apr 2022 10:17:20 +0000 (UTC) HMM_SOURCE_IP: 172.18.0.188:44128.524426405 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-110.188.55.93 (unknown [172.18.0.188]) by chinatelecom.cn (HERMES) with SMTP id C5B9F28008F; Tue, 5 Apr 2022 18:17:17 +0800 (CST) X-189-SAVE-TO-SEND: +lic121@chinatelecom.cn Received: from ([172.18.0.188]) by app0023 with ESMTP id 8f9c5265f6714e42a6d36df80d151721 for dev@openvswitch.org; Tue, 05 Apr 2022 18:17:19 CST X-Transaction-ID: 8f9c5265f6714e42a6d36df80d151721 X-Real-From: lic121@chinatelecom.cn X-Receive-IP: 172.18.0.188 X-MEDUSA-Status: 0 From: lic121 To: dev Date: Tue, 5 Apr 2022 10:16:59 +0000 Message-Id: <8c82ba08f6ecd59a82866267f300c34ec1fe78db.1649149317.git.lic121@chinatelecom.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: Subject: [ovs-dev] [PATCH 2/2] ofproto-dpif: avoid unneccesary backer revalidation 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" If lldp didn't change, we are not supposed to trigger backer revalidation. Without this patch, bridge_reconfigure() always trigger udpif revalidator because of lldp. This patch also fix lldp memory leak bug: lldp_create() malloc memory for lldp->lldpd->g_hardware. lldp_unref is supposed to free the memory, but it doesn't. Signed-off-by: lic121 Signed-off-by: Eelco Chaudron Co-authored-by: Eelco Chaudron Acked-by: Eelco Chaudron --- lib/lldp/lldpd.c | 10 +++------- lib/ovs-lldp.c | 8 ++++++++ lib/ovs-lldp.h | 1 + ofproto/ofproto-dpif.c | 7 +++++-- tests/ofproto-dpif.at | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c index 403f1f5..4bff7b0 100644 --- a/lib/lldp/lldpd.c +++ b/lib/lldp/lldpd.c @@ -140,13 +140,9 @@ lldpd_cleanup(struct lldpd *cfg) VLOG_DBG("cleanup all ports"); LIST_FOR_EACH_SAFE (hw, h_entries, &cfg->g_hardware) { - if (!hw->h_flags) { - ovs_list_remove(&hw->h_entries); - lldpd_remote_cleanup(hw, NULL, true); - lldpd_hardware_cleanup(cfg, hw); - } else { - lldpd_remote_cleanup(hw, NULL, false); - } + ovs_list_remove(&hw->h_entries); + lldpd_remote_cleanup(hw, NULL, true); + lldpd_hardware_cleanup(cfg, hw); } VLOG_DBG("cleanup all chassis"); diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c index a9d205e..2d13e97 100644 --- a/lib/ovs-lldp.c +++ b/lib/ovs-lldp.c @@ -738,6 +738,14 @@ lldp_put_packet(struct lldp *lldp, struct dp_packet *packet, ovs_mutex_unlock(&mutex); } +/* Is LLDP enabled? + */ +bool +lldp_is_enabled(struct lldp *lldp) +{ + return lldp ? lldp->enabled : false; +} + /* Configures the LLDP stack. */ bool diff --git a/lib/ovs-lldp.h b/lib/ovs-lldp.h index 0e536e8..661ac4e 100644 --- a/lib/ovs-lldp.h +++ b/lib/ovs-lldp.h @@ -86,6 +86,7 @@ void lldp_run(struct lldpd *cfg); bool lldp_should_send_packet(struct lldp *cfg); bool lldp_should_process_flow(struct lldp *lldp, const struct flow *flow); bool lldp_configure(struct lldp *lldp, const struct smap *cfg); +bool lldp_is_enabled(struct lldp *lldp); void lldp_process_packet(struct lldp *cfg, const struct dp_packet *); void lldp_put_packet(struct lldp *lldp, struct dp_packet *packet, const struct eth_addr eth_src); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 7a1bb0d..3ae44f0 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -2490,11 +2490,11 @@ set_lldp(struct ofport *ofport_, { struct ofport_dpif *ofport = ofport_dpif_cast(ofport_); struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofport->up.ofproto); + bool old_enable = lldp_is_enabled(ofport->lldp); int error = 0; - if (cfg) { + if (cfg && !smap_is_empty(cfg)) { if (!ofport->lldp) { - ofproto->backer->need_revalidate = REV_RECONFIGURE; ofport->lldp = lldp_create(ofport->up.netdev, ofport_->mtu, cfg); } @@ -2506,6 +2506,9 @@ set_lldp(struct ofport *ofport_, } else if (ofport->lldp) { lldp_unref(ofport->lldp); ofport->lldp = NULL; + } + + if (lldp_is_enabled(ofport->lldp) != old_enable) { ofproto->backer->need_revalidate = REV_RECONFIGURE; } diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index dbb3b6d..1c9a94c 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -29,6 +29,39 @@ AT_CHECK([ovs-appctl revalidator/wait]) OVS_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([ofproto-dpif - lldp revalidator event(REV_RECONFIGURE)]) +OVS_VSWITCHD_START( + [add-port br0 p1 -- set interface p1 ofport_request=1 type=dummy] +) +dnl first revalidation triggered by add interface +AT_CHECK([ovs-appctl coverage/read-counter rev_reconfigure], [0], [dnl +1 +]) + +dnl enable lldp +AT_CHECK([ovs-vsctl set interface p1 lldp:enable=true]) +AT_CHECK([ovs-appctl revalidator/wait]) +AT_CHECK([ovs-appctl coverage/read-counter rev_reconfigure], [0], [dnl +2 +]) + +dnl disable lldp +AT_CHECK([ovs-vsctl set interface p1 lldp:enable=false]) +AT_CHECK([ovs-appctl revalidator/wait]) +AT_CHECK([ovs-appctl coverage/read-counter rev_reconfigure], [0], [dnl +3 +]) + +dnl remove lldp, no revalidation as lldp was disabled +AT_CHECK([ovs-vsctl remove interface p1 lldp enable]) +AT_CHECK([ovs-appctl revalidator/wait]) +AT_CHECK([ovs-appctl coverage/read-counter rev_reconfigure], [0], [dnl +3 +]) + +OVS_VSWITCHD_STOP +AT_CLEANUP + AT_SETUP([ofproto-dpif - active-backup bonding (with primary)]) dnl Create br0 with members p1, p2 and p7, creating bond0 with p1 and