Deleted Added
full compact
if_var.h (128871) if_var.h (130416)
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 128871 2004-05-03 13:48:35Z andre $
30 * $FreeBSD: head/sys/net/if_var.h 130416 2004-06-13 17:29:10Z mlaier $
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).

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

77#include <sys/eventhandler.h>
78#endif /* _KERNEL */
79#include <sys/lock.h> /* XXX */
80#include <sys/mutex.h> /* XXX */
81#include <sys/event.h> /* XXX */
82
83#define IF_DUNIT_NONE -1
84
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).

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

77#include <sys/eventhandler.h>
78#endif /* _KERNEL */
79#include <sys/lock.h> /* XXX */
80#include <sys/mutex.h> /* XXX */
81#include <sys/event.h> /* XXX */
82
83#define IF_DUNIT_NONE -1
84
85#if 1 /* ALTQ */
86#include <altq/if_altq.h>
87#endif
88
85TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */
86TAILQ_HEAD(ifaddrhead, ifaddr); /* instantiation is preserved in the list */
87TAILQ_HEAD(ifprefixhead, ifprefix);
88TAILQ_HEAD(ifmultihead, ifmultiaddr);
89
90/*
91 * Structure defining a queue for a network interface.
92 */

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

166 int (*if_ioctl) /* ioctl routine */
167 (struct ifnet *, u_long, caddr_t);
168 void (*if_watchdog) /* timer routine */
169 (struct ifnet *);
170 void (*if_init) /* Init routine */
171 (void *);
172 int (*if_resolvemulti) /* validate/resolve multicast */
173 (struct ifnet *, struct sockaddr **, struct sockaddr *);
89TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */
90TAILQ_HEAD(ifaddrhead, ifaddr); /* instantiation is preserved in the list */
91TAILQ_HEAD(ifprefixhead, ifprefix);
92TAILQ_HEAD(ifmultihead, ifmultiaddr);
93
94/*
95 * Structure defining a queue for a network interface.
96 */

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

170 int (*if_ioctl) /* ioctl routine */
171 (struct ifnet *, u_long, caddr_t);
172 void (*if_watchdog) /* timer routine */
173 (struct ifnet *);
174 void (*if_init) /* Init routine */
175 (void *);
176 int (*if_resolvemulti) /* validate/resolve multicast */
177 (struct ifnet *, struct sockaddr **, struct sockaddr *);
178#if 1 /* ALTQ */
179 struct ifaltq if_snd; /* output queue (includes altq) */
180#else
174 struct ifqueue if_snd; /* output queue */
181 struct ifqueue if_snd; /* output queue */
182#endif
175 const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
176
177 struct lltable *lltables; /* list of L3-L2 resolution tables */
178
179 struct label *if_label; /* interface MAC label */
180
181 /* these are only used by IPv6 */
182 struct ifprefixhead if_prefixhead; /* list of prefixes per if */

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

223/*
224 * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
225 * are queues of messages stored on ifqueue structures
226 * (defined above). Entries are added to and deleted from these structures
227 * by these macros, which should be called with ipl raised to splimp().
228 */
229#define IF_LOCK(ifq) mtx_lock(&(ifq)->ifq_mtx)
230#define IF_UNLOCK(ifq) mtx_unlock(&(ifq)->ifq_mtx)
183 const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
184
185 struct lltable *lltables; /* list of L3-L2 resolution tables */
186
187 struct label *if_label; /* interface MAC label */
188
189 /* these are only used by IPv6 */
190 struct ifprefixhead if_prefixhead; /* list of prefixes per if */

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

231/*
232 * Output queues (ifp->if_snd) and slow device input queues (*ifp->if_slowq)
233 * are queues of messages stored on ifqueue structures
234 * (defined above). Entries are added to and deleted from these structures
235 * by these macros, which should be called with ipl raised to splimp().
236 */
237#define IF_LOCK(ifq) mtx_lock(&(ifq)->ifq_mtx)
238#define IF_UNLOCK(ifq) mtx_unlock(&(ifq)->ifq_mtx)
239#define IF_LOCK_ASSERT(ifq) mtx_assert(&(ifq)->ifq_mtx, MA_OWNED)
231#define _IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
232#define _IF_DROP(ifq) ((ifq)->ifq_drops++)
233#define _IF_QLEN(ifq) ((ifq)->ifq_len)
234
235#define _IF_ENQUEUE(ifq, m) do { \
236 (m)->m_nextpkt = NULL; \
237 if ((ifq)->ifq_tail == NULL) \
238 (ifq)->ifq_head = m; \

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

273} while (0)
274
275#define IF_DEQUEUE(ifq, m) do { \
276 IF_LOCK(ifq); \
277 _IF_DEQUEUE(ifq, m); \
278 IF_UNLOCK(ifq); \
279} while (0)
280
240#define _IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
241#define _IF_DROP(ifq) ((ifq)->ifq_drops++)
242#define _IF_QLEN(ifq) ((ifq)->ifq_len)
243
244#define _IF_ENQUEUE(ifq, m) do { \
245 (m)->m_nextpkt = NULL; \
246 if ((ifq)->ifq_tail == NULL) \
247 (ifq)->ifq_head = m; \

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

282} while (0)
283
284#define IF_DEQUEUE(ifq, m) do { \
285 IF_LOCK(ifq); \
286 _IF_DEQUEUE(ifq, m); \
287 IF_UNLOCK(ifq); \
288} while (0)
289
281#define IF_DRAIN(ifq) do { \
290#define _IF_POLL(ifq, m) ((m) = (ifq)->ifq_head)
291#define IF_POLL(ifq, m) _IF_POLL(ifq, m)
292
293#define _IF_DRAIN(ifq) do { \
282 struct mbuf *m; \
294 struct mbuf *m; \
283 IF_LOCK(ifq); \
284 for (;;) { \
285 _IF_DEQUEUE(ifq, m); \
286 if (m == NULL) \
287 break; \
288 m_freem(m); \
289 } \
295 for (;;) { \
296 _IF_DEQUEUE(ifq, m); \
297 if (m == NULL) \
298 break; \
299 m_freem(m); \
300 } \
290 IF_UNLOCK(ifq); \
291} while (0)
292
301} while (0)
302
303#define IF_DRAIN(ifq) do { \
304 IF_LOCK(ifq); \
305 _IF_DRAIN(ifq); \
306 IF_UNLOCK(ifq); \
307} while(0)
308
293#ifdef _KERNEL
294/* interface address change event */
295typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
296EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
297/* new interface arrival event */
298typedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *);
299EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t);
300/* interface departure event */

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

306
307#define IF_AFDATA_LOCK_INIT(ifp) \
308 mtx_init(&(ifp)->if_afdata_mtx, "if_afdata", NULL, MTX_DEF)
309#define IF_AFDATA_LOCK(ifp) mtx_lock(&(ifp)->if_afdata_mtx)
310#define IF_AFDATA_TRYLOCK(ifp) mtx_trylock(&(ifp)->if_afdata_mtx)
311#define IF_AFDATA_UNLOCK(ifp) mtx_unlock(&(ifp)->if_afdata_mtx)
312#define IF_AFDATA_DESTROY(ifp) mtx_destroy(&(ifp)->if_afdata_mtx)
313
309#ifdef _KERNEL
310/* interface address change event */
311typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
312EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
313/* new interface arrival event */
314typedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *);
315EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t);
316/* interface departure event */

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

322
323#define IF_AFDATA_LOCK_INIT(ifp) \
324 mtx_init(&(ifp)->if_afdata_mtx, "if_afdata", NULL, MTX_DEF)
325#define IF_AFDATA_LOCK(ifp) mtx_lock(&(ifp)->if_afdata_mtx)
326#define IF_AFDATA_TRYLOCK(ifp) mtx_trylock(&(ifp)->if_afdata_mtx)
327#define IF_AFDATA_UNLOCK(ifp) mtx_unlock(&(ifp)->if_afdata_mtx)
328#define IF_AFDATA_DESTROY(ifp) mtx_destroy(&(ifp)->if_afdata_mtx)
329
314#define IF_HANDOFF(ifq, m, ifp) if_handoff(ifq, m, ifp, 0)
315#define IF_HANDOFF_ADJ(ifq, m, ifp, adj) if_handoff(ifq, m, ifp, adj)
330#define IF_HANDOFF(ifq, m, ifp) \
331 if_handoff((struct ifqueue *)ifq, m, ifp, 0)
332#define IF_HANDOFF_ADJ(ifq, m, ifp, adj) \
333 if_handoff((struct ifqueue *)ifq, m, ifp, adj)
316
317static __inline int
318if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
319{
320 int active = 0;
321
322 IF_LOCK(ifq);
323 if (_IF_QFULL(ifq)) {

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

333 active = ifp->if_flags & IFF_OACTIVE;
334 }
335 _IF_ENQUEUE(ifq, m);
336 IF_UNLOCK(ifq);
337 if (ifp != NULL && !active)
338 (*ifp->if_start)(ifp);
339 return (1);
340}
334
335static __inline int
336if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
337{
338 int active = 0;
339
340 IF_LOCK(ifq);
341 if (_IF_QFULL(ifq)) {

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

351 active = ifp->if_flags & IFF_OACTIVE;
352 }
353 _IF_ENQUEUE(ifq, m);
354 IF_UNLOCK(ifq);
355 if (ifp != NULL && !active)
356 (*ifp->if_start)(ifp);
357 return (1);
358}
359#if 1 /* ALTQ */
360#define IFQ_ENQUEUE(ifq, m, err) \
361do { \
362 IF_LOCK(ifq); \
363 if (ALTQ_IS_ENABLED(ifq)) \
364 ALTQ_ENQUEUE(ifq, m, NULL, err); \
365 else { \
366 if (_IF_QFULL(ifq)) { \
367 m_freem(m); \
368 (err) = ENOBUFS; \
369 } else { \
370 _IF_ENQUEUE(ifq, m); \
371 (err) = 0; \
372 } \
373 } \
374 if (err) \
375 (ifq)->ifq_drops++; \
376 IF_UNLOCK(ifq); \
377} while (0)
341
378
379#define IFQ_DEQUEUE_NOLOCK(ifq, m) \
380do { \
381 if (TBR_IS_ENABLED(ifq)) \
382 (m) = tbr_dequeue(ifq, ALTDQ_REMOVE); \
383 else if (ALTQ_IS_ENABLED(ifq)) \
384 ALTQ_DEQUEUE(ifq, m); \
385 else \
386 _IF_DEQUEUE(ifq, m); \
387} while (0)
388
389#define IFQ_DEQUEUE(ifq, m) \
390do { \
391 IF_LOCK(ifq); \
392 IFQ_DEQUEUE_NOLOCK(ifq, m); \
393 IF_UNLOCK(ifq); \
394} while (0)
395
396#define IFQ_POLL_NOLOCK(ifq, m) \
397do { \
398 if (TBR_IS_ENABLED(ifq)) \
399 (m) = tbr_dequeue(ifq, ALTDQ_POLL); \
400 else if (ALTQ_IS_ENABLED(ifq)) \
401 ALTQ_POLL(ifq, m); \
402 else \
403 _IF_POLL(ifq, m); \
404} while (0)
405
406#define IFQ_POLL(ifq, m) \
407do { \
408 IF_LOCK(ifq); \
409 IFQ_POLL_NOLOCK(ifq, m); \
410 IF_UNLOCK(ifq); \
411} while (0)
412
413#define IFQ_PURGE_NOLOCK(ifq) \
414do { \
415 if (ALTQ_IS_ENABLED(ifq)) { \
416 ALTQ_PURGE(ifq); \
417 } else \
418 _IF_DRAIN(ifq); \
419} while (0)
420
421#define IFQ_PURGE(ifq) \
422do { \
423 IF_LOCK(ifq); \
424 IFQ_PURGE_NOLOCK(ifq); \
425 IF_UNLOCK(ifq); \
426} while (0)
427
428#define IFQ_SET_READY(ifq) \
429 do { ((ifq)->altq_flags |= ALTQF_READY); } while (0)
430
431#else /* !ALTQ */
432#define IFQ_ENQUEUE(ifq, m, err) \
433do { \
434 IF_LOCK(ifq); \
435 if (_IF_QFULL(ifq)) { \
436 m_freem(m); \
437 (err) = ENOBUFS; \
438 } else { \
439 _IF_ENQUEUE(ifq, m); \
440 (err) = 0; \
441 } \
442 if (err) \
443 (ifq)->ifq_drops++; \
444 IF_UNLOCK(ifq); \
445} while (0)
446
447#define IFQ_DEQUEUE_NOLOCK(ifq, m) _IF_DEQUEUE(ifq, m)
448#define IFQ_DEQUEUE(ifq, m) IF_DEQUEUE(ifq, m)
449#define IFQ_POLL_NOLOCK(ifq, m) _IF_POLL(ifq, m)
450#define IFQ_POLL(ifq, m) IF_POLL(ifq, m)
451#define IFQ_PURGE_NOLOCK(ifq) _IF_DRAIN(ifq)
452#define IFQ_PURGE(ifq) IF_DRAIN(ifq)
453
454#define IFQ_SET_READY(ifq) /* nothing */
455
456#endif /* !ALTQ */
457
458#define IFQ_LOCK(ifq) IF_LOCK(ifq)
459#define IFQ_UNLOCK(ifq) IF_UNLOCK(ifq)
460#define IFQ_LOCK_ASSERT(ifq) IF_LOCK_ASSERT(ifq)
461#define IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0)
462#define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++)
463#define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len)
464#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++)
465#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len))
466
467#define IFQ_HANDOFF_ADJ(ifp, m, adj, err) \
468do { \
469 int len; \
470 short mflags; \
471 \
472 len = (m)->m_pkthdr.len; \
473 mflags = (m)->m_flags; \
474 IFQ_ENQUEUE(&(ifp)->if_snd, m, err); \
475 if ((err) == 0) { \
476 (ifp)->if_obytes += len + (adj); \
477 if (mflags & M_MCAST) \
478 (ifp)->if_omcasts++; \
479 if (((ifp)->if_flags & IFF_OACTIVE) == 0) \
480 (*(ifp)->if_start)(ifp); \
481 } \
482} while (0)
483
484#define IFQ_HANDOFF(ifp, m, err) \
485 IFQ_HANDOFF_ADJ(ifq, m, 0, err)
486
487#define IFQ_DRV_DEQUEUE(ifq, m) \
488do { \
489 (m) = (ifq)->ifq_drv_head; \
490 if (m) { \
491 if (((ifq)->ifq_drv_head = (m)->m_nextpkt) == NULL) \
492 (ifq)->ifq_drv_tail = NULL; \
493 (m)->m_nextpkt = NULL; \
494 (ifq)->ifq_drv_len--; \
495 } else { \
496 IFQ_LOCK(ifq); \
497 IFQ_DEQUEUE_NOLOCK(ifq, m); \
498 while ((ifq)->ifq_drv_len < (ifq)->ifq_drv_maxlen) { \
499 struct mbuf *m0; \
500 IFQ_DEQUEUE_NOLOCK(ifq, m0); \
501 if (m0 == NULL) \
502 break; \
503 m0->m_nextpkt = NULL; \
504 if ((ifq)->ifq_drv_tail == NULL) \
505 (ifq)->ifq_drv_head = m0; \
506 else \
507 (ifq)->ifq_drv_tail->m_nextpkt = m0; \
508 (ifq)->ifq_drv_tail = m0; \
509 (ifq)->ifq_drv_len++; \
510 } \
511 IFQ_UNLOCK(ifq); \
512 } \
513} while (0)
514
515#define IFQ_DRV_PREPEND(ifq, m) \
516do { \
517 (m)->m_nextpkt = (ifq)->ifq_drv_head; \
518 if ((ifq)->ifq_tail == NULL) \
519 (ifq)->ifq_tail = (m); \
520 (ifq)->ifq_drv_head = (m); \
521 (ifq)->ifq_drv_len++; \
522} while (0)
523
524#define IFQ_DRV_IS_EMPTY(ifq) \
525 (((ifq)->ifq_drv_len == 0) && ((ifq)->ifq_len == 0))
526
527#define IFQ_DRV_PURGE(ifq) \
528do { \
529 struct mbuf *m = (ifq)->ifq_drv_head; \
530 while(m != NULL) { \
531 m = m->m_nextpkt; \
532 m_freem(m); \
533 } \
534 (ifq)->ifq_drv_head = (ifq)->ifq_drv_tail = NULL; \
535 (ifq)->ifq_drv_len = 0; \
536 IFQ_PURGE(ifq); \
537} while (0)
538
342/*
343 * 72 was chosen below because it is the size of a TCP/IP
344 * header (40) + the minimum mss (32).
345 */
346#define IF_MINMTU 72
347#define IF_MAXMTU 65535
348
349#endif /* _KERNEL */

--- 161 unchanged lines hidden ---
539/*
540 * 72 was chosen below because it is the size of a TCP/IP
541 * header (40) + the minimum mss (32).
542 */
543#define IF_MINMTU 72
544#define IF_MAXMTU 65535
545
546#endif /* _KERNEL */

--- 161 unchanged lines hidden ---