From patchwork Mon Aug 8 16:54:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1664648 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=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M1j3X61vkz9sB4 for ; Tue, 9 Aug 2022 02:54:32 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id EC6D241497; Mon, 8 Aug 2022 16:54:30 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org EC6D241497 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yyjuUo29vFk7; Mon, 8 Aug 2022 16:54:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id B2774410A6; Mon, 8 Aug 2022 16:54:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org B2774410A6 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 602ACC0033; Mon, 8 Aug 2022 16:54:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 414C0C002D for ; Mon, 8 Aug 2022 16:54:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0859781826 for ; Mon, 8 Aug 2022 16:54:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0859781826 X-Virus-Scanned: amavisd-new at osuosl.org 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 CzN9xG7qbU_Y for ; Mon, 8 Aug 2022 16:54:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 185A081699 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by smtp1.osuosl.org (Postfix) with ESMTPS id 185A081699 for ; Mon, 8 Aug 2022 16:54:25 +0000 (UTC) Received: (Authenticated sender: hzhou@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 2EF3B1C0005; Mon, 8 Aug 2022 16:54:22 +0000 (UTC) From: Han Zhou To: dev@openvswitch.org Date: Mon, 8 Aug 2022 09:54:01 -0700 Message-Id: <20220808165401.3684424-2-hzhou@ovn.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220808165401.3684424-1-hzhou@ovn.org> References: <20220808165401.3684424-1-hzhou@ovn.org> MIME-Version: 1.0 Cc: Ariel Levkovich Subject: [ovs-dev] [PATCH 2/2] bridge.c: Retry when iface_create encounters transient failures. 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" Starts a timer when EBUSY is returned, to let it retry, because EBUSY is considered a temporary error when the device is operated by something else (e.g. Network Manager) at the moment, and retry should succeed. Signed-off-by: Han Zhou --- vswitchd/bridge.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 1db74de9d..f0b52ecb5 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -249,6 +249,11 @@ static long long int stats_timer = LLONG_MIN; #define AA_REFRESH_INTERVAL (1000) /* In milliseconds. */ static long long int aa_refresh_timer = LLONG_MIN; +/* Whenever there is an transient error (such as EBUSY) returned by + * iface_create, this timer is started to give a chance to retry. */ +#define IFACE_CREATE_FAIL_RETRY 1000 +static bool need_iface_create_retry = false; + /* Whenever system interfaces are added, removed or change state, the bridge * will be reconfigured. */ @@ -2110,6 +2115,10 @@ iface_create(struct bridge *br, const struct ovsrec_interface *iface_cfg, if (error) { iface_clear_db_record(iface_cfg, errp); free(errp); + if (error == EBUSY) { + poll_timer_wait_until(time_msec() + IFACE_CREATE_FAIL_RETRY); + need_iface_create_retry = true; + } return false; } @@ -3326,11 +3335,13 @@ bridge_run(void) } if (ovsdb_idl_get_seqno(idl) != idl_seqno || - if_notifier_changed(ifnotifier)) { + if_notifier_changed(ifnotifier) || + need_iface_create_retry) { struct ovsdb_idl_txn *txn; idl_seqno = ovsdb_idl_get_seqno(idl); txn = ovsdb_idl_txn_create(idl); + need_iface_create_retry = false; bridge_reconfigure(cfg ? cfg : &null_cfg); if (cfg) {