summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorsam <sam@FreeBSD.org>2008-12-15 01:44:23 +0000
committersam <sam@FreeBSD.org>2008-12-15 01:44:23 +0000
commitef924e3391ec453d522343f7eb057d0994bda1e1 (patch)
tree231674357caab874c3bd4f889ad403f5c8c77e39 /sbin/ifconfig
parentdc256886cd00e7367a087d21fe06be26030d80e0 (diff)
downloadFreeBSD-src-ef924e3391ec453d522343f7eb057d0994bda1e1.zip
FreeBSD-src-ef924e3391ec453d522343f7eb057d0994bda1e1.tar.gz
back out unintended change
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/ifvlan.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
index 5a6d81c..6742789 100644
--- a/sbin/ifconfig/ifvlan.c
+++ b/sbin/ifconfig/ifvlan.c
@@ -119,9 +119,10 @@ vlan_set(int s, struct ifreq *ifr)
}
}
-static void
-getvlantag(const char *val)
+static
+DECL_CMD_FUNC(setvlantag, val, d)
{
+ struct vlanreq vreq;
u_long ul;
char *endp;
@@ -132,31 +133,11 @@ getvlantag(const char *val)
/* check if the value can be represented in vlr_tag */
if (params.vlr_tag != ul)
errx(1, "value for vlan out of range");
-}
-static
-DECL_CMD_FUNC(setvlantag_clone, val, d)
-{
- getvlantag(val);
- clone_setcallback(vlan_create);
-}
-
-static
-DECL_CMD_FUNC(setvlantag, val, d)
-{
- struct vlanreq vreq;
-
- getvlantag(val);
- if (getvlan(s, &ifr, &vreq) == -1)
- errx(1, "no existing vlan");
- vlan_set(s, &ifr);
-}
-
-static
-DECL_CMD_FUNC(setvlandev_clone, val, d)
-{
- strlcpy(params.vlr_parent, val, sizeof(params.vlr_parent));
- clone_setcallback(vlan_create);
+ if (getvlan(s, &ifr, &vreq) != -1)
+ vlan_set(s, &ifr);
+ else
+ clone_setcallback(vlan_create);
}
static
@@ -165,9 +146,11 @@ DECL_CMD_FUNC(setvlandev, val, d)
struct vlanreq vreq;
strlcpy(params.vlr_parent, val, sizeof(params.vlr_parent));
+
if (getvlan(s, &ifr, &vreq) != -1)
- errx(1, "no existing vlan");
- vlan_set(s, &ifr);
+ vlan_set(s, &ifr);
+ else
+ clone_setcallback(vlan_create);
}
static
@@ -189,8 +172,8 @@ DECL_CMD_FUNC(unsetvlandev, val, d)
}
static struct cmd vlan_cmds[] = {
- DEF_CLONE_CMD_ARG("vlan", setvlantag_clone),
- DEF_CLONE_CMD_ARG("vlandev", setvlandev_clone),
+ DEF_CLONE_CMD_ARG("vlan", setvlantag),
+ DEF_CLONE_CMD_ARG("vlandev", setvlandev),
/* NB: non-clone cmds */
DEF_CMD_ARG("vlan", setvlantag),
DEF_CMD_ARG("vlandev", setvlandev),
OpenPOWER on IntegriCloud