diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-10-23 01:19:05 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-10-23 01:19:05 +0000 |
commit | 46414bebb04bce3ce52afb402304f9ca4e155da1 (patch) | |
tree | 4a7ac5d924992ef441ebab088e79729a1751e4b4 /sbin | |
parent | 0f34f3b38d145dba1f857d12fe969dd0fb4dab0d (diff) |
tweak the vnetid so it can be optional and therefore cleared/deleted.
the abstract vnetid is promoted to a uin32_t, and adds a SIOCDVNETID
ioctl so it can be cleared.
this is all because i set an assignment on implementing a virtual
network interface and the students got confused when vnetid 0 didnt
show up in ifconfig output.
the vnetid in the vxlan(4) protocol is optional, but the current
code confuses 0 with no vnetid being set. this makes it clear.
ok reyk@ who also simplified my diff
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 7 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 16 |
2 files changed, 18 insertions, 5 deletions
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 35137b537bb..3412f74f09a 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.257 2015/10/06 17:23:21 benno Exp $ +.\" $OpenBSD: ifconfig.8,v 1.258 2015/10/23 01:19:04 dlg 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: October 6 2015 $ +.Dd $Mdocdate: October 23 2015 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -1504,6 +1504,7 @@ for a complete list of the available protocols, .Op Cm tunnel Ar src_address dest_address .Op Cm tunneldomain Ar tableid .Op Cm vnetid Ar network-id +.Op Cm -vnetid .Ek .nr nS 0 .Pp @@ -1559,6 +1560,8 @@ to identify packets with a virtual network. The accepted size of the number depends on the individual tunnel protocol; it is a 24-bit number for .Xr vxlan 4 . +.It Cm -vnetid +Clear the virtual network identifier. .El .\" VLAN .Sh VLAN diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 5c015f67930..6c681e3fa5e 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.302 2015/10/03 10:44:23 florian Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.303 2015/10/23 01:19:04 dlg Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -181,6 +181,7 @@ void deletetunnel(const char *, int); void settunnelinst(const char *, int); void settunnelttl(const char *, int); void setvnetid(const char *, int); +void delvnetid(const char *, int); #ifdef INET6 void setia6flags(const char *, int); void setia6pltime(const char *, int); @@ -413,6 +414,7 @@ const struct cmd { { "tunneldomain", NEXTARG, 0, settunnelinst } , { "tunnelttl", NEXTARG, 0, settunnelttl } , { "vnetid", NEXTARG, 0, setvnetid }, + { "-vnetid", 0, 0, delvnetid }, { "pppoedev", NEXTARG, 0, setpppoe_dev }, { "pppoesvc", NEXTARG, 0, setpppoe_svc }, { "-pppoesvc", 1, 0, setpppoe_svc }, @@ -2868,7 +2870,7 @@ phys_status(int force) if (dstport) printf(":%u", ntohs(dstport)); - if (ioctl(s, SIOCGVNETID, (caddr_t)&ifr) == 0 && ifr.ifr_vnetid > 0) + if (ioctl(s, SIOCGVNETID, (caddr_t)&ifr) == 0) printf(" vnetid %d", ifr.ifr_vnetid); if (ioctl(s, SIOCGLIFPHYTTL, (caddr_t)&ifr) == 0 && ifr.ifr_ttl > 0) printf(" ttl %d", ifr.ifr_ttl); @@ -3391,7 +3393,7 @@ void setvnetid(const char *id, int param) { const char *errmsg = NULL; - int vnetid; + uint32_t vnetid; vnetid = strtonum(id, 0, UINT_MAX, &errmsg); if (errmsg) @@ -3403,6 +3405,14 @@ setvnetid(const char *id, int param) warn("SIOCSVNETID"); } +/* ARGSUSED */ +void +delvnetid(const char *ignored, int alsoignored) +{ + if (ioctl(s, SIOCDVNETID, &ifr) < 0) + warn("SIOCDVNETID"); +} + void mpe_status(void) { |