diff --git a/sys/altq/altq_subr.c b/sys/altq/altq_subr.c index 2d6409b..36745dc 100644 --- a/sys/altq/altq_subr.c +++ b/sys/altq/altq_subr.c @@ -48,6 +48,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.29 2014/05/17 20:44:24 rmind Exp $") #include #include #include +#include #include #include @@ -224,6 +225,48 @@ altq_disable(struct ifaltq *ifq) return 0; } +static pool_cache_t altq_pattr_cache __read_mostly; + +void +altq_m_tag_init(void) +{ + + altq_pattr_cache = pool_cache_init(sizeof(struct altq_pktattr) + + sizeof(struct m_tag), + 0, 0, 0, "altqmtag", NULL, IPL_NET, NULL, NULL, NULL); +} + +struct m_tag * +altq_m_tag_get(int type, int len, int wait) +{ + struct m_tag *t; + + KASSERT(len == sizeof(struct altq_pktattr)); + + t = pool_cache_get(altq_pattr_cache, + wait == M_NOWAIT ? PR_NOWAIT : PR_WAITOK); + if (t == NULL) + return (NULL); + t->m_tag_id = type; + t->m_tag_len = len; + return (t); +} + +static void +altq_m_tag_free(struct m_tag *t) +{ + + pool_cache_put(altq_pattr_cache, t); +} + +void +altq_m_tag_delete(struct mbuf *m, struct m_tag *t) +{ + + m_tag_unlink(m, t); + altq_m_tag_free(t); +} + #ifdef ALTQ_DEBUG void altq_assert(const char *file, int line, const char *failedexpr) diff --git a/sys/altq/if_altq.h b/sys/altq/if_altq.h index 1858e9d..193c936 100644 --- a/sys/altq/if_altq.h +++ b/sys/altq/if_altq.h @@ -157,6 +157,8 @@ struct tb_regulator { #define ALTQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0) #define TBR_IS_ENABLED(ifq) ((ifq)->altq_tbr != NULL) +extern void altq_m_tag_init(void); + extern int altq_attach(struct ifaltq *, int, void *, int (*)(struct ifaltq *, struct mbuf *, struct altq_pktattr *), @@ -167,6 +169,8 @@ extern int altq_attach(struct ifaltq *, int, void *, extern int altq_detach(struct ifaltq *); extern int altq_enable(struct ifaltq *); extern int altq_disable(struct ifaltq *); +extern struct m_tag *altq_m_tag_get(int, int, int); +extern void altq_m_tag_delete(struct mbuf *, struct m_tag *); extern struct mbuf *tbr_dequeue(struct ifaltq *, int); extern int (*altq_input)(struct mbuf *, int); #if 1 /* ALTQ3_CLFIER_COMPAT */ diff --git a/sys/dev/ic/hd64570.c b/sys/dev/ic/hd64570.c index 9d7deb9..69e3760 100644 --- a/sys/dev/ic/hd64570.c +++ b/sys/dev/ic/hd64570.c @@ -798,7 +798,6 @@ sca_output( struct ifqueue *ifq = NULL; int s, error, len; short mflags; - ALTQ_DECL(struct altq_pktattr pktattr;) error = 0; @@ -811,7 +810,7 @@ sca_output( * If the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); /* * determine address family, and priority for this packet @@ -876,7 +875,7 @@ sca_output( } else IF_ENQUEUE(ifq, m); } else - IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); if (error != 0) { splx(s); ifp->if_oerrors++; diff --git a/sys/dev/pci/if_lmc.c b/sys/dev/pci/if_lmc.c index 1533f08..deca057 100644 --- a/sys/dev/pci/if_lmc.c +++ b/sys/dev/pci/if_lmc.c @@ -3375,7 +3375,7 @@ ifnet_output(struct ifnet *ifp, struct mbuf *m, /* Some BSD QUEUE routines are not interrupt-safe. */ { DISABLE_INTR; /* noop in FreeBSD */ - IFQ_ENQUEUE(&ifp->if_snd, m, NULL, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); ENABLE_INTR; /* noop in FreeBSD */ } diff --git a/sys/dev/ppbus/if_plip.c b/sys/dev/ppbus/if_plip.c index 9b617fd..1c9fb00 100644 --- a/sys/dev/ppbus/if_plip.c +++ b/sys/dev/ppbus/if_plip.c @@ -704,7 +704,6 @@ lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct lp_softc * sc = ifp->if_softc; device_t dev = sc->ppbus_dev.sc_dev; device_t ppbus = device_parent(dev); - ALTQ_DECL(struct altq_pktattr pktattr;) int err; int s; @@ -731,8 +730,8 @@ lpoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, goto endoutput; } - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); - IFQ_ENQUEUE(&ifp->if_snd, m, NULL, err); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); + IFQ_ENQUEUE(&ifp->if_snd, m, err); if(err == 0) { if((ifp->if_flags & IFF_OACTIVE) == 0) lpstart(ifp); diff --git a/sys/dev/qbus/if_dmc.c b/sys/dev/qbus/if_dmc.c index 619e664..e5943b3 100644 --- a/sys/dev/qbus/if_dmc.c +++ b/sys/dev/qbus/if_dmc.c @@ -762,14 +762,13 @@ dmcoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, int type, error, s; struct mbuf *m = m0; struct dmc_header *dh; - ALTQ_DECL(struct altq_pktattr pktattr;) if ((ifp->if_flags & IFF_UP) == 0) { error = ENETDOWN; goto bad; } - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); switch (dst->sa_family) { #ifdef INET @@ -807,7 +806,7 @@ dmcoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst, * not yet active. */ s = splnet(); - IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); if (error) { /* mbuf is already freed */ splx(s); diff --git a/sys/dev/usb/if_upl.c b/sys/dev/usb/if_upl.c index 20003a3..6a80a7f 100644 --- a/sys/dev/usb/if_upl.c +++ b/sys/dev/usb/if_upl.c @@ -998,7 +998,6 @@ upl_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct rtentry *rt0) { int s, len, error; - ALTQ_DECL(struct altq_pktattr pktattr;) DPRINTFN(10,("%s: %s: enter\n", device_xname(((struct upl_softc *)ifp->if_softc)->sc_dev), @@ -1008,7 +1007,7 @@ upl_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * if the queueing discipline needs packet classification, * do it now. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); len = m->m_pkthdr.len; s = splnet(); @@ -1016,7 +1015,7 @@ upl_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * Queue message on interface, and start output if interface * not yet active. */ - IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); if (error) { /* mbuf is already freed */ splx(s); diff --git a/sys/dev/usb/uhso.c b/sys/dev/usb/uhso.c index fc7f75b..8805a69 100644 --- a/sys/dev/usb/uhso.c +++ b/sys/dev/usb/uhso.c @@ -2340,18 +2340,17 @@ Static int uhso_ifnet_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct rtentry *rt0) { - ALTQ_DECL(struct altq_pktattr pktattr); int error; if (!ISSET(ifp->if_flags, IFF_RUNNING)) return EIO; - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); switch (dst->sa_family) { #ifdef INET case AF_INET: - error = ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + error = ifq_enqueue(ifp, m); break; #endif diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index f2056da..da61570 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -234,6 +234,10 @@ mbinit(void) MOWNER_ATTACH(&unknown_mowners[i]); } #endif + +#ifdef ALTQ + altq_m_tag_init(); +#endif } /* diff --git a/sys/net/if.c b/sys/net/if.c index 2633c72..4791944 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -2572,15 +2572,14 @@ ifreq_setaddr(u_long cmd, struct ifreq *ifr, const struct sockaddr *sa) * not yet active. */ int -ifq_enqueue(struct ifnet *ifp, struct mbuf *m - ALTQ_COMMA ALTQ_DECL(struct altq_pktattr *pktattr)) +ifq_enqueue(struct ifnet *ifp, struct mbuf *m) { int len = m->m_pkthdr.len; int mflags = m->m_flags; int s = splnet(); int error; - IFQ_ENQUEUE(&ifp->if_snd, m, pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); if (error != 0) goto out; ifp->if_obytes += len; @@ -2597,8 +2596,7 @@ out: * Queue message on interface, possibly using a second fast queue */ int -ifq_enqueue2(struct ifnet *ifp, struct ifqueue *ifq, struct mbuf *m - ALTQ_COMMA ALTQ_DECL(struct altq_pktattr *pktattr)) +ifq_enqueue2(struct ifnet *ifp, struct ifqueue *ifq, struct mbuf *m) { int error = 0; @@ -2615,7 +2613,7 @@ ifq_enqueue2(struct ifnet *ifp, struct ifqueue *ifq, struct mbuf *m } else IF_ENQUEUE(ifq, m); } else - IFQ_ENQUEUE(&ifp->if_snd, m, pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); if (error != 0) { ++ifp->if_oerrors; return error; diff --git a/sys/net/if.h b/sys/net/if.h index f7bb337..4395544 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -80,6 +80,7 @@ #include #include #include +#include #include #include @@ -284,6 +285,8 @@ typedef struct ifnet { void (*if_drain) /* routine to release resources */ (struct ifnet *); struct ifaltq if_snd; /* output queue (includes altq) */ + void (*if_altq_classify) /* altq classify */ + (struct ifaltq *, struct mbuf *, struct altq_pktattr *); struct ifaddr *if_dl; /* identity of this interface. */ const struct sockaddr_dl *if_sadl; /* pointer to sockaddr_dl * of if_dl @@ -754,15 +757,70 @@ struct if_addrprefreq { #ifdef _KERNEL #ifdef ALTQ -#define ALTQ_DECL(x) x -#define ALTQ_COMMA , +static inline int +altq_set_pattr(struct ifaltq *ifq, struct mbuf *m, int af) +{ + struct altq_pktattr *pattr; + struct m_tag *mtag; + struct ifnet *ifp; + + mtag = altq_m_tag_get(PACKET_TAG_ALTQ_PATTR, sizeof(*pattr), M_NOWAIT); + if (mtag == NULL) + return ENOMEM; + pattr = (struct altq_pktattr *)(mtag + 1); + + ifp = ifq->altq_ifp; + if (ifp->if_altq_classify) { + (*ifp->if_altq_classify)(ifq, m, pattr); + } else { + if (ALTQ_NEEDS_CLASSIFY(ifq)) + pattr->pattr_class = + (*ifq->altq_classify)(ifq->altq_clfier, m, af); + pattr->pattr_af = af; + pattr->pattr_hdr = mtod(m, void *); + } + m_tag_prepend(m, mtag); + + return 0; +} + +/* + * Different from the mbuf of ALTQ_SET_PATTR, the mbuf of ALTQ_SET_PATTR + * may be M_PREPEND(). + */ +static inline struct altq_pktattr * +altq_get_pattr(struct ifaltq *ifq, struct mbuf *m) +{ + struct mbuf *m0; + struct m_tag *mtag = NULL; + + for (m0 = m; m0; m0 = m0->m_next) { + mtag = m_tag_find(m, PACKET_TAG_ALTQ_PATTR, NULL); + if (mtag != NULL) + return (struct altq_pktattr *)(mtag + 1); + } + + return NULL; +} + +static inline void +altq_delete_pattr(struct mbuf *m, struct altq_pktattr *pattr) +{ + struct m_tag *mtag; + + mtag = (struct m_tag *)pattr - 1; + altq_m_tag_delete(m, mtag); +} -#define IFQ_ENQUEUE(ifq, m, pattr, err) \ +#define IFQ_ENQUEUE(ifq, m, err) \ do { \ IFQ_LOCK((ifq)); \ - if (ALTQ_IS_ENABLED((ifq))) \ + if (ALTQ_IS_ENABLED((ifq))) { \ + struct altq_pktattr *pattr; \ + pattr = altq_get_pattr((ifq), (m)); \ ALTQ_ENQUEUE((ifq), (m), (pattr), (err)); \ - else { \ + altq_delete_pattr(m, pattr); \ + } else { \ if (IF_QFULL((ifq))) { \ m_freem((m)); \ (err) = ENOBUFS; \ @@ -815,23 +873,15 @@ do { \ (ifq)->altq_flags |= ALTQF_READY; \ } while (/*CONSTCOND*/ 0) -#define IFQ_CLASSIFY(ifq, m, af, pattr) \ +#define IFQ_CLASSIFY(ifq, m, af) \ do { \ IFQ_LOCK((ifq)); \ - if (ALTQ_IS_ENABLED((ifq))) { \ - if (ALTQ_NEEDS_CLASSIFY((ifq))) \ - (pattr)->pattr_class = (*(ifq)->altq_classify) \ - ((ifq)->altq_clfier, (m), (af)); \ - (pattr)->pattr_af = (af); \ - (pattr)->pattr_hdr = mtod((m), void *); \ - } \ + if (ALTQ_IS_ENABLED((ifq))) \ + altq_set_pattr((ifq), (m), (af)); \ IFQ_UNLOCK((ifq)); \ } while (/*CONSTCOND*/ 0) #else /* ! ALTQ */ -#define ALTQ_DECL(x) /* nothing */ -#define ALTQ_COMMA - -#define IFQ_ENQUEUE(ifq, m, pattr, err) \ +#define IFQ_ENQUEUE(ifq, m, err) \ do { \ IFQ_LOCK((ifq)); \ if (IF_QFULL((ifq))) { \ @@ -869,7 +919,7 @@ do { \ #define IFQ_SET_READY(ifq) /* nothing */ -#define IFQ_CLASSIFY(ifq, m, af, pattr) /* nothing */ +#define IFQ_CLASSIFY(ifq, m, af) /* nothing */ #endif /* ALTQ */ @@ -945,10 +995,8 @@ void p2p_rtrequest(int, struct rtentry *, const struct rt_addrinfo *); void if_clone_attach(struct if_clone *); void if_clone_detach(struct if_clone *); -int ifq_enqueue(struct ifnet *, struct mbuf * ALTQ_COMMA - ALTQ_DECL(struct altq_pktattr *)); -int ifq_enqueue2(struct ifnet *, struct ifqueue *, struct mbuf * ALTQ_COMMA - ALTQ_DECL(struct altq_pktattr *)); +int ifq_enqueue(struct ifnet *, struct mbuf *); +int ifq_enqueue2(struct ifnet *, struct ifqueue *, struct mbuf *); int loioctl(struct ifnet *, u_long, void *); void loopattach(int); diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index 84dff27..e4019f9 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -122,7 +122,6 @@ arc_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, int error, newencoding; uint8_t atype, adst, myself; int tfrags, sflag, fsflag, rsflag; - ALTQ_DECL(struct altq_pktattr pktattr;) if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) return (ENETDOWN); /* m, m1 aren't initialized yet */ @@ -138,7 +137,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, * if the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); switch (dst->sa_family) { #ifdef INET @@ -273,8 +272,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, ah->arc_flag = rsflag; ah->arc_seqid = ac->ac_seqid; - if ((error = ifq_enqueue(ifp, m ALTQ_COMMA - ALTQ_DECL(&pktattr))) != 0) + if ((error = ifq_enqueue(ifp, m)) != 0) return (error); m = m1; @@ -322,7 +320,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, ah->arc_shost = myself; } - return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + return ifq_enqueue(ifp, m); bad: if (m1) diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c index 8d1414a..50b6cc2 100644 --- a/sys/net/if_atmsubr.c +++ b/sys/net/if_atmsubr.c @@ -98,7 +98,6 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, struct mbuf *m = m0; struct atmllc *atmllc; uint32_t atm_flags; - ALTQ_DECL(struct altq_pktattr pktattr;) if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); @@ -108,7 +107,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, * do it before prepending link headers. */ IFQ_CLASSIFY(&ifp->if_snd, m, - (dst != NULL ? dst->sa_family : AF_UNSPEC), &pktattr); + (dst != NULL ? dst->sa_family : AF_UNSPEC)); /* * check for non-native ATM traffic (dst != NULL) @@ -179,7 +178,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, } } - return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + return ifq_enqueue(ifp, m); bad: if (m) diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index ec26b68..a5ae07a 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -429,6 +429,9 @@ bridge_clone_create(struct if_clone *ifc, int unit) if_initialize(ifp); if_register(ifp); +#ifdef ALTQ + ifp->if_altq_classify = altq_etherclassify; +#endif if_alloc_sadl(ifp); @@ -1358,7 +1361,6 @@ void bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m, int runfilt) { - ALTQ_DECL(struct altq_pktattr pktattr;) int len, error; short mflags; @@ -1387,14 +1389,14 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m, */ if (ALTQ_IS_ENABLED(&dst_ifp->if_snd)) { /* XXX IFT_ETHER */ - altq_etherclassify(&dst_ifp->if_snd, m, &pktattr); + IFQ_CLASSIFY(&dst_ifp->if_snd, m, 0/* not used */); } #endif /* ALTQ */ len = m->m_pkthdr.len; mflags = m->m_flags; - IFQ_ENQUEUE(&dst_ifp->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&dst_ifp->if_snd, m, error); if (error) { /* mbuf is already freed */ diff --git a/sys/net/if_ecosubr.c b/sys/net/if_ecosubr.c index a8d685ae..175f3cf 100644 --- a/sys/net/if_ecosubr.c +++ b/sys/net/if_ecosubr.c @@ -178,7 +178,6 @@ eco_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, void *tha; struct eco_arp *ecah; #endif - ALTQ_DECL(struct altq_pktattr pktattr;) if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); @@ -186,7 +185,7 @@ eco_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, * If the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); hdrcmplt = 0; retry_delay = hz / 16; @@ -293,7 +292,7 @@ eco_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, if (m == NULL) return (0); - return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + return ifq_enqueue(ifp, m); bad: if (m) @@ -848,6 +847,6 @@ eco_retry(void *arg) ifp = er->er_ifp; m = er->er_packet; LIST_REMOVE(er, er_link); - (void)ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(NULL)); + (void)ifq_enqueue(ifp, m); free(er, M_TEMP); } diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 236aec0..a4cd0ea 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -197,7 +197,6 @@ ether_output(struct ifnet * const ifp0, struct mbuf * const m0, struct mbuf *mcopy = NULL; struct ether_header *eh; struct ifnet *ifp = ifp0; - ALTQ_DECL(struct altq_pktattr pktattr;) #ifdef INET struct arphdr *ah; #endif /* INET */ @@ -416,10 +415,11 @@ ether_output(struct ifnet * const ifp0, struct mbuf * const m0, * require classification, but might require the * address family/header pointer in the pktattr. */ - if (ALTQ_IS_ENABLED(&ifp->if_snd)) - altq_etherclassify(&ifp->if_snd, m, &pktattr); + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_CLASSIFY(&ifp->if_snd, m, 0/* not used */); + } #endif - return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + return ifq_enqueue(ifp, m); bad: if (m) @@ -427,7 +427,6 @@ bad: return (error); } -#ifdef ALTQ /* * This routine is a slight hack to allow a packet to be classified * if the Ethernet headers are present. It will go away when ALTQ's @@ -518,7 +517,6 @@ altq_etherclassify(struct ifaltq *ifq, struct mbuf *m, pktattr->pattr_hdr = NULL; pktattr->pattr_af = AF_UNSPEC; } -#endif /* ALTQ */ /* * Process a received Ethernet packet; @@ -957,6 +955,12 @@ ether_ifattach(struct ifnet *ifp, const uint8_t *lla) MOWNER_ATTACH(&ec->ec_rx_mowner); ifp->if_mowner = &ec->ec_tx_mowner; #endif + +#ifdef ALTQ + ifp->if_altq_classify = altq_etherclassify; +#else + ifp->if_altq_classify = NULL; +#endif } void diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 7ef5110..ca8765f 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -195,7 +195,6 @@ fddi_output(struct ifnet *ifp0, struct mbuf *m0, const struct sockaddr *dst, struct fddi_header *fh; struct mbuf *mcopy = NULL; struct ifnet *ifp = ifp0; - ALTQ_DECL(struct altq_pktattr pktattr;) MCLAIM(m, ifp->if_mowner); @@ -224,7 +223,7 @@ fddi_output(struct ifnet *ifp0, struct mbuf *m0, const struct sockaddr *dst, * If the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); switch (dst->sa_family) { @@ -399,7 +398,7 @@ fddi_output(struct ifnet *ifp0, struct mbuf *m0, const struct sockaddr *dst, if (ifp != ifp0) ifp0->if_obytes += m->m_pkthdr.len; #endif /* NCARP > 0 */ - return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + return ifq_enqueue(ifp, m); bad: if (m) diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index 0310969..b513f2d 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -310,10 +310,9 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, { struct gif_softc *sc = ifp->if_softc; int error = 0; - ALTQ_DECL(struct altq_pktattr pktattr;) int s; - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); if ((error = gif_check_nesting(ifp, m)) != 0) { m_free(m); @@ -344,7 +343,7 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, m->m_pkthdr.csum_data = 0; s = splnet(); - IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); if (error) { splx(s); goto end; diff --git a/sys/net/if_hippisubr.c b/sys/net/if_hippisubr.c index 67ea509..f446810 100644 --- a/sys/net/if_hippisubr.c +++ b/sys/net/if_hippisubr.c @@ -94,7 +94,6 @@ hippi_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, struct hippi_header *hh; uint32_t *cci; uint32_t d2_len; - ALTQ_DECL(struct altq_pktattr pktattr;) if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) senderr(ENETDOWN); @@ -107,7 +106,7 @@ hippi_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, * If the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); switch (dst->sa_family) { #ifdef INET @@ -185,7 +184,7 @@ hippi_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, m_copyback(m, m->m_pkthdr.len, 8 - d2_len % 8, (void *) buffer); } - return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + return ifq_enqueue(ifp, m); bad: if (m) diff --git a/sys/net/if_ieee1394subr.c b/sys/net/if_ieee1394subr.c index 8b8bdc1..1978114 100644 --- a/sys/net/if_ieee1394subr.c +++ b/sys/net/if_ieee1394subr.c @@ -92,7 +92,6 @@ ieee1394_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, struct mbuf *mcopy = NULL; struct ieee1394_hwaddr *hwdst, baddr; const struct ieee1394_hwaddr *myaddr; - ALTQ_DECL(struct altq_pktattr pktattr;) #ifdef INET struct arphdr *ah; #endif /* INET */ @@ -106,7 +105,7 @@ ieee1394_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, * If the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family); /* * For unicast, we make a tag to store the lladdr of the @@ -228,7 +227,7 @@ ieee1394_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, splx(s); senderr(ENOBUFS); } - IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); if (error) { /* mbuf is already freed */ splx(s); diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 1af29fb..5d36d29 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -241,14 +241,13 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, */ if ((ALTQ_IS_ENABLED(&ifp->if_snd) || TBR_IS_ENABLED(&ifp->if_snd)) && ifp->if_start == lostart) { - struct altq_pktattr pktattr; int error; /* * If the queueing discipline needs packet classification, * do it before prepending the link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); M_PREPEND(m, sizeof(uint32_t), M_DONTWAIT); if (m == NULL) @@ -256,7 +255,7 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, *(mtod(m, uint32_t *)) = dst->sa_family; s = splnet(); - IFQ_ENQUEUE(&ifp->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m, error); (*ifp->if_start)(ifp); splx(s); return (error); diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 5863121..726f42a 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -851,7 +851,6 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, struct ifqueue *ifq; enum NPmode mode; int len; - ALTQ_DECL(struct altq_pktattr pktattr;) if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { @@ -859,7 +858,7 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, goto bad; } - IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family); /* * Compute PPP header. @@ -991,8 +990,7 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, sc->sc_npqtail = &m0->m_nextpkt; } else { ifq = (m0->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; - if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0 - ALTQ_COMMA ALTQ_DECL(&pktattr))) != 0) { + if ((error = ifq_enqueue2(&sc->sc_if, ifq, m0)) != 0) { splx(s); sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; @@ -1045,8 +1043,7 @@ ppp_requeue(struct ppp_softc *sc) *mpp = m->m_nextpkt; m->m_nextpkt = NULL; ifq = (m->m_flags & M_HIGHPRI) ? &sc->sc_fastq : NULL; - if ((error = ifq_enqueue2(&sc->sc_if, ifq, m ALTQ_COMMA - ALTQ_DECL(NULL))) != 0) { + if ((error = ifq_enqueue2(&sc->sc_if, ifq, m)) != 0) { sc->sc_if.if_oerrors++; sc->sc_stats.ppp_oerrors++; } diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index 3fb55e2..f0a0886 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -439,9 +439,8 @@ sloutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct ip *ip; struct ifqueue *ifq = NULL; int s, error; - ALTQ_DECL(struct altq_pktattr pktattr;) - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); /* * `Cannot happen' (see slioctl). Someday we will extend @@ -492,8 +491,7 @@ sloutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, if ((ip->ip_tos & IPTOS_LOWDELAY) != 0) ifq = &sc->sc_fastq; #endif - if ((error = ifq_enqueue2(ifp, ifq, m ALTQ_COMMA - ALTQ_DECL(&pktattr))) != 0) { + if ((error = ifq_enqueue2(ifp, ifq, m)) != 0) { splx(s); return error; } diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 5c71239..b5fce71 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -647,7 +647,6 @@ sppp_output(struct ifnet *ifp, struct mbuf *m, struct ifqueue *ifq = NULL; /* XXX */ int s, error = 0; uint16_t protocol; - ALTQ_DECL(struct altq_pktattr pktattr;) s = splnet(); @@ -675,7 +674,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m, * If the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); #ifdef INET if (dst->sa_family == AF_INET) { @@ -824,7 +823,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m, } - error = ifq_enqueue2(ifp, ifq, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + error = ifq_enqueue2(ifp, ifq, m); if (error == 0) { /* diff --git a/sys/net/if_strip.c b/sys/net/if_strip.c index 0cc79a5..1151758 100644 --- a/sys/net/if_strip.c +++ b/sys/net/if_strip.c @@ -730,7 +730,6 @@ stripoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct ifqueue *ifq; int s, error; u_char dl_addrbuf[STARMODE_ADDR_LEN+1]; - ALTQ_DECL(struct altq_pktattr pktattr;) /* * Verify tty line is up and alive. @@ -854,8 +853,7 @@ stripoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, splx(s); s = splnet(); - if ((error = ifq_enqueue2(ifp, ifq, m ALTQ_COMMA - ALTQ_DECL(&pktattr))) != 0) { + if ((error = ifq_enqueue2(ifp, ifq, m)) != 0) { splx(s); return error; } diff --git a/sys/net/if_tokensubr.c b/sys/net/if_tokensubr.c index df1db1b..2357860 100644 --- a/sys/net/if_tokensubr.c +++ b/sys/net/if_tokensubr.c @@ -169,7 +169,6 @@ token_output(struct ifnet *ifp0, struct mbuf *m0, const struct sockaddr *dst, struct token_rif bcastrif; struct ifnet *ifp = ifp0; size_t riflen = 0; - ALTQ_DECL(struct altq_pktattr pktattr;) #if NCARP > 0 if (ifp->if_type == IFT_CARP) { @@ -197,7 +196,7 @@ token_output(struct ifnet *ifp0, struct mbuf *m0, const struct sockaddr *dst, * If the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); switch (dst->sa_family) { @@ -370,7 +369,7 @@ send: } #endif /* NCARP > 0 */ - return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr)); + return ifq_enqueue(ifp, m); bad: if (m) m_freem(m); diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index e5778bb..753abb1 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -503,7 +503,6 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, int mlen; uint32_t *af; #endif - ALTQ_DECL(struct altq_pktattr pktattr;) s = splnet(); mutex_enter(&tp->tun_lock); @@ -520,7 +519,7 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, * if the queueing discipline needs packet classification, * do it before prepending link headers. */ - IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m0, dst->sa_family); bpf_mtap_af(ifp, dst->sa_family, m0); @@ -564,7 +563,7 @@ tun_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst, } /* FALLTHROUGH */ case AF_UNSPEC: - IFQ_ENQUEUE(&ifp->if_snd, m0, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m0, error); if (error) { ifp->if_collisions++; error = EAFNOSUPPORT; diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 936016b..7830502 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -238,6 +238,11 @@ vlan_clone_create(struct if_clone *ifc, int unit) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_start = vlan_start; ifp->if_ioctl = vlan_ioctl; + +#ifdef ALTQ + ifp->if_altq_classify = altq_etherclassify; +#endif + IFQ_SET_READY(&ifp->if_snd); if_initialize(ifp); @@ -686,7 +691,6 @@ vlan_start(struct ifnet *ifp) struct ethercom *ec = (void *) ifv->ifv_p; struct mbuf *m; int error; - ALTQ_DECL(struct altq_pktattr pktattr;) #ifndef NET_MPSAFE KASSERT(KERNEL_LOCKED_P()); @@ -709,7 +713,7 @@ vlan_start(struct ifnet *ifp) if (ALTQ_IS_ENABLED(&p->if_snd)) { switch (p->if_type) { case IFT_ETHER: - altq_etherclassify(&p->if_snd, m, &pktattr); + IFQ_CLASSIFY(&p->if_snd, m, 0); break; #ifdef DIAGNOSTIC default: @@ -808,7 +812,7 @@ vlan_start(struct ifnet *ifp) * Send it, precisely as the parent's output routine * would have. We are already running at splnet. */ - IFQ_ENQUEUE(&p->if_snd, m, &pktattr, error); + IFQ_ENQUEUE(&p->if_snd, m, error); if (error) { /* mbuf is already freed */ ifp->if_oerrors++; diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 37bcb7b..c0d03bb 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -698,7 +698,6 @@ ieee80211_deliver_data(struct ieee80211com *ic, { struct ether_header *eh = mtod(m, struct ether_header *); struct ifnet *ifp = ic->ic_ifp; - ALTQ_DECL(struct altq_pktattr pktattr;) int error; /* perform as a bridge within the AP */ @@ -741,12 +740,12 @@ ieee80211_deliver_data(struct ieee80211com *ic, int len; #ifdef ALTQ if (ALTQ_IS_ENABLED(&ifp->if_snd)) { - altq_etherclassify(&ifp->if_snd, m1, - &pktattr); + ifp->if_altq_classify = altq_etherclassify; /* XXX */ + IFQ_CLASSIFY(&ifp->if_snd, m1, 0/* not used */); } #endif len = m1->m_pkthdr.len; - IFQ_ENQUEUE(&ifp->if_snd, m1, &pktattr, error); + IFQ_ENQUEUE(&ifp->if_snd, m1, error); if (error) { ifp->if_omcasts++; m = NULL; diff --git a/sys/netisdn/i4b_ipr.c b/sys/netisdn/i4b_ipr.c index 238f748..e7dd856 100644 --- a/sys/netisdn/i4b_ipr.c +++ b/sys/netisdn/i4b_ipr.c @@ -421,7 +421,6 @@ iripoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, int s, rv; struct ifqueue *ifq = NULL; struct ip *ip; - ALTQ_DECL(struct altq_pktattr pktattr;) s = splnet(); @@ -515,7 +514,7 @@ iripoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, * else (i.e. ftp traffic) put it into the "normal" queue */ - IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family, &pktattr); + IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family); ip = mtod(m, struct ip *); /* get ptr to ip header */ @@ -540,7 +539,7 @@ iripoutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, } IF_ENQUEUE(ifq, m); } else { - IFQ_ENQUEUE(&sc->sc_if.if_snd, m, &pktattr, rv); + IFQ_ENQUEUE(&sc->sc_if.if_snd, m, rv); if (rv != 0) { sc->sc_if.if_oerrors++; splx(s); diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 75f4d64..2b4bd1a 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -892,6 +892,7 @@ struct m_tag *m_tag_next(struct mbuf *, struct m_tag *); #define PACKET_TAG_ESP 3 /* ESP information */ #define PACKET_TAG_PF 11 /* packet filter */ #define PACKET_TAG_ALTQ_QID 12 /* ALTQ queue id */ +#define PACKET_TAG_ALTQ_PATTR 13 /* ALTQ packet attr */ #define PACKET_TAG_IPSEC_IN_CRYPTO_DONE 16 #define PACKET_TAG_IPSEC_IN_DONE 17