Deleted Added
full compact
ng_base.c (186093) ng_base.c (191510)
1/*
2 * ng_base.c
3 */
4
5/*-
6 * Copyright (c) 1996-1999 Whistle Communications, Inc.
7 * All rights reserved.
8 *

--- 24 unchanged lines hidden (view full) ---

33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36 * OF SUCH DAMAGE.
37 *
38 * Authors: Julian Elischer <julian@freebsd.org>
39 * Archie Cobbs <archie@freebsd.org>
40 *
1/*
2 * ng_base.c
3 */
4
5/*-
6 * Copyright (c) 1996-1999 Whistle Communications, Inc.
7 * All rights reserved.
8 *

--- 24 unchanged lines hidden (view full) ---

33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
36 * OF SUCH DAMAGE.
37 *
38 * Authors: Julian Elischer <julian@freebsd.org>
39 * Archie Cobbs <archie@freebsd.org>
40 *
41 * $FreeBSD: head/sys/netgraph/ng_base.c 186093 2008-12-14 20:15:30Z mav $
41 * $FreeBSD: head/sys/netgraph/ng_base.c 191510 2009-04-26 07:14:50Z zec $
42 * $Whistle: ng_base.c,v 1.39 1999/01/28 23:54:53 julian Exp $
43 */
44
45/*
46 * This file implements the base netgraph code.
47 */
48
49#include <sys/param.h>

--- 29 unchanged lines hidden (view full) ---

79#ifndef VIMAGE_GLOBALS
80struct vnet_netgraph vnet_netgraph_0;
81#endif
82#endif
83
84/* Mutex to protect topology events. */
85static struct mtx ng_topo_mtx;
86
42 * $Whistle: ng_base.c,v 1.39 1999/01/28 23:54:53 julian Exp $
43 */
44
45/*
46 * This file implements the base netgraph code.
47 */
48
49#include <sys/param.h>

--- 29 unchanged lines hidden (view full) ---

79#ifndef VIMAGE_GLOBALS
80struct vnet_netgraph vnet_netgraph_0;
81#endif
82#endif
83
84/* Mutex to protect topology events. */
85static struct mtx ng_topo_mtx;
86
87static vnet_attach_fn vnet_netgraph_iattach;
88
87#ifdef NETGRAPH_DEBUG
88static struct mtx ng_nodelist_mtx; /* protects global node/hook lists */
89static struct mtx ngq_mtx; /* protects the queue item list */
90
91static SLIST_HEAD(, ng_node) ng_allnodes;
92static LIST_HEAD(, ng_node) ng_freenodes; /* in debug, we never free() them */
93static SLIST_HEAD(, ng_hook) ng_allhooks;
94static LIST_HEAD(, ng_hook) ng_freehooks; /* in debug, we never free() them */

--- 127 unchanged lines hidden (view full) ---

222 node_p node2, const char *name2);
223static int ng_con_part2(node_p node, item_p item, hook_p hook);
224static int ng_con_part3(node_p node, item_p item, hook_p hook);
225static int ng_mkpeer(node_p node, const char *name,
226 const char *name2, char *type);
227
228/* Imported, these used to be externally visible, some may go back. */
229void ng_destroy_hook(hook_p hook);
89#ifdef NETGRAPH_DEBUG
90static struct mtx ng_nodelist_mtx; /* protects global node/hook lists */
91static struct mtx ngq_mtx; /* protects the queue item list */
92
93static SLIST_HEAD(, ng_node) ng_allnodes;
94static LIST_HEAD(, ng_node) ng_freenodes; /* in debug, we never free() them */
95static SLIST_HEAD(, ng_hook) ng_allhooks;
96static LIST_HEAD(, ng_hook) ng_freehooks; /* in debug, we never free() them */

--- 127 unchanged lines hidden (view full) ---

224 node_p node2, const char *name2);
225static int ng_con_part2(node_p node, item_p item, hook_p hook);
226static int ng_con_part3(node_p node, item_p item, hook_p hook);
227static int ng_mkpeer(node_p node, const char *name,
228 const char *name2, char *type);
229
230/* Imported, these used to be externally visible, some may go back. */
231void ng_destroy_hook(hook_p hook);
230node_p ng_name2noderef(node_p node, const char *name);
231int ng_path2noderef(node_p here, const char *path,
232 node_p *dest, hook_p *lasthook);
233int ng_make_node(const char *type, node_p *nodepp);
234int ng_path_parse(char *addr, char **node, char **path, char **hook);
235void ng_rmnode(node_p node, hook_p dummy1, void *dummy2, int dummy3);
236void ng_unname(node_p node);
237
238

--- 2824 unchanged lines hidden (view full) ---

3063 error = (*type->mod_event)(mod, event, data);
3064 else
3065 error = EOPNOTSUPP; /* XXX ? */
3066 break;
3067 }
3068 return (error);
3069}
3070
232int ng_path2noderef(node_p here, const char *path,
233 node_p *dest, hook_p *lasthook);
234int ng_make_node(const char *type, node_p *nodepp);
235int ng_path_parse(char *addr, char **node, char **path, char **hook);
236void ng_rmnode(node_p node, hook_p dummy1, void *dummy2, int dummy3);
237void ng_unname(node_p node);
238
239

--- 2824 unchanged lines hidden (view full) ---

3064 error = (*type->mod_event)(mod, event, data);
3065 else
3066 error = EOPNOTSUPP; /* XXX ? */
3067 break;
3068 }
3069 return (error);
3070}
3071
3072#ifndef VIMAGE_GLOBALS
3073static const vnet_modinfo_t vnet_netgraph_modinfo = {
3074 .vmi_id = VNET_MOD_NETGRAPH,
3075 .vmi_name = "netgraph",
3076#ifdef VIMAGE
3077 .vmi_size = sizeof(struct vnet_netgraph),
3078#endif
3079 .vmi_iattach = vnet_netgraph_iattach
3080};
3081#endif
3082
3083static int
3084vnet_netgraph_iattach(const void *arg __unused)
3085{
3086 INIT_VNET_NETGRAPH(curvnet);
3087
3088 V_nextID = 1;
3089
3090 return (0);
3091}
3092
3071/*
3072 * Handle loading and unloading for this code.
3073 * The only thing we need to link into is the NETISR strucure.
3074 */
3075static int
3076ngb_mod_event(module_t mod, int event, void *data)
3077{
3078 struct proc *p;
3079 struct thread *td;
3080 int i, error = 0;
3081
3082 switch (event) {
3083 case MOD_LOAD:
3084 /* Initialize everything. */
3093/*
3094 * Handle loading and unloading for this code.
3095 * The only thing we need to link into is the NETISR strucure.
3096 */
3097static int
3098ngb_mod_event(module_t mod, int event, void *data)
3099{
3100 struct proc *p;
3101 struct thread *td;
3102 int i, error = 0;
3103
3104 switch (event) {
3105 case MOD_LOAD:
3106 /* Initialize everything. */
3085 V_nextID = 1;
3107#ifndef VIMAGE_GLOBALS
3108 vnet_mod_register(&vnet_netgraph_modinfo);
3109#else
3110 vnet_netgraph_iattach(NULL);
3111#endif
3086 NG_WORKLIST_LOCK_INIT();
3087 mtx_init(&ng_typelist_mtx, "netgraph types mutex", NULL,
3088 MTX_DEF);
3089 mtx_init(&ng_idhash_mtx, "netgraph idhash mutex", NULL,
3090 MTX_DEF);
3091 mtx_init(&ng_namehash_mtx, "netgraph namehash mutex", NULL,
3092 MTX_DEF);
3093 mtx_init(&ng_topo_mtx, "netgraph topology mutex", NULL,

--- 660 unchanged lines hidden ---
3112 NG_WORKLIST_LOCK_INIT();
3113 mtx_init(&ng_typelist_mtx, "netgraph types mutex", NULL,
3114 MTX_DEF);
3115 mtx_init(&ng_idhash_mtx, "netgraph idhash mutex", NULL,
3116 MTX_DEF);
3117 mtx_init(&ng_namehash_mtx, "netgraph namehash mutex", NULL,
3118 MTX_DEF);
3119 mtx_init(&ng_topo_mtx, "netgraph topology mutex", NULL,

--- 660 unchanged lines hidden ---