From owner-svn-src-stable@FreeBSD.ORG Fri Nov 23 21:29:09 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 1AB71503; Fri, 23 Nov 2012 21:29:09 +0000 (UTC) (envelope-from remko@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F396F8FC0C; Fri, 23 Nov 2012 21:29:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qANLT8Yc098330; Fri, 23 Nov 2012 21:29:08 GMT (envelope-from remko@svn.freebsd.org) Received: (from remko@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qANLT8tX098328; Fri, 23 Nov 2012 21:29:08 GMT (envelope-from remko@svn.freebsd.org) Message-Id: <201211232129.qANLT8tX098328@svn.freebsd.org> From: Remko Lodder Date: Fri, 23 Nov 2012 21:29:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r243467 - stable/7/sbin/ifconfig X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2012 21:29:09 -0000 Author: remko Date: Fri Nov 23 21:29:08 2012 New Revision: 243467 URL: http://svnweb.freebsd.org/changeset/base/243467 Log: MFC r232486 Add an ifconfig carp option that enables users to set the state of the carp cluster. This is a direct commit to stable/9 because -HEAD's code is very different. I discussed this with Gleb and the reason for this is that since we do not touch the kernel itself and are not adding very weird or confusing things, we can commit this to the stable branch directly. The options 'master' and 'backup' are now available, which enables the administrator to force a node into the backup or master state on the cluster. Ofcourse preempt has to be disabled otherwise the master node will become master again. One can do that with: sysctl net.inet.carp.preempt=0 After that one can schedule maintenance on the node normally running as the master and such. PR: 100956 Discussed with: glebius Modified: stable/7/sbin/ifconfig/ifcarp.c stable/7/sbin/ifconfig/ifconfig.8 Directory Properties: stable/7/sbin/ifconfig/ (props changed) Modified: stable/7/sbin/ifconfig/ifcarp.c ============================================================================== --- stable/7/sbin/ifconfig/ifcarp.c Fri Nov 23 21:27:26 2012 (r243466) +++ stable/7/sbin/ifconfig/ifcarp.c Fri Nov 23 21:29:08 2012 (r243467) @@ -57,6 +57,7 @@ void setcarp_advbase(const char *,int, i void setcarp_advskew(const char *, int, int, const struct afswtch *rafp); void setcarp_passwd(const char *, int, int, const struct afswtch *rafp); void setcarp_vhid(const char *, int, int, const struct afswtch *rafp); +void setcarp_state(const char *, int, int, const struct afswtch *rafp); void carp_status(int s) @@ -175,11 +176,34 @@ setcarp_advbase(const char *val, int d, return; } +void setcarp_state(const char *val, int d, int s, const struct afswtch *afp) +{ + struct carpreq carpr; + int i; + + bzero((char *)&carpr, sizeof(struct carpreq)); + ifr.ifr_data = (caddr_t)&carpr; + + if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1) + err(1, "SIOCGVH"); + + for (i = 0; i <= CARP_MAXSTATE; i++) { + if (!strcasecmp(val, carp_states[i])) { + carpr.carpr_state = i; + break; + } + } + + if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1) + err(1, "SIOCSVH"); +} + static struct cmd carp_cmds[] = { DEF_CMD_ARG("advbase", setcarp_advbase), DEF_CMD_ARG("advskew", setcarp_advskew), DEF_CMD_ARG("pass", setcarp_passwd), DEF_CMD_ARG("vhid", setcarp_vhid), + DEF_CMD_ARG("state", setcarp_state), }; static struct afswtch af_carp = { .af_name = "af_carp", Modified: stable/7/sbin/ifconfig/ifconfig.8 ============================================================================== --- stable/7/sbin/ifconfig/ifconfig.8 Fri Nov 23 21:27:26 2012 (r243466) +++ stable/7/sbin/ifconfig/ifconfig.8 Fri Nov 23 21:29:08 2012 (r243467) @@ -1825,6 +1825,13 @@ Set the authentication key to Set the virtual host ID. This is a required setting. Acceptable values are 1 to 255. +.It Cm state Ar state +Force the interface into state +.Ar state . +Valid states are INIT, BACKUP, and MASTER. Note that manually setting the state +to INIT is ignored by +.Xr carp 4 . +This state is set automatically when the underlying interface is down. .El .Pp The