summaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2008-02-05 22:57:32 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2008-02-05 22:57:32 +0000
commit279d8911f3838a3d1546b31c4801fac650ddc9ce (patch)
tree3f4efb4bfc2385425ae2ad31c7f392ddc1729137 /sbin/ifconfig
parent1c85bd544fb9501c3922670c79d44a2d5baedad0 (diff)
Move carp load balancing (ARP/IP) to a simpler configuration scheme.
Instead of using the same IP on multiple interfaces, carp has to be configured with the new "carpnodes" and "balancing" options. # ifconfig carp0 carpnodes 1:0,2:100,3:100 balancing ip carpdev sis0 192.168.5.50 Please note, that this is a flag day for anyone using carp balancing. You'll need to adjust your configuration accordingly. Addititionally this diff adds IPv6 NDP balancing support. Tested and OK mcbride@, reyk@. Manpage help by jmc@.
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifconfig.824
-rw-r--r--sbin/ifconfig/ifconfig.c48
2 files changed, 63 insertions, 9 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index dbc0621e741..43565c49db2 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ifconfig.8,v 1.151 2007/11/09 15:07:08 jmc Exp $
+.\" $OpenBSD: ifconfig.8,v 1.152 2008/02/05 22:57:30 mpf 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 $
.\"
@@ -31,7 +31,7 @@
.\"
.\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94
.\"
-.Dd $Mdocdate: November 9 2007 $
+.Dd $Mdocdate: February 5 2008 $
.Dt IFCONFIG 8
.Os
.Sh NAME
@@ -445,6 +445,8 @@ and
.Ar carp-interface
.Op Cm advbase Ar n
.Op Cm advskew Ar n
+.Op Cm balancing Ar mode
+.Op Cm carpnodes Ar vhid:advskew,vhid:advskew,...
.Op Cm carpdev Ar iface
.Op Cm pass Ar passphrase
.Op Cm state Ar state
@@ -466,6 +468,24 @@ If the driver is a
pseudo-device, skew the advertisement interval by
.Ar n .
This is an 8-bit number; the default value is 0.
+.It Cm balancing Ar mode
+If the driver is a
+.Xr carp 4
+pseudo-device, set the load balancing mode to
+.Ar mode .
+Valid modes are
+.Ar arp ,
+.Ar ip ,
+.Ar ip-stealth ,
+and
+.Ar ip-unicast .
+.It Cm carpnodes Ar vhid:advskew,vhid:advskew,...
+If the driver is a
+.Xr carp 4
+pseudo-device, create a load balancing group consisting of up to 32 nodes.
+Each node is specified as a
+.Ar vhid:advskew
+tuple in a comma separated list.
.It Cm carpdev Ar iface
If the driver is a
.Xr carp 4
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 6efed484d53..addce6ad612 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.192 2007/11/27 16:21:02 chl Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.193 2008/02/05 22:57:30 mpf Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -196,7 +196,8 @@ void setcarp_vhid(const char *, int);
void setcarp_state(const char *, int);
void setcarpdev(const char *, int);
void unsetcarpdev(const char *, int);
-void setcarpnodes(const char *, int);
+void setcarp_nodes(const char *, int);
+void setcarp_balancing(const char *, int);
void setpfsync_syncdev(const char *, int);
void setpfsync_maxupd(const char *, int);
void unsetpfsync_syncdev(const char *, int);
@@ -314,7 +315,8 @@ const struct cmd {
{ "vhid", NEXTARG, 0, setcarp_vhid },
{ "state", NEXTARG, 0, setcarp_state },
{ "carpdev", NEXTARG, 0, setcarpdev },
- { "carpnodes", NEXTARG, 0, setcarpnodes },
+ { "carpnodes", NEXTARG, 0, setcarp_nodes },
+ { "balancing", NEXTARG, 0, setcarp_balancing },
{ "-carpdev", 1, 0, unsetcarpdev },
{ "syncdev", NEXTARG, 0, setpfsync_syncdev },
{ "-syncdev", 1, 0, unsetpfsync_syncdev },
@@ -2885,11 +2887,12 @@ unsetvlandev(const char *val, int d)
}
static const char *carp_states[] = { CARP_STATES };
+static const char *carp_bal_modes[] = { CARP_BAL_MODES };
void
carp_status(void)
{
- const char *state;
+ const char *state, *balmode;
struct carpreq carpr;
int i;
@@ -2902,6 +2905,11 @@ carp_status(void)
if (carpr.carpr_vhids[0] == 0)
return;
+ if (carpr.carpr_balancing > CARP_BAL_MAXID)
+ balmode = "<UNKNOWN>";
+ else
+ balmode = carp_bal_modes[carpr.carpr_balancing];
+
for (i = 0; carpr.carpr_vhids[i]; i++) {
if (carpr.carpr_states[i] > CARP_MAXSTATE)
state = "<UNKNOWN>";
@@ -2915,10 +2923,11 @@ carp_status(void)
carpr.carpr_advbase, carpr.carpr_advskews[0]);
} else {
if (i == 0) {
- printf("\tcarp: carpdev %s advbase %d\n",
+ printf("\tcarp: carpdev %s advbase %d"
+ " balancing %s\n",
carpr.carpr_carpdev[0] != '\0' ?
carpr.carpr_carpdev : "none",
- carpr.carpr_advbase);
+ carpr.carpr_advbase, balmode);
}
printf("\t\tstate %s vhid %u advskew %u\n", state,
carpr.carpr_vhids[i], carpr.carpr_advskews[i]);
@@ -3078,7 +3087,7 @@ unsetcarpdev(const char *val, int d)
}
void
-setcarpnodes(const char *val, int d)
+setcarp_nodes(const char *val, int d)
{
char *str;
int i;
@@ -3120,6 +3129,31 @@ setcarpnodes(const char *val, int d)
}
void
+setcarp_balancing(const char *val, int d)
+{
+ int i;
+ struct carpreq carpr;
+
+ 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_BAL_MAXID; i++)
+ if (!strcasecmp(val, carp_bal_modes[i]))
+ break;
+
+ if (i > CARP_BAL_MAXID)
+ errx(1, "balancing %s: unknown mode", val);
+
+ carpr.carpr_balancing = i;
+
+ if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ err(1, "SIOCSVH");
+}
+
+void
setpfsync_syncdev(const char *val, int d)
{
struct pfsyncreq preq;