From patchwork Sat Dec 26 09:51:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 1420667 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=none (p=none dis=none) header.from=huawei.com 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 4D2zcS2KfCz9sWM for ; Sat, 26 Dec 2020 20:52:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B43D720361; Sat, 26 Dec 2020 09:52:01 +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 3fI1zAc6l0Sa; Sat, 26 Dec 2020 09:52:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id D8BFB20338; Sat, 26 Dec 2020 09:51:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BCDFFC1825; Sat, 26 Dec 2020 09:51:59 +0000 (UTC) X-Original-To: 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 B7D7DC0893 for ; Sat, 26 Dec 2020 09:51:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 92EAD20338 for ; Sat, 26 Dec 2020 09:51:57 +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 gbLlULYjU5zh for ; Sat, 26 Dec 2020 09:51:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by silver.osuosl.org (Postfix) with ESMTPS id C2A2620029 for ; Sat, 26 Dec 2020 09:51:54 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4D2zbP6FFbzhwKP; Sat, 26 Dec 2020 17:51:13 +0800 (CST) Received: from localhost (10.174.243.127) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Sat, 26 Dec 2020 17:51:43 +0800 From: wangyunjian To: Date: Sat, 26 Dec 2020 17:51:23 +0800 Message-ID: <1608976283-8044-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.174.243.127] X-CFilter-Loop: Reflected Cc: Lvmengfan , chenchanghu@huawei.com, jerry.lilijun@huawei.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH] upcall: avoid handler block in recv_upcalls 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" From: Lvmengfan When upcall_receive or process_upcall returns error in recv_upcalls, the n_upcalls count would not increased. If this situation continues, the loop may failed to exit, then the handler block occurs. Add a n_errors to count the errors and jump out of the loop, cloud avoid block happening. Signed-off-by: Lvmengfan --- ofproto/ofproto-dpif-upcall.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index 27924fa..6b32b18 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -776,9 +776,10 @@ recv_upcalls(struct handler *handler) struct dpif_upcall dupcalls[UPCALL_MAX_BATCH]; struct upcall upcalls[UPCALL_MAX_BATCH]; struct flow flows[UPCALL_MAX_BATCH]; - size_t n_upcalls, i; + size_t n_upcalls, i, n_errors; n_upcalls = 0; + n_errors = 0; while (n_upcalls < UPCALL_MAX_BATCH) { struct ofpbuf *recv_buf = &recv_bufs[n_upcalls]; struct dpif_upcall *dupcall = &dupcalls[n_upcalls]; @@ -810,6 +811,7 @@ recv_upcalls(struct handler *handler) dupcall->type, dupcall->userdata, flow, mru, &dupcall->ufid, PMD_ID_NULL); if (error) { + n_errors++; if (error == ENODEV) { /* Received packet on datapath port for which we couldn't * associate an ofproto. This can happen if a port is removed @@ -837,6 +839,7 @@ recv_upcalls(struct handler *handler) error = process_upcall(udpif, upcall, &upcall->odp_actions, &upcall->wc); if (error) { + n_errors++; goto cleanup; } @@ -848,6 +851,13 @@ cleanup: free_dupcall: dp_packet_uninit(&dupcall->packet); ofpbuf_uninit(recv_buf); + if (n_errors >= UPCALL_MAX_BATCH * 2) { + if (n_upcalls == 0) { + return 1; + } else { + break; + } + } } if (n_upcalls) {