From patchwork Fri Mar 29 21:59:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1070205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="b8ciRb/0"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44WFyg0fRyz9sPc for ; Sat, 30 Mar 2019 08:59:53 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 20FBEFCA; Fri, 29 Mar 2019 21:59:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 6B0B0F15 for ; Fri, 29 Mar 2019 21:59:35 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 12ED5D3 for ; Fri, 29 Mar 2019 21:59:35 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id i17so1663064pfo.6 for ; Fri, 29 Mar 2019 14:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=qUpLP3ADRmRJwvj9IebLCBiU9O33k7mdn4WAuCwtibM=; b=b8ciRb/0cE+Za6qxjX0JVf763hGGqkF/gGeg6UZ9e80SdBJEBk7TOvd4nirAY7cVXO mGUvLIg+aJjwnBcpnVzJPM+NYrK1W1DJm8GpbvvC2devPeB6kQKCqHdTbMzBnBr/Ta5a u7SU/qPw9PVBgNPr5nrmx50wHANAyEcD/HRJDRwRrxMb0hK92CD4LPtgl6v2Bi4jKpcT p5meL6EDb3/DDyzVo0e3my9YL8GML+FyqYInSBsbNE89wGECV5975JRvosk87buR9eG2 HlANEWU09Ysg3PTZ9u1Ezmc1QwxcPMC9/u9FQXicy/DxUr+NQMWE7P1SEdjkMLLguA+i v/Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qUpLP3ADRmRJwvj9IebLCBiU9O33k7mdn4WAuCwtibM=; b=uWMjCrU85W+ZMHP17G4fwqwjfKoghf2DOa5YiM32vqr3bprRzxUehaIcxU07Kp0Jga nBikVQtTmQm1GXRU8igcA2hZk5wWMswA0RmMxgPm34UTYb4jLuzr/3L0TBHWYeX1DKg8 kVLNt+05dvJ5NhLplEboO13jpddF76OoOR7A9QBA+fJYjzdKSxPFBXbImFBtpnHnk1kd MMgJuryQt79Y7wRjCZoHMgpn+XZmJkNEtImO6KabpPa5HSJ7cDe1khDAB6l+9NmuQy8O BMOPwdsk2G5c4v1uJ8FopbuvH4abfGEZm1INU2V9PFvH+KyWrSAufqCndBIFalvCo98Q q1CQ== X-Gm-Message-State: APjAAAWQXiweL3ywp41VcD7bghXcQwC2neIL4A11TFpAwPQIJgqXvq/f 7RTCsF2TW6y+bzSkPKUlihc= X-Google-Smtp-Source: APXvYqyu6vBrnwaY39kCentLWh30KwlTDjdi+dLSTj/+dAZtCpLo4XHepSu+bU1QScoOpXwUMmpDOA== X-Received: by 2002:a63:5150:: with SMTP id r16mr39164341pgl.307.1553896774026; Fri, 29 Mar 2019 14:59:34 -0700 (PDT) Received: from ubuntu.localdomain (96-82-111-186-static.hfc.comcastbusiness.net. [96.82.111.186]) by smtp.gmail.com with ESMTPSA id w21sm4136473pfn.48.2019.03.29.14.59.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Mar 2019 14:59:33 -0700 (PDT) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Fri, 29 Mar 2019 14:59:07 -0700 Message-Id: <1553896747-19775-1-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v2] conntrack: Fix minimum connections to clean. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org If there is low maximum connection count configuration and less than 10 connections in a bucket, the calculation of the maximum number of connections to clean for the bucket could be zero, leading to these connections not being cleaned until and if the connection count in the bucket increases. Fix this by checking for low maximum connection count configuration and do this outside of the buckets loop, thereby simplifying the loop. Fixes: e6ef6cc6349b ("conntrack: Periodically delete expired connections.") CC: Daniele Di Proietto Reported-by: Liujiaxin Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2019-March/357703.html Signed-off-by: Darrell Ball --- v2: Fix local variable naming. Backport to 2.6. lib/conntrack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index 9c2abd1..da2dd1f 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -1489,6 +1489,8 @@ conntrack_clean(struct conntrack *ct, long long now) size_t clean_count = 0; atomic_read_relaxed(&ct->n_conn_limit, &n_conn_limit); + size_t clean_max = n_conn_limit > CONNTRACK_BUCKETS * 10 + ? n_conn_limit / (CONNTRACK_BUCKETS * 10) : 1; for (unsigned i = 0; i < CONNTRACK_BUCKETS; i++) { struct conntrack_bucket *ctb = &ct->buckets[i]; @@ -1506,8 +1508,7 @@ conntrack_clean(struct conntrack *ct, long long now) * limit to 10% of the global limit equally split among buckets. If * the bucket is busier than the others, we limit to 10% of its * current size. */ - min_exp = sweep_bucket(ct, ctb, now, - MAX(prev_count/10, n_conn_limit/(CONNTRACK_BUCKETS*10))); + min_exp = sweep_bucket(ct, ctb, now, MAX(prev_count / 10, clean_max)); clean_count += prev_count - hmap_count(&ctb->connections); if (min_exp > now) {