Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Nov 2012 21:29:08 +0000 (UTC)
From:      Remko Lodder <remko@FreeBSD.org>
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
Message-ID:  <201211232129.qANLT8tX098328@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211232129.qANLT8tX098328>