summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/alpha/conf.c5
-rw-r--r--sys/arch/i386/i386/conf.c5
-rw-r--r--sys/conf/files16
-rw-r--r--sys/net/if.c17
-rw-r--r--sys/net/if.h139
-rw-r--r--sys/netinet/ip_input.c8
-rw-r--r--sys/netinet6/ip6_input.c9
7 files changed, 184 insertions, 15 deletions
diff --git a/sys/arch/alpha/alpha/conf.c b/sys/arch/alpha/alpha/conf.c
index 85c2ceff63d..6648a10318a 100644
--- a/sys/arch/alpha/alpha/conf.c
+++ b/sys/arch/alpha/alpha/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.26 2001/06/26 20:24:10 art Exp $ */
+/* $OpenBSD: conf.c,v 1.27 2001/06/27 05:50:03 kjc Exp $ */
/* $NetBSD: conf.c,v 1.16 1996/10/18 21:26:57 cgd Exp $ */
/*-
@@ -145,6 +145,8 @@ cdev_decl(pf);
cdev_decl(pci);
#endif
+#include <altq/altqconf.h>
+
struct cdevsw cdevsw[] =
{
cdev_cn_init(1,cn), /* 0: virtual console */
@@ -208,6 +210,7 @@ struct cdevsw cdevsw[] =
#else
cdev_notdef(),
#endif
+ cdev_altq_init(NALTQ, altq), /* 53: ALTQ control interface */
};
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c
index 3c76c36bebe..a78d7d8cc94 100644
--- a/sys/arch/i386/i386/conf.c
+++ b/sys/arch/i386/i386/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.74 2001/06/25 03:19:59 kjell Exp $ */
+/* $OpenBSD: conf.c,v 1.75 2001/06/27 05:50:04 kjc Exp $ */
/* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */
/*
@@ -232,6 +232,8 @@ cdev_decl(pci);
#include "pf.h"
cdev_decl(pf);
+#include <altq/altqconf.h>
+
struct cdevsw cdevsw[] =
{
cdev_cn_init(1,cn), /* 0: virtual console */
@@ -336,6 +338,7 @@ struct cdevsw cdevsw[] =
cdev_notdef(),
#endif
cdev_pf_init(NPF,pf), /* 73: packet filter */
+ cdev_altq_init(NALTQ,altq), /* 74: ALTQ control interface */
};
int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
diff --git a/sys/conf/files b/sys/conf/files
index a7ce14ec0bf..3177a4b48aa 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.209 2001/06/27 05:10:55 art Exp $
+# $OpenBSD: files,v 1.210 2001/06/27 05:50:05 kjc Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -302,6 +302,20 @@ file adosfs/adlookup.c adosfs
file adosfs/adutil.c adosfs
file adosfs/advfsops.c adosfs
file adosfs/advnops.c adosfs
+file altq/altq_afmap.c altq
+file altq/altq_blue.c altq
+file altq/altq_cbq.c altq
+file altq/altq_cdnr.c altq
+file altq/altq_conf.c altq
+file altq/altq_fifoq.c altq
+file altq/altq_hfsc.c altq
+file altq/altq_localq.c altq
+file altq/altq_priq.c altq
+file altq/altq_red.c altq
+file altq/altq_rio.c altq
+file altq/altq_rmclass.c altq
+file altq/altq_subr.c altq
+file altq/altq_wfq.c altq
file ddb/db_access.c ddb | kgdb
file ddb/db_aout.c ddb
file ddb/db_break.c ddb
diff --git a/sys/net/if.c b/sys/net/if.c
index 29154351c49..4dacd829228 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.47 2001/06/22 14:28:58 deraadt Exp $ */
+/* $OpenBSD: if.c,v 1.48 2001/06/27 05:50:06 kjc Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -234,6 +234,13 @@ if_attachsetup(ifp)
sdl->sdl_len = masklen;
while (namelen != 0)
sdl->sdl_data[--namelen] = 0xff;
+#ifdef ALTQ
+ ifp->if_snd.altq_type = 0;
+ ifp->if_snd.altq_disc = NULL;
+ ifp->if_snd.altq_flags &= ALTQF_CANTCHANGE;
+ ifp->if_snd.altq_tbr = NULL;
+ ifp->if_snd.altq_ifp = ifp;
+#endif
}
void
@@ -340,6 +347,12 @@ if_detach(ifp)
if (ifp->if_bpf)
bpfdetach(ifp);
#endif
+#ifdef ALTQ
+ if (ALTQ_IS_ENABLED(&ifp->if_snd))
+ altq_disable(&ifp->if_snd);
+ if (ALTQ_IS_ATTACHED(&ifp->if_snd))
+ altq_detach(&ifp->if_snd);
+#endif
/*
* Find and remove all routes which is using this interface.
@@ -579,7 +592,7 @@ if_down(ifp)
microtime(&ifp->if_lastchange);
for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next)
pfctlinput(PRC_IFDOWN, ifa->ifa_addr);
- if_qflush(&ifp->if_snd);
+ IFQ_PURGE(&ifp->if_snd);
rt_ifmsg(ifp);
/*
diff --git a/sys/net/if.h b/sys/net/if.h
index 0bf2b61588f..e486c42adc5 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.h,v 1.28 2001/06/23 22:52:51 fgsch Exp $ */
+/* $OpenBSD: if.h,v 1.29 2001/06/27 05:50:06 kjc Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -42,6 +42,14 @@
#include <sys/queue.h>
/*
+ * Always include ALTQ glue here -- we use the ALTQ interface queue
+ * structure even when ALTQ is not configured into the kernel so that
+ * the size of struct ifnet does not changed based on the option. The
+ * ALTQ queue structure is API-compatible with the legacy ifqueue.
+ */
+#include <altq/if_altq.h>
+
+/*
* Structures defining a network interface, providing a packet
* transport mechanism (ala level 0 of the PUP protocols).
*
@@ -105,6 +113,17 @@ struct if_data {
};
/*
+ * Structure defining a queue for a network interface.
+ */
+struct ifqueue {
+ struct mbuf *ifq_head;
+ struct mbuf *ifq_tail;
+ int ifq_len;
+ int ifq_maxlen;
+ int ifq_drops;
+};
+
+/*
* Values for if_link_state.
*/
#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */
@@ -151,13 +170,7 @@ struct ifnet { /* and the entries */
__P((struct ifnet *));
void (*if_watchdog) /* timer routine */
__P((struct ifnet *));
- struct ifqueue {
- struct mbuf *ifq_head;
- struct mbuf *ifq_tail;
- int ifq_len;
- int ifq_maxlen;
- int ifq_drops;
- } if_snd; /* output queue */
+ struct ifaltq if_snd; /* output queue (includes altq) */
struct ifprefix *if_prefixlist; /* linked list of prefixes per if */
};
#define if_mtu if_data.ifi_mtu
@@ -250,6 +263,20 @@ struct ifnet { /* and the entries */
(ifq)->ifq_len--; \
} \
}
+#define IF_POLL(ifq, m) ((m) = (ifq)->ifq_head)
+#define IF_PURGE(ifq) \
+do { \
+ struct mbuf *__m0; \
+ \
+ for (;;) { \
+ IF_DEQUEUE((ifq), __m0); \
+ if (__m0 == NULL) \
+ break; \
+ else \
+ m_freem(__m0); \
+ } \
+} while (0)
+#define IF_IS_EMPTY(ifq) ((ifq)->ifq_len == 0)
#define IFQ_MAXLEN 50
#define IFNET_SLOWHZ 1 /* granularity is 1 second */
@@ -415,6 +442,102 @@ do { \
(ifa)->ifa_refcnt--; \
} while (0)
+#ifdef ALTQ
+#define ALTQ_DECL(x) x
+
+#define IFQ_ENQUEUE(ifq, m, pattr, err) \
+do { \
+ if (ALTQ_IS_ENABLED((ifq))) \
+ ALTQ_ENQUEUE((ifq), (m), (pattr), (err)); \
+ else { \
+ if (IF_QFULL((ifq))) { \
+ m_freem((m)); \
+ (err) = ENOBUFS; \
+ } else { \
+ IF_ENQUEUE((ifq), (m)); \
+ (err) = 0; \
+ } \
+ } \
+ if ((err)) \
+ (ifq)->ifq_drops++; \
+} while (0)
+
+#define IFQ_DEQUEUE(ifq, m) \
+do { \
+ if (TBR_IS_ENABLED((ifq))) \
+ (m) = tbr_dequeue((ifq), ALTDQ_REMOVE); \
+ else if (ALTQ_IS_ENABLED((ifq))) \
+ ALTQ_DEQUEUE((ifq), (m)); \
+ else \
+ IF_DEQUEUE((ifq), (m)); \
+} while (0)
+
+#define IFQ_POLL(ifq, m) \
+do { \
+ if (TBR_IS_ENABLED((ifq))) \
+ (m) = tbr_dequeue((ifq), ALTDQ_POLL); \
+ else if (ALTQ_IS_ENABLED((ifq))) \
+ ALTQ_POLL((ifq), (m)); \
+ else \
+ IF_POLL((ifq), (m)); \
+} while (0)
+
+#define IFQ_PURGE(ifq) \
+do { \
+ if (ALTQ_IS_ENABLED((ifq))) \
+ ALTQ_PURGE((ifq)); \
+ else \
+ IF_PURGE((ifq)); \
+} while (0)
+
+#define IFQ_SET_READY(ifq) \
+ do { ((ifq)->altq_flags |= ALTQF_READY); } while (0)
+
+#define IFQ_CLASSIFY(ifq, m, af, pa) \
+do { \
+ if (ALTQ_IS_ENABLED((ifq))) { \
+ if (ALTQ_NEEDS_CLASSIFY((ifq))) \
+ (pa)->pattr_class = (*(ifq)->altq_classify) \
+ ((ifq)->altq_clfier, (m), (af)); \
+ (pa)->pattr_af = (af); \
+ (pa)->pattr_hdr = mtod((m), caddr_t); \
+ } \
+} while (0)
+
+#else /* !ALTQ */
+#define ALTQ_DECL(x) /* nothing */
+
+#define IFQ_ENQUEUE(ifq, m, pattr, err) \
+do { \
+ if (IF_QFULL((ifq))) { \
+ m_freem((m)); \
+ (err) = ENOBUFS; \
+ } else { \
+ IF_ENQUEUE((ifq), (m)); \
+ (err) = 0; \
+ } \
+ if ((err)) \
+ (ifq)->ifq_drops++; \
+} while (0)
+
+#define IFQ_DEQUEUE(ifq, m) IF_DEQUEUE((ifq), (m))
+
+#define IFQ_POLL(ifq, m) IF_POLL((ifq), (m))
+
+#define IFQ_PURGE(ifq) IF_PURGE((ifq))
+
+#define IFQ_SET_READY(ifq) /* nothing */
+
+#define IFQ_CLASSIFY(ifq, m, af, pa) /* nothing */
+
+#endif /* ALTQ */
+
+#define IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0)
+#define IFQ_INC_LEN(ifq) ((ifq)->ifq_len++)
+#define IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len)
+#define IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++)
+#define IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len))
+
struct ifnet_head ifnet;
struct ifnet **ifindex2ifnet;
struct ifnet *lo0ifp;
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index c57dba67acc..e2957ae31df 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.87 2001/06/26 18:17:54 deraadt Exp $ */
+/* $OpenBSD: ip_input.c,v 1.88 2001/06/27 05:50:07 kjc Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -354,6 +354,12 @@ ipv4_input(m)
ipstat.ips_inhwcsum++;
}
+#ifdef ALTQ
+ if (altq_input != NULL && (*altq_input)(m, AF_INET) == 0)
+ /* packet is dropped by traffic conditioner */
+ return;
+#endif
+
/*
* Convert fields to host representation.
*/
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index ee46c273860..1ae9ff7183d 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_input.c,v 1.31 2001/06/09 06:43:38 angelos Exp $ */
+/* $OpenBSD: ip6_input.c,v 1.32 2001/06/27 05:50:07 kjc Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -275,6 +275,13 @@ ip6_input(m)
ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
+#ifdef ALTQ
+ if (altq_input != NULL && (*altq_input)(m, AF_INET6) == 0) {
+ /* packet is dropped by traffic conditioner */
+ return;
+ }
+#endif
+
/*
* Scope check
*/