diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-03-18 20:52:14 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-03-18 20:52:14 +0000 |
commit | 7e2b18d06ceab37d9dbeabd704454bf5b0ff0d90 (patch) | |
tree | 1086d30a17efa7cda60f2a446887a72bbfd627bf /sbin | |
parent | a39e994dc6904a18adc1022b4d97c5246fbdf760 (diff) |
Allow the state of a carp interface to be changed explicitly.
ok markus@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 9 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 29 |
2 files changed, 35 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index fac19e816a8..155ffefc176 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.78 2004/01/13 07:45:10 jmc Exp $ +.\" $OpenBSD: ifconfig.8,v 1.79 2004/03/18 20:52:13 mcbride Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -398,6 +398,13 @@ will begin advertising as master. If the driver is a carp pseudo-device, set the authentication key to .Ar passphrase . There is no passphrase by default. +.It Cm state Ar state +Explicitly force the carp pseudo-device to enter this state. +Valid states are +.Ar init , +.Ar backup , +and +.Ar master . .It Cm syncif Ar iface If the driver is a pfsync pseudo-device, use the specified interface to send and receive pfsync state synchronisation messages. diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6f1bd7352f3..a136e391001 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.92 2004/03/15 08:52:17 deraadt Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.93 2004/03/18 20:52:13 mcbride Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -77,7 +77,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)ifconfig.c 8.2 (Berkeley) 2/16/94"; #else -static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.92 2004/03/15 08:52:17 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: ifconfig.c,v 1.93 2004/03/18 20:52:13 mcbride Exp $"; #endif #endif /* not lint */ @@ -207,6 +207,7 @@ void setcarp_advbase(const char *,int); void setcarp_advskew(const char *, int); void setcarp_passwd(const char *, int); void setcarp_vhid(const char *, int); +void setcarp_state(const char *, int); void setpfsync_syncif(const char *, int); void setpfsync_maxupd(const char *, int); void unsetpfsync_syncif(const char *, int); @@ -298,6 +299,7 @@ const struct cmd { { "advskew", NEXTARG, 0, setcarp_advskew }, { "pass", NEXTARG, 0, setcarp_passwd }, { "vhid", NEXTARG, 0, setcarp_vhid }, + { "state", NEXTARG, 0, setcarp_state }, { "syncif", NEXTARG, 0, setpfsync_syncif }, { "maxupd", NEXTARG, 0, setpfsync_maxupd }, { "-syncif", 1, 0, unsetpfsync_syncif }, @@ -2833,6 +2835,29 @@ setcarp_advbase(const char *val, int d) } void +setcarp_state(const char *val, int d) +{ + 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"); +} + +void setpfsync_syncif(const char *val, int d) { struct pfsyncreq preq; |