summaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2006-06-02 19:53:13 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2006-06-02 19:53:13 +0000
commitbcd3f8f0d9fbf81babcd87d65fd75f73642581a2 (patch)
tree3fd29f560705ee795bfede421840439d62026d09 /sbin/ifconfig
parent6de597ae247e471ba7a7fee9b537d54455271290 (diff)
Introduce attributes to interface groups.
As a first user, move the global carp(4) demotion counter into the interface group. Thus we have the possibility to define which carp interfaces are demoted together. Put the demotion counter into the reserved field of the carp header. With this, we can have carp act smarter if multiple errors occur. It now always takes over other carp peers, that are advertising with a higher demote count. As a side effect, we can also have group failovers without the need of running in preempt mode. The protocol change does not break compability with older implementations. Collaborative work with mcbride@ OK mcbride@, henning@
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifconfig.817
-rw-r--r--sbin/ifconfig/ifconfig.c57
2 files changed, 72 insertions, 2 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 3a7c3474de1..a36a8368fbe 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ifconfig.8,v 1.121 2006/05/17 12:10:16 jmc Exp $
+.\" $OpenBSD: ifconfig.8,v 1.122 2006/06/02 19:53:12 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 $
.\"
@@ -52,6 +52,10 @@
.Nm ifconfig
.Fl C
.Nm ifconfig
+.Fl g
+.Ar group-name
+.Op Ar group_parameters
+.Nm ifconfig
.Ar interface
.Cm create
.Nm ifconfig
@@ -200,6 +204,9 @@ In Host AP mode, this will dump the list of known nodes.
.It Fl m Ar interface
Print media information for a given
.Ar interface .
+.It Fl m Ar group-name
+Print or configure group attributes for a given
+.Ar group-name .
.It Ar address
For the
.Tn DARPA
@@ -374,6 +381,14 @@ Set the desired BSSID for IEEE 802.11-based wireless network interfaces.
Unset the desired BSSID for IEEE 802.11-based wireless network interfaces.
The interface will automatically select a BSSID in this mode, which is
the default.
+.It Cm carpdemote
+Increase
+.Xr carp 4
+demote count for given interface group.
+.It Fl carpdemote
+Decrease
+.Xr carp 4
+demote count for given interface group.
.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 2528940c5a5..07b1a1ec675 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.162 2006/06/01 21:01:10 claudio Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.163 2006/06/02 19:53:12 mpf Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -380,6 +380,8 @@ const struct cmd {
int getinfo(struct ifreq *, int);
void getsock(int);
int printgroup(char *, int);
+void printgroupattribs(char *);
+void setgroupattribs(char *, int, char *[]);
void printif(char *, int);
void printb(char *, unsigned short, char *);
void printb_status(unsigned short, char *);
@@ -459,6 +461,7 @@ main(int argc, char *argv[])
int aflag = 0;
int ifaliases = 0;
int Cflag = 0;
+ int gflag = 0;
int i;
/* If no args at all, print all interfaces. */
@@ -481,6 +484,9 @@ main(int argc, char *argv[])
ifaliases = 1;
nomore = 1;
break;
+ case 'g':
+ gflag = 1;
+ break;
case 'm':
mflag = 1;
break;
@@ -523,6 +529,13 @@ main(int argc, char *argv[])
list_cloners();
exit(0);
}
+ if (gflag) {
+ if (argc == 0)
+ printgroupattribs(name);
+ else
+ setgroupattribs(name, argc, argv);
+ exit(0);
+ }
if (aflag) {
if (argc > 0)
usage(0);
@@ -726,6 +739,47 @@ printgroup(char *groupname, int ifaliases)
}
void
+printgroupattribs(char *groupname)
+{
+ struct ifgroupreq ifgr;
+
+ getsock(AF_INET);
+ bzero(&ifgr, sizeof(ifgr));
+ strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name));
+ if (ioctl(s, SIOCGIFGATTR, (caddr_t)&ifgr) == -1)
+ err(1, "SIOCGIFGATTR");
+
+ printf("%s:", groupname);
+ printf(" carp demote count %d", ifgr.ifgr_attrib.ifg_carp_demoted);
+ printf("\n");
+}
+
+void
+setgroupattribs(char *groupname, int argc, char *argv[])
+{
+ char *p = argv[0];
+ int neg = 1;
+
+ struct ifgroupreq ifgr;
+ struct ifg_attrib *ifga;
+
+ getsock(AF_INET);
+ bzero(&ifgr, sizeof(ifgr));
+ strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name));
+ if (p[0] == '-') {
+ neg = -1;
+ p++;
+ }
+ if (!strcmp(p, "carpdemote"))
+ ifgr.ifgr_attrib.ifg_carp_demoted = neg;
+ else
+ usage(1);
+
+ if (ioctl(s, SIOCSIFGATTR, (caddr_t)&ifgr) == -1)
+ err(1, "SIOCSIFGATTR");
+}
+
+void
printif(char *ifname, int ifaliases)
{
struct ifaddrs *ifap, *ifa;
@@ -3811,6 +3865,7 @@ usage(int value)
"\t[authname name] [authkey key] [peerproto proto]\n"
"\t[peername name] [peerkey key] [[-]peerflag flag]\n"
" ifconfig [-AaCMm] [interface] [address_family]\n"
+ " ifconfig -g group-name [[-]carpdemote]\n"
" ifconfig interface create\n"
" ifconfig interface destroy\n");
exit(value);