From patchwork Sat Feb 5 02:58:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Li X-Patchwork-Id: 1588697 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::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4JrHCj0yHmz9sCD for ; Sat, 5 Feb 2022 13:58:24 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 7DD3060E86; Sat, 5 Feb 2022 02:58:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org 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 69GB2qWkGC06; Sat, 5 Feb 2022 02:58:20 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 983F760B55; Sat, 5 Feb 2022 02:58:19 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 67C24C001A; Sat, 5 Feb 2022 02:58:19 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 26CB7C000B for ; Sat, 5 Feb 2022 02:58:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1522440151 for ; Sat, 5 Feb 2022 02:58:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org 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 q_TMflQn3TJy for ; Sat, 5 Feb 2022 02:58:16 +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 smtp2.osuosl.org (Postfix) with ESMTP id 4DDBF400BA for ; Sat, 5 Feb 2022 02:58:16 +0000 (UTC) HMM_SOURCE_IP: 172.18.0.48:51808.1682460808 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-218.88.38.16 (unknown [172.18.0.48]) by chinatelecom.cn (HERMES) with SMTP id 2282728008B; Sat, 5 Feb 2022 10:58:14 +0800 (CST) X-189-SAVE-TO-SEND: lic121@chinatelecom.cn Received: from ([172.18.0.48]) by app0024 with ESMTP id 45893227d2f543798d1b6f1232727aa5 for dev@openvswitch.org; Sat, 05 Feb 2022 10:58:15 CST X-Transaction-ID: 45893227d2f543798d1b6f1232727aa5 X-Real-From: lic121@chinatelecom.cn X-Receive-IP: 172.18.0.48 X-MEDUSA-Status: 0 Date: Sat, 5 Feb 2022 10:58:15 +0800 From: lic121 To: "dev@openvswitch.org" , =?utf-8?q?Eelco=C2=A0Chaudr?= =?utf-8?q?on?= X-Priority: 3 X-Has-Attach: no X-Mailer: Foxmail 7.2.23.116[cn] Mime-Version: 1.0 Message-ID: <2022020510581518971432@chinatelecom.cn> X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [ovs-dev] [PATCH v3 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: , 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. Signed-off-by: lic121 Co-authored-by: Eelco Chaudron --- lib/ovs-lldp.c | 8 ++++++++ lib/ovs-lldp.h | 1 + ofproto/ofproto-dpif.c | 5 ++++- tests/ofproto-dpif.at | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) -- 1.8.3.1 diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c index 162311f..bfc69a3 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 ced67b0..c2f5b12 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -2499,11 +2499,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 (!ofport->lldp) { - ofproto->backer->need_revalidate = REV_RECONFIGURE; ofport->lldp = lldp_create(ofport->up.netdev, ofport_->mtu, cfg); } @@ -2515,6 +2515,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 7f273e5..edb6aa1 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