svn commit: r232486 - stable/9/sbin/ifconfig
Remko Lodder
remko at FreeBSD.org
Sun Mar 4 10:37:26 UTC 2012
Author: remko
Date: Sun Mar 4 10:37:26 2012
New Revision: 232486
URL: http://svn.freebsd.org/changeset/base/232486
Log:
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
MFC after: 1 weeks
Modified:
stable/9/sbin/ifconfig/ifcarp.c
stable/9/sbin/ifconfig/ifconfig.8
Modified: stable/9/sbin/ifconfig/ifcarp.c
==============================================================================
--- stable/9/sbin/ifconfig/ifcarp.c Sun Mar 4 09:48:58 2012 (r232485)
+++ stable/9/sbin/ifconfig/ifcarp.c Sun Mar 4 10:37:26 2012 (r232486)
@@ -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/9/sbin/ifconfig/ifconfig.8
==============================================================================
--- stable/9/sbin/ifconfig/ifconfig.8 Sun Mar 4 09:48:58 2012 (r232485)
+++ stable/9/sbin/ifconfig/ifconfig.8 Sun Mar 4 10:37:26 2012 (r232486)
@@ -28,7 +28,7 @@
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD$
.\"
-.Dd December 17, 2011
+.Dd March 4, 2012
.Dt IFCONFIG 8
.Os
.Sh NAME
@@ -2436,6 +2436,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
More information about the svn-src-stable-9
mailing list