From patchwork Fri Feb 17 05:55:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liang Mancang X-Patchwork-Id: 1744066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PJ1Jc11LPz23r4 for ; Fri, 17 Feb 2023 16:55:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E237C60BDB; Fri, 17 Feb 2023 05:55:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E237C60BDB 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 ypKZtdTcbW84; Fri, 17 Feb 2023 05:55:55 +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 0AEED60AE7; Fri, 17 Feb 2023 05:55:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 0AEED60AE7 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D35DDC0032; Fri, 17 Feb 2023 05:55:53 +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 5005BC002B for ; Fri, 17 Feb 2023 05:55:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1EFFC60BC0 for ; Fri, 17 Feb 2023 05:55:52 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1EFFC60BC0 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 JVEqwfXcBfAh for ; Fri, 17 Feb 2023 05:55:51 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9152560AE7 Received: from chinatelecom.cn (prt-mail.chinatelecom.cn [42.123.76.220]) by smtp3.osuosl.org (Postfix) with ESMTP id 9152560AE7 for ; Fri, 17 Feb 2023 05:55:50 +0000 (UTC) HMM_SOURCE_IP: 172.18.0.188:43327.1754654187 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-36.111.64.85 (unknown [172.18.0.188]) by chinatelecom.cn (HERMES) with SMTP id 322F2280090; Fri, 17 Feb 2023 13:55:41 +0800 (CST) X-189-SAVE-TO-SEND: +liangmc1@chinatelecom.cn Received: from ([36.111.64.85]) by app0023 with ESMTP id 9bb4d00f8c774918918134b38d58260b for dev@openvswitch.org; Fri, 17 Feb 2023 13:55:45 CST X-Transaction-ID: 9bb4d00f8c774918918134b38d58260b X-Real-From: liangmc1@chinatelecom.cn X-Receive-IP: 36.111.64.85 X-MEDUSA-Status: 0 From: Liang Mancang To: dev@openvswitch.org, i.maximets@ovn.org Date: Fri, 17 Feb 2023 13:55:17 +0800 Message-Id: <20230217055517.1828-1-liangmc1@chinatelecom.cn> X-Mailer: git-send-email 2.30.0.windows.2 MIME-Version: 1.0 Cc: Liang Mancang Subject: [ovs-dev] [PATCH] conntrack:fix conntrack_clean may access the same exp_list each time be called 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" when a exp_list contains more than the clean_end's number of nodes, and these nodes will not expire immediately. Then, every times we call conntrack_clean, it use the same next_sweep to get exp_list. Actually, we should add i every times after we call ct_sweep. Signed-off-by: Liang Mancang --- lib/conntrack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index 524670e45..5029b2cda 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1512,12 +1512,13 @@ conntrack_clean(struct conntrack *ct, long long now) clean_end = n_conn_limit / 64; for (i = ct->next_sweep; i < N_EXP_LISTS; i++) { - count += ct_sweep(ct, &ct->exp_lists[i], now); - if (count > clean_end) { next_wakeup = 0; + break; } + + count += ct_sweep(ct, &ct->exp_lists[i], now); } ct->next_sweep = (i < N_EXP_LISTS) ? i : 0;