Diff below adds a new pointer to "struct pkthdr" to explicitly pass some wireless nodes to the pointer without abusing the interface pointer that I'd like to kill.
I kept and updated the comments saying that this way of passing the corresponding node is a hack since using a dedicated pointer does not change the design. Somebody will certainly dig into this at some point :) ok? Index: dev/usb/if_athn_usb.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_athn_usb.c,v retrieving revision 1.18 diff -u -p -r1.18 if_athn_usb.c --- dev/usb/if_athn_usb.c 7 Aug 2013 01:06:41 -0000 1.18 +++ dev/usb/if_athn_usb.c 14 Mar 2014 11:49:43 -0000 @@ -2009,7 +2009,7 @@ athn_usb_start(struct ifnet *ifp) /* Send pending management frames first. */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) Index: dev/usb/if_atu.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_atu.c,v retrieving revision 1.105 diff -u -p -r1.105 if_atu.c --- dev/usb/if_atu.c 7 Mar 2014 18:39:02 -0000 1.105 +++ dev/usb/if_atu.c 14 Mar 2014 11:49:43 -0000 @@ -2015,15 +2015,14 @@ atu_start(struct ifnet *ifp) /* * Hack! The referenced node pointer is in the - * rcvif field of the packet header. This is + * `ni' field of the packet header. This is * placed there by ieee80211_mgmt_output because * we need to hold the reference with the frame * and there's no other way (other than packet * tags which we consider too expensive to use) * to pass it along. */ - ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; wh = mtod(m, struct ieee80211_frame *); /* sc->sc_stats.ast_tx_mgmt++; */ Index: dev/usb/if_otus.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_otus.c,v retrieving revision 1.38 diff -u -p -r1.38 if_otus.c --- dev/usb/if_otus.c 7 Mar 2014 18:39:02 -0000 1.38 +++ dev/usb/if_otus.c 14 Mar 2014 11:49:43 -0000 @@ -1438,7 +1438,7 @@ otus_start(struct ifnet *ifp) /* Send pending management frames first. */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) Index: dev/usb/if_ral.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_ral.c,v retrieving revision 1.125 diff -u -p -r1.125 if_ral.c --- dev/usb/if_ral.c 7 Mar 2014 18:39:02 -0000 1.125 +++ dev/usb/if_ral.c 14 Mar 2014 11:49:43 -0000 @@ -1255,8 +1255,7 @@ ural_start(struct ifnet *ifp) } IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m0, BPF_DIRECTION_OUT); Index: dev/usb/if_rum.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_rum.c,v retrieving revision 1.102 diff -u -p -r1.102 if_rum.c --- dev/usb/if_rum.c 7 Mar 2014 18:39:02 -0000 1.102 +++ dev/usb/if_rum.c 14 Mar 2014 11:49:43 -0000 @@ -1274,8 +1274,7 @@ rum_start(struct ifnet *ifp) } IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m0, BPF_DIRECTION_OUT); Index: dev/usb/if_run.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_run.c,v retrieving revision 1.96 diff -u -p -r1.96 if_run.c --- dev/usb/if_run.c 7 Mar 2014 18:39:02 -0000 1.96 +++ dev/usb/if_run.c 14 Mar 2014 11:49:43 -0000 @@ -2273,7 +2273,7 @@ run_start(struct ifnet *ifp) /* send pending management frames first */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) Index: dev/usb/if_uath.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_uath.c,v retrieving revision 1.57 diff -u -p -r1.57 if_uath.c --- dev/usb/if_uath.c 7 Mar 2014 18:39:02 -0000 1.57 +++ dev/usb/if_uath.c 14 Mar 2014 11:49:43 -0000 @@ -1492,8 +1492,7 @@ uath_start(struct ifnet *ifp) } IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m0, BPF_DIRECTION_OUT); Index: dev/usb/if_upgt.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_upgt.c,v retrieving revision 1.60 diff -u -p -r1.60 if_upgt.c --- dev/usb/if_upgt.c 21 Aug 2013 05:21:45 -0000 1.60 +++ dev/usb/if_upgt.c 14 Mar 2014 11:49:43 -0000 @@ -1410,8 +1410,7 @@ upgt_start(struct ifnet *ifp) /* management frame */ IF_DEQUEUE(&ic->ic_mgtq, m); - ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m, BPF_DIRECTION_OUT); Index: dev/usb/if_urtw.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_urtw.c,v retrieving revision 1.44 diff -u -p -r1.44 if_urtw.c --- dev/usb/if_urtw.c 7 Mar 2014 18:39:02 -0000 1.44 +++ dev/usb/if_urtw.c 14 Mar 2014 11:49:43 -0000 @@ -2496,8 +2496,7 @@ urtw_start(struct ifnet *ifp) break; } IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m0, BPF_DIRECTION_OUT); Index: dev/usb/if_urtwn.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_urtwn.c,v retrieving revision 1.33 diff -u -p -r1.33 if_urtwn.c --- dev/usb/if_urtwn.c 7 Mar 2014 18:39:02 -0000 1.33 +++ dev/usb/if_urtwn.c 14 Mar 2014 11:49:43 -0000 @@ -1918,7 +1918,7 @@ urtwn_start(struct ifnet *ifp) /* Send pending management frames first. */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) Index: dev/usb/if_zyd.c =================================================================== RCS file: /home/ncvs/src/sys/dev/usb/if_zyd.c,v retrieving revision 1.96 diff -u -p -r1.96 if_zyd.c --- dev/usb/if_zyd.c 7 Mar 2014 18:39:02 -0000 1.96 +++ dev/usb/if_zyd.c 14 Mar 2014 11:49:43 -0000 @@ -2230,7 +2230,7 @@ zyd_start(struct ifnet *ifp) /* send pending management frames first */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) Index: sys/mbuf.h =================================================================== RCS file: /home/ncvs/src/sys/sys/mbuf.h,v retrieving revision 1.172 diff -u -p -r1.172 mbuf.h --- sys/mbuf.h 19 Jan 2014 03:04:54 -0000 1.172 +++ sys/mbuf.h 14 Mar 2014 11:49:43 -0000 @@ -111,13 +111,14 @@ struct pkthdr_pf { /* record/packet header in first mbuf of chain; valid if M_PKTHDR set */ struct pkthdr { struct ifnet *rcvif; /* rcv interface */ - SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ + SLIST_HEAD(packet_tags, m_tag) tags; /* list of packet tags */ int len; /* total packet length */ u_int16_t tagsset; /* mtags attached */ u_int16_t pad; u_int16_t csum_flags; /* checksum flags */ u_int16_t ether_vtag; /* Ethernet 802.1p+Q vlan tag */ u_int rdomain; /* routing domain id */ + void *ni; /* ieee80211 node */ struct pkthdr_pf pf; }; Index: net80211/ieee80211_output.c =================================================================== RCS file: /home/ncvs/src/sys/net80211/ieee80211_output.c,v retrieving revision 1.89 diff -u -p -r1.89 ieee80211_output.c --- net80211/ieee80211_output.c 7 Dec 2013 01:55:06 -0000 1.89 +++ net80211/ieee80211_output.c 14 Mar 2014 11:49:43 -0000 @@ -206,13 +206,12 @@ ieee80211_mgmt_output(struct ifnet *ifp, * driver's start routine. We could stick this in an m_tag * and tack that on to the mbuf. However that's rather * expensive to do for every frame so instead we stuff it in - * the rcvif field since outbound frames do not (presently) - * use this. + * a special pkthdr field. */ M_PREPEND(m, sizeof(struct ieee80211_frame), M_DONTWAIT); if (m == NULL) return ENOMEM; - m->m_pkthdr.rcvif = (void *)ni; + m->m_pkthdr.ni = ni; wh = mtod(m, struct ieee80211_frame *); wh->i_fc[0] = IEEE80211_FC0_VERSION_0 | IEEE80211_FC0_TYPE_MGT | type; @@ -1864,7 +1863,7 @@ ieee80211_beacon_alloc(struct ieee80211c #endif m->m_pkthdr.len = m->m_len = frm - mtod(m, u_int8_t *); - m->m_pkthdr.rcvif = (void *)ni; + m->m_pkthdr.ni = ni; return m; } @@ -1914,10 +1913,10 @@ ieee80211_pwrsave(struct ieee80211com *i } else { IF_ENQUEUE(&ni->ni_savedq, m); /* - * Similar to ieee80211_mgmt_output, store the node in the - * rcvif field. + * Similar to ieee80211_mgmt_output, store the node in a + * special pkthdr field. */ - m->m_pkthdr.rcvif = (void *)ni; + m->m_pkthdr.ni = ni; } return 1; } Index: dev/ic/acx.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/acx.c,v retrieving revision 1.101 diff -u -p -r1.101 acx.c --- dev/ic/acx.c 7 Aug 2013 01:06:27 -0000 1.101 +++ dev/ic/acx.c 14 Mar 2014 11:49:43 -0000 @@ -948,8 +948,7 @@ acx_start(struct ifnet *ifp) IF_DEQUEUE(&ic->ic_mgtq, m); /* first dequeue management frames */ if (m != NULL) { - ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; /* * probe response mgmt frames are handled by the @@ -976,8 +975,7 @@ acx_start(struct ifnet *ifp) /* then dequeue packets on the powersave queue */ IF_DEQUEUE(&ic->ic_pwrsaveq, m); if (m != NULL) { - ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto encapped; } else { IFQ_DEQUEUE(&ifp->if_snd, m); Index: dev/ic/ath.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/ath.c,v retrieving revision 1.98 diff -u -p -r1.98 ath.c --- dev/ic/ath.c 26 Nov 2013 09:50:32 -0000 1.98 +++ dev/ic/ath.c 14 Mar 2014 11:49:43 -0000 @@ -906,8 +906,7 @@ ath_start(struct ifnet *ifp) * tags which we consider too expensive to use) * to pass it along. */ - ni = (struct ieee80211_node *) m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; wh = mtod(m, struct ieee80211_frame *); if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == Index: dev/ic/athn.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/athn.c,v retrieving revision 1.80 diff -u -p -r1.80 athn.c --- dev/ic/athn.c 6 Dec 2013 21:03:02 -0000 1.80 +++ dev/ic/athn.c 14 Mar 2014 11:49:43 -0000 @@ -2554,7 +2554,7 @@ athn_start(struct ifnet *ifp) /* Send pending management frames first. */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) @@ -2562,7 +2562,7 @@ athn_start(struct ifnet *ifp) IF_DEQUEUE(&ic->ic_pwrsaveq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) Index: dev/ic/atw.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/atw.c,v retrieving revision 1.80 diff -u -p -r1.80 atw.c --- dev/ic/atw.c 6 Dec 2013 21:03:02 -0000 1.80 +++ dev/ic/atw.c 14 Mar 2014 11:49:43 -0000 @@ -3605,8 +3605,7 @@ atw_start(struct ifnet *ifp) */ IF_DEQUEUE(&ic->ic_mgtq, m0); if (m0 != NULL) { - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; } else { /* send no data packets until we are associated */ if (ic->ic_state != IEEE80211_S_RUN) Index: dev/ic/bwi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/bwi.c,v retrieving revision 1.100 diff -u -p -r1.100 bwi.c --- dev/ic/bwi.c 6 Dec 2013 21:03:02 -0000 1.100 +++ dev/ic/bwi.c 14 Mar 2014 11:49:43 -0000 @@ -7202,8 +7202,7 @@ bwi_start(struct ifnet *ifp) if (m != NULL) { IF_DEQUEUE(&ic->ic_mgtq, m); - ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; mgt_pkt = 1; } else { Index: dev/ic/malo.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/malo.c,v retrieving revision 1.97 diff -u -p -r1.97 malo.c --- dev/ic/malo.c 6 Dec 2013 21:03:03 -0000 1.97 +++ dev/ic/malo.c 14 Mar 2014 11:49:43 -0000 @@ -1026,8 +1026,7 @@ malo_start(struct ifnet *ifp) } IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m0, BPF_DIRECTION_OUT); Index: dev/ic/rt2560.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/rt2560.c,v retrieving revision 1.62 diff -u -p -r1.62 rt2560.c --- dev/ic/rt2560.c 6 Dec 2013 21:03:03 -0000 1.62 +++ dev/ic/rt2560.c 14 Mar 2014 11:49:43 -0000 @@ -1945,8 +1945,7 @@ rt2560_start(struct ifnet *ifp) } IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m0, BPF_DIRECTION_OUT); Index: dev/ic/rt2661.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/rt2661.c,v retrieving revision 1.71 diff -u -p -r1.71 rt2661.c --- dev/ic/rt2661.c 11 Mar 2014 19:45:28 -0000 1.71 +++ dev/ic/rt2661.c 14 Mar 2014 11:49:43 -0000 @@ -1947,8 +1947,7 @@ rt2661_start(struct ifnet *ifp) } IF_DEQUEUE(&ic->ic_mgtq, m0); - ni = (struct ieee80211_node *)m0->m_pkthdr.rcvif; - m0->m_pkthdr.rcvif = NULL; + ni = (struct ieee80211_node *)m0->m_pkthdr.ni; #if NBPFILTER > 0 if (ic->ic_rawbpf != NULL) bpf_mtap(ic->ic_rawbpf, m0, BPF_DIRECTION_OUT); Index: dev/ic/rt2860.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/rt2860.c,v retrieving revision 1.71 diff -u -p -r1.71 rt2860.c --- dev/ic/rt2860.c 6 Dec 2013 21:03:03 -0000 1.71 +++ dev/ic/rt2860.c 14 Mar 2014 11:49:43 -0000 @@ -1758,7 +1758,7 @@ rt2860_start(struct ifnet *ifp) /* send pending management frames first */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) @@ -1767,7 +1767,7 @@ rt2860_start(struct ifnet *ifp) /* send buffered frames for power-save mode */ IF_DEQUEUE(&ic->ic_pwrsaveq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } Index: dev/ic/rtw.c =================================================================== RCS file: /home/ncvs/src/sys/dev/ic/rtw.c,v retrieving revision 1.83 diff -u -p -r1.83 rtw.c --- dev/ic/rtw.c 26 Nov 2013 09:50:33 -0000 1.83 +++ dev/ic/rtw.c 14 Mar 2014 11:49:43 -0000 @@ -1504,7 +1504,7 @@ rtw_intr_beacon(struct rtw_softc *sc, u_ sc->sc_dev.dv_xname); return; } - m->m_pkthdr.rcvif = (void *)ieee80211_ref_node(ic->ic_bss); + m->m_pkthdr.ni = ieee80211_ref_node(ic->ic_bss); IF_ENQUEUE(&sc->sc_beaconq, m); rtw_start(&sc->sc_if); } @@ -2706,8 +2706,7 @@ rtw_80211_dequeue(struct rtw_softc *sc, return NULL; } IF_DEQUEUE(ifq, m); - *nip = (struct ieee80211_node *)m->m_pkthdr.rcvif; - m->m_pkthdr.rcvif = NULL; + *nip = (struct ieee80211_node *)m->m_pkthdr.ni; return m; } Index: dev/pci/if_iwn.c =================================================================== RCS file: /home/ncvs/src/sys/dev/pci/if_iwn.c,v retrieving revision 1.130 diff -u -p -r1.130 if_iwn.c --- dev/pci/if_iwn.c 11 Feb 2014 19:44:22 -0000 1.130 +++ dev/pci/if_iwn.c 14 Mar 2014 11:49:43 -0000 @@ -3064,7 +3064,7 @@ iwn_start(struct ifnet *ifp) /* Send pending management frames first. */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN) Index: dev/pci/if_wpi.c =================================================================== RCS file: /home/ncvs/src/sys/dev/pci/if_wpi.c,v retrieving revision 1.117 diff -u -p -r1.117 if_wpi.c --- dev/pci/if_wpi.c 6 Dec 2013 21:03:04 -0000 1.117 +++ dev/pci/if_wpi.c 14 Mar 2014 11:49:43 -0000 @@ -1926,7 +1926,7 @@ wpi_start(struct ifnet *ifp) /* Send pending management frames first. */ IF_DEQUEUE(&ic->ic_mgtq, m); if (m != NULL) { - ni = (void *)m->m_pkthdr.rcvif; + ni = (struct ieee80211_node *)m->m_pkthdr.ni; goto sendit; } if (ic->ic_state != IEEE80211_S_RUN)