diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2005-10-17 08:43:36 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2005-10-17 08:43:36 +0000 |
commit | 39fabf35216b41e26fde1267b94c91b0684dcba2 (patch) | |
tree | 4f38d7d737c137e9efdcf90a5f79c72f0a1a1ff4 /sys/altq | |
parent | 232a2a344188b9fbf9d6c7825619aa59ddafa7e5 (diff) |
make pf use one mbuf tag instead of 6 distinct ones. use a little struct
in the data part for the data from the previously distinct tags.
look up the tag early and carry a pointer to it around.
makes the code easier and saves some tag lookups and thus helps performance,
as proven by tests run by Schberle Dniel <Schoeberle.Daniel@aamtech.hu>
Initially hacked up somewhere over the atlantic ocean in an A330
early testing reyk and moritz, "put it in" theo
Diffstat (limited to 'sys/altq')
-rw-r--r-- | sys/altq/altq_cbq.c | 8 | ||||
-rw-r--r-- | sys/altq/altq_hfsc.c | 8 | ||||
-rw-r--r-- | sys/altq/altq_priq.c | 8 | ||||
-rw-r--r-- | sys/altq/altq_red.c | 29 | ||||
-rw-r--r-- | sys/altq/if_altq.h | 12 |
5 files changed, 22 insertions, 43 deletions
diff --git a/sys/altq/altq_cbq.c b/sys/altq/altq_cbq.c index 604cbbdb207..d3ec56199f2 100644 --- a/sys/altq/altq_cbq.c +++ b/sys/altq/altq_cbq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_cbq.c,v 1.18 2004/01/14 08:42:23 kjc Exp $ */ +/* $OpenBSD: altq_cbq.c,v 1.19 2005/10/17 08:43:35 henning Exp $ */ /* $KAME: altq_cbq.c,v 1.9 2000/12/14 08:12:45 thorpej Exp $ */ /* @@ -441,7 +441,7 @@ cbq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) { cbq_state_t *cbqp = (cbq_state_t *)ifq->altq_disc; struct rm_class *cl; - struct m_tag *t; + struct pf_mtag *t; int len; /* grab class set by classifier */ @@ -452,9 +452,9 @@ cbq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) m_freem(m); return (ENOBUFS); } - t = m_tag_find(m, PACKET_TAG_PF_QID, NULL); + t = pf_find_mtag(m); if (t == NULL || - (cl = clh_to_clp(cbqp, ((struct altq_tag *)(t+1))->qid)) == NULL) { + (cl = clh_to_clp(cbqp, t->qid)) == NULL) { cl = cbqp->ifnp.default_; if (cl == NULL) { m_freem(m); diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c index e78965cf9b2..fc58f4af129 100644 --- a/sys/altq/altq_hfsc.c +++ b/sys/altq/altq_hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_hfsc.c,v 1.21 2004/01/14 08:42:23 kjc Exp $ */ +/* $OpenBSD: altq_hfsc.c,v 1.22 2005/10/17 08:43:35 henning Exp $ */ /* $KAME: altq_hfsc.c,v 1.17 2002/11/29 07:48:33 kjc Exp $ */ /* @@ -618,7 +618,7 @@ hfsc_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) { struct hfsc_if *hif = (struct hfsc_if *)ifq->altq_disc; struct hfsc_class *cl; - struct m_tag *t; + struct pf_mtag *t; int len; /* grab class set by classifier */ @@ -629,9 +629,9 @@ hfsc_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) m_freem(m); return (ENOBUFS); } - t = m_tag_find(m, PACKET_TAG_PF_QID, NULL); + t = pf_find_mtag(m); if (t == NULL || - (cl = clh_to_clp(hif, ((struct altq_tag *)(t+1))->qid)) == NULL || + (cl = clh_to_clp(hif, t->qid)) == NULL || is_a_parent_class(cl)) { cl = hif->hif_defaultclass; if (cl == NULL) { diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c index 436aa6829ea..3f04e81a35c 100644 --- a/sys/altq/altq_priq.c +++ b/sys/altq/altq_priq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_priq.c,v 1.17 2004/01/14 08:42:23 kjc Exp $ */ +/* $OpenBSD: altq_priq.c,v 1.18 2005/10/17 08:43:35 henning Exp $ */ /* $KAME: altq_priq.c,v 1.1 2000/10/18 09:15:23 kjc Exp $ */ /* * Copyright (C) 2000 @@ -396,7 +396,7 @@ priq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) { struct priq_if *pif = (struct priq_if *)ifq->altq_disc; struct priq_class *cl; - struct m_tag *t; + struct pf_mtag *t; int len; /* grab class set by classifier */ @@ -407,9 +407,9 @@ priq_enqueue(struct ifaltq *ifq, struct mbuf *m, struct altq_pktattr *pktattr) m_freem(m); return (ENOBUFS); } - t = m_tag_find(m, PACKET_TAG_PF_QID, NULL); + t = pf_find_mtag(m); if (t == NULL || - (cl = clh_to_clp(pif, ((struct altq_tag *)(t+1))->qid)) == NULL) { + (cl = clh_to_clp(pif, t->qid)) == NULL) { cl = pif->pif_default; if (cl == NULL) { m_freem(m); diff --git a/sys/altq/altq_red.c b/sys/altq/altq_red.c index b126ba1f0d9..0de641866a7 100644 --- a/sys/altq/altq_red.c +++ b/sys/altq/altq_red.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_red.c,v 1.11 2003/05/12 00:50:12 henning Exp $ */ +/* $OpenBSD: altq_red.c,v 1.12 2005/10/17 08:43:35 henning Exp $ */ /* $KAME: altq_red.c,v 1.10 2002/04/03 05:38:51 kjc Exp $ */ /* @@ -420,39 +420,28 @@ int mark_ecn(struct mbuf *m, struct altq_pktattr *pktattr, int flags) { struct mbuf *m0; - struct m_tag *t; - struct altq_tag *at; - void *hdr; - int af; + struct pf_mtag *t; - t = m_tag_find(m, PACKET_TAG_PF_QID, NULL); - if (t == NULL) + if ((t = pf_find_mtag(m)) == NULL) return (0); - at = (struct altq_tag *)(t + 1); - if (at == NULL) - return (0); - - af = at->af; - hdr = at->hdr; - - if (af != AF_INET && af != AF_INET6) + if (t->af != AF_INET && t->af != AF_INET6) return (0); /* verify that pattr_hdr is within the mbuf data */ for (m0 = m; m0 != NULL; m0 = m0->m_next) - if (((caddr_t)hdr >= m0->m_data) && - ((caddr_t)hdr < m0->m_data + m0->m_len)) + if (((caddr_t)(t->hdr) >= m0->m_data) && + ((caddr_t)(t->hdr) < m0->m_data + m0->m_len)) break; if (m0 == NULL) { /* ick, tag info is stale */ return (0); } - switch (af) { + switch (t->af) { case AF_INET: if (flags & REDF_ECN4) { - struct ip *ip = hdr; + struct ip *ip = t->hdr; u_int8_t otos; int sum; @@ -485,7 +474,7 @@ mark_ecn(struct mbuf *m, struct altq_pktattr *pktattr, int flags) #ifdef INET6 case AF_INET6: if (flags & REDF_ECN6) { - struct ip6_hdr *ip6 = hdr; + struct ip6_hdr *ip6 = t->hdr; u_int32_t flowlabel; flowlabel = ntohl(ip6->ip6_flow); diff --git a/sys/altq/if_altq.h b/sys/altq/if_altq.h index 2d9599b6277..79494208986 100644 --- a/sys/altq/if_altq.h +++ b/sys/altq/if_altq.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_altq.h,v 1.9 2004/04/17 00:09:00 henning Exp $ */ +/* $OpenBSD: if_altq.h,v 1.10 2005/10/17 08:43:35 henning Exp $ */ /* $KAME: if_altq.h,v 1.6 2001/01/29 19:59:09 itojun Exp $ */ /* @@ -92,16 +92,6 @@ struct altq_pktattr { }; /* - * mbuf tag to carry a queue id (and hints for ECN). - */ -struct altq_tag { - u_int32_t qid; /* queue id */ - /* hints for ecn */ - int af; /* address family */ - void *hdr; /* saved header position in mbuf */ -}; - -/* * a token-bucket regulator limits the rate that a network driver can * dequeue packets from the output queue. * modern cards are able to buffer a large amount of packets and dequeue |