{"id":2221780,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2221780/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260410112352.23599-4-fw@strlen.de/","project":{"id":26,"url":"http://patchwork.ozlabs.org/api/1.2/projects/26/?format=json","name":"Netfilter Development","link_name":"netfilter-devel","list_id":"netfilter-devel.vger.kernel.org","list_email":"netfilter-devel@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260410112352.23599-4-fw@strlen.de>","list_archive_url":null,"date":"2026-04-10T11:23:44","name":"[net-next,03/11] ipvs: add conn_lfactor and svc_lfactor sysctl vars","commit_ref":null,"pull_url":null,"state":"handled-elsewhere","archived":true,"hash":"32ac506f6852f4df710add37946d12a0610e54bb","submitter":{"id":1025,"url":"http://patchwork.ozlabs.org/api/1.2/people/1025/?format=json","name":"Florian Westphal","email":"fw@strlen.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/netfilter-devel/patch/20260410112352.23599-4-fw@strlen.de/mbox/","series":[{"id":499444,"url":"http://patchwork.ozlabs.org/api/1.2/series/499444/?format=json","web_url":"http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=499444","date":"2026-04-10T11:23:46","name":"[net-next,01/11] ipvs: show the current conn_tab size to users","version":1,"mbox":"http://patchwork.ozlabs.org/series/499444/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221780/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221780/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <netfilter-devel+bounces-11799-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","netfilter-devel@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=netfilter-devel+bounces-11799-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=91.216.245.30","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=strlen.de","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsZNs4YqMz1yGS\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 21:30:37 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 11F48306777D\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 11:24:14 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 49A6C39E162;\n\tFri, 10 Apr 2026 11:24:12 +0000 (UTC)","from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc\n [91.216.245.30])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B730939A06E;\n\tFri, 10 Apr 2026 11:24:10 +0000 (UTC)","by Chamillionaire.breakpoint.cc (Postfix, from userid 1003)\n\tid 45F9560B78; Fri, 10 Apr 2026 13:24:09 +0200 (CEST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775820252; cv=none;\n b=fgaaOJE3WhaJhnh38y0FaCnYI2mIf69Ptq/Qr2rn7V7q9GSNwRK7bzSVJG15NnqmBMwiIME2QLubC/9ZirY3xn7znwqveHDiSmwuPP2Ztp42yJ30SUN2mEK6/zGt4ToOfrah8mKoKdktqA0xMY1M4lJtg/ktdlKdcuTdmu4OLBY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775820252; c=relaxed/simple;\n\tbh=1tE7XB8kMZHHljrDiTAqlkOhu6G0o8VWm+a5sDa+8Os=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=FbT8ZT4gGbk8VhrKsSaorPwKgExv+KO1KqMh9a0IuJ5+BBBj96sz20gdokUU6B11NNpprxD0+zVmQ0HbZR9ui4P/j9PcrNx8FHOSoh/Zy0J1viQE64tVJTP1xNG7wmIhJF/gSXZbkCEWyIIkS1iUcBEgGyoBt2zBUO/Du0iYDWM=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=strlen.de;\n spf=pass smtp.mailfrom=Chamillionaire.breakpoint.cc;\n arc=none smtp.client-ip=91.216.245.30","From":"Florian Westphal <fw@strlen.de>","To":"<netdev@vger.kernel.org>","Cc":"Paolo Abeni <pabeni@redhat.com>,\n\t\"David S. Miller\" <davem@davemloft.net>,\n\tEric Dumazet <edumazet@google.com>,\n\tJakub Kicinski <kuba@kernel.org>,\n\t<netfilter-devel@vger.kernel.org>,\n\tpablo@netfilter.org","Subject":"[PATCH net-next 03/11] ipvs: add conn_lfactor and svc_lfactor sysctl\n vars","Date":"Fri, 10 Apr 2026 13:23:44 +0200","Message-ID":"<20260410112352.23599-4-fw@strlen.de>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260410112352.23599-1-fw@strlen.de>","References":"<20260410112352.23599-1-fw@strlen.de>","Precedence":"bulk","X-Mailing-List":"netfilter-devel@vger.kernel.org","List-Id":"<netfilter-devel.vger.kernel.org>","List-Subscribe":"<mailto:netfilter-devel+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:netfilter-devel+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit"},"content":"From: Julian Anastasov <ja@ssi.bg>\n\nAllow the default load factor for the connection and service tables\nto be configured.\n\nSigned-off-by: Julian Anastasov <ja@ssi.bg>\nSigned-off-by: Florian Westphal <fw@strlen.de>\n---\n Documentation/networking/ipvs-sysctl.rst | 37 ++++++++++++\n net/netfilter/ipvs/ip_vs_ctl.c           | 76 ++++++++++++++++++++++++\n 2 files changed, 113 insertions(+)","diff":"diff --git a/Documentation/networking/ipvs-sysctl.rst b/Documentation/networking/ipvs-sysctl.rst\nindex 3fb5fa142eef..a556439f8be7 100644\n--- a/Documentation/networking/ipvs-sysctl.rst\n+++ b/Documentation/networking/ipvs-sysctl.rst\n@@ -29,6 +29,33 @@ backup_only - BOOLEAN\n \tIf set, disable the director function while the server is\n \tin backup mode to avoid packet loops for DR/TUN methods.\n \n+conn_lfactor - INTEGER\n+\tPossible values: -8 (larger table) .. 8 (smaller table)\n+\n+\tDefault: -4\n+\n+\tControls the sizing of the connection hash table based on the\n+\tload factor (number of connections per table buckets):\n+\n+\t\t2^conn_lfactor = nodes / buckets\n+\n+\tAs result, the table grows if load increases and shrinks when\n+\tload decreases in the range of 2^8 - 2^conn_tab_bits (module\n+\tparameter).\n+\tThe value is a shift count where negative values select\n+\tbuckets = (connection hash nodes << -value) while positive\n+\tvalues select buckets = (connection hash nodes >> value). The\n+\tnegative values reduce the collisions and reduce the time for\n+\tlookups but increase the table size. Positive values will\n+\ttolerate load above 100% when using smaller table is\n+\tpreferred with the cost of more collisions. If using NAT\n+\tconnections consider decreasing the value with one because\n+\tthey add two nodes in the hash table.\n+\n+\tExample:\n+\t-4: grow if load goes above 6% (buckets = nodes * 16)\n+\t2: grow if load goes above 400% (buckets = nodes / 4)\n+\n conn_reuse_mode - INTEGER\n \t1 - default\n \n@@ -219,6 +246,16 @@ secure_tcp - INTEGER\n \tThe value definition is the same as that of drop_entry and\n \tdrop_packet.\n \n+svc_lfactor - INTEGER\n+\tPossible values: -8 (larger table) .. 8 (smaller table)\n+\n+\tDefault: -3\n+\n+\tControls the sizing of the service hash table based on the\n+\tload factor (number of services per table buckets). The table\n+\twill grow and shrink in the range of 2^4 - 2^20.\n+\tSee conn_lfactor for explanation.\n+\n sync_threshold - vector of 2 INTEGERs: sync_threshold, sync_period\n \tdefault 3 50\n \ndiff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c\nindex fb1df61edfdd..6632daa87ded 100644\n--- a/net/netfilter/ipvs/ip_vs_ctl.c\n+++ b/net/netfilter/ipvs/ip_vs_ctl.c\n@@ -2445,6 +2445,60 @@ static int ipvs_proc_run_estimation(const struct ctl_table *table, int write,\n \treturn ret;\n }\n \n+static int ipvs_proc_conn_lfactor(const struct ctl_table *table, int write,\n+\t\t\t\t  void *buffer, size_t *lenp, loff_t *ppos)\n+{\n+\tstruct netns_ipvs *ipvs = table->extra2;\n+\tint *valp = table->data;\n+\tint val = *valp;\n+\tint ret;\n+\n+\tstruct ctl_table tmp_table = {\n+\t\t.data = &val,\n+\t\t.maxlen = sizeof(int),\n+\t};\n+\n+\tret = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);\n+\tif (write && ret >= 0) {\n+\t\tif (val < -8 || val > 8) {\n+\t\t\tret = -EINVAL;\n+\t\t} else {\n+\t\t\t*valp = val;\n+\t\t\tif (rcu_access_pointer(ipvs->conn_tab))\n+\t\t\t\tmod_delayed_work(system_unbound_wq,\n+\t\t\t\t\t\t &ipvs->conn_resize_work, 0);\n+\t\t}\n+\t}\n+\treturn ret;\n+}\n+\n+static int ipvs_proc_svc_lfactor(const struct ctl_table *table, int write,\n+\t\t\t\t void *buffer, size_t *lenp, loff_t *ppos)\n+{\n+\tstruct netns_ipvs *ipvs = table->extra2;\n+\tint *valp = table->data;\n+\tint val = *valp;\n+\tint ret;\n+\n+\tstruct ctl_table tmp_table = {\n+\t\t.data = &val,\n+\t\t.maxlen = sizeof(int),\n+\t};\n+\n+\tret = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);\n+\tif (write && ret >= 0) {\n+\t\tif (val < -8 || val > 8) {\n+\t\t\tret = -EINVAL;\n+\t\t} else {\n+\t\t\t*valp = val;\n+\t\t\tif (rcu_access_pointer(ipvs->svc_table))\n+\t\t\t\tmod_delayed_work(system_unbound_wq,\n+\t\t\t\t\t\t &ipvs->svc_resize_work, 0);\n+\t\t}\n+\t}\n+\treturn ret;\n+}\n+\n /*\n  *\tIPVS sysctl table (under the /proc/sys/net/ipv4/vs/)\n  *\tDo not change order or insert new entries without\n@@ -2633,6 +2687,18 @@ static struct ctl_table vs_vars[] = {\n \t\t.mode\t\t= 0644,\n \t\t.proc_handler\t= ipvs_proc_est_nice,\n \t},\n+\t{\n+\t\t.procname\t= \"conn_lfactor\",\n+\t\t.maxlen\t\t= sizeof(int),\n+\t\t.mode\t\t= 0644,\n+\t\t.proc_handler\t= ipvs_proc_conn_lfactor,\n+\t},\n+\t{\n+\t\t.procname\t= \"svc_lfactor\",\n+\t\t.maxlen\t\t= sizeof(int),\n+\t\t.mode\t\t= 0644,\n+\t\t.proc_handler\t= ipvs_proc_svc_lfactor,\n+\t},\n #ifdef CONFIG_IP_VS_DEBUG\n \t{\n \t\t.procname\t= \"debug_level\",\n@@ -4853,6 +4919,16 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)\n \ttbl[idx].extra2 = ipvs;\n \ttbl[idx++].data = &ipvs->sysctl_est_nice;\n \n+\tif (unpriv)\n+\t\ttbl[idx].mode = 0444;\n+\ttbl[idx].extra2 = ipvs;\n+\ttbl[idx++].data = &ipvs->sysctl_conn_lfactor;\n+\n+\tif (unpriv)\n+\t\ttbl[idx].mode = 0444;\n+\ttbl[idx].extra2 = ipvs;\n+\ttbl[idx++].data = &ipvs->sysctl_svc_lfactor;\n+\n #ifdef CONFIG_IP_VS_DEBUG\n \t/* Global sysctls must be ro in non-init netns */\n \tif (!net_eq(net, &init_net))\n","prefixes":["net-next","03/11"]}