ifconfig: improve vlan options parsing
PR: 261136 Reported by: Daniel O'Connor MFC after: 2 weeks
This commit is contained in:
parent
b1f7154cb1
commit
779fd05344
@ -126,11 +126,6 @@ vlan_parse_ethervid(const char *name)
|
|||||||
strlcpy(ifname, name, IFNAMSIZ);
|
strlcpy(ifname, name, IFNAMSIZ);
|
||||||
if ((cp = strrchr(ifname, '.')) == NULL)
|
if ((cp = strrchr(ifname, '.')) == NULL)
|
||||||
return;
|
return;
|
||||||
/*
|
|
||||||
* Don't mix vlan/vlandev parameters with dot notation.
|
|
||||||
*/
|
|
||||||
if (params.vlr_tag != NOTAG || params.vlr_parent[0] != '\0')
|
|
||||||
errx(1, "ambiguous vlan specification");
|
|
||||||
/*
|
/*
|
||||||
* Derive params from interface name: "parent.vid".
|
* Derive params from interface name: "parent.vid".
|
||||||
*/
|
*/
|
||||||
@ -144,8 +139,20 @@ vlan_parse_ethervid(const char *name)
|
|||||||
if ((*cp != '\0') || (vid & ~0xFFF))
|
if ((*cp != '\0') || (vid & ~0xFFF))
|
||||||
errx(1, "invalid vlan tag");
|
errx(1, "invalid vlan tag");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* allow "devX.Y vlandev devX vlan Y" syntax
|
||||||
|
*/
|
||||||
|
if (params.vlr_tag == NOTAG || params.vlr_tag == vid)
|
||||||
|
params.vlr_tag = vid;
|
||||||
|
else
|
||||||
|
errx(1, "ambiguous vlan specification");
|
||||||
|
|
||||||
|
/* Restrict overriding interface name */
|
||||||
|
if (params.vlr_parent[0] == '\0' || !strcmp(params.vlr_parent, ifname))
|
||||||
strlcpy(params.vlr_parent, ifname, IFNAMSIZ);
|
strlcpy(params.vlr_parent, ifname, IFNAMSIZ);
|
||||||
params.vlr_tag = (vid & 0xFFF);
|
else
|
||||||
|
errx(1, "ambiguous vlan specification");
|
||||||
|
printf("CR: %s %d\n", params.vlr_parent, params.vlr_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user