From patchwork Mon Aug 8 16:54:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1664649 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 (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M1j3b1tJzz9sB4 for ; Tue, 9 Aug 2022 02:54:35 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2898960DED; Mon, 8 Aug 2022 16:54:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2898960DED 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 VJ4YqPODYLD5; Mon, 8 Aug 2022 16:54:32 +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 4CFC0605E0; Mon, 8 Aug 2022 16:54:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4CFC0605E0 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8CF13C007F; Mon, 8 Aug 2022 16:54:29 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5828BC0033 for ; Mon, 8 Aug 2022 16:54:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2392C607F2 for ; Mon, 8 Aug 2022 16:54:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2392C607F2 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 NHayysKOQtfb 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 smtp3.osuosl.org ACB2E605E0 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by smtp3.osuosl.org (Postfix) with ESMTPS id ACB2E605E0 for ; Mon, 8 Aug 2022 16:54:25 +0000 (UTC) Received: (Authenticated sender: hzhou@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 71A501C0003; Mon, 8 Aug 2022 16:54:21 +0000 (UTC) From: Han Zhou To: dev@openvswitch.org Date: Mon, 8 Aug 2022 09:54:00 -0700 Message-Id: <20220808165401.3684424-1-hzhou@ovn.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Cc: Ariel Levkovich Subject: [ovs-dev] [PATCH 1/2] netdev-offload: Expose error when init_flow_api() returns EBUSY. 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" init_flow_api() can fail due to errors, such as netlink "Device or resource busy". Today the errors are ignored except just an INFO log. This ends up with an interface created without offload enabled, and application won't notice it. This patch expose the error to the OVSDB record, and reverts the dpif port changes upon failure. Signed-off-by: Han Zhou Acked-by: Mike Pattrick --- lib/dpif.c | 12 ++++++++++-- lib/netdev-offload.c | 32 +++++++++++++++++++++++--------- lib/netdev-offload.h | 1 - 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/lib/dpif.c b/lib/dpif.c index 40f5fe446..b68929bae 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -609,9 +609,17 @@ dpif_port_add(struct dpif *dpif, struct netdev *netdev, odp_port_t *port_nop) dpif_port.type = CONST_CAST(char *, netdev_get_type(netdev)); dpif_port.name = CONST_CAST(char *, netdev_name); dpif_port.port_no = port_no; - netdev_ports_insert(netdev, &dpif_port); + error = netdev_ports_insert(netdev, &dpif_port); + if (error) { + if (error == EEXIST) { + error = 0; + } else { + dpif->dpif_class->port_del(dpif, port_no); + } + } } - } else { + } + if (error) { VLOG_WARN_RL(&error_rl, "%s: failed to add %s as port: %s", dpif_name(dpif), netdev_name, ovs_strerror(error)); port_no = ODPP_NONE; diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 9fde5f7a9..f30b20673 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -179,21 +179,29 @@ static int netdev_assign_flow_api(struct netdev *netdev) { struct netdev_registered_flow_api *rfa; - + int ret = -1; CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) { - if (!rfa->flow_api->init_flow_api(netdev)) { + int error = rfa->flow_api->init_flow_api(netdev); + if (!error) { ovs_refcount_ref(&rfa->refcnt); ovsrcu_set(&netdev->flow_api, rfa->flow_api); VLOG_INFO("%s: Assigned flow API '%s'.", netdev_get_name(netdev), rfa->flow_api->type); return 0; + } else { + VLOG_DBG("%s: flow API '%s' is not suitable.", + netdev_get_name(netdev), rfa->flow_api->type); + if (ret == EBUSY) { + /* If all API fail and at least one of the error is EBUSY, we + * will return this error code EBUSY so that the upper layer + * can decide to retry later. */ + ret = error; + } } - VLOG_DBG("%s: flow API '%s' is not suitable.", - netdev_get_name(netdev), rfa->flow_api->type); } VLOG_INFO("%s: No suitable flow API found.", netdev_get_name(netdev)); - return -1; + return ret; } void @@ -368,7 +376,7 @@ netdev_flow_get_n_flows(struct netdev *netdev, uint64_t *n_flows) : EOPNOTSUPP; } -int +static int netdev_init_flow_api(struct netdev *netdev) { if (!netdev_is_flow_api_enabled()) { @@ -379,7 +387,10 @@ netdev_init_flow_api(struct netdev *netdev) return 0; } - if (netdev_assign_flow_api(netdev)) { + int error = netdev_assign_flow_api(netdev); + if (error == EBUSY) { + return error; + } else if (error) { return EOPNOTSUPP; } @@ -729,8 +740,11 @@ netdev_ports_insert(struct netdev *netdev, struct dpif_port *dpif_port) netdev_ports_hash(dpif_port->port_no, dpif_type)); ovs_rwlock_unlock(&netdev_hmap_rwlock); - netdev_init_flow_api(netdev); - + int error = netdev_init_flow_api(netdev); + if (error && error != EOPNOTSUPP) { + netdev_ports_remove(dpif_port->port_no, dpif_type); + return error; + } return 0; } diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 249a3102a..2974e5497 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -118,7 +118,6 @@ int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions, struct dpif_flow_attrs *, struct ofpbuf *wbuffer); int netdev_flow_del(struct netdev *, const ovs_u128 *, struct dpif_flow_stats *); -int netdev_init_flow_api(struct netdev *); void netdev_uninit_flow_api(struct netdev *); uint32_t netdev_get_block_id(struct netdev *); int netdev_get_hw_info(struct netdev *, int); 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) {