if_clone.c (183210) | if_clone.c (191816) |
---|---|
1/*- 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)if.c 8.5 (Berkeley) 1/9/95 | 1/*- 2 * Copyright (c) 1980, 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)if.c 8.5 (Berkeley) 1/9/95 |
30 * $FreeBSD: head/sys/net/if_clone.c 183210 2008-09-20 19:38:37Z thompsa $ | 30 * $FreeBSD: head/sys/net/if_clone.c 191816 2009-05-05 10:56:12Z zec $ |
31 */ 32 33#include <sys/param.h> 34#include <sys/malloc.h> 35#include <sys/limits.h> 36#include <sys/lock.h> 37#include <sys/mutex.h> 38#include <sys/kernel.h> 39#include <sys/systm.h> 40#include <sys/types.h> 41#include <sys/socket.h> | 31 */ 32 33#include <sys/param.h> 34#include <sys/malloc.h> 35#include <sys/limits.h> 36#include <sys/lock.h> 37#include <sys/mutex.h> 38#include <sys/kernel.h> 39#include <sys/systm.h> 40#include <sys/types.h> 41#include <sys/socket.h> |
42#include <sys/vimage.h> |
|
42 43#include <net/if.h> 44#include <net/if_clone.h> 45#if 0 46#include <net/if_dl.h> 47#endif 48#include <net/if_types.h> 49#include <net/if_var.h> 50#include <net/radix.h> 51#include <net/route.h> | 43 44#include <net/if.h> 45#include <net/if_clone.h> 46#if 0 47#include <net/if_dl.h> 48#endif 49#include <net/if_types.h> 50#include <net/if_var.h> 51#include <net/radix.h> 52#include <net/route.h> |
53#include <net/vnet.h> |
|
52 53static void if_clone_free(struct if_clone *ifc); 54static int if_clone_createif(struct if_clone *ifc, char *name, size_t len, 55 caddr_t params); 56 57static struct mtx if_cloners_mtx; 58static int if_cloners_count; 59LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners); --- 138 unchanged lines hidden (view full) --- 198/* 199 * Destroy a clone network interface. 200 */ 201int 202if_clone_destroyif(struct if_clone *ifc, struct ifnet *ifp) 203{ 204 int err; 205 | 54 55static void if_clone_free(struct if_clone *ifc); 56static int if_clone_createif(struct if_clone *ifc, char *name, size_t len, 57 caddr_t params); 58 59static struct mtx if_cloners_mtx; 60static int if_cloners_count; 61LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners); --- 138 unchanged lines hidden (view full) --- 200/* 201 * Destroy a clone network interface. 202 */ 203int 204if_clone_destroyif(struct if_clone *ifc, struct ifnet *ifp) 205{ 206 int err; 207 |
206 if (ifc->ifc_destroy == NULL) { 207 err = EOPNOTSUPP; 208 goto done; 209 } | 208 if (ifc->ifc_destroy == NULL) 209 return(EOPNOTSUPP); |
210 211 IF_CLONE_LOCK(ifc); 212 IFC_IFLIST_REMOVE(ifc, ifp); 213 IF_CLONE_UNLOCK(ifc); 214 | 210 211 IF_CLONE_LOCK(ifc); 212 IFC_IFLIST_REMOVE(ifc, ifp); 213 IF_CLONE_UNLOCK(ifc); 214 |
215 CURVNET_SET_QUIET(ifp->if_vnet); |
|
215 if_delgroup(ifp, ifc->ifc_name); 216 217 err = (*ifc->ifc_destroy)(ifc, ifp); 218 219 if (err != 0) { 220 if_addgroup(ifp, ifc->ifc_name); 221 222 IF_CLONE_LOCK(ifc); 223 IFC_IFLIST_INSERT(ifc, ifp); 224 IF_CLONE_UNLOCK(ifc); 225 } | 216 if_delgroup(ifp, ifc->ifc_name); 217 218 err = (*ifc->ifc_destroy)(ifc, ifp); 219 220 if (err != 0) { 221 if_addgroup(ifp, ifc->ifc_name); 222 223 IF_CLONE_LOCK(ifc); 224 IFC_IFLIST_INSERT(ifc, ifp); 225 IF_CLONE_UNLOCK(ifc); 226 } |
226 227done: | 227 CURVNET_RESTORE(); |
228 return (err); 229} 230 231/* 232 * Register a network interface cloner. 233 */ 234void 235if_clone_attach(struct if_clone *ifc) --- 329 unchanged lines hidden --- | 228 return (err); 229} 230 231/* 232 * Register a network interface cloner. 233 */ 234void 235if_clone_attach(struct if_clone *ifc) --- 329 unchanged lines hidden --- |