summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_carp.c
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2012-12-25 14:08:13 +0000
committerglebius <glebius@FreeBSD.org>2012-12-25 14:08:13 +0000
commit7ccc77532c6e05b3e2eee10cc7a5cacda533fda0 (patch)
tree0da71cd8a002919afd54043c3c4af86b6dc47ffc /sys/netinet/ip_carp.c
parent2b889e140744e78d10733f1576cd273c5957766a (diff)
downloadFreeBSD-src-7ccc77532c6e05b3e2eee10cc7a5cacda533fda0.zip
FreeBSD-src-7ccc77532c6e05b3e2eee10cc7a5cacda533fda0.tar.gz
Change net.inet.carp.demotion sysctl to add the supplied value
to the current demotion factor instead of assigning it. This allows external scripts to control demotion factor together with kernel in a raceless manner.
Diffstat (limited to 'sys/netinet/ip_carp.c')
-rw-r--r--sys/netinet/ip_carp.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 75e0585..7afe1af 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -192,6 +192,7 @@ static int carp_log = 1; /* Log level. */
static int carp_demotion = 0; /* Global advskew demotion. */
static int carp_senderr_adj = CARP_MAXSKEW; /* Send error demotion factor */
static int carp_ifdown_adj = CARP_MAXSKEW; /* Iface down demotion factor */
+static int carp_demote_adj_sysctl(SYSCTL_HANDLER_ARGS);
SYSCTL_NODE(_net_inet, IPPROTO_CARP, carp, CTLFLAG_RW, 0, "CARP");
SYSCTL_INT(_net_inet_carp, OID_AUTO, allow, CTLFLAG_RW, &carp_allow, 0,
@@ -200,8 +201,9 @@ SYSCTL_INT(_net_inet_carp, OID_AUTO, preempt, CTLFLAG_RW, &carp_preempt, 0,
"High-priority backup preemption mode");
SYSCTL_INT(_net_inet_carp, OID_AUTO, log, CTLFLAG_RW, &carp_log, 0,
"CARP log level");
-SYSCTL_INT(_net_inet_carp, OID_AUTO, demotion, CTLFLAG_RW, &carp_demotion, 0,
- "Demotion factor (skew of advskew)");
+SYSCTL_PROC(_net_inet_carp, OID_AUTO, demotion, CTLTYPE_INT|CTLFLAG_RW,
+ 0, 0, carp_demote_adj_sysctl, "I",
+ "Adjust demotion factor (skew of advskew)");
SYSCTL_INT(_net_inet_carp, OID_AUTO, senderr_demotion_factor, CTLFLAG_RW,
&carp_senderr_adj, 0, "Send error demotion factor adjustment");
SYSCTL_INT(_net_inet_carp, OID_AUTO, ifdown_demotion_factor, CTLFLAG_RW,
@@ -1999,11 +2001,26 @@ carp_sc_state(struct carp_softc *sc)
static void
carp_demote_adj(int adj, char *reason)
{
- carp_demotion += adj;
+ atomic_add_int(&carp_demotion, adj);
CARP_LOG("demoted by %d to %d (%s)\n", adj, carp_demotion, reason);
taskqueue_enqueue(taskqueue_swi, &carp_sendall_task);
}
+static int
+carp_demote_adj_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ int new, error;
+
+ new = carp_demotion;
+ error = sysctl_handle_int(oidp, &new, 0, req);
+ if (error || !req->newptr)
+ return (error);
+
+ carp_demote_adj(new, "sysctl");
+
+ return (0);
+}
+
#ifdef INET
extern struct domain inetdomain;
static struct protosw in_carp_protosw = {
OpenPOWER on IntegriCloud