summaryrefslogtreecommitdiff
path: root/sbin/ifconfig/ifconfig.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2015-10-23 01:19:05 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2015-10-23 01:19:05 +0000
commit46414bebb04bce3ce52afb402304f9ca4e155da1 (patch)
tree4a7ac5d924992ef441ebab088e79729a1751e4b4 /sbin/ifconfig/ifconfig.c
parent0f34f3b38d145dba1f857d12fe969dd0fb4dab0d (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/ifconfig/ifconfig.c')
-rw-r--r--sbin/ifconfig/ifconfig.c16
1 files changed, 13 insertions, 3 deletions
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)
{