Date: Tue, 25 Dec 2012 14:08:14 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244681 - in head: share/man/man4 sys/netinet Message-ID: <201212251408.qBPE8Eii068715@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Tue Dec 25 14:08:13 2012 New Revision: 244681 URL: http://svnweb.freebsd.org/changeset/base/244681 Log: 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. Modified: head/share/man/man4/carp.4 head/sys/netinet/ip_carp.c Modified: head/share/man/man4/carp.4 ============================================================================== --- head/share/man/man4/carp.4 Tue Dec 25 13:55:21 2012 (r244680) +++ head/share/man/man4/carp.4 Tue Dec 25 14:08:13 2012 (r244681) @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 29, 2012 +.Dd December 25, 2012 .Dt CARP 4 .Os .Sh NAME @@ -125,15 +125,14 @@ experiences problem with sending announc running a vhid goes down, or while the .Xr pfsync 4 interface is not synchronized. -The demotion value is writable, so that user may alter it -depending on some external conditions, for example on the status of some -daemon utility. -However, altering the value should be performed with care, so as to -not conflict with subsystems that adjust demotion factor -automatically: +The demotion factor can be adjusted writing to the sysctl oid. +The signed value supplied to the +.Xr sysctl 8 +command is added to current demotion factor. +This allows to control .Nm -and -.Xr pfsync 4 . +behaviour depending on some external conditions, for example on the status +of some daemon utility. .It Va net.inet.carp.ifdown_demotion_factor This value is added to .Va net.inet.carp.demotion Modified: head/sys/netinet/ip_carp.c ============================================================================== --- head/sys/netinet/ip_carp.c Tue Dec 25 13:55:21 2012 (r244680) +++ head/sys/netinet/ip_carp.c Tue Dec 25 14:08:13 2012 (r244681) @@ -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, pre "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 = {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201212251408.qBPE8Eii068715>