Deleted Added
full compact
ifq.h (186119) ifq.h (186199)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 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 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
1/*-
2 * Copyright (c) 1982, 1986, 1989, 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 * From: @(#)if.h 8.1 (Berkeley) 6/10/93
30 * $FreeBSD: head/sys/net/if_var.h 186119 2008-12-15 06:10:57Z qingli $
30 * $FreeBSD: head/sys/net/if_var.h 186199 2008-12-17 00:11:56Z kmacy $
31 */
32
33#ifndef _NET_IF_VAR_H_
34#define _NET_IF_VAR_H_
35
36/*
37 * Structures defining a network interface, providing a packet
38 * transport mechanism (ala level 0 of the PUP protocols).

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

75#include <sys/queue.h> /* get TAILQ macros */
76
77#ifdef _KERNEL
78#include <sys/mbuf.h>
79#include <sys/eventhandler.h>
80#endif /* _KERNEL */
81#include <sys/lock.h> /* XXX */
82#include <sys/mutex.h> /* XXX */
31 */
32
33#ifndef _NET_IF_VAR_H_
34#define _NET_IF_VAR_H_
35
36/*
37 * Structures defining a network interface, providing a packet
38 * transport mechanism (ala level 0 of the PUP protocols).

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

75#include <sys/queue.h> /* get TAILQ macros */
76
77#ifdef _KERNEL
78#include <sys/mbuf.h>
79#include <sys/eventhandler.h>
80#endif /* _KERNEL */
81#include <sys/lock.h> /* XXX */
82#include <sys/mutex.h> /* XXX */
83#include <sys/rwlock.h> /* XXX */
83#include <sys/event.h> /* XXX */
84#include <sys/_task.h>
85
86#define IF_DUNIT_NONE -1
87
88#include <altq/if_altq.h>
89
90TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */

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

170 void *if_bridge; /* bridge glue */
171
172 struct label *if_label; /* interface MAC label */
173
174 /* these are only used by IPv6 */
175 struct ifprefixhead if_prefixhead; /* list of prefixes per if */
176 void *if_afdata[AF_MAX];
177 int if_afdata_initialized;
84#include <sys/event.h> /* XXX */
85#include <sys/_task.h>
86
87#define IF_DUNIT_NONE -1
88
89#include <altq/if_altq.h>
90
91TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */

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

171 void *if_bridge; /* bridge glue */
172
173 struct label *if_label; /* interface MAC label */
174
175 /* these are only used by IPv6 */
176 struct ifprefixhead if_prefixhead; /* list of prefixes per if */
177 void *if_afdata[AF_MAX];
178 int if_afdata_initialized;
178 struct mtx if_afdata_mtx;
179 struct rwlock if_afdata_lock;
179 struct task if_starttask; /* task for IFF_NEEDSGIANT */
180 struct task if_linktask; /* task for link change events */
181 struct mtx if_addr_mtx; /* mutex to protect address lists */
182
183 LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */
184 TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */
185 /* protected by if_addr_mtx */
186 void *if_pf_kif;
187 void *if_lagg; /* lagg glue */
180 struct task if_starttask; /* task for IFF_NEEDSGIANT */
181 struct task if_linktask; /* task for link change events */
182 struct mtx if_addr_mtx; /* mutex to protect address lists */
183
184 LIST_ENTRY(ifnet) if_clones; /* interfaces of a cloner */
185 TAILQ_HEAD(, ifg_list) if_groups; /* linked list of groups per if */
186 /* protected by if_addr_mtx */
187 void *if_pf_kif;
188 void *if_lagg; /* lagg glue */
188 void *if_pspare[8]; /* multiq/TOE 3; vimage 3; general use 4 */
189 void (*if_qflush) /* flush any queues */
189 void *if_pspare[8]; /* TOE 3; vimage 3; general use 4 */
190 void (*if_qflush) /* flush any queues */
190 (struct ifnet *);
191 int (*if_transmit) /* initiate output routine */
192 (struct ifnet *, struct mbuf *);
193 int if_ispare[2]; /* general use 2 */
194};
195
196typedef void if_init_f_t(void *);
197

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

353/* group detach event */
354typedef void (*group_detach_event_handler_t)(void *, struct ifg_group *);
355EVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t);
356/* group change event */
357typedef void (*group_change_event_handler_t)(void *, const char *);
358EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
359
360#define IF_AFDATA_LOCK_INIT(ifp) \
191 (struct ifnet *);
192 int (*if_transmit) /* initiate output routine */
193 (struct ifnet *, struct mbuf *);
194 int if_ispare[2]; /* general use 2 */
195};
196
197typedef void if_init_f_t(void *);
198

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

354/* group detach event */
355typedef void (*group_detach_event_handler_t)(void *, struct ifg_group *);
356EVENTHANDLER_DECLARE(group_detach_event, group_detach_event_handler_t);
357/* group change event */
358typedef void (*group_change_event_handler_t)(void *, const char *);
359EVENTHANDLER_DECLARE(group_change_event, group_change_event_handler_t);
360
361#define IF_AFDATA_LOCK_INIT(ifp) \
361 mtx_init(&(ifp)->if_afdata_mtx, "if_afdata", NULL, MTX_DEF)
362#define IF_AFDATA_LOCK(ifp) mtx_lock(&(ifp)->if_afdata_mtx)
363#define IF_AFDATA_TRYLOCK(ifp) mtx_trylock(&(ifp)->if_afdata_mtx)
364#define IF_AFDATA_UNLOCK(ifp) mtx_unlock(&(ifp)->if_afdata_mtx)
365#define IF_AFDATA_DESTROY(ifp) mtx_destroy(&(ifp)->if_afdata_mtx)
362 rw_init(&(ifp)->if_afdata_lock, "if_afdata")
366
363
367#define IF_AFDATA_LOCK_ASSERT(ifp) mtx_assert(&(ifp)->if_afdata_mtx, MA_OWNED)
368#define IF_AFDATA_UNLOCK_ASSERT(ifp) mtx_assert(&(ifp)->if_afdata_mtx, MA_NOTOWNED)
364#define IF_AFDATA_WLOCK(ifp) rw_wlock(&(ifp)->if_afdata_lock)
365#define IF_AFDATA_RLOCK(ifp) rw_rlock(&(ifp)->if_afdata_lock)
366#define IF_AFDATA_WUNLOCK(ifp) rw_wunlock(&(ifp)->if_afdata_lock)
367#define IF_AFDATA_RUNLOCK(ifp) rw_runlock(&(ifp)->if_afdata_lock)
368#define IF_AFDATA_LOCK(ifp) IF_AFDATA_WLOCK(ifp)
369#define IF_AFDATA_UNLOCK(ifp) IF_AFDATA_WUNLOCK(ifp)
370#define IF_AFDATA_TRYLOCK(ifp) rw_try_wlock(&(ifp)->if_afdata_lock)
371#define IF_AFDATA_DESTROY(ifp) rw_destroy(&(ifp)->if_afdata_lock)
369
372
373#define IF_AFDATA_LOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_LOCKED)
374#define IF_AFDATA_UNLOCK_ASSERT(ifp) rw_assert(&(ifp)->if_afdata_lock, RA_UNLOCKED)
375
370#define IFF_LOCKGIANT(ifp) do { \
371 if ((ifp)->if_flags & IFF_NEEDSGIANT) \
372 mtx_lock(&Giant); \
373} while (0)
374
375#define IFF_UNLOCKGIANT(ifp) do { \
376 if ((ifp)->if_flags & IFF_NEEDSGIANT) \
377 mtx_unlock(&Giant); \

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

632
633#define IFAREF(ifa) \
634 do { \
635 IFA_LOCK(ifa); \
636 ++(ifa)->ifa_refcnt; \
637 IFA_UNLOCK(ifa); \
638 } while (0)
639
376#define IFF_LOCKGIANT(ifp) do { \
377 if ((ifp)->if_flags & IFF_NEEDSGIANT) \
378 mtx_lock(&Giant); \
379} while (0)
380
381#define IFF_UNLOCKGIANT(ifp) do { \
382 if ((ifp)->if_flags & IFF_NEEDSGIANT) \
383 mtx_unlock(&Giant); \

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

638
639#define IFAREF(ifa) \
640 do { \
641 IFA_LOCK(ifa); \
642 ++(ifa)->ifa_refcnt; \
643 IFA_UNLOCK(ifa); \
644 } while (0)
645
640extern struct mtx ifnet_lock;
646extern struct rwlock ifnet_lock;
641#define IFNET_LOCK_INIT() \
647#define IFNET_LOCK_INIT() \
642 mtx_init(&ifnet_lock, "ifnet", NULL, MTX_DEF | MTX_RECURSE)
643#define IFNET_WLOCK() mtx_lock(&ifnet_lock)
644#define IFNET_WUNLOCK() mtx_unlock(&ifnet_lock)
645#define IFNET_WLOCK_ASSERT() mtx_assert(&ifnet_lock, MA_OWNED)
646#define IFNET_RLOCK() IFNET_WLOCK()
647#define IFNET_RUNLOCK() IFNET_WUNLOCK()
648 rw_init_flags(&ifnet_lock, "ifnet", RW_RECURSE)
649#define IFNET_WLOCK() rw_wlock(&ifnet_lock)
650#define IFNET_WUNLOCK() rw_wunlock(&ifnet_lock)
651#define IFNET_WLOCK_ASSERT() rw_assert(&ifnet_lock, RA_LOCKED)
652#define IFNET_RLOCK() rw_rlock(&ifnet_lock)
653#define IFNET_RUNLOCK() rw_runlock(&ifnet_lock)
648
649struct ifindex_entry {
650 struct ifnet *ife_ifnet;
651 struct cdev *ife_dev;
652};
653
654struct ifnet *ifnet_byindex(u_short idx);
655

--- 74 unchanged lines hidden ---
654
655struct ifindex_entry {
656 struct ifnet *ife_ifnet;
657 struct cdev *ife_dev;
658};
659
660struct ifnet *ifnet_byindex(u_short idx);
661

--- 74 unchanged lines hidden ---