summaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2010-06-26 19:51:13 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2010-06-26 19:51:13 +0000
commitb4642ed443e9fe719f3e3bfba3f21744177c44a4 (patch)
treeeddf919cb03fa6a44fe6ad3b1f6b7ff78aefb13b /sbin/ifconfig
parent65037ace5cd66de6d2def3c899589e4b1a811e76 (diff)
Add a way to enable and set the keepalive parameters for gre(4).
OK deraadt, reyk
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifconfig.824
-rw-r--r--sbin/ifconfig/ifconfig.c47
2 files changed, 68 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 51acd4a5992..7153b03752c 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ifconfig.8,v 1.202 2010/05/28 13:23:43 jmc Exp $
+.\" $OpenBSD: ifconfig.8,v 1.203 2010/06/26 19:51:12 claudio 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: May 28 2010 $
+.Dd $Mdocdate: June 26 2010 $
.Dt IFCONFIG 8
.Os
.Sh NAME
@@ -1400,6 +1400,7 @@ for a complete list of the available protocols,
.Bk -words
.Ar tunnel-interface
.Op Cm deletetunnel Ar src_address dest_address
+.Op Oo Fl Oc Ns Cm keepalive Ar period Ar count
.Op Cm tunnel Ar src_address dest_address
.Op Cm tunneldomain Ar route-id
.Ek
@@ -1408,6 +1409,25 @@ The following options are available for a tunnel interface:
.Bl -tag -width Ds
.It Cm deletetunnel Ar src_address dest_address
Remove the source and destination tunnel addresses.
+.It Cm keepalive Ar period Ar count
+Enable
+.Xr gre 4
+keepalive with a packet sent every
+.Ar period
+seconds.
+A second timer is run with a timeout of
+.Ar count
+*
+.Ar period .
+If no keepalive response is received during that time, the link is considered
+down.
+The minimal usable
+.Ar count
+is 2 since the round-trip time of keepalive packets is not accounted.
+.It Fl keepalive
+Disable the
+.Xr gre 4
+keepalive mechanism.
.It Cm tunnel Ar src_address dest_address
Set the source and destination tunnel addresses on a tunnel interface,
including
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index ed734262545..92cb5405fec 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.236 2010/06/07 14:50:34 claudio Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.237 2010/06/26 19:51:12 claudio Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -180,6 +180,8 @@ void setia6pltime(const char *, int);
void setia6vltime(const char *, int);
void setia6lifetime(const char *, const char *);
void setia6eui64(const char *, int);
+void setkeepalive(const char *, const char *);
+void unsetkeepalive(const char *, int);
#endif /* INET6 */
void checkatrange(struct sockaddr_at *);
void setmedia(const char *, int);
@@ -401,6 +403,8 @@ const struct cmd {
{ "flowdst", NEXTARG, 0, setpflow_receiver },
{ "-flowdst", 1, 0, unsetpflow_receiver },
{ "-inet6", IFXF_NOINET6, 0, setifxflags } ,
+ { "keepalive", NEXTARG2, 0, NULL, setkeepalive },
+ { "-keepalive", 1, 0, unsetkeepalive },
{ "add", NEXTARG, 0, bridge_add },
{ "del", NEXTARG, 0, bridge_delete },
{ "addspan", NEXTARG, 0, bridge_addspan },
@@ -2705,6 +2709,9 @@ status(int link, struct sockaddr_dl *sdl, int ls)
const struct afswtch *p = afp;
struct ifmediareq ifmr;
struct ifreq ifrdesc;
+#ifndef SMALL
+ struct ifkalivereq ikardesc;
+#endif
int *media_list, i;
char ifdescr[IFDESCRSIZE];
@@ -2732,6 +2739,12 @@ status(int link, struct sockaddr_dl *sdl, int ls)
#ifndef SMALL
if (!is_bridge(name) && ioctl(s, SIOCGIFPRIORITY, &ifrdesc) == 0)
printf("\tpriority: %d\n", ifrdesc.ifr_metric);
+ (void) memset(&ikardesc, 0, sizeof(ikardesc));
+ (void) strlcpy(ikardesc.ikar_name, name, sizeof(ikardesc.ikar_name));
+ if (ioctl(s, SIOCGETKALIVE, &ikardesc) == 0 &&
+ (ikardesc.ikar_timeo != 0 || ikardesc.ikar_cnt != 0))
+ printf("\tkeepalive: timeout %d count %d\n",
+ ikardesc.ikar_timeo, ikardesc.ikar_cnt);
#endif
vlan_status();
#ifndef SMALL
@@ -4425,6 +4438,38 @@ trunk_status(void)
} else if (isport)
printf("\ttrunk: trunkdev %s\n", rp.rp_ifname);
}
+
+void
+setkeepalive(const char *timeout, const char *count)
+{
+ const char *errmsg = NULL;
+ struct ifkalivereq ikar;
+ int t, c;
+
+ t = strtonum(timeout, 1, 3600, &errmsg);
+ if (errmsg)
+ errx(1, "keepalive period %s: %s", timeout, errmsg);
+ c = strtonum(count, 2, 600, &errmsg);
+ if (errmsg)
+ errx(1, "keepalive count %s: %s", count, errmsg);
+
+ strlcpy(ikar.ikar_name, name, sizeof(ikar.ikar_name));
+ ikar.ikar_timeo = t;
+ ikar.ikar_cnt = c;
+ if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) < 0)
+ warn("SIOCSETKALIVE");
+}
+
+void
+unsetkeepalive(const char *val, int d)
+{
+ struct ifkalivereq ikar;
+
+ bzero(&ikar, sizeof(ikar));
+ strlcpy(ikar.ikar_name, name, sizeof(ikar.ikar_name));
+ if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) < 0)
+ warn("SIOCSETKALIVE");
+}
#endif /* SMALL */
void