Deleted Added
full compact
pfil.c (198233) pfil.c (241888)
1/* $FreeBSD: head/sys/net/pfil.c 198233 2009-10-19 15:19:14Z rwatson $ */
1/* $FreeBSD: head/sys/net/pfil.c 241888 2012-10-22 14:10:17Z melifaro $ */
2/* $NetBSD: pfil.c,v 1.20 2001/11/12 23:49:46 lukem Exp $ */
3
4/*-
5 * Copyright (c) 1996 Matthew R. Green
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

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

56
57static int pfil_list_remove(pfil_list_t *,
58 int (*)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *),
59 void *);
60
61LIST_HEAD(pfilheadhead, pfil_head);
62VNET_DEFINE(struct pfilheadhead, pfil_head_list);
63#define V_pfil_head_list VNET(pfil_head_list)
2/* $NetBSD: pfil.c,v 1.20 2001/11/12 23:49:46 lukem Exp $ */
3
4/*-
5 * Copyright (c) 1996 Matthew R. Green
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

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

56
57static int pfil_list_remove(pfil_list_t *,
58 int (*)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *),
59 void *);
60
61LIST_HEAD(pfilheadhead, pfil_head);
62VNET_DEFINE(struct pfilheadhead, pfil_head_list);
63#define V_pfil_head_list VNET(pfil_head_list)
64VNET_DEFINE(struct rmlock, pfil_lock);
65#define V_pfil_lock VNET(pfil_lock)
64
65/*
66 * pfil_run_hooks() runs the specified packet filter hooks.
67 */
68int
69pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp,
70 int dir, struct inpcb *inp)
71{

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

86 }
87 }
88 PFIL_RUNLOCK(ph, &rmpt);
89 *mp = m;
90 return (rv);
91}
92
93/*
66
67/*
68 * pfil_run_hooks() runs the specified packet filter hooks.
69 */
70int
71pfil_run_hooks(struct pfil_head *ph, struct mbuf **mp, struct ifnet *ifp,
72 int dir, struct inpcb *inp)
73{

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

88 }
89 }
90 PFIL_RUNLOCK(ph, &rmpt);
91 *mp = m;
92 return (rv);
93}
94
95/*
96 * pfil_try_rlock() acquires rm reader lock for specified head
97 * if this is immediately possible,
98 */
99int
100pfil_try_rlock(struct pfil_head *ph, struct rm_priotracker *tracker)
101{
102 return PFIL_TRY_RLOCK(ph, tracker);
103}
104
105/*
106 * pfil_rlock() acquires rm reader lock for specified head.
107 */
108void
109pfil_rlock(struct pfil_head *ph, struct rm_priotracker *tracker)
110{
111 PFIL_RLOCK(ph, tracker);
112}
113
114/*
115 * pfil_runlock() releases reader lock for specified head.
116 */
117void
118pfil_runlock(struct pfil_head *ph, struct rm_priotracker *tracker)
119{
120 PFIL_RUNLOCK(ph, tracker);
121}
122
123/*
124 * pfil_wlock() acquires writer lock for specified head.
125 */
126void
127pfil_wlock(struct pfil_head *ph)
128{
129 PFIL_WLOCK(ph);
130}
131
132/*
133 * pfil_wunlock() releases writer lock for specified head.
134 */
135void
136pfil_wunlock(struct pfil_head *ph)
137{
138 PFIL_WUNLOCK(ph);
139}
140
141/*
142 * pfil_wowned() releases writer lock for specified head.
143 */
144int
145pfil_wowned(struct pfil_head *ph)
146{
147 return PFIL_WOWNED(ph);
148}
149/*
94 * pfil_head_register() registers a pfil_head with the packet filter hook
95 * mechanism.
96 */
97int
98pfil_head_register(struct pfil_head *ph)
99{
100 struct pfil_head *lph;
101

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

290 * Stuff that must be initialized for every instance (including the first of
291 * course).
292 */
293static int
294vnet_pfil_init(const void *unused)
295{
296
297 LIST_INIT(&V_pfil_head_list);
150 * pfil_head_register() registers a pfil_head with the packet filter hook
151 * mechanism.
152 */
153int
154pfil_head_register(struct pfil_head *ph)
155{
156 struct pfil_head *lph;
157

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

346 * Stuff that must be initialized for every instance (including the first of
347 * course).
348 */
349static int
350vnet_pfil_init(const void *unused)
351{
352
353 LIST_INIT(&V_pfil_head_list);
354 PFIL_LOCK_INIT_REAL(&V_pfil_lock, "shared");
298 return (0);
299}
300
301/*
302 * Called for the removal of each instance.
303 */
304static int
305vnet_pfil_uninit(const void *unused)
306{
307
308 /* XXX should panic if list is not empty */
355 return (0);
356}
357
358/*
359 * Called for the removal of each instance.
360 */
361static int
362vnet_pfil_uninit(const void *unused)
363{
364
365 /* XXX should panic if list is not empty */
366 PFIL_LOCK_DESTROY_REAL(&V_pfil_lock);
309 return (0);
310}
311
312/* Define startup order. */
313#define PFIL_SYSINIT_ORDER SI_SUB_PROTO_BEGIN
314#define PFIL_MODEVENT_ORDER (SI_ORDER_FIRST) /* On boot slot in here. */
315#define PFIL_VNET_ORDER (PFIL_MODEVENT_ORDER + 2) /* Later still. */
316

--- 15 unchanged lines hidden ---
367 return (0);
368}
369
370/* Define startup order. */
371#define PFIL_SYSINIT_ORDER SI_SUB_PROTO_BEGIN
372#define PFIL_MODEVENT_ORDER (SI_ORDER_FIRST) /* On boot slot in here. */
373#define PFIL_VNET_ORDER (PFIL_MODEVENT_ORDER + 2) /* Later still. */
374

--- 15 unchanged lines hidden ---