mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
ipvs: add conn_lfactor and svc_lfactor sysctl vars
Allow the default load factor for the connection and service tables to be configured. Signed-off-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Florian Westphal <fw@strlen.de>
This commit is contained in:
committed by
Florian Westphal
parent
9a9ccef907
commit
8d7de5477e
@@ -2445,6 +2445,60 @@ static int ipvs_proc_run_estimation(const struct ctl_table *table, int write,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ipvs_proc_conn_lfactor(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
struct netns_ipvs *ipvs = table->extra2;
|
||||
int *valp = table->data;
|
||||
int val = *valp;
|
||||
int ret;
|
||||
|
||||
struct ctl_table tmp_table = {
|
||||
.data = &val,
|
||||
.maxlen = sizeof(int),
|
||||
};
|
||||
|
||||
ret = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);
|
||||
if (write && ret >= 0) {
|
||||
if (val < -8 || val > 8) {
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
*valp = val;
|
||||
if (rcu_access_pointer(ipvs->conn_tab))
|
||||
mod_delayed_work(system_unbound_wq,
|
||||
&ipvs->conn_resize_work, 0);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int ipvs_proc_svc_lfactor(const struct ctl_table *table, int write,
|
||||
void *buffer, size_t *lenp, loff_t *ppos)
|
||||
{
|
||||
struct netns_ipvs *ipvs = table->extra2;
|
||||
int *valp = table->data;
|
||||
int val = *valp;
|
||||
int ret;
|
||||
|
||||
struct ctl_table tmp_table = {
|
||||
.data = &val,
|
||||
.maxlen = sizeof(int),
|
||||
};
|
||||
|
||||
ret = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);
|
||||
if (write && ret >= 0) {
|
||||
if (val < -8 || val > 8) {
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
*valp = val;
|
||||
if (rcu_access_pointer(ipvs->svc_table))
|
||||
mod_delayed_work(system_unbound_wq,
|
||||
&ipvs->svc_resize_work, 0);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* IPVS sysctl table (under the /proc/sys/net/ipv4/vs/)
|
||||
* Do not change order or insert new entries without
|
||||
@@ -2633,6 +2687,18 @@ static struct ctl_table vs_vars[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = ipvs_proc_est_nice,
|
||||
},
|
||||
{
|
||||
.procname = "conn_lfactor",
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = ipvs_proc_conn_lfactor,
|
||||
},
|
||||
{
|
||||
.procname = "svc_lfactor",
|
||||
.maxlen = sizeof(int),
|
||||
.mode = 0644,
|
||||
.proc_handler = ipvs_proc_svc_lfactor,
|
||||
},
|
||||
#ifdef CONFIG_IP_VS_DEBUG
|
||||
{
|
||||
.procname = "debug_level",
|
||||
@@ -4853,6 +4919,16 @@ static int __net_init ip_vs_control_net_init_sysctl(struct netns_ipvs *ipvs)
|
||||
tbl[idx].extra2 = ipvs;
|
||||
tbl[idx++].data = &ipvs->sysctl_est_nice;
|
||||
|
||||
if (unpriv)
|
||||
tbl[idx].mode = 0444;
|
||||
tbl[idx].extra2 = ipvs;
|
||||
tbl[idx++].data = &ipvs->sysctl_conn_lfactor;
|
||||
|
||||
if (unpriv)
|
||||
tbl[idx].mode = 0444;
|
||||
tbl[idx].extra2 = ipvs;
|
||||
tbl[idx++].data = &ipvs->sysctl_svc_lfactor;
|
||||
|
||||
#ifdef CONFIG_IP_VS_DEBUG
|
||||
/* Global sysctls must be ro in non-init netns */
|
||||
if (!net_eq(net, &init_net))
|
||||
|
||||
Reference in New Issue
Block a user