diff options
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 27 | ||||
-rw-r--r-- | sys/net/if.h | 16 | ||||
-rw-r--r-- | sys/net/if_arcsubr.c | 8 | ||||
-rw-r--r-- | sys/net/if_atmsubr.c | 8 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 8 | ||||
-rw-r--r-- | sys/net/if_fddisubr.c | 8 | ||||
-rw-r--r-- | sys/net/if_tokensubr.c | 9 |
7 files changed, 51 insertions, 33 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 0a0620fa711..0524b3fabf4 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.84 2004/02/28 09:14:10 mcbride Exp $ */ +/* $OpenBSD: if.c,v 1.85 2004/04/17 00:09:01 henning Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -130,6 +130,8 @@ void if_detached_watchdog(struct ifnet *); int if_clone_list(struct if_clonereq *); struct if_clone *if_clone_lookup(const char *, int *); +void if_congestion_clear(void *); + LIST_HEAD(, if_clone) if_cloners = LIST_HEAD_INITIALIZER(if_cloners); int if_cloners_count; @@ -782,6 +784,29 @@ if_clone_list(ifcr) } /* + * set queue congestion marker and register timeout to clear it + */ +void +if_congestion(struct ifqueue *ifq) +{ + static struct timeout to; + + ifq->ifq_congestion = 1; + bzero(&to, sizeof(to)); + timeout_set(&to, if_congestion_clear, ifq); + timeout_add(&to, hz / 100); +} + +/* + * clear the congestion flag + */ +void +if_congestion_clear(void *ifq) +{ + ((struct ifqueue *)ifq)->ifq_congestion = 0; +} + +/* * Locate an interface based on a complete address. */ /*ARGSUSED*/ diff --git a/sys/net/if.h b/sys/net/if.h index 3025d26a0ef..96bb77a1fa1 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.49 2004/01/15 10:47:55 markus Exp $ */ +/* $OpenBSD: if.h,v 1.50 2004/04/17 00:09:01 henning Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -141,6 +141,7 @@ struct ifqueue { int ifq_len; int ifq_maxlen; int ifq_drops; + int ifq_congestion; }; /* @@ -290,6 +291,17 @@ struct ifnet { /* and the entries */ (ifq)->ifq_len--; \ } \ } + +#define IF_INPUT_ENQUEUE(ifq, m) { \ + if (IF_QFULL(ifq)) { \ + IF_DROP(ifq); \ + m_freem(m); \ + if (!ifq->ifq_congestion) \ + if_congestion(ifq); \ + } else \ + IF_ENQUEUE(ifq, m); \ +} + #define IF_POLL(ifq, m) ((m) = (ifq)->ifq_head) #define IF_PURGE(ifq) \ do { \ @@ -614,6 +626,8 @@ void if_clone_detach(struct if_clone *); int if_clone_create(const char *); int if_clone_destroy(const char *); +void if_congestion(struct ifqueue *); + int loioctl(struct ifnet *, u_long, caddr_t); void loopattach(int); int looutput(struct ifnet *, diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index 01cd531503b..e9d40ca6fd2 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_arcsubr.c,v 1.18 2003/12/12 12:54:57 hshoexer Exp $ */ +/* $OpenBSD: if_arcsubr.c,v 1.19 2004/04/17 00:09:01 henning Exp $ */ /* $NetBSD: if_arcsubr.c,v 1.8 1996/05/07 02:40:29 thorpej Exp $ */ /* @@ -509,11 +509,7 @@ arc_input(ifp, m) } s = splimp(); - if (IF_QFULL(inq)) { - IF_DROP(inq); - m_freem(m); - } else - IF_ENQUEUE(inq, m); + IF_INPUT_ENQUEUE(inq, m); splx(s); } diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index f1bbeba56f5..efdc96f0c8d 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atmsubr.c,v 1.22 2003/12/10 07:22:42 itojun Exp $ */ +/* $OpenBSD: if_atmsubr.c,v 1.23 2004/04/17 00:09:01 henning Exp $ */ /* * @@ -354,11 +354,7 @@ atm_input(ifp, ah, m, rxhand) } s = splimp(); - if (IF_QFULL(inq)) { - IF_DROP(inq); - m_freem(m); - } else - IF_ENQUEUE(inq, m); + IF_INPUT_ENQUEUE(inq); splx(s); } diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index f5958851582..0471a4ac5d3 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.75 2004/02/15 02:52:41 avsm Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.76 2004/04/17 00:09:01 henning Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -914,11 +914,7 @@ decapsulate: } s = splimp(); - if (IF_QFULL(inq)) { - IF_DROP(inq); - m_freem(m); - } else - IF_ENQUEUE(inq, m); + IF_INPUT_ENQUEUE(inq, m); splx(s); } diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 486ca958bd0..0b7b6dcb018 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fddisubr.c,v 1.36 2003/12/10 07:22:42 itojun Exp $ */ +/* $OpenBSD: if_fddisubr.c,v 1.37 2004/04/17 00:09:01 henning Exp $ */ /* $NetBSD: if_fddisubr.c,v 1.5 1996/05/07 23:20:21 christos Exp $ */ /* @@ -653,11 +653,7 @@ fddi_input(ifp, fh, m) } s = splimp(); - if (IF_QFULL(inq)) { - IF_DROP(inq); - m_freem(m); - } else - IF_ENQUEUE(inq, m); + IF_INPUT_ENQUEUE(inq, m); splx(s); } /* diff --git a/sys/net/if_tokensubr.c b/sys/net/if_tokensubr.c index a43b00cf9c1..b58bb40e22a 100644 --- a/sys/net/if_tokensubr.c +++ b/sys/net/if_tokensubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tokensubr.c,v 1.13 2003/12/10 07:22:42 itojun Exp $ */ +/* $OpenBSD: if_tokensubr.c,v 1.14 2004/04/17 00:09:01 henning Exp $ */ /* $NetBSD: if_tokensubr.c,v 1.7 1999/05/30 00:39:07 bad Exp $ */ /* @@ -657,12 +657,7 @@ token_input(ifp, m) } s = splimp(); - if (IF_QFULL(inq)) { - IF_DROP(inq); - m_freem(m); - } - else - IF_ENQUEUE(inq, m); + IF_INPUT_ENQUEUE(inq, m); splx(s); } |