Page MenuHomeFreeBSD

D27505.id80423.diff
No OneTemporary

D27505.id80423.diff

Index: sys/net/if_clone.c
===================================================================
--- sys/net/if_clone.c
+++ sys/net/if_clone.c
@@ -571,7 +571,7 @@
/*
* A utility function to extract unit numbers from interface names of
- * the form name###[.###].
+ * the form name###.
*
* Returns 0 on success and an error on failure.
*/
@@ -582,9 +582,7 @@
int cutoff = INT_MAX / 10;
int cutlim = INT_MAX % 10;
- if ((cp = strrchr(name, '.')) == NULL)
- cp = name;
- for (; *cp != '\0' && (*cp < '0' || *cp > '9'); cp++);
+ for (cp = name; *cp != '\0' && (*cp < '0' || *cp > '9'); cp++);
if (*cp == '\0') {
*unit = -1;
} else if (cp[0] == '0' && cp[1] != '\0') {
Index: sys/net/if_vlan.c
===================================================================
--- sys/net/if_vlan.c
+++ sys/net/if_vlan.c
@@ -976,9 +976,6 @@
static int
vlan_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
{
- char *dp;
- int wildcard;
- int unit;
int error;
int vid;
uint16_t proto;
@@ -993,11 +990,12 @@
proto = ETHERTYPE_VLAN;
/*
- * There are two ways to specify the cloned device:
+ * There are three ways to specify the cloned device:
* o pass a parameter block with the clone request.
+ * o specify parameters in the text of the clone device name
* o specify no parameters and get an unattached device that
* must be configured separately.
- * The first technique is preferred; the latter is supported
+ * The first technique is preferred; the latter two are supported
* for backwards compatibility.
*
* XXXRW: Note historic use of the word "tag" here. New ioctls may be
@@ -1010,43 +1008,22 @@
p = ifunit_ref(vlr.vlr_parent);
if (p == NULL)
return (ENXIO);
- error = ifc_name2unit(name, &unit);
- if (error != 0) {
- if_rele(p);
- return (error);
- }
vid = vlr.vlr_tag;
proto = vlr.vlr_proto;
- wildcard = (unit < 0);
+ } else if ((p = vlan_clone_match_ethervid(name, &vid)) != NULL) {
} else {
p = NULL;
- error = ifc_name2unit(name, &unit);
+ error = ifc_name2unit(name, &vid);
if (error != 0)
return (error);
-
- wildcard = (unit < 0);
}
- error = ifc_alloc_unit(ifc, &unit);
- if (error != 0) {
- if (p != NULL)
- if_rele(p);
- return (error);
- }
+ if (vid <= 0)
+ return (EINVAL);
- /* In the wildcard case, we need to update the name. */
- if (wildcard) {
- for (dp = name; *dp != '\0'; dp++);
- if (snprintf(dp, len - (dp-name), "%d", unit) >
- len - (dp-name) - 1) {
- panic("%s: interface name too long", __func__);
- }
- }
-
ifv = malloc(sizeof(struct ifvlan), M_VLAN, M_WAITOK | M_ZERO);
ifp = ifv->ifv_ifp = if_alloc(IFT_ETHER);
if (ifp == NULL) {
- ifc_free_unit(ifc, unit);
free(ifv, M_VLAN);
if (p != NULL)
if_rele(p);
@@ -1060,7 +1037,7 @@
*/
strlcpy(ifp->if_xname, name, IFNAMSIZ);
ifp->if_dname = vlanname;
- ifp->if_dunit = unit;
+ ifp->if_dunit = vid;
ifp->if_init = vlan_init;
ifp->if_transmit = vlan_transmit;
@@ -1094,7 +1071,6 @@
ether_ifdetach(ifp);
vlan_unconfig(ifp);
if_free(ifp);
- ifc_free_unit(ifc, unit);
free(ifv, M_VLAN);
return (error);
@@ -1123,7 +1099,6 @@
NET_EPOCH_WAIT();
if_free(ifp);
free(ifv, M_VLAN);
- ifc_free_unit(ifc, ifp->if_dunit);
return (0);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 15, 7:19 AM (2 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15807466
Default Alt Text
D27505.id80423.diff (3 KB)

Event Timeline