mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 13:08:35 +08:00
Update to FreeBSD head 2016-08-23
Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2012 Gleb Smirnoff <glebius@FreeBSD.org>
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
@@ -33,6 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/limits.h>
|
||||
#include <rtems/bsd/sys/lock.h>
|
||||
@@ -43,29 +45,74 @@
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
#if 0
|
||||
#include <net/if_dl.h>
|
||||
#endif
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/if_clone.h>
|
||||
#include <net/radix.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
/* Current IF_MAXUNIT expands maximum to 5 characters. */
|
||||
#define IFCLOSIZ (IFNAMSIZ - 5)
|
||||
|
||||
/*
|
||||
* Structure describing a `cloning' interface.
|
||||
*
|
||||
* List of locks
|
||||
* (c) const until freeing
|
||||
* (d) driver specific data, may need external protection.
|
||||
* (e) locked by if_cloners_mtx
|
||||
* (i) locked by ifc_mtx mtx
|
||||
*/
|
||||
struct if_clone {
|
||||
char ifc_name[IFCLOSIZ]; /* (c) Name of device, e.g. `gif' */
|
||||
struct unrhdr *ifc_unrhdr; /* (c) alloc_unr(9) header */
|
||||
int ifc_maxunit; /* (c) maximum unit number */
|
||||
long ifc_refcnt; /* (i) Reference count. */
|
||||
LIST_HEAD(, ifnet) ifc_iflist; /* (i) List of cloned interfaces */
|
||||
struct mtx ifc_mtx; /* Mutex to protect members. */
|
||||
|
||||
enum { SIMPLE, ADVANCED } ifc_type; /* (c) */
|
||||
|
||||
/* (c) Driver specific cloning functions. Called with no locks held. */
|
||||
union {
|
||||
struct { /* advanced cloner */
|
||||
ifc_match_t *_ifc_match;
|
||||
ifc_create_t *_ifc_create;
|
||||
ifc_destroy_t *_ifc_destroy;
|
||||
} A;
|
||||
struct { /* simple cloner */
|
||||
ifcs_create_t *_ifcs_create;
|
||||
ifcs_destroy_t *_ifcs_destroy;
|
||||
int _ifcs_minifs; /* minimum ifs */
|
||||
|
||||
} S;
|
||||
} U;
|
||||
#define ifc_match U.A._ifc_match
|
||||
#define ifc_create U.A._ifc_create
|
||||
#define ifc_destroy U.A._ifc_destroy
|
||||
#define ifcs_create U.S._ifcs_create
|
||||
#define ifcs_destroy U.S._ifcs_destroy
|
||||
#define ifcs_minifs U.S._ifcs_minifs
|
||||
|
||||
LIST_ENTRY(if_clone) ifc_list; /* (e) On list of cloners */
|
||||
};
|
||||
|
||||
static void if_clone_free(struct if_clone *ifc);
|
||||
static int if_clone_createif(struct if_clone *ifc, char *name, size_t len,
|
||||
caddr_t params);
|
||||
|
||||
static struct mtx if_cloners_mtx;
|
||||
static int ifc_simple_match(struct if_clone *, const char *);
|
||||
static int ifc_simple_create(struct if_clone *, char *, size_t, caddr_t);
|
||||
static int ifc_simple_destroy(struct if_clone *, struct ifnet *);
|
||||
|
||||
static struct mtx if_cloners_mtx;
|
||||
MTX_SYSINIT(if_cloners_lock, &if_cloners_mtx, "if_cloners lock", MTX_DEF);
|
||||
static VNET_DEFINE(int, if_cloners_count);
|
||||
VNET_DEFINE(LIST_HEAD(, if_clone), if_cloners);
|
||||
|
||||
#define V_if_cloners_count VNET(if_cloners_count)
|
||||
#define V_if_cloners VNET(if_cloners)
|
||||
|
||||
#define IF_CLONERS_LOCK_INIT() \
|
||||
mtx_init(&if_cloners_mtx, "if_cloners lock", NULL, MTX_DEF)
|
||||
#define IF_CLONERS_LOCK_ASSERT() mtx_assert(&if_cloners_mtx, MA_OWNED)
|
||||
#define IF_CLONERS_LOCK() mtx_lock(&if_cloners_mtx)
|
||||
#define IF_CLONERS_UNLOCK() mtx_unlock(&if_cloners_mtx)
|
||||
@@ -123,13 +170,6 @@ vnet_if_clone_init(void)
|
||||
LIST_INIT(&V_if_cloners);
|
||||
}
|
||||
|
||||
void
|
||||
if_clone_init(void)
|
||||
{
|
||||
|
||||
IF_CLONERS_LOCK_INIT();
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup and create a clone network interface.
|
||||
*/
|
||||
@@ -140,18 +180,25 @@ if_clone_create(char *name, size_t len, caddr_t params)
|
||||
|
||||
/* Try to find an applicable cloner for this request */
|
||||
IF_CLONERS_LOCK();
|
||||
LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
|
||||
if (ifc->ifc_match(ifc, name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef VIMAGE
|
||||
if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) {
|
||||
CURVNET_SET_QUIET(vnet0);
|
||||
LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
|
||||
LIST_FOREACH(ifc, &V_if_cloners, ifc_list)
|
||||
if (ifc->ifc_type == SIMPLE) {
|
||||
if (ifc_simple_match(ifc, name))
|
||||
break;
|
||||
} else {
|
||||
if (ifc->ifc_match(ifc, name))
|
||||
break;
|
||||
}
|
||||
#ifdef VIMAGE
|
||||
if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) {
|
||||
CURVNET_SET_QUIET(vnet0);
|
||||
LIST_FOREACH(ifc, &V_if_cloners, ifc_list)
|
||||
if (ifc->ifc_type == SIMPLE) {
|
||||
if (ifc_simple_match(ifc, name))
|
||||
break;
|
||||
} else {
|
||||
if (ifc->ifc_match(ifc, name))
|
||||
break;
|
||||
}
|
||||
CURVNET_RESTORE();
|
||||
}
|
||||
#endif
|
||||
@@ -175,7 +222,10 @@ if_clone_createif(struct if_clone *ifc, char *name, size_t len, caddr_t params)
|
||||
if (ifunit(name) != NULL)
|
||||
return (EEXIST);
|
||||
|
||||
err = (*ifc->ifc_create)(ifc, name, len, params);
|
||||
if (ifc->ifc_type == SIMPLE)
|
||||
err = ifc_simple_create(ifc, name, len, params);
|
||||
else
|
||||
err = (*ifc->ifc_create)(ifc, name, len, params);
|
||||
|
||||
if (!err) {
|
||||
ifp = ifunit(name);
|
||||
@@ -216,10 +266,14 @@ if_clone_destroy(const char *name)
|
||||
#ifdef VIMAGE
|
||||
if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) {
|
||||
CURVNET_SET_QUIET(vnet0);
|
||||
LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
|
||||
if (ifc->ifc_match(ifc, name))
|
||||
break;
|
||||
}
|
||||
LIST_FOREACH(ifc, &V_if_cloners, ifc_list)
|
||||
if (ifc->ifc_type == SIMPLE) {
|
||||
if (ifc_simple_match(ifc, name))
|
||||
break;
|
||||
} else {
|
||||
if (ifc->ifc_match(ifc, name))
|
||||
break;
|
||||
}
|
||||
CURVNET_RESTORE();
|
||||
}
|
||||
#endif
|
||||
@@ -243,7 +297,7 @@ if_clone_destroyif(struct if_clone *ifc, struct ifnet *ifp)
|
||||
int err;
|
||||
struct ifnet *ifcifp;
|
||||
|
||||
if (ifc->ifc_destroy == NULL)
|
||||
if (ifc->ifc_type == ADVANCED && ifc->ifc_destroy == NULL)
|
||||
return(EOPNOTSUPP);
|
||||
|
||||
/*
|
||||
@@ -268,7 +322,10 @@ if_clone_destroyif(struct if_clone *ifc, struct ifnet *ifp)
|
||||
|
||||
if_delgroup(ifp, ifc->ifc_name);
|
||||
|
||||
err = (*ifc->ifc_destroy)(ifc, ifp);
|
||||
if (ifc->ifc_type == SIMPLE)
|
||||
err = ifc_simple_destroy(ifc, ifp);
|
||||
else
|
||||
err = (*ifc->ifc_destroy)(ifc, ifp);
|
||||
|
||||
if (err != 0) {
|
||||
if_addgroup(ifp, ifc->ifc_name);
|
||||
@@ -281,36 +338,97 @@ if_clone_destroyif(struct if_clone *ifc, struct ifnet *ifp)
|
||||
return (err);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register a network interface cloner.
|
||||
*/
|
||||
void
|
||||
if_clone_attach(struct if_clone *ifc)
|
||||
static struct if_clone *
|
||||
if_clone_alloc(const char *name, int maxunit)
|
||||
{
|
||||
int len, maxclone;
|
||||
struct if_clone *ifc;
|
||||
|
||||
/*
|
||||
* Compute bitmap size and allocate it.
|
||||
*/
|
||||
maxclone = ifc->ifc_maxunit + 1;
|
||||
len = maxclone >> 3;
|
||||
if ((len << 3) < maxclone)
|
||||
len++;
|
||||
ifc->ifc_units = malloc(len, M_CLONE, M_WAITOK | M_ZERO);
|
||||
ifc->ifc_bmlen = len;
|
||||
KASSERT(name != NULL, ("%s: no name\n", __func__));
|
||||
|
||||
ifc = malloc(sizeof(struct if_clone), M_CLONE, M_WAITOK | M_ZERO);
|
||||
strncpy(ifc->ifc_name, name, IFCLOSIZ-1);
|
||||
IF_CLONE_LOCK_INIT(ifc);
|
||||
IF_CLONE_ADDREF(ifc);
|
||||
ifc->ifc_maxunit = maxunit ? maxunit : IF_MAXUNIT;
|
||||
ifc->ifc_unrhdr = new_unrhdr(0, ifc->ifc_maxunit, &ifc->ifc_mtx);
|
||||
LIST_INIT(&ifc->ifc_iflist);
|
||||
|
||||
return (ifc);
|
||||
}
|
||||
|
||||
static int
|
||||
if_clone_attach(struct if_clone *ifc)
|
||||
{
|
||||
struct if_clone *ifc1;
|
||||
|
||||
IF_CLONERS_LOCK();
|
||||
LIST_FOREACH(ifc1, &V_if_cloners, ifc_list)
|
||||
if (strcmp(ifc->ifc_name, ifc1->ifc_name) == 0) {
|
||||
IF_CLONERS_UNLOCK();
|
||||
IF_CLONE_REMREF(ifc);
|
||||
return (EEXIST);
|
||||
}
|
||||
LIST_INSERT_HEAD(&V_if_cloners, ifc, ifc_list);
|
||||
V_if_cloners_count++;
|
||||
IF_CLONERS_UNLOCK();
|
||||
|
||||
LIST_INIT(&ifc->ifc_iflist);
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct if_clone *
|
||||
if_clone_advanced(const char *name, u_int maxunit, ifc_match_t match,
|
||||
ifc_create_t create, ifc_destroy_t destroy)
|
||||
{
|
||||
struct if_clone *ifc;
|
||||
|
||||
ifc = if_clone_alloc(name, maxunit);
|
||||
ifc->ifc_type = ADVANCED;
|
||||
ifc->ifc_match = match;
|
||||
ifc->ifc_create = create;
|
||||
ifc->ifc_destroy = destroy;
|
||||
|
||||
if (if_clone_attach(ifc) != 0) {
|
||||
if_clone_free(ifc);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (ifc->ifc_attach != NULL)
|
||||
(*ifc->ifc_attach)(ifc);
|
||||
EVENTHANDLER_INVOKE(if_clone_event, ifc);
|
||||
|
||||
return (ifc);
|
||||
}
|
||||
|
||||
struct if_clone *
|
||||
if_clone_simple(const char *name, ifcs_create_t create, ifcs_destroy_t destroy,
|
||||
u_int minifs)
|
||||
{
|
||||
struct if_clone *ifc;
|
||||
u_int unit;
|
||||
|
||||
ifc = if_clone_alloc(name, 0);
|
||||
ifc->ifc_type = SIMPLE;
|
||||
ifc->ifcs_create = create;
|
||||
ifc->ifcs_destroy = destroy;
|
||||
ifc->ifcs_minifs = minifs;
|
||||
|
||||
if (if_clone_attach(ifc) != 0) {
|
||||
if_clone_free(ifc);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
for (unit = 0; unit < minifs; unit++) {
|
||||
char name[IFNAMSIZ];
|
||||
int error;
|
||||
|
||||
snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, unit);
|
||||
error = if_clone_createif(ifc, name, IFNAMSIZ, NULL);
|
||||
KASSERT(error == 0,
|
||||
("%s: failed to create required interface %s",
|
||||
__func__, name));
|
||||
}
|
||||
|
||||
EVENTHANDLER_INVOKE(if_clone_event, ifc);
|
||||
|
||||
return (ifc);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -319,7 +437,6 @@ if_clone_attach(struct if_clone *ifc)
|
||||
void
|
||||
if_clone_detach(struct if_clone *ifc)
|
||||
{
|
||||
struct ifc_simple_data *ifcs = ifc->ifc_data;
|
||||
|
||||
IF_CLONERS_LOCK();
|
||||
LIST_REMOVE(ifc, ifc_list);
|
||||
@@ -327,8 +444,8 @@ if_clone_detach(struct if_clone *ifc)
|
||||
IF_CLONERS_UNLOCK();
|
||||
|
||||
/* Allow all simples to be destroyed */
|
||||
if (ifc->ifc_attach == ifc_simple_attach)
|
||||
ifcs->ifcs_minifs = 0;
|
||||
if (ifc->ifc_type == SIMPLE)
|
||||
ifc->ifcs_minifs = 0;
|
||||
|
||||
/* destroy all interfaces for this cloner */
|
||||
while (!LIST_EMPTY(&ifc->ifc_iflist))
|
||||
@@ -340,16 +457,13 @@ if_clone_detach(struct if_clone *ifc)
|
||||
static void
|
||||
if_clone_free(struct if_clone *ifc)
|
||||
{
|
||||
for (int bytoff = 0; bytoff < ifc->ifc_bmlen; bytoff++) {
|
||||
KASSERT(ifc->ifc_units[bytoff] == 0x00,
|
||||
("ifc_units[%d] is not empty", bytoff));
|
||||
}
|
||||
|
||||
KASSERT(LIST_EMPTY(&ifc->ifc_iflist),
|
||||
("%s: ifc_iflist not empty", __func__));
|
||||
|
||||
IF_CLONE_LOCK_DESTROY(ifc);
|
||||
free(ifc->ifc_units, M_CLONE);
|
||||
delete_unrhdr(ifc->ifc_unrhdr);
|
||||
free(ifc, M_CLONE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -372,7 +486,7 @@ if_clone_list(struct if_clonereq *ifcr)
|
||||
* below, but that's not a major problem. Not caping our
|
||||
* allocation to the number of cloners actually in the system
|
||||
* could be because that would let arbitrary users cause us to
|
||||
* allocate abritrary amounts of kernel memory.
|
||||
* allocate arbitrary amounts of kernel memory.
|
||||
*/
|
||||
buf_count = (V_if_cloners_count < ifcr->ifcr_count) ?
|
||||
V_if_cloners_count : ifcr->ifcr_count;
|
||||
@@ -405,6 +519,49 @@ done:
|
||||
return (err);
|
||||
}
|
||||
|
||||
/*
|
||||
* if_clone_findifc() looks up ifnet from the current
|
||||
* cloner list, and returns ifc if found. Note that ifc_refcnt
|
||||
* is incremented.
|
||||
*/
|
||||
struct if_clone *
|
||||
if_clone_findifc(struct ifnet *ifp)
|
||||
{
|
||||
struct if_clone *ifc, *ifc0;
|
||||
struct ifnet *ifcifp;
|
||||
|
||||
ifc0 = NULL;
|
||||
IF_CLONERS_LOCK();
|
||||
LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
|
||||
IF_CLONE_LOCK(ifc);
|
||||
LIST_FOREACH(ifcifp, &ifc->ifc_iflist, if_clones) {
|
||||
if (ifp == ifcifp) {
|
||||
ifc0 = ifc;
|
||||
IF_CLONE_ADDREF_LOCKED(ifc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
IF_CLONE_UNLOCK(ifc);
|
||||
if (ifc0 != NULL)
|
||||
break;
|
||||
}
|
||||
IF_CLONERS_UNLOCK();
|
||||
|
||||
return (ifc0);
|
||||
}
|
||||
|
||||
/*
|
||||
* if_clone_addgroup() decrements ifc_refcnt because it is called after
|
||||
* if_clone_findifc().
|
||||
*/
|
||||
void
|
||||
if_clone_addgroup(struct ifnet *ifp, struct if_clone *ifc)
|
||||
{
|
||||
|
||||
if_addgroup(ifp, ifc->ifc_name);
|
||||
IF_CLONE_REMREF(ifc);
|
||||
}
|
||||
|
||||
/*
|
||||
* A utility function to extract unit numbers from interface names of
|
||||
* the form name###.
|
||||
@@ -443,98 +600,52 @@ ifc_name2unit(const char *name, int *unit)
|
||||
int
|
||||
ifc_alloc_unit(struct if_clone *ifc, int *unit)
|
||||
{
|
||||
int wildcard, bytoff, bitoff;
|
||||
int err = 0;
|
||||
char name[IFNAMSIZ];
|
||||
int wildcard;
|
||||
|
||||
IF_CLONE_LOCK(ifc);
|
||||
|
||||
bytoff = bitoff = 0;
|
||||
wildcard = (*unit < 0);
|
||||
/*
|
||||
* Find a free unit if none was given.
|
||||
*/
|
||||
if (wildcard) {
|
||||
while ((bytoff < ifc->ifc_bmlen)
|
||||
&& (ifc->ifc_units[bytoff] == 0xff))
|
||||
bytoff++;
|
||||
if (bytoff >= ifc->ifc_bmlen) {
|
||||
err = ENOSPC;
|
||||
goto done;
|
||||
retry:
|
||||
if (*unit > ifc->ifc_maxunit)
|
||||
return (ENOSPC);
|
||||
if (*unit < 0) {
|
||||
*unit = alloc_unr(ifc->ifc_unrhdr);
|
||||
if (*unit == -1)
|
||||
return (ENOSPC);
|
||||
} else {
|
||||
*unit = alloc_unr_specific(ifc->ifc_unrhdr, *unit);
|
||||
if (*unit == -1) {
|
||||
if (wildcard) {
|
||||
(*unit)++;
|
||||
goto retry;
|
||||
} else
|
||||
return (EEXIST);
|
||||
}
|
||||
while ((ifc->ifc_units[bytoff] & (1 << bitoff)) != 0)
|
||||
bitoff++;
|
||||
*unit = (bytoff << 3) + bitoff;
|
||||
}
|
||||
|
||||
if (*unit > ifc->ifc_maxunit) {
|
||||
err = ENOSPC;
|
||||
goto done;
|
||||
snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, *unit);
|
||||
if (ifunit(name) != NULL) {
|
||||
free_unr(ifc->ifc_unrhdr, *unit);
|
||||
if (wildcard) {
|
||||
(*unit)++;
|
||||
goto retry;
|
||||
} else
|
||||
return (EEXIST);
|
||||
}
|
||||
|
||||
if (!wildcard) {
|
||||
bytoff = *unit >> 3;
|
||||
bitoff = *unit - (bytoff << 3);
|
||||
}
|
||||
IF_CLONE_ADDREF(ifc);
|
||||
|
||||
if((ifc->ifc_units[bytoff] & (1 << bitoff)) != 0) {
|
||||
err = EEXIST;
|
||||
goto done;
|
||||
}
|
||||
/*
|
||||
* Allocate the unit in the bitmap.
|
||||
*/
|
||||
KASSERT((ifc->ifc_units[bytoff] & (1 << bitoff)) == 0,
|
||||
("%s: bit is already set", __func__));
|
||||
ifc->ifc_units[bytoff] |= (1 << bitoff);
|
||||
IF_CLONE_ADDREF_LOCKED(ifc);
|
||||
|
||||
done:
|
||||
IF_CLONE_UNLOCK(ifc);
|
||||
return (err);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
ifc_free_unit(struct if_clone *ifc, int unit)
|
||||
{
|
||||
int bytoff, bitoff;
|
||||
|
||||
|
||||
/*
|
||||
* Compute offset in the bitmap and deallocate the unit.
|
||||
*/
|
||||
bytoff = unit >> 3;
|
||||
bitoff = unit - (bytoff << 3);
|
||||
|
||||
IF_CLONE_LOCK(ifc);
|
||||
KASSERT((ifc->ifc_units[bytoff] & (1 << bitoff)) != 0,
|
||||
("%s: bit is already cleared", __func__));
|
||||
ifc->ifc_units[bytoff] &= ~(1 << bitoff);
|
||||
IF_CLONE_REMREF_LOCKED(ifc); /* releases lock */
|
||||
free_unr(ifc->ifc_unrhdr, unit);
|
||||
IF_CLONE_REMREF(ifc);
|
||||
}
|
||||
|
||||
void
|
||||
ifc_simple_attach(struct if_clone *ifc)
|
||||
{
|
||||
int err;
|
||||
int unit;
|
||||
char name[IFNAMSIZ];
|
||||
struct ifc_simple_data *ifcs = ifc->ifc_data;
|
||||
|
||||
KASSERT(ifcs->ifcs_minifs - 1 <= ifc->ifc_maxunit,
|
||||
("%s: %s requested more units than allowed (%d > %d)",
|
||||
__func__, ifc->ifc_name, ifcs->ifcs_minifs,
|
||||
ifc->ifc_maxunit + 1));
|
||||
|
||||
for (unit = 0; unit < ifcs->ifcs_minifs; unit++) {
|
||||
snprintf(name, IFNAMSIZ, "%s%d", ifc->ifc_name, unit);
|
||||
err = if_clone_createif(ifc, name, IFNAMSIZ, NULL);
|
||||
KASSERT(err == 0,
|
||||
("%s: failed to create required interface %s",
|
||||
__func__, name));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ifc_simple_match(struct if_clone *ifc, const char *name)
|
||||
{
|
||||
const char *cp;
|
||||
@@ -555,14 +666,13 @@ ifc_simple_match(struct if_clone *ifc, const char *name)
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ifc_simple_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
|
||||
{
|
||||
char *dp;
|
||||
int wildcard;
|
||||
int unit;
|
||||
int err;
|
||||
struct ifc_simple_data *ifcs = ifc->ifc_data;
|
||||
|
||||
err = ifc_name2unit(name, &unit);
|
||||
if (err != 0)
|
||||
@@ -574,7 +684,7 @@ ifc_simple_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
|
||||
if (err != 0)
|
||||
return (err);
|
||||
|
||||
err = ifcs->ifcs_create(ifc, unit, params);
|
||||
err = ifc->ifcs_create(ifc, unit, params);
|
||||
if (err != 0) {
|
||||
ifc_free_unit(ifc, unit);
|
||||
return (err);
|
||||
@@ -598,18 +708,17 @@ ifc_simple_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
ifc_simple_destroy(struct if_clone *ifc, struct ifnet *ifp)
|
||||
{
|
||||
int unit;
|
||||
struct ifc_simple_data *ifcs = ifc->ifc_data;
|
||||
|
||||
unit = ifp->if_dunit;
|
||||
|
||||
if (unit < ifcs->ifcs_minifs)
|
||||
if (unit < ifc->ifcs_minifs)
|
||||
return (EINVAL);
|
||||
|
||||
ifcs->ifcs_destroy(ifp);
|
||||
ifc->ifcs_destroy(ifp);
|
||||
|
||||
ifc_free_unit(ifc, unit);
|
||||
|
||||
|
Reference in New Issue
Block a user