--- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_input.h 2016-05-25 15:26:27.000000000 -0700 +++ ./ieee80211_input.h 2016-06-08 13:40:34.000000000 -0700 @@ -45,8 +45,8 @@ #define IEEE80211_VERIFY_LENGTH(_len, _minlen, _action) do { \ if ((_len) < (_minlen)) { \ IEEE80211_DISCARD(vap, IEEE80211_MSG_ELEMID, \ - wh, NULL, "ie too short, got %d, expected %d", \ - (_len), (_minlen)); \ + wh, NULL, "ie too short, got %ld, expected %ld", \ + (long)(_len), (long)(_minlen)); \ vap->iv_stats.is_rx_elem_toosmall++; \ _action; \ } \ --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ioctl.h 2017-01-17 13:55:20.000000000 -0800 +++ ./ieee80211_ioctl.h 2016-06-08 13:40:34.000000000 -0700 @@ -31,9 +31,9 @@ /* * IEEE 802.11 ioctls. */ -#include -#include -#include +#include +#include +#include /* * Per/node (station) statistics. @@ -578,7 +578,7 @@ uint16_t sv_vlan; }; -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__DragonFly__) /* * FreeBSD-style ioctls. */ --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_node.h 2017-01-17 13:55:20.000000000 -0800 +++ ./ieee80211_node.h 2016-06-08 13:40:34.000000000 -0700 @@ -28,8 +28,8 @@ #ifndef _NET80211_IEEE80211_NODE_H_ #define _NET80211_IEEE80211_NODE_H_ -#include /* for ieee80211_nodestats */ -#include /* for aggregation state */ +#include /* for ieee80211_nodestats */ +#include /* for aggregation state */ /* * Each ieee80211com instance has a single timer that fires every --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_proto.h 2017-01-17 13:55:20.000000000 -0800 +++ ./ieee80211_proto.h 2016-06-08 13:40:34.000000000 -0700 @@ -73,12 +73,21 @@ void ieee80211_proto_vattach(struct ieee80211vap *); void ieee80211_proto_vdetach(struct ieee80211vap *); +#if defined(__DragonFly__) +void ieee80211_promisc(struct ieee80211vap *, int); +void ieee80211_allmulti(struct ieee80211vap *, int); +#else void ieee80211_promisc(struct ieee80211vap *, bool); void ieee80211_allmulti(struct ieee80211vap *, bool); +#endif void ieee80211_syncflag(struct ieee80211vap *, int flag); void ieee80211_syncflag_ht(struct ieee80211vap *, int flag); void ieee80211_syncflag_ext(struct ieee80211vap *, int flag); +#if defined(__DragonFly__) +struct route; +#endif + #define ieee80211_input(ni, m, rssi, nf) \ ((ni)->ni_vap->iv_input(ni, m, NULL, rssi, nf)) int ieee80211_input_all(struct ieee80211com *, struct mbuf *, int, int); @@ -93,8 +102,13 @@ struct ieee80211_bpf_params *); int ieee80211_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); +#if defined(__DragonFly__) +int ieee80211_output(struct ifnet *, struct mbuf *, + struct sockaddr *, struct rtentry *rt); +#else int ieee80211_output(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *ro); +#endif int ieee80211_vap_pkt_send_dest(struct ieee80211vap *, struct mbuf *, struct ieee80211_node *); int ieee80211_raw_output(struct ieee80211vap *, struct ieee80211_node *, @@ -102,6 +116,9 @@ void ieee80211_send_setup(struct ieee80211_node *, struct mbuf *, int, int, const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN]); +#if defined(__DragonFly__) +void ieee80211_vap_start(struct ifnet *ifp, struct ifaltq_subque *ifsq); +#endif int ieee80211_vap_transmit(struct ifnet *ifp, struct mbuf *m); void ieee80211_vap_qflush(struct ifnet *ifp); int ieee80211_send_nulldata(struct ieee80211_node *); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ratectl.h 2017-01-17 13:55:20.000000000 -0800 +++ ./ieee80211_ratectl.h 2016-06-08 13:40:34.000000000 -0700 @@ -85,7 +85,7 @@ vap->iv_rate->ir_node_deinit(ni); } -static int __inline +static __inline int ieee80211_ratectl_rate(struct ieee80211_node *ni, void *arg, uint32_t iarg) { const struct ieee80211vap *vap = ni->ni_vap; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_var.h 2017-01-17 13:55:20.000000000 -0800 +++ ./ieee80211_var.h 2017-01-16 21:27:43.000000000 -0800 @@ -33,27 +33,29 @@ */ /* NB: portability glue must go first */ #if defined(__NetBSD__) -#include +#include #elif defined(__FreeBSD__) -#include +#include +#elif defined(__DragonFly__) +#include #elif defined(__linux__) -#include +#include #else #error "No support for your operating system!" #endif -#include -#include -#include -#include -#include -#include /* for ieee80211_stats */ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* for ieee80211_stats */ +#include +#include +#include +#include +#include +#include #define IEEE80211_TXPOWER_MAX 100 /* .5 dBm (XXX units?) */ #define IEEE80211_TXPOWER_MIN 0 /* kill radio */ @@ -137,8 +139,13 @@ struct task ic_wme_task; /* deferred WME update */ struct task ic_restart_task; /* deferred device restart */ +#if defined(__DragonFly__) + uint64_t ic_ierrors; /* input errors */ + uint64_t ic_oerrors; /* output errors */ +#else counter_u64_t ic_ierrors; /* input errors */ counter_u64_t ic_oerrors; /* output errors */ +#endif uint32_t ic_flags; /* state flags */ uint32_t ic_flags_ext; /* extended state flags */ @@ -520,8 +527,13 @@ int (*iv_newstate)(struct ieee80211vap *, enum ieee80211_state, int); /* 802.3 output method for raw frame xmit */ +#if defined(__DragonFly__) + int (*iv_output)(struct ifnet *, struct mbuf *, + struct sockaddr *, struct rtentry *); +#else int (*iv_output)(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *); +#endif uint64_t iv_spare[6]; }; MALLOC_DECLARE(M_80211_VAP); @@ -600,11 +612,12 @@ #define IEEE80211_FEXT_WDSLEGACY 0x00010000 /* CONF: legacy WDS operation */ #define IEEE80211_FEXT_PROBECHAN 0x00020000 /* CONF: probe passive channel*/ #define IEEE80211_FEXT_UNIQMAC 0x00040000 /* CONF: user or computed mac */ +#define IEEE80211_FEXT_SCAN_OFFLOAD 0x00080000 /* CONF: scan is fully offloaded */ #define IEEE80211_FEXT_BITS \ "\20\2INACT\3SCANWAIT\4BGSCAN\5WPS\6TSN\7SCANREQ\10RESUME" \ "\0114ADDR\12NONEPR_PR\13SWBMISS\14DFS\15DOTD\16STATEWAIT\17REINIT" \ - "\20BPF\21WDSLEGACY\22PROBECHAN\23UNIQMAC" + "\20BPF\21WDSLEGACY\22PROBECHAN\23UNIQMAC\24SCAN_OFFLOAD" /* ic_flags_ht/iv_flags_ht */ #define IEEE80211_FHT_NONHT_PR 0x00000001 /* STATUS: non-HT sta present */ @@ -716,7 +729,11 @@ struct ieee80211com *ieee80211_find_com(const char *name); int ieee80211_media_change(struct ifnet *); void ieee80211_media_status(struct ifnet *, struct ifmediareq *); +#if defined(__DragonFly__) +int ieee80211_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *); +#else int ieee80211_ioctl(struct ifnet *, u_long, caddr_t); +#endif int ieee80211_rate2media(struct ieee80211com *, int, enum ieee80211_phymode); int ieee80211_media2rate(int); @@ -949,11 +966,14 @@ if (ieee80211_msg(_vap, _m)) \ ieee80211_note_frame(_vap, _wh, _fmt, __VA_ARGS__); \ } while (0) -void ieee80211_note(const struct ieee80211vap *, const char *, ...); +void ieee80211_note(const struct ieee80211vap *, const char *, ...) + __printflike(2, 3); void ieee80211_note_mac(const struct ieee80211vap *, - const uint8_t mac[IEEE80211_ADDR_LEN], const char *, ...); + const uint8_t mac[IEEE80211_ADDR_LEN], const char *, ...) + __printflike(3, 4); void ieee80211_note_frame(const struct ieee80211vap *, - const struct ieee80211_frame *, const char *, ...); + const struct ieee80211_frame *, const char *, ...) + __printflike(3, 4); #define ieee80211_msg_debug(_vap) \ ((_vap)->iv_debug & IEEE80211_MSG_DEBUG) #define ieee80211_msg_dumppkts(_vap) \ @@ -991,12 +1011,15 @@ } while (0) void ieee80211_discard_frame(const struct ieee80211vap *, - const struct ieee80211_frame *, const char *type, const char *fmt, ...); + const struct ieee80211_frame *, const char *type, const char *fmt, ...) + __printflike(4, 5); void ieee80211_discard_ie(const struct ieee80211vap *, - const struct ieee80211_frame *, const char *type, const char *fmt, ...); + const struct ieee80211_frame *, const char *type, const char *fmt, ...) + __printflike(4, 5); void ieee80211_discard_mac(const struct ieee80211vap *, const uint8_t mac[IEEE80211_ADDR_LEN], const char *type, - const char *fmt, ...); + const char *fmt, ...) + __printflike(4, 5); #else #define IEEE80211_DPRINTF(_vap, _m, _fmt, ...) #define IEEE80211_NOTE(_vap, _m, _ni, _fmt, ...) --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211.c 2016-06-08 13:40:34.000000000 -0700 @@ -48,12 +48,12 @@ #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif -#include +#include #include @@ -95,7 +95,10 @@ ifm_change_cb_t media_change, ifm_stat_cb_t media_stat); static int media_status(enum ieee80211_opmode, const struct ieee80211_channel *); +#if defined(__DragonFly__) +#else static uint64_t ieee80211_get_counter(struct ifnet *, ift_counter); +#endif MALLOC_DEFINE(M_80211_VAP, "80211vap", "802.11 vap state"); @@ -248,6 +251,15 @@ int ic_printf(struct ieee80211com *ic, const char * fmt, ...) { +#if defined(__DragonFly__) + osdep_va_list ap; + int retval; + + retval = kprintf("%s: ", ic->ic_name); + osdep_va_start(ap, fmt); + retval += kvprintf(fmt, ap); + osdep_va_end(ap); +#else va_list ap; int retval; @@ -255,12 +267,18 @@ va_start(ap, fmt); retval += vprintf(fmt, ap); va_end(ap); +#endif return (retval); } static LIST_HEAD(, ieee80211com) ic_head = LIST_HEAD_INITIALIZER(ic_head); +#if defined(__DragonFly__) +static struct lock ic_list_lock = + LOCK_INITIALIZER("80211list", 0, LK_CANRECURSE); +#else static struct mtx ic_list_mtx; MTX_SYSINIT(ic_list, &ic_list_mtx, "ieee80211com list", MTX_DEF); +#endif static int sysctl_ieee80211coms(SYSCTL_HANDLER_ARGS) @@ -270,26 +288,47 @@ char *sp; int error; +#if defined(__DragonFly__) +#else error = sysctl_wire_old_buffer(req, 0); if (error) return (error); +#endif sbuf_new_for_sysctl(&sb, NULL, 8, req); +#if defined(__DragonFly__) +#else sbuf_clear_flags(&sb, SBUF_INCLUDENUL); +#endif sp = ""; +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_EXCLUSIVE); +#else mtx_lock(&ic_list_mtx); +#endif LIST_FOREACH(ic, &ic_head, ic_next) { sbuf_printf(&sb, "%s%s", sp, ic->ic_name); sp = " "; } +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_RELEASE); +#else mtx_unlock(&ic_list_mtx); +#endif error = sbuf_finish(&sb); sbuf_delete(&sb); return (error); } +#if defined(__DragonFly__) +SYSCTL_PROC(_net_wlan, OID_AUTO, devices, + CTLTYPE_STRING | CTLFLAG_RD, NULL, 0, + sysctl_ieee80211coms, "A", "names of available 802.11 devices"); +#else SYSCTL_PROC(_net_wlan, OID_AUTO, devices, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_ieee80211coms, "A", "names of available 802.11 devices"); +#endif + /* * Attach/setup the common net80211 state. Called by @@ -306,10 +345,15 @@ /* Create a taskqueue for all state changes */ ic->ic_tq = taskqueue_create("ic_taskq", M_WAITOK | M_ZERO, taskqueue_thread_enqueue, &ic->ic_tq); +#if defined(__DragonFly__) + taskqueue_start_threads(&ic->ic_tq, 1, TDPRI_KERN_DAEMON, -1, + "%s net80211 taskq", ic->ic_name); +#else taskqueue_start_threads(&ic->ic_tq, 1, PI_NET, "%s net80211 taskq", ic->ic_name); ic->ic_ierrors = counter_u64_alloc(M_WAITOK); ic->ic_oerrors = counter_u64_alloc(M_WAITOK); +#endif /* * Fill in 802.11 available channel set, mark all * available channels as active, and pick a default @@ -340,9 +384,17 @@ ieee80211_sysctl_attach(ic); +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_EXCLUSIVE); +#else mtx_lock(&ic_list_mtx); +#endif LIST_INSERT_HEAD(&ic_head, ic, ic_next); +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_RELEASE); +#else mtx_unlock(&ic_list_mtx); +#endif } /* @@ -356,11 +408,27 @@ { struct ieee80211vap *vap; +#if defined(__DragonFly__) + wlan_serialize_enter(); +#endif + +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_EXCLUSIVE); +#else mtx_lock(&ic_list_mtx); +#endif LIST_REMOVE(ic, ic_next); +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_RELEASE); +#else mtx_unlock(&ic_list_mtx); +#endif +#if defined(__DragonFly__) + taskqueue_drain(taskqueue_thread[0], &ic->ic_restart_task); +#else taskqueue_drain(taskqueue_thread, &ic->ic_restart_task); +#endif /* * The VAP is responsible for setting and clearing @@ -384,12 +452,19 @@ ieee80211_power_detach(ic); ieee80211_node_detach(ic); +#if defined(__DragonFly__) +#else counter_u64_free(ic->ic_ierrors); counter_u64_free(ic->ic_oerrors); +#endif taskqueue_free(ic->ic_tq); IEEE80211_TX_LOCK_DESTROY(ic); IEEE80211_LOCK_DESTROY(ic); + +#if defined(__DragonFly__) + wlan_serialize_exit(); +#endif } struct ieee80211com * @@ -397,11 +472,20 @@ { struct ieee80211com *ic; +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_EXCLUSIVE); +#else mtx_lock(&ic_list_mtx); - LIST_FOREACH(ic, &ic_head, ic_next) +#endif + LIST_FOREACH(ic, &ic_head, ic_next) { if (strcmp(ic->ic_name, name) == 0) break; + } +#if defined(__DragonFly__) + lockmgr(&ic_list_lock, LK_RELEASE); +#else mtx_unlock(&ic_list_mtx); +#endif return (ic); } @@ -421,6 +505,8 @@ return ENETRESET; } +#if defined(__DragonFly__) +#else /* * Add underlying device errors to vap errors. */ @@ -446,6 +532,8 @@ return (rv); } +#endif + /* * Prepare a vap for use. Drivers use this call to * setup net80211 state in new vap's prior attaching @@ -467,11 +555,18 @@ if_initname(ifp, name, unit); ifp->if_softc = vap; /* back pointer */ ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; +#if defined(__DragonFly__) + ifp->if_start = ieee80211_vap_start; +#else ifp->if_transmit = ieee80211_vap_transmit; ifp->if_qflush = ieee80211_vap_qflush; +#endif ifp->if_ioctl = ieee80211_ioctl; ifp->if_init = ieee80211_init; +#if defined(__DragonFly__) +#else ifp->if_get_counter = ieee80211_get_counter; +#endif vap->iv_ifp = ifp; vap->iv_ic = ic; @@ -532,9 +627,17 @@ if (vap->iv_caps & IEEE80211_C_BURST) vap->iv_flags |= IEEE80211_F_BURST; /* NB: bg scanning only makes sense for station mode right now */ +#if defined(__DragonFly__) + /* + * DISABLE BGSCAN BY DEFAULT, many issues can crop up including + * the link going dead. + */ + /* empty */ +#else if (vap->iv_opmode == IEEE80211_M_STA && (vap->iv_caps & IEEE80211_C_BGSCAN)) vap->iv_flags |= IEEE80211_F_BGSCAN; +#endif vap->iv_flags |= IEEE80211_F_DOTH; /* XXX no cap, just ena */ /* NB: DFS support only makes sense for ap mode right now */ if (vap->iv_opmode == IEEE80211_M_HOSTAP && @@ -581,6 +684,13 @@ struct ifmediareq imr; int maxrate; +#if defined(__DragonFly__) + /* + * This function must _not_ be serialized by the WLAN serializer, + * since it could dead-lock the domsg to netisrs in ether_ifattach(). + */ + wlan_assert_notserialized(); +#endif IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s parent %s flags 0x%x flags_ext 0x%x\n", __func__, ieee80211_opmode_name[vap->iv_opmode], @@ -602,7 +712,11 @@ if (maxrate) ifp->if_baudrate = IF_Mbps(maxrate); +#if defined(__DragonFly__) + ether_ifattach(ifp, macaddr, &wlan_global_serializer); +#else ether_ifattach(ifp, macaddr); +#endif IEEE80211_ADDR_COPY(vap->iv_myaddr, IF_LLADDR(ifp)); /* hook output method setup by ether_ifattach */ vap->iv_output = ifp->if_output; @@ -636,6 +750,13 @@ struct ieee80211com *ic = vap->iv_ic; struct ifnet *ifp = vap->iv_ifp; +#if defined(__DragonFly__) + /* + * This function must _not_ be serialized by the WLAN serializer, + * since it could dead-lock the domsg to netisrs in ether_ifdettach(). + */ + wlan_assert_notserialized(); +#endif CURVNET_SET(ifp->if_vnet); IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s parent %s\n", @@ -652,8 +773,12 @@ ieee80211_draintask(ic, &vap->iv_nstate_task); ieee80211_draintask(ic, &vap->iv_swbmiss_task); +#if defined(__DragonFly__) + /* XXX hmm, not sure what we should do here */ +#else /* XXX band-aid until ifnet handles this for us */ taskqueue_drain(taskqueue_swi, &ifp->if_linktask); +#endif IEEE80211_LOCK(ic); KASSERT(vap->iv_state == IEEE80211_S_INIT , ("vap still running")); @@ -668,10 +793,17 @@ ieee80211_syncflag_ht_locked(ic, IEEE80211_FHT_USEHT40); /* NB: this handles the bpfdetach done below */ ieee80211_syncflag_ext_locked(ic, IEEE80211_FEXT_BPF); +#if defined(__DragonFly__) + if (vap->iv_ifflags & IFF_PROMISC) + ieee80211_promisc(vap, 0); + if (vap->iv_ifflags & IFF_ALLMULTI) + ieee80211_allmulti(vap, 0); +#else if (vap->iv_ifflags & IFF_PROMISC) ieee80211_promisc(vap, false); if (vap->iv_ifflags & IFF_ALLMULTI) ieee80211_allmulti(vap, false); +#endif IEEE80211_UNLOCK(ic); ifmedia_removeall(&vap->iv_media); @@ -699,8 +831,13 @@ * Count number of vaps in promisc, and issue promisc on * parent respectively. */ +#if defined(__DragonFly__) +void +ieee80211_promisc(struct ieee80211vap *vap, int on) +#else void ieee80211_promisc(struct ieee80211vap *vap, bool on) +#endif { struct ieee80211com *ic = vap->iv_ic; @@ -721,8 +858,13 @@ * Count number of vaps in allmulti, and issue allmulti on * parent respectively. */ +#if defined(__DragonFly__) +void +ieee80211_allmulti(struct ieee80211vap *vap, int on) +#else void ieee80211_allmulti(struct ieee80211vap *vap, bool on) +#endif { struct ieee80211com *ic = vap->iv_ic; @@ -1169,6 +1311,9 @@ uint16_t freq; int i, j, error; +#if defined(__DragonFly__) + error = 0; /* work-around GCC uninitialized variable warning */ +#endif for (i = 0; i < nieee; i++) { freq = ieee80211_ieee2mhz(ieee[i], flags[0]); for (j = 0; flags[j] != 0; j++) { @@ -1499,10 +1644,10 @@ if (mword == 0) continue; rate = ieee80211_media2rate(mword); - printf("%s%d%sMbps", (i != 0 ? " " : ""), + kprintf("%s%d%sMbps", (i != 0 ? " " : ""), rate / 2, ((rate & 0x1) != 0 ? ".5" : "")); } - printf("\n"); + kprintf("\n"); } ieee80211_ht_announce(ic); } @@ -1514,7 +1659,7 @@ char type; int i, cw; - printf("Chan Freq CW RegPwr MinPwr MaxPwr\n"); + kprintf("Chan Freq CW RegPwr MinPwr MaxPwr\n"); for (i = 0; i < ic->ic_nchans; i++) { c = &ic->ic_channels[i]; if (IEEE80211_IS_CHAN_ST(c)) @@ -1541,7 +1686,7 @@ cw = 5; else cw = 20; - printf("%4d %4d%c %2d%c %6d %4d.%d %4d.%d\n" + kprintf("%4d %4d%c %2d%c %6d %4d.%d %4d.%d\n" , c->ic_ieee, c->ic_freq, type , cw , IEEE80211_IS_CHAN_HT40U(c) ? '+' : @@ -1773,7 +1918,7 @@ return IEEE80211_MODE_FH; /* NB: should not get here */ - printf("%s: cannot map channel to mode; freq %u flags 0x%x\n", + kprintf("%s: cannot map channel to mode; freq %u flags 0x%x\n", __func__, chan->ic_freq, chan->ic_flags); return IEEE80211_MODE_11B; } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_action.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_action.c 2016-06-08 13:40:34.000000000 -0700 @@ -47,9 +47,9 @@ #include #include -#include -#include -#include +#include +#include +#include static int send_inval(struct ieee80211_node *ni, int cat, int act, void *sa) --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_adhoc.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_adhoc.c 2016-06-08 13:40:34.000000000 -0700 @@ -55,16 +55,16 @@ #include -#include -#include -#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif -#include +#include #define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2) @@ -224,7 +224,7 @@ ieee80211_print_essid(vap->iv_bss->ni_essid, ni->ni_esslen); /* XXX MCS/HT */ - printf(" channel %d start %uMb\n", + kprintf(" channel %d start %uMb\n", ieee80211_chan2ieee(ic, ic->ic_curchan), IEEE80211_RATE2MBS(ni->ni_txrate)); } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ageq.c 2016-03-14 16:15:53.000000000 -0700 +++ ./wlan/ieee80211_ageq.c 2016-06-08 13:40:34.000000000 -0700 @@ -43,7 +43,7 @@ #include #include -#include +#include /* * Initialize an ageq. --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_alq.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_alq.c 2016-06-08 13:40:34.000000000 -0700 @@ -56,9 +56,9 @@ #include #include -#include -#include -#include +#include +#include +#include static struct alq *ieee80211_alq; static int ieee80211_alq_lost; @@ -83,7 +83,7 @@ ieee80211_alq_qsize); ieee80211_alq_lost = 0; ieee80211_alq_logged = 0; - printf("net80211: logging to %s enabled; " + kprintf("net80211: logging to %s enabled; " "struct size %d bytes\n", ieee80211_alq_logfile, sizeof(struct ieee80211_alq_rec)); @@ -91,7 +91,7 @@ if (ieee80211_alq) alq_close(ieee80211_alq); ieee80211_alq = NULL; - printf("net80211: logging disabled\n"); + kprintf("net80211: logging disabled\n"); error = 0; } return (error); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_amrr.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_amrr.c 2016-06-08 13:40:34.000000000 -0700 @@ -49,10 +49,10 @@ #include #endif -#include -#include -#include -#include +#include +#include +#include +#include #define is_success(amn) \ ((amn)->amn_retrycnt < (amn)->amn_txcnt / 10) @@ -117,8 +117,13 @@ KASSERT(vap->iv_rs == NULL, ("%s called multiple times", __func__)); +#if defined(__DragonFly__) + amrr = vap->iv_rs = kmalloc(sizeof(struct ieee80211_amrr), + M_80211_RATECTL, M_INTWAIT|M_ZERO); +#else amrr = vap->iv_rs = IEEE80211_MALLOC(sizeof(struct ieee80211_amrr), M_80211_RATECTL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (amrr == NULL) { if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n"); return; @@ -164,8 +169,13 @@ uint8_t rate; if (ni->ni_rctls == NULL) { +#if defined(__DragonFly__) + ni->ni_rctls = amn = kmalloc(sizeof(struct ieee80211_amrr_node), + M_80211_RATECTL, M_INTWAIT|M_ZERO); +#else ni->ni_rctls = amn = IEEE80211_MALLOC(sizeof(struct ieee80211_amrr_node), M_80211_RATECTL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (amn == NULL) { if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl " "structure\n"); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_crypto.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_crypto.c 2016-06-08 13:40:34.000000000 -0700 @@ -43,7 +43,7 @@ #include #include /* XXX ETHER_HDR_LEN */ -#include +#include MALLOC_DEFINE(M_80211_CRYPTO, "80211crypto", "802.11 crypto state"); @@ -193,12 +193,12 @@ ieee80211_crypto_register(const struct ieee80211_cipher *cip) { if (cip->ic_cipher >= IEEE80211_CIPHER_MAX) { - printf("%s: cipher %s has an invalid cipher index %u\n", + kprintf("%s: cipher %s has an invalid cipher index %u\n", __func__, cip->ic_name, cip->ic_cipher); return; } if (ciphers[cip->ic_cipher] != NULL && ciphers[cip->ic_cipher] != cip) { - printf("%s: cipher %s registered with a different template\n", + kprintf("%s: cipher %s registered with a different template\n", __func__, cip->ic_name); return; } @@ -212,12 +212,12 @@ ieee80211_crypto_unregister(const struct ieee80211_cipher *cip) { if (cip->ic_cipher >= IEEE80211_CIPHER_MAX) { - printf("%s: cipher %s has an invalid cipher index %u\n", + kprintf("%s: cipher %s has an invalid cipher index %u\n", __func__, cip->ic_name, cip->ic_cipher); return; } if (ciphers[cip->ic_cipher] != NULL && ciphers[cip->ic_cipher] != cip) { - printf("%s: cipher %s registered with a different template\n", + kprintf("%s: cipher %s registered with a different template\n", __func__, cip->ic_name); return; } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_crypto_none.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_crypto_none.c 2016-06-08 13:40:34.000000000 -0700 @@ -44,7 +44,7 @@ #include #include -#include +#include static void *none_attach(struct ieee80211vap *, struct ieee80211_key *); static void none_detach(struct ieee80211_key *); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ddb.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_ddb.c 2016-06-08 13:40:34.000000000 -0700 @@ -45,14 +45,17 @@ #include #include #include +#if defined(__DragonFly__) +#else #include +#endif -#include +#include #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif #include @@ -159,6 +162,10 @@ _db_show_com(ic, showvaps, showsta, showmesh, showprocs); } +#if defined(__DragonFly__) +/* EMPTY */ +#else + DB_SHOW_ALL_COMMAND(vaps, db_show_all_vaps) { VNET_ITERATOR_DECL(vnet_iter); @@ -206,6 +213,8 @@ } #endif /* IEEE80211_SUPPORT_MESH */ +#endif + static void _db_show_txampdu(const char *sep, int ix, const struct ieee80211_tx_ampdu *tap) { @@ -886,8 +895,14 @@ db_printf("routing table:\n"); i = 0; TAILQ_FOREACH(rt, &ms->ms_routes, rt_next) { +#if defined(__DragonFly__) + db_printf("entry %d:\tdest: %s nexthop: %s metric: %u", i, + ether_sprintf(rt->rt_dest), ether_sprintf(rt->rt_nexthop), + rt->rt_metric); +#else db_printf("entry %d:\tdest: %6D nexthop: %6D metric: %u", i, rt->rt_dest, ":", rt->rt_nexthop, ":", rt->rt_metric); +#endif db_printf("\tlifetime: %u lastseq: %u priv: %p\n", ieee80211_mesh_rt_update(rt, 0), --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_dfs.c 2016-05-25 15:26:27.000000000 -0700 +++ ./wlan/ieee80211_dfs.c 2016-06-08 13:40:34.000000000 -0700 @@ -52,9 +52,7 @@ #include #include -#include - -static MALLOC_DEFINE(M_80211_DFS, "80211dfs", "802.11 DFS state"); +#include static int ieee80211_nol_timeout = 30*60; /* 30 minutes */ SYSCTL_INT(_net_wlan, OID_AUTO, nol_timeout, CTLFLAG_RW, @@ -267,7 +265,12 @@ } if (oldest != now) { /* arrange to process next channel up for a status change */ +#if defined(__DragonFly__) + callout_schedule_dfly(&dfs->nol_timer, oldest + NOL_TIMEOUT - now, + dfs_timeout, ic); +#else callout_schedule(&dfs->nol_timer, oldest + NOL_TIMEOUT - now); +#endif } } @@ -367,7 +370,11 @@ announce_radar(ic, chan, dfs->newchan); if (callout_pending(&dfs->cac_timer)) +#if defined(__DragonFly__) + callout_schedule_dfly(&dfs->cac_timer, 0, cac_timeout, dfs->cac_timer.c_arg); +#else callout_schedule(&dfs->cac_timer, 0); +#endif else if (dfs->newchan != NULL) { /* XXX mode 1, switch count 2 */ /* XXX calculate switch count based on max --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_hostap.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_hostap.c 2016-06-08 13:40:34.000000000 -0700 @@ -55,13 +55,13 @@ #include -#include -#include -#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif -#include +#include #define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2) @@ -310,7 +310,7 @@ ieee80211_print_essid(ni->ni_essid, ni->ni_esslen); /* XXX MCS/HT */ - printf(" channel %d start %uMb\n", + kprintf(" channel %d start %uMb\n", ieee80211_chan2ieee(ic, ic->ic_curchan), IEEE80211_RATE2MBS(ni->ni_txrate)); } @@ -357,8 +357,12 @@ struct ifnet *ifp = vap->iv_ifp; /* clear driver/net80211 flags before passing up */ +#if defined(__DragonFly__) + m->m_flags &= ~(M_80211_RX | M_MCAST | M_BCAST); +#else m->m_flags &= ~(M_MCAST | M_BCAST); m_clrprotoflags(m); +#endif KASSERT(vap->iv_opmode == IEEE80211_M_HOSTAP, ("gack, opmode %d", vap->iv_opmode)); @@ -437,10 +441,19 @@ } if (ni->ni_vlan != 0) { /* attach vlan tag */ +#if defined(__DragonFly__) + /* XXX ntohs() needed? */ + m->m_pkthdr.ether_vlantag = ni->ni_vlan; +#else m->m_pkthdr.ether_vtag = ni->ni_vlan; +#endif m->m_flags |= M_VLANTAG; } +#if defined(__DragonFly__) + ifp->if_input(ifp, m, NULL, -1); +#else ifp->if_input(ifp, m); +#endif } } @@ -1022,7 +1035,7 @@ if ((frm[1] + 2) > (efrm - frm)) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, ni->ni_macaddr, "shared key auth", - "ie %d/%d too long", + "ie %d/%ld too long", frm[0], (frm[1] + 2) - (efrm - frm)); vap->iv_stats.is_rx_bad_auth++; estatus = IEEE80211_STATUS_CHALLENGE; @@ -1614,7 +1627,7 @@ int reassoc, int resp) { IEEE80211_NOTE_MAC(ni->ni_vap, IEEE80211_MSG_ANY, wh->i_addr2, - "deny %s request, %s missing HT ie", reassoc ? "reassoc" : "assoc"); + "deny %s request, missing HT ie", reassoc ? "reassoc" : "assoc"); /* XXX no better code */ IEEE80211_SEND_MGMT(ni, resp, IEEE80211_STATUS_MISSING_HT_CAPS); ieee80211_node_leave(ni); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ht.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_ht.c 2016-06-08 13:40:34.000000000 -0700 @@ -48,9 +48,9 @@ #include #include -#include -#include -#include +#include +#include +#include /* define here, used throughout file */ #define MS(_v, _f) (((_v) & _f) >> _f##_S) @@ -1716,7 +1716,11 @@ static void ampdu_tx_setup(struct ieee80211_tx_ampdu *tap) { +#if defined(__DragonFly__) + callout_init_mp(&tap->txa_timer); +#else callout_init(&tap->txa_timer, 1); +#endif tap->txa_flags |= IEEE80211_AGGR_SETUP; tap->txa_lastsample = ticks; } @@ -2034,8 +2038,8 @@ IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_11N, ni->ni_macaddr, "ADDBA response", - "policy mismatch: expecting %s, " - "received %s, tid %d code %d", + "policy mismatch: expecting %d, " + "received %d, tid %d code %d", tap->txa_flags & IEEE80211_AGGR_IMMEDIATE, policy, tid, code); vap->iv_stats.is_addba_badpolicy++; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_hwmp.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_hwmp.c 2016-06-08 13:40:34.000000000 -0700 @@ -59,10 +59,10 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include static void hwmp_vattach(struct ieee80211vap *); static void hwmp_vdetach(struct ieee80211vap *); @@ -256,14 +256,23 @@ KASSERT(vap->iv_opmode == IEEE80211_M_MBSS, ("not a mesh vap, opmode %d", vap->iv_opmode)); +#if defined(__DragonFly__) + hs = kmalloc(sizeof(struct ieee80211_hwmp_state), M_80211_VAP, + M_INTWAIT | M_ZERO); +#else hs = IEEE80211_MALLOC(sizeof(struct ieee80211_hwmp_state), M_80211_VAP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (hs == NULL) { - printf("%s: couldn't alloc HWMP state\n", __func__); + kprintf("%s: couldn't alloc HWMP state\n", __func__); return; } hs->hs_maxhops = IEEE80211_HWMP_DEFAULT_MAXHOPS; +#if defined(__DragonFly__) + callout_init_mp(&hs->hs_roottimer); +#else callout_init(&hs->hs_roottimer, 1); +#endif vap->iv_hwmp = hs; } @@ -417,10 +426,16 @@ vap->iv_stats.is_rx_mgtdiscard++; break; } +#if defined(__DragonFly__) + preq = kmalloc(sizeof(*preq) + + (ndest - 1) * sizeof(*preq->preq_targets), + M_80211_MESH_PREQ, M_INTWAIT | M_ZERO); +#else preq = IEEE80211_MALLOC(sizeof(*preq) + (ndest - 1) * sizeof(*preq->preq_targets), M_80211_MESH_PREQ, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif KASSERT(preq != NULL, ("preq == NULL")); preq->preq_ie = *iefrm_t++; @@ -465,9 +480,14 @@ vap->iv_stats.is_rx_mgtdiscard++; break; } +#if defined(__DragonFly__) + prep = kmalloc(sizeof(*prep), + M_80211_MESH_PREP, M_INTWAIT | M_ZERO); +#else prep = IEEE80211_MALLOC(sizeof(*prep), M_80211_MESH_PREP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif KASSERT(prep != NULL, ("prep == NULL")); prep->prep_ie = *iefrm_t++; @@ -505,10 +525,16 @@ vap->iv_stats.is_rx_mgtdiscard++; break; } +#if defined(__DragonFly__) + perr = kmalloc(sizeof(*perr) + + (ndest - 1) * sizeof(*perr->perr_dests), + M_80211_MESH_PERR, M_INTWAIT | M_ZERO); +#else perr = IEEE80211_MALLOC(sizeof(*perr) + (ndest - 1) * sizeof(*perr->perr_dests), M_80211_MESH_PERR, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif KASSERT(perr != NULL, ("perr == NULL")); perr->perr_ie = *iefrm_t++; @@ -907,9 +933,15 @@ if (rttran == NULL) { rttran = ieee80211_mesh_rt_add(vap, ni->ni_macaddr); if (rttran == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add path to transmitter %s of %s", + ether_sprintf(ni->ni_macaddr), hwmp_frame); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add path to transmitter %6D of %s", ni->ni_macaddr, ":", hwmp_frame); +#endif vap->iv_stats.is_mesh_rtaddfailed++; return; } @@ -918,11 +950,20 @@ if (!(rttran->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) || rttran->rt_metric > metric) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "%s path to transmitter %s of %s, metric %d:%d", + rttran->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? + "prefer" : "update", ether_sprintf(ni->ni_macaddr), + hwmp_frame, + rttran->rt_metric, metric); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "%s path to transmiter %6D of %s, metric %d:%d", rttran->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? "prefer" : "update", ni->ni_macaddr, ":", hwmp_frame, rttran->rt_metric, metric); +#endif IEEE80211_ADDR_COPY(rttran->rt_nexthop, ni->ni_macaddr); rttran->rt_metric = metric; rttran->rt_nhops = 1; @@ -956,9 +997,16 @@ if (IEEE80211_ADDR_EQ(vap->iv_myaddr, preq->preq_origaddr)) return; +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREQ, orig %s, targ(0) %s", + ether_sprintf(preq->preq_origaddr), + ether_sprintf(PREQ_TADDR(0))); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "received PREQ, orig %6D, targ(0) %6D", preq->preq_origaddr, ":", PREQ_TADDR(0), ":"); +#endif /* * Acceptance criteria: (if the PREQ is not for us or not broadcast, @@ -987,10 +1035,17 @@ if(preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_AM && rttarg == NULL && !IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0))) { +#if defined(__DragonFly__) + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_HWMP, + preq->preq_origaddr, NULL, + "unicast addressed PREQ of unknown target %s", + ether_sprintf(PREQ_TADDR(0))); +#else IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_HWMP, preq->preq_origaddr, NULL, "unicast addressed PREQ of unknown target %6D", PREQ_TADDR(0), ":"); +#endif return; } @@ -1000,14 +1055,26 @@ if (rtorig == NULL) { rtorig = ieee80211_mesh_rt_add(vap, preq->preq_origaddr); if (rtorig == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add orig path to %s", + ether_sprintf(preq->preq_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add orig path to %6D", preq->preq_origaddr, ":"); +#endif vap->iv_stats.is_mesh_rtaddfailed++; return; } +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "adding originator %s", + ether_sprintf(preq->preq_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "adding originator %6D", preq->preq_origaddr, ":"); +#endif } hrorig = IEEE80211_MESH_ROUTE_PRIV(rtorig, struct ieee80211_hwmp_route); @@ -1036,12 +1103,21 @@ !HWMP_SEQ_EQ(hrtarg->hr_seq, PREQ_TSEQ(0))) || (rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID && preqid >= preq->preq_id)) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "discard PREQ from %s, old seqno %u <= %u," + " or old preqid %u < %u", + ether_sprintf(preq->preq_origaddr), + preq->preq_origseq, hrorig->hr_seq, + preq->preq_id, preqid); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "discard PREQ from %6D, old seqno %u <= %u," " or old preqid %u < %u", preq->preq_origaddr, ":", preq->preq_origseq, hrorig->hr_seq, preq->preq_id, preqid); +#endif return; } @@ -1070,8 +1146,14 @@ IEEE80211_ADDR_COPY(prep.prep_targetaddr, vap->iv_myaddr); if (rttarg != NULL && /* if NULL it means we are the target */ rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "reply for proxy %s", + ether_sprintf(rttarg->rt_dest)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "reply for proxy %6D", rttarg->rt_dest, ":"); +#endif prep.prep_flags |= IEEE80211_MESHPREP_FLAGS_AE; IEEE80211_ADDR_COPY(prep.prep_target_ext_addr, rttarg->rt_dest); @@ -1090,8 +1172,13 @@ IEEE80211_ADDR_COPY(prep.prep_origaddr, preq->preq_origaddr); prep.prep_origseq = preq->preq_origseq; +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "reply to %s", ether_sprintf(preq->preq_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "reply to %6D", preq->preq_origaddr, ":"); +#endif hwmp_send_prep(vap, wh->i_addr2, &prep); return; } @@ -1103,9 +1190,15 @@ rtorig_ext = ieee80211_mesh_rt_add(vap, preq->preq_orig_ext_addr); if (rtorig_ext == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add orig ext proxy to %s", + ether_sprintf(preq->preq_orig_ext_addr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add orig ext proxy to %6D", preq->preq_orig_ext_addr, ":"); +#endif vap->iv_stats.is_mesh_rtaddfailed++; return; } @@ -1121,8 +1214,14 @@ */ if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr) && (PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "root mesh station @ %s", + ether_sprintf(preq->preq_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "root mesh station @ %6D", preq->preq_origaddr, ":"); +#endif /* Check if root is a mesh gate, mark it */ if (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_GATE) { @@ -1180,9 +1279,15 @@ !IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr)) { struct ieee80211_meshprep_ie prep; +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "intermediate reply for PREQ from %s", + ether_sprintf(preq->preq_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "intermediate reply for PREQ from %6D", preq->preq_origaddr, ":"); +#endif prep.prep_flags = 0; prep.prep_hopcount = rttarg->rt_nhops; prep.prep_ttl = ms->ms_ttl; @@ -1205,9 +1310,15 @@ } } +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "forward PREQ from %s", + ether_sprintf(preq->preq_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "forward PREQ from %6D", preq->preq_origaddr, ":"); +#endif ppreq.preq_hopcount += 1; ppreq.preq_ttl -= 1; ppreq.preq_metric += ms->ms_pmetric->mpm_metric(ni); @@ -1271,9 +1382,16 @@ uint32_t metric = 0; const uint8_t *addr; +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP, orig %s, targ %s", + ether_sprintf(prep->prep_origaddr), + ether_sprintf(prep->prep_targetaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "received PREP, orig %6D, targ %6D", prep->prep_origaddr, ":", prep->prep_targetaddr, ":"); +#endif /* * Acceptance criteria: (If the corresponding PREP was not generated @@ -1284,9 +1402,15 @@ if ((!IEEE80211_ADDR_EQ(vap->iv_myaddr, prep->prep_origaddr) || (rtorig != NULL && IS_PROXY(rtorig) && !PROXIED_BY_US(rtorig))) && !(ms->ms_flags & IEEE80211_MESHFLAGS_FWD)){ +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "discard PREP, orig(%s) not proxied or generated by us", + ether_sprintf(prep->prep_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "discard PREP, orig(%6D) not proxied or generated by us", prep->prep_origaddr, ":"); +#endif return; } @@ -1303,35 +1427,69 @@ if (rt == NULL) { rt = ieee80211_mesh_rt_add(vap, prep->prep_targetaddr); if (rt == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add PREP path to %s", + ether_sprintf(prep->prep_targetaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add PREP path to %6D", prep->prep_targetaddr, ":"); +#endif vap->iv_stats.is_mesh_rtaddfailed++; return; } +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "adding target %s", ether_sprintf(prep->prep_targetaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "adding target %6D", prep->prep_targetaddr, ":"); +#endif } hr = IEEE80211_MESH_ROUTE_PRIV(rt, struct ieee80211_hwmp_route); /* update path metric */ metric = prep->prep_metric + ms->ms_pmetric->mpm_metric(ni); if ((rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID)) { if (HWMP_SEQ_LT(prep->prep_targetseq, hr->hr_seq)) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "discard PREP from %s, old seq no %u < %u", + ether_sprintf(prep->prep_targetaddr), + prep->prep_targetseq, hr->hr_seq); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "discard PREP from %6D, old seq no %u < %u", prep->prep_targetaddr, ":", prep->prep_targetseq, hr->hr_seq); +#endif return; } else if (HWMP_SEQ_LEQ(prep->prep_targetseq, hr->hr_seq) && metric > rt->rt_metric) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "discard PREP from %s, new metric %u > %u", + ether_sprintf(prep->prep_targetaddr), + metric, rt->rt_metric); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "discard PREP from %6D, new metric %u > %u", prep->prep_targetaddr, ":", metric, rt->rt_metric); +#endif return; } } +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "%s path to %s, hopcount %d:%d metric %d:%d", + rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? + "prefer" : "update", + ether_sprintf(prep->prep_targetaddr), + rt->rt_nhops, prep->prep_hopcount + 1, + rt->rt_metric, metric); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "%s path to %6D, hopcount %d:%d metric %d:%d", rt->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? @@ -1339,6 +1497,7 @@ prep->prep_targetaddr, ":", rt->rt_nhops, prep->prep_hopcount + 1, rt->rt_metric, metric); +#endif hr->hr_seq = prep->prep_targetseq; hr->hr_preqretries = 0; @@ -1369,15 +1528,27 @@ * XXX: for now just ignore. */ if (rtorig == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PREP for an unknown orig(%s)", + ether_sprintf(prep->prep_origaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "received PREP for an unknown orig(%6D)", prep->prep_origaddr, ":"); +#endif return; } +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "propagate PREP from %s", + ether_sprintf(prep->prep_targetaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "propagate PREP from %6D", prep->prep_targetaddr, ":"); +#endif memcpy(&pprep, prep, sizeof(pprep)); pprep.prep_hopcount += 1; @@ -1400,13 +1571,28 @@ rtext = ieee80211_mesh_rt_add(vap, prep->prep_target_ext_addr); if (rtext == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "unable to add PREP path to proxy %s", + ether_sprintf(prep->prep_targetaddr)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add PREP path to proxy %6D", prep->prep_targetaddr, ":"); +#endif vap->iv_stats.is_mesh_rtaddfailed++; return; } } +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "%s path to %s, hopcount %d:%d metric %d:%d", + rtext->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? + "prefer" : "update", + ether_sprintf(prep->prep_target_ext_addr), + rtext->rt_nhops, prep->prep_hopcount + 1, + rtext->rt_metric, metric); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "%s path to %6D, hopcount %d:%d metric %d:%d", rtext->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ? @@ -1414,6 +1600,7 @@ prep->prep_target_ext_addr, ":", rtext->rt_nhops, prep->prep_hopcount + 1, rtext->rt_metric, metric); +#endif rtext->rt_flags = IEEE80211_MESHRT_FLAGS_PROXY | IEEE80211_MESHRT_FLAGS_VALID; @@ -1538,16 +1725,26 @@ struct ieee80211_meshperr_ie *pperr = NULL; int i, j = 0, forward = 0; +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "received PERR from %s", ether_sprintf(wh->i_addr2)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "received PERR from %6D", wh->i_addr2, ":"); +#endif /* * if forwarding is true, prepare pperr */ if (ms->ms_flags & IEEE80211_MESHFLAGS_FWD) { forward = 1; +#if defined(__DragonFly__) + pperr = kmalloc(sizeof(*perr) + 31*sizeof(*perr->perr_dests), + M_80211_MESH_PERR, M_INTWAIT); /* XXX: magic number, 32 err dests */ +#else pperr = IEEE80211_MALLOC(sizeof(*perr) + 31*sizeof(*perr->perr_dests), M_80211_MESH_PERR, IEEE80211_M_NOWAIT); /* XXX: magic number, 32 err dests */ +#endif } /* @@ -1614,8 +1811,13 @@ * Propagate the PERR if we previously found it on our routing table. */ if (forward && perr->perr_ttl > 1) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, + "propagate PERR from %s", ether_sprintf(wh->i_addr2)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "propagate PERR from %6D", wh->i_addr2, ":"); +#endif pperr->perr_ndests = j; pperr->perr_ttl--; hwmp_send_perr(vap, broadcastaddr, pperr); @@ -1771,9 +1973,15 @@ if (rt == NULL) { rt = ieee80211_mesh_rt_add(vap, rann->rann_addr); if (rt == NULL) { +#if defined(__DragonFly__) + IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, + "unable to add mac for RANN root %s", + ether_sprintf(rann->rann_addr)); +#else IEEE80211_DISCARD(vap, IEEE80211_MSG_HWMP, wh, NULL, "unable to add mac for RANN root %6D", rann->rann_addr, ":"); +#endif vap->iv_stats.is_mesh_rtaddfailed++; return; } @@ -1924,9 +2132,15 @@ if (rt == NULL) { rt = ieee80211_mesh_rt_add(vap, dest); if (rt == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, + ni, "unable to add discovery path to %s", + ether_sprintf(dest)); +#else IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni, "unable to add discovery path to %6D", dest, ":"); +#endif vap->iv_stats.is_mesh_rtaddfailed++; goto done; } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_input.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_input.c 2017-01-16 21:27:43.000000000 -0800 @@ -43,12 +43,16 @@ #include #include #include +#if defined(__DragonFly__) +#include +#else #include +#endif -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif #include @@ -249,7 +253,13 @@ mfrag = m; } else { /* concatenate */ m_adj(m, hdrspace); /* strip header */ +#if defined(__DragonFly__) + m_cat(mfrag, m); + /* NB: m_cat doesn't update the packet header */ + mfrag->m_pkthdr.len += m->m_pkthdr.len; +#else m_catpkt(mfrag, m); +#endif /* track last seqnum and fragno */ lwh = mtod(mfrag, struct ieee80211_frame *); *(uint16_t *) lwh->i_seq = *(uint16_t *) wh->i_seq; @@ -271,7 +281,10 @@ /* clear driver/net80211 flags before passing up */ m->m_flags &= ~(M_MCAST | M_BCAST); +#if defined(__DragonFly__) +#else m_clrprotoflags(m); +#endif /* NB: see hostap_deliver_data, this path doesn't handle hostap */ KASSERT(vap->iv_opmode != IEEE80211_M_HOSTAP, ("gack, hostap")); @@ -290,10 +303,18 @@ if (ni->ni_vlan != 0) { /* attach vlan tag */ +#if defined(__DragonFly__) + m->m_pkthdr.ether_vlantag = ni->ni_vlan; +#else m->m_pkthdr.ether_vtag = ni->ni_vlan; +#endif m->m_flags |= M_VLANTAG; } +#if defined(__DragonFly__) + ifp->if_input(ifp, m, NULL, -1); +#else ifp->if_input(ifp, m); +#endif } struct mbuf * @@ -383,7 +404,7 @@ *framelen = ntohs(eh->ether_type) /* encap'd frame size */ + sizeof(struct ether_header) - sizeof(struct llc); eh->ether_type = llc->llc_un.type_snap.ether_type; - ovbcopy(eh, mtod(m, uint8_t *) + sizeof(struct llc), + bcopy(eh, mtod(m, uint8_t *) + sizeof(struct llc), sizeof(struct ether_header)); m_adj(m, sizeof(struct llc)); return m; @@ -465,9 +486,14 @@ ieee80211_alloc_challenge(struct ieee80211_node *ni) { if (ni->ni_challenge == NULL) +#if defined(__DragonFly__) + ni->ni_challenge = (uint32_t *) kmalloc(IEEE80211_CHALLENGE_LEN, + M_80211_NODE, M_INTWAIT); +#else ni->ni_challenge = (uint32_t *) IEEE80211_MALLOC(IEEE80211_CHALLENGE_LEN, M_80211_NODE, IEEE80211_M_NOWAIT); +#endif if (ni->ni_challenge == NULL) { IEEE80211_NOTE(ni->ni_vap, IEEE80211_MSG_DEBUG | IEEE80211_MSG_AUTH, ni, @@ -855,10 +881,10 @@ ieee80211_ssid_mismatch(struct ieee80211vap *vap, const char *tag, uint8_t mac[IEEE80211_ADDR_LEN], uint8_t *ssid) { - printf("[%s] discard %s frame, ssid mismatch: ", + kprintf("[%s] discard %s frame, ssid mismatch: ", ether_sprintf(mac), tag); ieee80211_print_essid(ssid + 2, ssid[1]); - printf("\n"); + kprintf("\n"); } /* @@ -883,11 +909,19 @@ ieee80211_note(const struct ieee80211vap *vap, const char *fmt, ...) { char buf[128]; /* XXX */ +#if defined(__DragonFly__) + osdep_va_list ap; + + osdep_va_start(ap, fmt); + kvsnprintf(buf, sizeof(buf), fmt, ap); + osdep_va_end(ap); +#else va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); +#endif if_printf(vap->iv_ifp, "%s", buf); /* NB: no \n */ } @@ -898,11 +932,19 @@ const char *fmt, ...) { char buf[128]; /* XXX */ +#if defined(__DragonFly__) + osdep_va_list ap; + + osdep_va_start(ap, fmt); + kvsnprintf(buf, sizeof(buf), fmt, ap); + osdep_va_end(ap); +#else va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); +#endif if_printf(vap->iv_ifp, "[%s] %s\n", ether_sprintf(ieee80211_getbssid(vap, wh)), buf); } @@ -913,11 +955,19 @@ const char *fmt, ...) { char buf[128]; /* XXX */ +#if defined(__DragonFly__) + osdep_va_list ap; + + osdep_va_start(ap, fmt); + kvsnprintf(buf, sizeof(buf), fmt, ap); + osdep_va_end(ap); +#else va_list ap; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); +#endif if_printf(vap->iv_ifp, "[%s] %s\n", ether_sprintf(mac), buf); } @@ -926,6 +976,17 @@ const struct ieee80211_frame *wh, const char *type, const char *fmt, ...) { +#if defined(__DragonFly__) + osdep_va_list ap; + + if_printf(vap->iv_ifp, "[%s] discard ", + ether_sprintf(ieee80211_getbssid(vap, wh))); + kprintf("%s frame, ", type != NULL ? type : + ieee80211_mgt_subtype_name(wh->i_fc[0])); + osdep_va_start(ap, fmt); + kvprintf(fmt, ap); + osdep_va_end(ap); +#else va_list ap; if_printf(vap->iv_ifp, "[%s] discard ", @@ -935,7 +996,8 @@ va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); - printf("\n"); +#endif + kprintf("\n"); } void @@ -943,8 +1005,20 @@ const struct ieee80211_frame *wh, const char *type, const char *fmt, ...) { - va_list ap; + osdep_va_list ap; +#if defined(__DragonFly__) + if_printf(vap->iv_ifp, "[%s] discard ", + ether_sprintf(ieee80211_getbssid(vap, wh))); + if (type != NULL) + kprintf("%s information element, ", type); + else + kprintf("information element, "); + osdep_va_start(ap, fmt); + kvprintf(fmt, ap); + osdep_va_end(ap); + kprintf("\n"); +#else if_printf(vap->iv_ifp, "[%s] discard ", ether_sprintf(ieee80211_getbssid(vap, wh))); if (type != NULL) @@ -955,6 +1029,7 @@ vprintf(fmt, ap); va_end(ap); printf("\n"); +#endif } void @@ -962,6 +1037,18 @@ const uint8_t mac[IEEE80211_ADDR_LEN], const char *type, const char *fmt, ...) { +#if defined(__DragonFly__) + osdep_va_list ap; + + if_printf(vap->iv_ifp, "[%s] discard ", ether_sprintf(mac)); + if (type != NULL) + kprintf("%s frame, ", type); + else + kprintf("frame, "); + osdep_va_start(ap, fmt); + kvprintf(fmt, ap); + osdep_va_end(ap); +#else va_list ap; if_printf(vap->iv_ifp, "[%s] discard ", ether_sprintf(mac)); @@ -972,6 +1059,7 @@ va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); - printf("\n"); +#endif + kprintf("\n"); } #endif /* IEEE80211_DEBUG */ --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ioctl.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_ioctl.c 2017-01-16 21:27:43.000000000 -0800 @@ -54,10 +54,10 @@ #include #endif -#include -#include -#include -#include +#include +#include +#include +#include #define IS_UP_AUTO(_vap) \ (IFNET_IS_UP_RUNNING((_vap)->iv_ifp) && \ @@ -159,8 +159,12 @@ if (ireq->i_len < IEEE80211_ADDR_LEN) return EINVAL; +#if defined(__DragonFly__) + wpaie = kmalloc(sizeof(*wpaie), M_TEMP, M_INTWAIT | M_ZERO); +#else wpaie = IEEE80211_MALLOC(sizeof(*wpaie), M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (wpaie == NULL) return ENOMEM; error = copyin(ireq->i_data, wpaie->wpa_macaddr, IEEE80211_ADDR_LEN); @@ -331,8 +335,12 @@ space = req.space; /* XXX M_WAITOK after driver lock released */ +#if defined(__DragonFly__) + p = kmalloc(space, M_TEMP, M_INTWAIT | M_ZERO); +#else p = IEEE80211_MALLOC(space, M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (p == NULL) return ENOMEM; req.sr = p; @@ -482,8 +490,12 @@ if (req.space > 0) { space = req.space; /* XXX M_WAITOK after driver lock released */ +#if defined(__DragonFly__) + p = kmalloc(space, M_TEMP, M_INTWAIT | M_ZERO); +#else p = IEEE80211_MALLOC(space, M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (p == NULL) { error = ENOMEM; goto bad; @@ -706,9 +718,14 @@ /* constrain max request size, 2K channels is ~24Kbytes */ if (maxchans > 2048) maxchans = 2048; +#if defined(__DragonFly__) + dc = (struct ieee80211_devcaps_req *) + kmalloc(IEEE80211_DEVCAPS_SIZE(maxchans), M_TEMP, M_INTWAIT | M_ZERO); +#else dc = (struct ieee80211_devcaps_req *) IEEE80211_MALLOC(IEEE80211_DEVCAPS_SIZE(maxchans), M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (dc == NULL) return ENOMEM; dc->dc_drivercaps = ic->ic_caps; @@ -1563,8 +1580,12 @@ if (ssid_len == 0) return EINVAL; +#if defined(__DragonFly__) + sr = kmalloc(sizeof(*sr), M_TEMP, M_INTWAIT | M_ZERO); +#else sr = IEEE80211_MALLOC(sizeof(*sr), M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (sr == NULL) return ENOMEM; @@ -1683,8 +1704,13 @@ if (ireq->i_len > sizeof(ic->ic_chan_active)) ireq->i_len = sizeof(ic->ic_chan_active); +#if defined(__DragonFly__) + list = kmalloc(ireq->i_len + IEEE80211_CHAN_BYTES, M_TEMP, + M_INTWAIT | M_ZERO); +#else list = IEEE80211_MALLOC(ireq->i_len + IEEE80211_CHAN_BYTES, M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (list == NULL) return ENOMEM; error = copyin(ireq->i_data, list, ireq->i_len); @@ -2110,9 +2136,14 @@ ireq->i_len, nchans); return EINVAL; } +#if defined(__DragonFly__) + reg = (struct ieee80211_regdomain_req *) + kmalloc(IEEE80211_REGDOMAIN_SIZE(nchans), M_TEMP, M_INTWAIT); +#else reg = (struct ieee80211_regdomain_req *) IEEE80211_MALLOC(IEEE80211_REGDOMAIN_SIZE(nchans), M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (reg == NULL) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_IOCTL, "%s: no memory, nchans %d\n", __func__, nchans); @@ -2260,9 +2291,14 @@ * * XXX bad bad bad */ +#if defined(__DragonFly__) + napp = (struct ieee80211_appie *) kmalloc( + sizeof(struct ieee80211_appie) + ireq->i_len, M_80211_NODE_IE, M_INTWAIT); +#else napp = (struct ieee80211_appie *) IEEE80211_MALLOC( sizeof(struct ieee80211_appie) + ireq->i_len, M_80211_NODE_IE, IEEE80211_M_NOWAIT); +#endif if (napp == NULL) return ENOMEM; /* XXX holding ic lock */ @@ -2486,6 +2522,11 @@ * Otherwise just invoke the scan machinery directly. */ IEEE80211_LOCK(ic); + if (ic->ic_nrunning == 0) { + IEEE80211_UNLOCK(ic); + return ENXIO; + } + if (vap->iv_state == IEEE80211_S_INIT) { /* NB: clobbers previous settings */ vap->iv_scanreq_flags = sr->sr_flags; @@ -2530,8 +2571,12 @@ if (ireq->i_len != sizeof(*sr)) return EINVAL; +#if defined(__DragonFly__) + sr = kmalloc(sizeof(*sr), M_TEMP, M_INTWAIT | M_ZERO); +#else sr = IEEE80211_MALLOC(sizeof(*sr), M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (sr == NULL) return ENOMEM; error = copyin(ireq->i_data, sr, sizeof(*sr)); @@ -3326,8 +3371,13 @@ return error; } +#if defined(__DragonFly__) +int +ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *ucred) +#else int ieee80211_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) +#endif { struct ieee80211vap *vap = ifp->if_softc; struct ieee80211com *ic = vap->iv_ic; @@ -3383,6 +3433,10 @@ IEEE80211_UNLOCK(ic); /* Wait for parent ioctl handler if it was queued */ if (wait) { +#if defined(__DragonFly__) + /* DragonFly: release serializer to avoid deadlock */ + wlan_serialize_exit(); +#endif ieee80211_waitfor_parent(ic); /* @@ -3393,14 +3447,19 @@ !IEEE80211_ADDR_EQ(vap->iv_myaddr, IF_LLADDR(ifp))) IEEE80211_ADDR_COPY(vap->iv_myaddr, IF_LLADDR(ifp)); +#if defined(__DragonFly__) + wlan_serialize_enter(); +#endif } break; case SIOCADDMULTI: case SIOCDELMULTI: + /* DragonFly: serializer must be held */ ieee80211_runtask(ic, &ic->ic_mcast_task); break; case SIOCSIFMEDIA: case SIOCGIFMEDIA: + /* DragonFly: serializer must be held */ ifr = (struct ifreq *)data; error = ifmedia_ioctl(ifp, ifr, &vap->iv_media, cmd); break; @@ -3461,6 +3520,7 @@ if (ic->ic_ioctl != NULL && (error = ic->ic_ioctl(ic, cmd, data)) != ENOTTY) break; + /* DragonFly: serializer must be held */ error = ether_ioctl(ifp, cmd, data); break; } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_mesh.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_mesh.c 2016-06-08 13:40:34.000000000 -0700 @@ -59,13 +59,13 @@ #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif -#include -#include +#include +#include static void mesh_rt_flush_invalid(struct ieee80211vap *); static int mesh_select_proto_path(struct ieee80211vap *, const char *); @@ -203,15 +203,24 @@ MESH_RT_LOCK_ASSERT(ms); +#if defined(__DragonFly__) + rt = kmalloc(ALIGN(sizeof(struct ieee80211_mesh_route)) + + ms->ms_ppath->mpp_privlen, M_80211_MESH_RT, M_INTWAIT | M_ZERO); +#else rt = IEEE80211_MALLOC(ALIGN(sizeof(struct ieee80211_mesh_route)) + ms->ms_ppath->mpp_privlen, M_80211_MESH_RT, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (rt != NULL) { rt->rt_vap = vap; IEEE80211_ADDR_COPY(rt->rt_dest, dest); rt->rt_priv = (void *)ALIGN(&rt[1]); MESH_RT_ENTRY_LOCK_INIT(rt, "MBSS_RT"); +#if defined(__DragonFly__) + callout_init_mp(&rt->rt_discovery); +#else callout_init(&rt->rt_discovery, 1); +#endif rt->rt_updtime = ticks; /* create time */ TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next); } @@ -658,10 +667,15 @@ vap->iv_opdetach = mesh_vdetach; vap->iv_recv_mgmt = mesh_recv_mgmt; vap->iv_recv_ctl = mesh_recv_ctl; +#if defined(__DragonFly__) + ms = kmalloc(sizeof(struct ieee80211_mesh_state), M_80211_VAP, + M_INTWAIT | M_ZERO); +#else ms = IEEE80211_MALLOC(sizeof(struct ieee80211_mesh_state), M_80211_VAP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ms == NULL) { - printf("%s: couldn't alloc MBSS state\n", __func__); + kprintf("%s: couldn't alloc MBSS state\n", __func__); return; } vap->iv_mesh = ms; @@ -671,8 +685,13 @@ TAILQ_INIT(&ms->ms_known_gates); TAILQ_INIT(&ms->ms_routes); MESH_RT_LOCK_INIT(ms, "MBSS"); +#if defined(__DragonFly__) + callout_init_mp(&ms->ms_cleantimer); + callout_init_mp(&ms->ms_gatetimer); +#else callout_init(&ms->ms_cleantimer, 1); callout_init(&ms->ms_gatetimer, 1); +#endif ms->ms_gateseq = 0; mesh_select_proto_metric(vap, "AIRTIME"); KASSERT(ms->ms_pmetric, ("ms_pmetric == NULL")); @@ -819,7 +838,7 @@ ieee80211_print_essid(ni->ni_meshid, ni->ni_meshidlen); /* XXX MCS/HT */ - printf(" channel %d\n", + kprintf(" channel %d\n", ieee80211_chan2ieee(ic, ic->ic_curchan)); } #endif @@ -876,9 +895,14 @@ /* New mesh gate add it to known table. */ IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, addr, "%s", "stored new gate information from pro-PREQ."); +#if defined(__DragonFly__) + gr = kmalloc(ALIGN(sizeof(struct ieee80211_mesh_gate_route)), + M_80211_MESH_GT_RT, M_INTWAIT | M_ZERO); +#else gr = IEEE80211_MALLOC(ALIGN(sizeof(struct ieee80211_mesh_gate_route)), M_80211_MESH_GT_RT, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif IEEE80211_ADDR_COPY(gr->gr_addr, addr); TAILQ_INSERT_TAIL(&ms->ms_known_gates, gr, gr_next); } @@ -1087,10 +1111,16 @@ TAILQ_FOREACH_SAFE(gr, &ms->ms_known_gates, gr_next, gr_next) { rt_gate = gr->gr_route; if (rt_gate == NULL) { +#if defined(__DragonFly__) IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, rt_dest->rt_dest, + "mesh gate with no path %s", + ether_sprintf(gr->gr_addr)); +#else + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_HWMP, "mesh gate with no path %6D", gr->gr_addr, ":"); +#endif continue; } if ((rt_gate->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) == 0) @@ -1387,8 +1417,13 @@ /* set lifetime of addr3 (meshDA) to initial value */ rt_meshda = ieee80211_mesh_rt_find(vap, qwh->i_addr3); if (rt_meshda == NULL) { +#if defined(__DragonFly__) + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, qwh->i_addr2, + "no route to meshDA(%s)", ether_sprintf(qwh->i_addr3)); +#else IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, qwh->i_addr2, "no route to meshDA(%6D)", qwh->i_addr3, ":"); +#endif /* * [Optional] any of the following three actions: * o silently discard [X] @@ -1474,9 +1509,16 @@ * All other cases: forward of MSDUs from the MBSS to DS indiv. * addressed according to 13.11.3.2. */ +#if defined(__DragonFly__) + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_OUTPUT, qwh->i_addr2, + "forward frame to DS, SA(%s) DA(%s)", + ether_sprintf(mc10->mc_addr6), + ether_sprintf(mc10->mc_addr5)); +#else IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_OUTPUT, qwh->i_addr2, "forward frame to DS, SA(%6D) DA(%6D)", mc10->mc_addr6, ":", mc10->mc_addr5, ":"); +#endif } return (0); /* process locally */ } @@ -2587,9 +2629,16 @@ if (IEEE80211_ADDR_EQ(vap->iv_myaddr, ie.gann_addr)) return 0; +#if defined(__DragonFly__) + IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, ni->ni_macaddr, + "received GANN, meshgate: %s (seq %u)", + ether_sprintf(ie.gann_addr), + ie.gann_seq); +#else IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, ni->ni_macaddr, "received GANN, meshgate: %6D (seq %u)", ie.gann_addr, ":", ie.gann_seq); +#endif if (ms == NULL) return (0); @@ -2614,9 +2663,14 @@ /* this GANN is from a new mesh Gate add it to known table. */ IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_MESH, ie.gann_addr, "stored new GANN information, seq %u.", ie.gann_seq); +#if defined(__DragonFly__) + gr = kmalloc(ALIGN(sizeof(struct ieee80211_mesh_gate_route)), + M_80211_MESH_GT_RT, M_INTWAIT | M_ZERO); +#else gr = IEEE80211_MALLOC(ALIGN(sizeof(struct ieee80211_mesh_gate_route)), M_80211_MESH_GT_RT, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif IEEE80211_ADDR_COPY(gr->gr_addr, ie.gann_addr); TAILQ_INSERT_TAIL(&ms->ms_known_gates, gr, gr_next); } @@ -3304,7 +3358,7 @@ #define S_FACTOR (2 * M_BITS) struct ieee80211com *ic = ni->ni_ic; struct ifnet *ifp = ni->ni_vap->iv_ifp; - const static int nbits = 8192 << M_BITS; + static const int nbits = 8192 << M_BITS; uint32_t overhead, rate, errrate; uint64_t res; @@ -3314,9 +3368,18 @@ ifp->if_mtu + IEEE80211_MESH_MAXOVERHEAD, rate, 0) << M_BITS; /* Error rate in percentage */ /* XXX assuming small failures are ok */ +#if defined(__DragonFly__) + u_long icount; + u_long ocount; + IFNET_STAT_GET(ifp, ierrors, icount); + IFNET_STAT_GET(ifp, oerrors, ocount); + errrate = (((ocount + icount) / 100) << M_BITS) + / 100; +#else errrate = (((ifp->if_get_counter(ifp, IFCOUNTER_OERRORS) + ifp->if_get_counter(ifp, IFCOUNTER_IERRORS)) / 100) << M_BITS) / 100; +#endif res = (overhead + (nbits / rate)) * ((1 << S_FACTOR) / ((1 << M_BITS) - errrate)); @@ -3365,8 +3428,13 @@ ieee80211_mesh_node_init(struct ieee80211vap *vap, struct ieee80211_node *ni) { ni->ni_flags |= IEEE80211_NODE_QOS; +#if defined(__DragonFly__) + callout_init_mp(&ni->ni_mltimer); + callout_init_mp(&ni->ni_mlhtimer); +#else callout_init(&ni->ni_mltimer, 1); callout_init(&ni->ni_mlhtimer, 1); +#endif } /* @@ -3463,8 +3531,12 @@ } ireq->i_len = len; /* XXX M_WAIT? */ +#if defined(__DragonFly__) + p = kmalloc(len, M_TEMP, M_INTWAIT | M_ZERO); +#else p = IEEE80211_MALLOC(len, M_TEMP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (p == NULL) return ENOMEM; off = 0; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_monitor.c 2016-01-18 12:53:05.000000000 -0800 +++ ./wlan/ieee80211_monitor.c 2016-06-08 13:40:34.000000000 -0700 @@ -55,8 +55,8 @@ #include -#include -#include +#include +#include static void monitor_vattach(struct ieee80211vap *); static int monitor_newstate(struct ieee80211vap *, enum ieee80211_state, int); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_node.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_node.c 2016-06-08 13:40:34.000000000 -0700 @@ -42,17 +42,17 @@ #include #include -#include -#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif -#include -#include -#include +#include +#include +#include #include @@ -114,7 +114,11 @@ "802.11 staging q"); ieee80211_node_table_init(ic, &ic->ic_sta, "station", IEEE80211_INACT_INIT, ic->ic_max_keyix); +#if defined(__DragonFly__) + callout_init_mp(&ic->ic_inact); +#else callout_init(&ic->ic_inact, 1); +#endif callout_reset(&ic->ic_inact, IEEE80211_INACT_WAIT*hz, ieee80211_node_timeout, ic); @@ -172,13 +176,19 @@ "WARNING: max aid too small, changed to %d\n", vap->iv_max_aid); } +#if defined(__DragonFly__) + vap->iv_aid_bitmap = (uint32_t *) kmalloc( + howmany(vap->iv_max_aid, 32) * sizeof(uint32_t), + M_80211_NODE, M_INTWAIT | M_ZERO); +#else vap->iv_aid_bitmap = (uint32_t *) IEEE80211_MALLOC( howmany(vap->iv_max_aid, 32) * sizeof(uint32_t), M_80211_NODE, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (vap->iv_aid_bitmap == NULL) { /* XXX no way to recover */ - printf("%s: no memory for AID bitmap, max aid %d!\n", + kprintf("%s: no memory for AID bitmap, max aid %d!\n", __func__, vap->iv_max_aid); vap->iv_max_aid = 0; } @@ -538,22 +548,22 @@ !IEEE80211_ADDR_EQ(vap->iv_des_bssid, ni->ni_bssid)) fail |= 0x20; - printf(" %c %s", fail ? '-' : '+', ether_sprintf(ni->ni_macaddr)); - printf(" %s%c", ether_sprintf(ni->ni_bssid), fail & 0x20 ? '!' : ' '); - printf(" %3d%c", + kprintf(" %c %s", fail ? '-' : '+', ether_sprintf(ni->ni_macaddr)); + kprintf(" %s%c", ether_sprintf(ni->ni_bssid), fail & 0x20 ? '!' : ' '); + kprintf(" %3d%c", ieee80211_chan2ieee(ic, ni->ni_chan), fail & 0x01 ? '!' : ' '); - printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2, + kprintf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2, fail & 0x08 ? '!' : ' '); - printf(" %4s%c", + kprintf(" %4s%c", (ni->ni_capinfo & IEEE80211_CAPINFO_ESS) ? "ess" : (ni->ni_capinfo & IEEE80211_CAPINFO_IBSS) ? "ibss" : "????", fail & 0x02 ? '!' : ' '); - printf(" %3s%c ", + kprintf(" %3s%c ", (ni->ni_capinfo & IEEE80211_CAPINFO_PRIVACY) ? "wep" : "no", fail & 0x04 ? '!' : ' '); ieee80211_print_essid(ni->ni_essid, ni->ni_esslen); - printf("%s\n", fail & 0x10 ? "!" : ""); + kprintf("%s\n", fail & 0x10 ? "!" : ""); } #endif /* IEEE80211_DEBUG */ @@ -908,8 +918,13 @@ { struct ieee80211_node *ni; +#if defined(__DragonFly__) + ni = (struct ieee80211_node *) kmalloc(sizeof(struct ieee80211_node), + M_80211_NODE, M_INTWAIT | M_ZERO); +#else ni = (struct ieee80211_node *) IEEE80211_MALLOC(sizeof(struct ieee80211_node), M_80211_NODE, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif return ni; } @@ -930,8 +945,14 @@ ies->data = NULL; } if (ies->data == NULL) { +#if defined(__DragonFly__) + ies->data = (uint8_t *) kmalloc(len, + M_80211_NODE_IE, M_INTWAIT | M_ZERO); +#else ies->data = (uint8_t *) IEEE80211_MALLOC(len, M_80211_NODE_IE, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); + +#endif if (ies->data == NULL) { ies->len = 0; /* NB: pointers have already been zero'd above */ @@ -1935,10 +1956,16 @@ nt->nt_inact_init = inact; nt->nt_keyixmax = keyixmax; if (nt->nt_keyixmax > 0) { +#if defined(__DragonFly__) + nt->nt_keyixmap = (struct ieee80211_node **) kmalloc( + keyixmax * sizeof(struct ieee80211_node *), + M_80211_NODE, M_INTWAIT | M_ZERO); +#else nt->nt_keyixmap = (struct ieee80211_node **) IEEE80211_MALLOC( keyixmax * sizeof(struct ieee80211_node *), M_80211_NODE, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (nt->nt_keyixmap == NULL) ic_printf(ic, "Cannot allocate key index map with %u entries\n", @@ -1994,7 +2021,7 @@ int i; for (i = 0; i < nt->nt_keyixmax; i++) if (nt->nt_keyixmap[i] != NULL) - printf("%s: %s[%u] still active\n", __func__, + kprintf("%s: %s[%u] still active\n", __func__, nt->nt_name, i); #endif IEEE80211_FREE(nt->nt_keyixmap, M_80211_NODE); @@ -2336,8 +2363,13 @@ max_aid = vap->iv_max_aid; size = max_aid * sizeof(struct ieee80211_node *); +#if defined(__DragonFly__) + ni_arr = (struct ieee80211_node **) kmalloc(size, M_80211_NODE, + M_INTWAIT | M_ZERO); +#else ni_arr = (struct ieee80211_node **) IEEE80211_MALLOC(size, M_80211_NODE, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ni_arr == NULL) return; @@ -2366,30 +2398,30 @@ void ieee80211_dump_node(struct ieee80211_node_table *nt, struct ieee80211_node *ni) { - printf("0x%p: mac %s refcnt %d\n", ni, + kprintf("0x%p: mac %s refcnt %d\n", ni, ether_sprintf(ni->ni_macaddr), ieee80211_node_refcnt(ni)); - printf("\tscangen %u authmode %u flags 0x%x\n", + kprintf("\tscangen %u authmode %u flags 0x%x\n", ni->ni_scangen, ni->ni_authmode, ni->ni_flags); - printf("\tassocid 0x%x txpower %u vlan %u\n", + kprintf("\tassocid 0x%x txpower %u vlan %u\n", ni->ni_associd, ni->ni_txpower, ni->ni_vlan); - printf("\ttxseq %u rxseq %u fragno %u rxfragstamp %u\n", + kprintf("\ttxseq %u rxseq %u fragno %u rxfragstamp %u\n", ni->ni_txseqs[IEEE80211_NONQOS_TID], ni->ni_rxseqs[IEEE80211_NONQOS_TID] >> IEEE80211_SEQ_SEQ_SHIFT, ni->ni_rxseqs[IEEE80211_NONQOS_TID] & IEEE80211_SEQ_FRAG_MASK, ni->ni_rxfragstamp); - printf("\trssi %d noise %d intval %u capinfo 0x%x\n", + kprintf("\trssi %d noise %d intval %u capinfo 0x%x\n", node_getrssi(ni), ni->ni_noise, ni->ni_intval, ni->ni_capinfo); - printf("\tbssid %s essid \"%.*s\" channel %u:0x%x\n", + kprintf("\tbssid %s essid \"%.*s\" channel %u:0x%x\n", ether_sprintf(ni->ni_bssid), ni->ni_esslen, ni->ni_essid, ni->ni_chan->ic_freq, ni->ni_chan->ic_flags); - printf("\tinact %u inact_reload %u txrate %u\n", + kprintf("\tinact %u inact_reload %u txrate %u\n", ni->ni_inact, ni->ni_inact_reload, ni->ni_txrate); - printf("\thtcap %x htparam %x htctlchan %u ht2ndchan %u\n", + kprintf("\thtcap %x htparam %x htctlchan %u ht2ndchan %u\n", ni->ni_htcap, ni->ni_htparam, ni->ni_htctlchan, ni->ni_ht2ndchan); - printf("\thtopmode %x htstbc %x chw %u\n", + kprintf("\thtopmode %x htstbc %x chw %u\n", ni->ni_htopmode, ni->ni_htstbc, ni->ni_chw); } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_output.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_output.c 2017-01-16 21:27:43.000000000 -0800 @@ -46,18 +46,22 @@ #include #include #include -#include +#include -#include -#include +#if defined(__DragonFly__) +#include +#endif + +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif -#include -#include +#include +#include #if defined(INET) || defined(INET6) #include @@ -72,7 +76,10 @@ #include #endif +#if defined(__DragonFly__) +#else #include +#endif #define ETHER_HEADER_COPY(dst, src) \ memcpy(dst, src, sizeof(struct ether_header)) @@ -393,10 +400,17 @@ /* XXX better status? */ return (ENOBUFS); } +#if defined(__DragonFly__) + IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, + "forward frame from DS SA(%s), DA(%s)\n", + ether_sprintf(eh->ether_shost), + ether_sprintf(eh->ether_dhost)); +#else IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, "forward frame from DS SA(%6D), DA(%6D)\n", eh->ether_shost, ":", eh->ether_dhost, ":"); +#endif ieee80211_mesh_proxy_check(vap, eh->ether_shost); } ni = ieee80211_mesh_discover(vap, eh->ether_dhost, m); @@ -443,6 +457,84 @@ * if_transmit() requires that the mbuf be consumed by this call * regardless of the return condition. */ + +#if defined(__DragonFly__) + +void +ieee80211_vap_start(struct ifnet *ifp, struct ifaltq_subque *ifsq) +{ + struct ieee80211vap *vap = ifp->if_softc; + struct ieee80211com *ic = vap->iv_ic; + struct ifnet *parent = vap->iv_ifp; + struct mbuf *m = NULL; + + /* NB: parent must be up and running */ + if (!IFNET_IS_UP_RUNNING(parent)) { + IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, + "%s: ignore queue, parent %s not up+running\n", + __func__, parent->if_xname); + /* XXX stat */ + /*m_freem(m);*/ + /*return (EINVAL);*/ + return; + } + + wlan_assert_serialized(); + ASSERT_ALTQ_SQ_DEFAULT(ifp, ifsq); + + /* + * No data frames go out unless we're running. + * Note in particular this covers CAC and CSA + * states (though maybe we should check muting + * for CSA). + */ + if (vap->iv_state != IEEE80211_S_RUN && + vap->iv_state != IEEE80211_S_SLEEP) { + IEEE80211_LOCK(ic); + /* re-check under the com lock to avoid races */ + if (vap->iv_state != IEEE80211_S_RUN && + vap->iv_state != IEEE80211_S_SLEEP) { + IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT, + "%s: ignore queue, in %s state\n", + __func__, ieee80211_state_name[vap->iv_state]); + vap->iv_stats.is_tx_badstate++; + IEEE80211_UNLOCK(ic); + ifsq_set_oactive(ifsq); + /*m_freem(m);*/ + /* return (EINVAL); */ + return; + } + IEEE80211_UNLOCK(ic); + } + + wlan_serialize_exit(); + for (;;) { + m = ifsq_dequeue(ifsq); + if (m == NULL) + break; + + /* + * Sanitize mbuf flags for net80211 use. We cannot + * clear M_PWR_SAV or M_MORE_DATA because these may + * be set for frames that are re-submitted from the + * power save queue. + * + * NB: This must be done before ieee80211_classify as + * it marks EAPOL in frames with M_EAPOL. + */ + m->m_flags &= ~(M_80211_TX - M_PWR_SAV - M_MORE_DATA); + + /* + * Bump to the packet transmission path. + * The mbuf will be consumed here. + */ + ieee80211_start_pkt(vap, m); + } + wlan_serialize_enter(); +} + +#else + int ieee80211_vap_transmit(struct ifnet *ifp, struct mbuf *m) { @@ -499,6 +591,8 @@ /* Empty for now */ } +#endif + /* * 802.11 raw output routine. * @@ -549,9 +643,15 @@ * connect bpf write calls to the 802.11 layer for injecting * raw 802.11 frames. */ +#if defined(__DragonFly__) +int +ieee80211_output(struct ifnet *ifp, struct mbuf *m, + struct sockaddr *dst, struct rtentry *rt) +#else int ieee80211_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, struct route *ro) +#endif { #define senderr(e) do { error = (e); goto bad;} while (0) struct ieee80211_node *ni = NULL; @@ -561,7 +661,13 @@ int error; int ret; +#if defined(__DragonFly__) + struct ifaltq_subque *ifsq; + ifsq = ifq_get_subq_default(&ifp->if_snd); + if (ifsq_is_oactive(ifsq)) { +#else if (ifp->if_drv_flags & IFF_DRV_OACTIVE) { +#endif /* * Short-circuit requests if the vap is marked OACTIVE * as this can happen because a packet came down through @@ -578,8 +684,13 @@ * Hand to the 802.3 code if not tagged as * a raw 802.11 frame. */ +#if defined(__DragonFly__) + if (dst->sa_family != AF_IEEE80211) + return vap->iv_output(ifp, m, dst, rt); +#else if (dst->sa_family != AF_IEEE80211) return vap->iv_output(ifp, m, dst, ro); +#endif #ifdef MAC error = mac_ifnet_check_transmit(ifp, m); if (error) @@ -786,8 +897,8 @@ * Send a management frame to the specified node. The node pointer * must have a reference as the pointer will be passed to the driver * and potentially held for a long time. If the frame is successfully - * dispatched to the driver, then it is responsible for freeing the - * reference (and potentially free'ing up any associated storage); + * dispatched to the driver, then it is responsible forkfreeing the + * reference (and potentiallykfree'ing up any associated storage); * otherwise deal with reclaiming any reference (on error). */ int @@ -837,7 +948,7 @@ /* avoid printing too many frames */ if ((ieee80211_msg_debug(vap) && doprint(vap, type)) || ieee80211_msg_dumppkts(vap)) { - printf("[%s] send %s on channel %u\n", + kprintf("[%s] send %s on channel %u\n", ether_sprintf(wh->i_addr1), ieee80211_mgt_subtype_name(type), ieee80211_chan2ieee(ic, ic->ic_curchan)); @@ -1009,11 +1120,19 @@ IEEE80211_NODE_STAT(ni, tx_novlantag); return 1; } +#if defined(__DragonFly__) + if (EVL_VLANOFTAG(m->m_pkthdr.ether_vlantag) != + EVL_VLANOFTAG(ni->ni_vlan)) { + IEEE80211_NODE_STAT(ni, tx_vlanmismatch); + return 1; + } +#else if (EVL_VLANOFTAG(m->m_pkthdr.ether_vtag) != EVL_VLANOFTAG(ni->ni_vlan)) { IEEE80211_NODE_STAT(ni, tx_vlanmismatch); return 1; } +#endif /* map vlan priority to AC */ v_wme_ac = TID_TO_WME_AC(EVL_PRIOFTAG(ni->ni_vlan)); } @@ -1134,8 +1253,13 @@ m_freem(m); return NULL; } +#if defined(__DragonFly__) + KASSERT(needed_space <= MHLEN, + ("not enough room, need %u got %zd\n", needed_space, MHLEN)); +#else KASSERT(needed_space <= MHLEN, ("not enough room, need %u got %d\n", needed_space, MHLEN)); +#endif /* * Setup new mbuf to have leading space to prepend the * 802.11 header and any crypto header bits that are @@ -1569,7 +1693,7 @@ * be forced to be non-QoS traffic to be A-MSDU encapsulated. */ if (is_amsdu) - printf("%s: XXX ERROR: is_amsdu set; not QoS!\n", + kprintf("%s: XXX ERROR: is_amsdu set; not QoS!\n", __func__); } @@ -2167,7 +2291,7 @@ IEEE80211_DPRINTF(vap, IEEE80211_MSG_DEBUG | IEEE80211_MSG_DUMPPKTS, "send probe req on channel %u bssid %s ssid \"%.*s\"\n", ieee80211_chan2ieee(ic, ic->ic_curchan), ether_sprintf(bssid), - ssidlen, ssid); + (int)ssidlen, ssid); memset(¶ms, 0, sizeof(params)); params.ibp_pri = M_WME_GETAC(m); @@ -3327,7 +3451,7 @@ /* copy up/down trailer */ int adjust = tie->tim_bitmap+timlen - bo->bo_tim_trailer; - ovbcopy(bo->bo_tim_trailer, + bcopy(bo->bo_tim_trailer, bo->bo_tim_trailer+adjust, bo->bo_tim_trailer_len); bo->bo_tim_trailer += adjust; @@ -3440,7 +3564,7 @@ if (aielen != bo->bo_appie_len) { /* copy up/down trailer */ int adjust = aielen - bo->bo_appie_len; - ovbcopy(bo->bo_tim_trailer, bo->bo_tim_trailer+adjust, + bcopy(bo->bo_tim_trailer, bo->bo_tim_trailer+adjust, bo->bo_tim_trailer_len); bo->bo_tim_trailer += adjust; bo->bo_appie += adjust; @@ -3522,10 +3646,18 @@ struct ifnet *ifp = ni->ni_vap->iv_ifp; if (status == 0) { - if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); +#if defined(__DragonFly__) + /* + * On DragonFly, IFCOUNTER_OBYTES and + * IFCOUNTER_OMCASTS increments are currently done + * by ifq_dispatch() already. + */ +#else + if_inc_counter(ifp, IFCOUNTER_OBYTES, m->m_pkthdr.len); if (m->m_flags & M_MCAST) if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1); +#endif } else if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); if (m->m_flags & M_TXCB) --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_phy.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_phy.c 2016-06-08 13:40:34.000000000 -0700 @@ -45,8 +45,8 @@ #include #include -#include -#include +#include +#include #ifdef notyet struct ieee80211_ds_plcp_hdr { --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_power.c 2016-05-25 15:26:27.000000000 -0700 +++ ./wlan/ieee80211_power.c 2016-06-08 13:40:34.000000000 -0700 @@ -43,7 +43,7 @@ #include #include -#include +#include #include @@ -84,11 +84,16 @@ */ if (vap->iv_opmode == IEEE80211_M_HOSTAP) { vap->iv_tim_len = howmany(vap->iv_max_aid,8) * sizeof(uint8_t); +#if defined(__DragonFly__) + vap->iv_tim_bitmap = (uint8_t *) kmalloc(vap->iv_tim_len, + M_80211_POWER, M_INTWAIT | M_ZERO); +#else vap->iv_tim_bitmap = (uint8_t *) IEEE80211_MALLOC(vap->iv_tim_len, M_80211_POWER, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (vap->iv_tim_bitmap == NULL) { - printf("%s: no memory for TIM bitmap!\n", __func__); + kprintf("%s: no memory for TIM bitmap!\n", __func__); /* XXX good enough to keep from crashing? */ vap->iv_tim_len = 0; } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_proto.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_proto.c 2016-06-08 13:40:34.000000000 -0700 @@ -48,16 +48,20 @@ #include #include /* XXX for ether_sprintf */ -#include -#include -#include -#include -#include +#if defined(__DragonFly__) +#include +#endif + +#include +#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif -#include -#include +#include +#include /* XXX tunables */ #define AGGRESSIVE_MODE_SWITCH_HYSTERESIS 3 /* pkts / 100ms */ @@ -335,7 +339,11 @@ vap->iv_fragthreshold = IEEE80211_FRAG_DEFAULT; vap->iv_bmiss_max = IEEE80211_BMISS_MAX; callout_init_mtx(&vap->iv_swbmiss, IEEE80211_LOCK_OBJ(ic), 0); +#if defined(__DragonFly__) + callout_init_mp(&vap->iv_mgtsend); +#else callout_init(&vap->iv_mgtsend, 1); +#endif TASK_INIT(&vap->iv_nstate_task, 0, ieee80211_newstate_cb, vap); TASK_INIT(&vap->iv_swbmiss_task, 0, beacon_swmiss, vap); /* @@ -493,7 +501,7 @@ void ieee80211_aclator_register(const struct ieee80211_aclator *iac) { - printf("wlan: %s acl policy registered\n", iac->iac_name); + kprintf("wlan: %s acl policy registered\n", iac->iac_name); acl = iac; } @@ -502,7 +510,7 @@ { if (acl == iac) acl = NULL; - printf("wlan: %s acl policy unregistered\n", iac->iac_name); + kprintf("wlan: %s acl policy unregistered\n", iac->iac_name); } const struct ieee80211_aclator * @@ -527,14 +535,14 @@ break; } if (i == len) { - printf("\""); + kprintf("\""); for (i = 0, p = essid; i < len; i++, p++) - printf("%c", *p); - printf("\""); + kprintf("%c", *p); + kprintf("\""); } else { - printf("0x"); + kprintf("0x"); for (i = 0, p = essid; i < len; i++, p++) - printf("%02x", *p); + kprintf("%02x", *p); } } @@ -548,67 +556,67 @@ wh = (const struct ieee80211_frame *)buf; switch (wh->i_fc[1] & IEEE80211_FC1_DIR_MASK) { case IEEE80211_FC1_DIR_NODS: - printf("NODS %s", ether_sprintf(wh->i_addr2)); - printf("->%s", ether_sprintf(wh->i_addr1)); - printf("(%s)", ether_sprintf(wh->i_addr3)); + kprintf("NODS %s", ether_sprintf(wh->i_addr2)); + kprintf("->%s", ether_sprintf(wh->i_addr1)); + kprintf("(%s)", ether_sprintf(wh->i_addr3)); break; case IEEE80211_FC1_DIR_TODS: - printf("TODS %s", ether_sprintf(wh->i_addr2)); - printf("->%s", ether_sprintf(wh->i_addr3)); - printf("(%s)", ether_sprintf(wh->i_addr1)); + kprintf("TODS %s", ether_sprintf(wh->i_addr2)); + kprintf("->%s", ether_sprintf(wh->i_addr3)); + kprintf("(%s)", ether_sprintf(wh->i_addr1)); break; case IEEE80211_FC1_DIR_FROMDS: - printf("FRDS %s", ether_sprintf(wh->i_addr3)); - printf("->%s", ether_sprintf(wh->i_addr1)); - printf("(%s)", ether_sprintf(wh->i_addr2)); + kprintf("FRDS %s", ether_sprintf(wh->i_addr3)); + kprintf("->%s", ether_sprintf(wh->i_addr1)); + kprintf("(%s)", ether_sprintf(wh->i_addr2)); break; case IEEE80211_FC1_DIR_DSTODS: - printf("DSDS %s", ether_sprintf((const uint8_t *)&wh[1])); - printf("->%s", ether_sprintf(wh->i_addr3)); - printf("(%s", ether_sprintf(wh->i_addr2)); - printf("->%s)", ether_sprintf(wh->i_addr1)); + kprintf("DSDS %s", ether_sprintf((const uint8_t *)&wh[1])); + kprintf("->%s", ether_sprintf(wh->i_addr3)); + kprintf("(%s", ether_sprintf(wh->i_addr2)); + kprintf("->%s)", ether_sprintf(wh->i_addr1)); break; } switch (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) { case IEEE80211_FC0_TYPE_DATA: - printf(" data"); + kprintf(" data"); break; case IEEE80211_FC0_TYPE_MGT: - printf(" %s", ieee80211_mgt_subtype_name(wh->i_fc[0])); + kprintf(" %s", ieee80211_mgt_subtype_name(wh->i_fc[0])); break; default: - printf(" type#%d", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK); + kprintf(" type#%d", wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK); break; } if (IEEE80211_QOS_HAS_SEQ(wh)) { const struct ieee80211_qosframe *qwh = (const struct ieee80211_qosframe *)buf; - printf(" QoS [TID %u%s]", qwh->i_qos[0] & IEEE80211_QOS_TID, + kprintf(" QoS [TID %u%s]", qwh->i_qos[0] & IEEE80211_QOS_TID, qwh->i_qos[0] & IEEE80211_QOS_ACKPOLICY ? " ACM" : ""); } if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) { int off; off = ieee80211_anyhdrspace(ic, wh); - printf(" WEP [IV %.02x %.02x %.02x", + kprintf(" WEP [IV %.02x %.02x %.02x", buf[off+0], buf[off+1], buf[off+2]); if (buf[off+IEEE80211_WEP_IVLEN] & IEEE80211_WEP_EXTIV) - printf(" %.02x %.02x %.02x", + kprintf(" %.02x %.02x %.02x", buf[off+4], buf[off+5], buf[off+6]); - printf(" KID %u]", buf[off+IEEE80211_WEP_IVLEN] >> 6); + kprintf(" KID %u]", buf[off+IEEE80211_WEP_IVLEN] >> 6); } if (rate >= 0) - printf(" %dM", rate / 2); + kprintf(" %dM", rate / 2); if (rssi >= 0) - printf(" +%d", rssi); - printf("\n"); + kprintf(" +%d", rssi); + kprintf("\n"); if (len > 0) { for (i = 0; i < len; i++) { if ((i & 1) == 0) - printf(" "); - printf("%02x", buf[i]); + kprintf(" "); + kprintf("%02x", buf[i]); } - printf("\n"); + kprintf("\n"); } } @@ -737,7 +745,8 @@ fixedrate != ucastrate)) { IEEE80211_NOTE(vap, IEEE80211_MSG_XRATE | IEEE80211_MSG_11N, ni, "%s: flags 0x%x okrate %d error %d fixedrate 0x%x " - "ucastrate %x\n", __func__, fixedrate, ucastrate, flags); + "ucastrate %x\n", __func__, flags, okrate, error, + fixedrate, ucastrate); return badrate | IEEE80211_RATE_BASIC; } else return IEEE80211_RV(okrate); @@ -1639,7 +1648,11 @@ * NB: do not use ieee80211_runtask here, we will * block & drain net80211 taskqueue. */ +#if defined(__DragonFly__) + taskqueue_enqueue(taskqueue_thread[0], &ic->ic_restart_task); +#else taskqueue_enqueue(taskqueue_thread, &ic->ic_restart_task); +#endif } void @@ -1989,7 +2002,18 @@ * Note this can also happen as a result of SLEEP->RUN * (i.e. coming out of power save mode). */ +#if defined(__DragonFly__) + struct ifaltq_subque *ifsq; + int wst; + + ifsq = ifq_get_subq_default(&vap->iv_ifp->if_snd); + ifsq_clr_oactive(ifsq); + wst = wlan_serialize_push(); + vap->iv_ifp->if_start(vap->iv_ifp, ifsq); + wlan_serialize_pop(wst); +#else vap->iv_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; +#endif /* * XXX TODO Kick-start a VAP queue - this should be a method! --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_radiotap.c 2016-01-18 12:53:05.000000000 -0800 +++ ./wlan/ieee80211_radiotap.c 2016-06-08 13:40:34.000000000 -0700 @@ -46,7 +46,17 @@ #include #include -#include +#include + +#if defined(__DragonFly__) +#define bpf_mtap2(rawbpf, rh, len, m) \ + { \ + bpf_gettoken(); \ + if (rawbpf) \ + bpf_ptap(rawbpf, m, rh, len); \ + bpf_reltoken(); \ + } +#endif static int radiotap_offset(struct ieee80211_radiotap_header *, int, int); @@ -115,10 +125,17 @@ struct ieee80211_radiotap_header *th = ic->ic_th; if (th != NULL && ic->ic_rh != NULL) { +#if defined(__DragonFly__) + bpfattach_dlt(vap->iv_ifp, DLT_IEEE802_11_RADIO, + sizeof(struct ieee80211_frame) + + le16toh(th->it_len), + &vap->iv_rawbpf); +#else /* radiotap DLT for raw 802.11 frames */ bpfattach2(vap->iv_ifp, DLT_IEEE802_11_RADIO, sizeof(struct ieee80211_frame) + le16toh(th->it_len), &vap->iv_rawbpf); +#endif } } @@ -354,14 +371,14 @@ continue; if (items[i].align == 0) { /* NB: unidentified element, don't guess */ - printf("%s: unknown item %d\n", __func__, i); + kprintf("%s: unknown item %d\n", __func__, i); return -1; } off = roundup2(off, items[i].align); if (i == item) { if (off + items[i].width > le16toh(rh->it_len)) { /* NB: item does not fit in header data */ - printf("%s: item %d not in header data, " + kprintf("%s: item %d not in header data, " "off %d width %zu len %d\n", __func__, i, off, items[i].width, le16toh(rh->it_len)); return -1; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ratectl.c 2016-03-16 15:30:15.000000000 -0700 +++ ./wlan/ieee80211_ratectl.c 2016-06-08 13:40:34.000000000 -0700 @@ -38,8 +38,8 @@ #include #include -#include -#include +#include +#include static const struct ieee80211_ratectl *ratectls[IEEE80211_RATECTL_MAX]; @@ -74,7 +74,11 @@ { struct sbuf *sb = (struct sbuf *) arg; +#if defined(__DragonFly__) + sbuf_printf(sb, "MAC: %6s\n", ether_sprintf(ni->ni_macaddr)); +#else sbuf_printf(sb, "MAC: %6D\n", ni->ni_macaddr, ":"); +#endif ieee80211_ratectl_node_stats(ni, sb); sbuf_printf(sb, "\n"); } @@ -87,11 +91,17 @@ struct sbuf sb; int error; +#if defined(__DragonFly__) +#else error = sysctl_wire_old_buffer(req, 0); if (error) return (error); +#endif sbuf_new_for_sysctl(&sb, NULL, 8, req); +#if defined(__DragonFly__) +#else sbuf_clear_flags(&sb, SBUF_INCLUDENUL); +#endif IEEE80211_LOCK(ic); ieee80211_iterate_nodes(&ic->ic_sta, @@ -112,9 +122,15 @@ vap->iv_rate->ir_init(vap); /* Attach generic stats sysctl */ +#if defined(__DragonFly__) + SYSCTL_ADD_PROC(vap->iv_sysctl, SYSCTL_CHILDREN(vap->iv_oid), OID_AUTO, + "rate_stats", CTLTYPE_STRING | CTLFLAG_RD, vap, + 0, ieee80211_ratectl_sysctl_stats, "A", "ratectl node stats"); +#else SYSCTL_ADD_PROC(vap->iv_sysctl, SYSCTL_CHILDREN(vap->iv_oid), OID_AUTO, "rate_stats", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, vap, 0, ieee80211_ratectl_sysctl_stats, "A", "ratectl node stats"); +#endif } void --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_ratectl_none.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_ratectl_none.c 2016-06-08 13:40:34.000000000 -0700 @@ -45,8 +45,8 @@ #include #endif -#include -#include +#include +#include static void none_init(struct ieee80211vap *vap) --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_regdomain.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_regdomain.c 2016-06-08 13:40:34.000000000 -0700 @@ -42,8 +42,8 @@ #include #include -#include -#include +#include +#include static void null_getradiocaps(struct ieee80211com *ic, int maxchan, @@ -244,8 +244,13 @@ struct ieee80211_country_ie *ie; int i, skip, nruns; +#if defined(__DragonFly__) + aie = kmalloc(IEEE80211_COUNTRY_MAX_SIZE, M_80211_NODE_IE, + M_INTWAIT | M_ZERO); +#else aie = IEEE80211_MALLOC(IEEE80211_COUNTRY_MAX_SIZE, M_80211_NODE_IE, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (aie == NULL) { ic_printf(ic, "%s: unable to allocate memory for country ie\n", __func__); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_rssadapt.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_rssadapt.c 2016-06-08 13:40:34.000000000 -0700 @@ -45,9 +45,9 @@ #include #include -#include -#include -#include +#include +#include +#include struct rssadapt_expavgctl { /* RSS threshold decay. */ @@ -132,8 +132,13 @@ KASSERT(vap->iv_rs == NULL, ("%s: iv_rs already initialized", __func__)); +#if defined(__DragonFly__) + vap->iv_rs = rs = kmalloc(sizeof(struct ieee80211_rssadapt), + M_80211_RATECTL, M_INTWAIT|M_ZERO); +#else vap->iv_rs = rs = IEEE80211_MALLOC(sizeof(struct ieee80211_rssadapt), M_80211_RATECTL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (rs == NULL) { if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n"); return; @@ -175,8 +180,13 @@ if (ni->ni_rctls == NULL) { ni->ni_rctls = ra = +#if defined(__DragonFly__) + kmalloc(sizeof(struct ieee80211_rssadapt_node), + M_80211_RATECTL, M_INTWAIT|M_ZERO); +#else IEEE80211_MALLOC(sizeof(struct ieee80211_rssadapt_node), M_80211_RATECTL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ra == NULL) { if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl " "structure\n"); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_scan.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_scan.c 2017-01-16 21:27:43.000000000 -0800 @@ -45,10 +45,10 @@ #include #include -#include +#include /* XXX until it's implemented as attach ops */ -#include +#include #include @@ -272,7 +272,7 @@ for (i = ss->ss_next; i < ss->ss_last; i++) { const struct ieee80211_channel *c = ss->ss_chans[i]; - printf("%s%u%c", sep, ieee80211_chan2ieee(ic, c), + kprintf("%s%u%c", sep, ieee80211_chan2ieee(ic, c), ieee80211_channel_type_char(c)); sep = ", "; } @@ -286,7 +286,7 @@ if_printf(vap->iv_ifp, "scan set "); ieee80211_scan_dump_channels(ss); - printf(" dwell min %lums max %lums\n", + kprintf(" dwell min %lums max %lums\n", ticks_to_msecs(ss->ss_mindwell), ticks_to_msecs(ss->ss_maxdwell)); } #endif /* IEEE80211_DEBUG */ @@ -347,7 +347,7 @@ scan = ieee80211_scanner_get(vap->iv_opmode); if (scan == NULL) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, - "%s: no scanner support for %s mode\n", + "%s: no scanner support for %d mode\n", __func__, vap->iv_opmode); /* XXX stat */ return 0; @@ -416,7 +416,7 @@ scan = ieee80211_scanner_get(vap->iv_opmode); if (scan == NULL) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, - "%s: no scanner support for %s mode\n", + "%s: no scanner support for %d mode\n", __func__, vap->iv_opmode); /* XXX stat */ return 0; @@ -443,6 +443,9 @@ /* * Cancel any scan currently going on. + * + * This is called during normal 802.11 data path to cancel + * a scan so a newly arrived normal data packet can be sent. */ void ieee80211_cancel_anyscan(struct ieee80211vap *vap) @@ -516,21 +519,21 @@ int i, nbands, schan, nchan; if (cie->len < 3) { - printf(" ", cie->len); + kprintf(" ", cie->len); return; } - printf(" country [%c%c%c", cie->cc[0], cie->cc[1], cie->cc[2]); + kprintf(" country [%c%c%c", cie->cc[0], cie->cc[1], cie->cc[2]); nbands = (cie->len - 3) / sizeof(cie->band[0]); for (i = 0; i < nbands; i++) { schan = cie->band[i].schan; nchan = cie->band[i].nchan; if (nchan != 1) - printf(" %u-%u,%u", schan, schan + nchan-1, + kprintf(" %u-%u,%u", schan, schan + nchan-1, cie->band[i].maxtxpwr); else - printf(" %u,%u", schan, cie->band[i].maxtxpwr); + kprintf(" %u,%u", schan, cie->band[i].maxtxpwr); } - printf("]"); + kprintf("]"); } void @@ -539,18 +542,18 @@ const struct ieee80211_scanparams *sp, int rssi) { - printf("[%s] %s%s on chan %u (bss chan %u) ", + kprintf("[%s] %s%s on chan %u (bss chan %u) ", ether_sprintf(mac), isnew ? "new " : "", ieee80211_mgt_subtype_name(subtype), sp->chan, sp->bchan); ieee80211_print_essid(sp->ssid + 2, sp->ssid[1]); - printf(" rssi %d\n", rssi); + kprintf(" rssi %d\n", rssi); if (isnew) { - printf("[%s] caps 0x%x bintval %u erp 0x%x", + kprintf("[%s] caps 0x%x bintval %u erp 0x%x", ether_sprintf(mac), sp->capinfo, sp->bintval, sp->erp); if (sp->country != NULL) dump_country(sp->country); - printf("\n"); + kprintf("\n"); } } #endif /* IEEE80211_DEBUG */ @@ -660,7 +663,7 @@ if (ss->ss_ops->scan_pickchan == NULL) { IEEE80211_DPRINTF(ss->ss_vap, IEEE80211_MSG_SCAN, "%s: scan module does not support picking a channel, " - "opmode %s\n", __func__, ss->ss_vap->iv_opmode); + "opmode %d\n", __func__, ss->ss_vap->iv_opmode); return NULL; } return ss->ss_ops->scan_pickchan(ss, flags); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_scan_sta.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_scan_sta.c 2017-01-16 21:27:43.000000000 -0800 @@ -45,16 +45,16 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_TDMA -#include +#include #endif #ifdef IEEE80211_SUPPORT_MESH -#include +#include #endif -#include +#include #include @@ -161,9 +161,14 @@ { struct sta_table *st; +#if defined(__DragonFly__) + st = (struct sta_table *) kmalloc(sizeof(struct sta_table), + M_80211_SCAN, M_INTWAIT | M_ZERO); +#else st = (struct sta_table *) IEEE80211_MALLOC(sizeof(struct sta_table), M_80211_SCAN, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (st == NULL) return 0; IEEE80211_SCAN_TABLE_LOCK_INIT(st, "scantable"); @@ -255,8 +260,13 @@ LIST_FOREACH(se, &st->st_hash[hash], se_hash) if (IEEE80211_ADDR_EQ(se->base.se_macaddr, macaddr)) goto found; +#if defined(__DragonFly__) + se = (struct sta_entry *) kmalloc(sizeof(struct sta_entry), + M_80211_SCAN, M_INTWAIT | M_ZERO); +#else se = (struct sta_entry *) IEEE80211_MALLOC(sizeof(struct sta_entry), M_80211_SCAN, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (se == NULL) { IEEE80211_SCAN_TABLE_UNLOCK(st); return 0; @@ -1110,7 +1120,7 @@ fail |= MATCH_RSSI; #ifdef IEEE80211_DEBUG if (ieee80211_msg(vap, debug)) { - printf(" %c %s", + kprintf(" %c %s", fail & MATCH_FAILS ? '=' : fail & MATCH_NOTSEEN ? '^' : fail & MATCH_CC ? '$' : @@ -1123,23 +1133,23 @@ #endif fail & MATCH_MESH_NOID ? 'm' : fail ? '-' : '+', ether_sprintf(se->se_macaddr)); - printf(" %s%c", ether_sprintf(se->se_bssid), + kprintf(" %s%c", ether_sprintf(se->se_bssid), fail & MATCH_BSSID ? '!' : ' '); - printf(" %3d%c", ieee80211_chan2ieee(ic, se->se_chan), + kprintf(" %3d%c", ieee80211_chan2ieee(ic, se->se_chan), fail & MATCH_CHANNEL ? '!' : ' '); - printf(" %+4d%c", se->se_rssi, fail & MATCH_RSSI ? '!' : ' '); - printf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2, + kprintf(" %+4d%c", se->se_rssi, fail & MATCH_RSSI ? '!' : ' '); + kprintf(" %2dM%c", (rate & IEEE80211_RATE_VAL) / 2, fail & MATCH_RATE ? '!' : ' '); - printf(" %4s%c", + kprintf(" %4s%c", (se->se_capinfo & IEEE80211_CAPINFO_ESS) ? "ess" : (se->se_capinfo & IEEE80211_CAPINFO_IBSS) ? "ibss" : "", fail & MATCH_CAPINFO ? '!' : ' '); - printf(" %3s%c ", + kprintf(" %3s%c ", (se->se_capinfo & IEEE80211_CAPINFO_PRIVACY) ? "wep" : "no", fail & MATCH_PRIVACY ? '!' : ' '); ieee80211_print_essid(se->se_ssid+2, se->se_ssid[1]); - printf("%s\n", fail & (MATCH_SSID | MATCH_MESHID) ? "!" : ""); + kprintf("%s\n", fail & (MATCH_SSID | MATCH_MESHID) ? "!" : ""); } #endif return fail; @@ -1334,7 +1344,8 @@ * XXX force immediate switch on scan complete */ if (!IEEE80211_IS_CHAN_DTURBO(ic->ic_curchan) && - ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle)) + ((vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) || + ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle))) ieee80211_bg_scan(vap, 0); return; } --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_scan_sw.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_scan_sw.c 2017-01-16 21:27:43.000000000 -0800 @@ -45,9 +45,9 @@ #include #include -#include +#include -#include +#include #include @@ -427,6 +427,12 @@ return (ic->ic_flags & IEEE80211_F_SCAN); } +/* + * Taskqueue work to cancel a scan. + * + * Note: for offload scan devices, we may want to call into the + * driver to try and cancel scanning, however it may not be cancelable. + */ static void cancel_scan(struct ieee80211vap *vap, int any, const char *func) { @@ -472,6 +478,10 @@ static void ieee80211_swscan_cancel_anyscan(struct ieee80211vap *vap) { + /* XXX for now - just don't do this per packet. */ + if (vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) + return; + cancel_scan(vap, 1, __func__); } @@ -523,6 +533,12 @@ int i; /* + * Full-offload scan devices don't require this. + */ + if (vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) + return; + + /* * Send directed probe requests followed by any * broadcast probe request. * XXX remove dependence on ic/vap->iv_bss @@ -628,14 +644,26 @@ return; } - if (vap->iv_opmode == IEEE80211_M_STA && + /* + * Put the station into power save mode. + * + * This is only required if we're not a full-offload device; + * those devices manage scan/traffic differently. + */ + if (((vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) == 0) && + vap->iv_opmode == IEEE80211_M_STA && vap->iv_state == IEEE80211_S_RUN) { if ((vap->iv_bss->ni_flags & IEEE80211_NODE_PWR_MGT) == 0) { /* Enable station power save mode */ vap->iv_sta_ps(vap, 1); /* Wait until null data frame will be ACK'ed */ +#if defined(__DragonFly__) + lksleep(vap, IEEE80211_LOCK_OBJ(ic), PCATCH, + "sta_ps", msecs_to_ticks(10)); +#else mtx_sleep(vap, IEEE80211_LOCK_OBJ(ic), PCATCH, "sta_ps", msecs_to_ticks(10)); +#endif if (ss_priv->ss_iflags & ISCAN_ABORT) { scan_done(ss, 0); return; @@ -881,11 +909,15 @@ * waiting for us. */ if (scandone) { + /* + * If we're not a scan offload device, come back out of + * station powersave. Offload devices handle this themselves. + */ + if ((vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) == 0) vap->iv_sta_ps(vap, 0); - if (ss->ss_next >= ss->ss_last) { - ieee80211_notify_scan_done(vap); + if (ss->ss_next >= ss->ss_last) ic->ic_flags_ext &= ~IEEE80211_FEXT_BGSCAN; - } + ieee80211_notify_scan_done(vap); } ss_priv->ss_iflags &= ~(ISCAN_CANCEL|ISCAN_ABORT); ss_priv->ss_scanend = 0; @@ -976,8 +1008,13 @@ ic->ic_scan_methods = &swscan_methods; /* Allocate initial scan state */ +#if defined(__DragonFly__) + ss = (struct scan_state *) kmalloc(sizeof(struct scan_state), + M_80211_SCAN, M_INTWAIT | M_ZERO); +#else ss = (struct scan_state *) IEEE80211_MALLOC(sizeof(struct scan_state), M_80211_SCAN, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ss == NULL) { ic->ic_scan = NULL; return; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_sta.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_sta.c 2017-01-16 21:27:43.000000000 -0800 @@ -56,14 +56,14 @@ #include -#include -#include -#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif -#include -#include +#include +#include #define IEEE80211_RATE2MBS(r) (((r) & IEEE80211_RATE_VAL) / 2) @@ -420,7 +420,7 @@ ieee80211_print_essid(vap->iv_bss->ni_essid, ni->ni_esslen); /* XXX MCS/HT */ - printf(" channel %d start %uMb\n", + kprintf(" channel %d start %uMb\n", ieee80211_chan2ieee(ic, ic->ic_curchan), IEEE80211_RATE2MBS(ni->ni_txrate)); } @@ -624,8 +624,14 @@ if ((! IEEE80211_IS_MULTICAST(wh->i_addr1)) && (! IEEE80211_ADDR_EQ(wh->i_addr1, IF_LLADDR(ifp)))) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, +#if defined(__DragonFly__) + bssid, NULL, "not to cur sta: lladdr=%s, addr1=%s", + ether_sprintf(IF_LLADDR(ifp)), + ether_sprintf(wh->i_addr1)); +#else bssid, NULL, "not to cur sta: lladdr=%6D, addr1=%6D", IF_LLADDR(ifp), ":", wh->i_addr1, ":"); +#endif vap->iv_stats.is_rx_wrongbss++; goto out; } @@ -1013,7 +1019,7 @@ if ((frm[1] + 2) > (efrm - frm)) { IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_AUTH, ni->ni_macaddr, "shared key auth", - "ie %d/%d too long", + "ie %d/%ld too long", frm[0], (frm[1] + 2) - (efrm - frm)); vap->iv_stats.is_rx_bad_auth++; estatus = IEEE80211_STATUS_CHALLENGE; @@ -1218,7 +1224,7 @@ IEEE80211_NOTE_FRAME(vap, IEEE80211_MSG_DOTH, wh, "CSA ie mismatch, initial ie <%d,%d,%d>, " "this ie <%d,%d,%d>", ic->ic_csa_mode, - ic->ic_csa_newchan, ic->ic_csa_count, + ic->ic_csa_newchan->ic_ieee, ic->ic_csa_count, csa->csa_mode, csa->csa_newchan, csa->csa_count); ieee80211_csa_cancelswitch(ic); } else { @@ -1237,6 +1243,7 @@ * o bg scan is active * o no channel switch is pending * o there has not been any traffic recently + * o no full-offload scan support (no need for explicitly continuing scan then) * * Note we do not check if there is an administrative enable; * this is only done to start the scan. We assume that any @@ -1250,6 +1257,7 @@ return ((ic->ic_flags_ext & IEEE80211_FEXT_BGSCAN) && (ic->ic_flags & IEEE80211_F_CSAPENDING) == 0 && + !(vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) && vap->iv_state == IEEE80211_S_RUN && /* XXX? */ ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle)); } @@ -1260,7 +1268,7 @@ * o no channel switch is pending * o we are not boosted on a dynamic turbo channel * o there has not been a scan recently - * o there has not been any traffic recently + * o there has not been any traffic recently (don't check if full-offload scan) */ static __inline int startbgscan(struct ieee80211vap *vap) @@ -1273,7 +1281,8 @@ !IEEE80211_IS_CHAN_DTURBO(ic->ic_curchan) && #endif ieee80211_time_after(ticks, ic->ic_lastscan + vap->iv_bgscanintvl) && - ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle)); + ((vap->iv_flags_ext & IEEE80211_FEXT_SCAN_OFFLOAD) || + ieee80211_time_after(ticks, ic->ic_lastdata + vap->iv_bgscanidle))); } static void --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_superg.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_superg.c 2016-06-08 13:40:34.000000000 -0700 @@ -45,10 +45,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include /* * Atheros fast-frame encapsulation format. @@ -99,11 +99,17 @@ { struct ieee80211_superg *sg; +#if defined(__DragonFly__) + sg = (struct ieee80211_superg *) kmalloc( + sizeof(struct ieee80211_superg), M_80211_VAP, + M_INTWAIT | M_ZERO); +#else sg = (struct ieee80211_superg *) IEEE80211_MALLOC( sizeof(struct ieee80211_superg), M_80211_VAP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (sg == NULL) { - printf("%s: cannot allocate SuperG state block\n", + kprintf("%s: cannot allocate SuperG state block\n", __func__); return; } @@ -365,7 +371,7 @@ ETHER_HEADER_COPY(&eh1, mtod(m1, caddr_t)); m1 = ieee80211_mbuf_adjust(vap, hdrspace, key, m1); if (m1 == NULL) { - printf("%s: failed initial mbuf_adjust\n", __func__); + kprintf("%s: failed initial mbuf_adjust\n", __func__); /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ m_freem(m2); goto bad; @@ -381,7 +387,7 @@ m2 = ieee80211_mbuf_adjust(vap, 4, NULL, m2); if (m2 == NULL) { /* NB: ieee80211_mbuf_adjust handles msgs+statistics */ - printf("%s: failed second \n", __func__); + kprintf("%s: failed second \n", __func__); goto bad; } @@ -704,7 +710,7 @@ } mprev = m; } - printf("%s: packet not found\n", __func__); + kprintf("%s: packet not found\n", __func__); } static uint32_t --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_tdma.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_tdma.c 2016-06-08 13:40:34.000000000 -0700 @@ -58,9 +58,9 @@ #include -#include -#include -#include +#include +#include +#include #ifndef TDMA_SLOTLEN_DEFAULT #define TDMA_SLOTLEN_DEFAULT 10*1000 /* 10ms */ @@ -149,11 +149,17 @@ KASSERT(vap->iv_caps & IEEE80211_C_TDMA, ("not a tdma vap, caps 0x%x", vap->iv_caps)); +#if defined(__DragonFly__) + ts = (struct ieee80211_tdma_state *) kmalloc( + sizeof(struct ieee80211_tdma_state), M_80211_VAP, + M_INTWAIT | M_ZERO); +#else ts = (struct ieee80211_tdma_state *) IEEE80211_MALLOC( sizeof(struct ieee80211_tdma_state), M_80211_VAP, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ts == NULL) { - printf("%s: cannot allocate TDMA state block\n", __func__); + kprintf("%s: cannot allocate TDMA state block\n", __func__); /* NB: fall back to adhdemo mode */ vap->iv_caps &= ~IEEE80211_C_TDMA; return; @@ -416,7 +422,7 @@ if (tdma->tdma_slotcnt != ts->tdma_slotcnt) { if (!TDMA_SLOTCNT_VALID(tdma->tdma_slotcnt)) { if (ppsratecheck(&ts->tdma_lastprint, &ts->tdma_fails, 1)) - printf("%s: bad slot cnt %u\n", + kprintf("%s: bad slot cnt %u\n", __func__, tdma->tdma_slotcnt); return 0; } @@ -426,7 +432,7 @@ if (slotlen != ts->tdma_slotlen) { if (!TDMA_SLOTLEN_VALID(slotlen)) { if (ppsratecheck(&ts->tdma_lastprint, &ts->tdma_fails, 1)) - printf("%s: bad slot len %u\n", + kprintf("%s: bad slot len %u\n", __func__, slotlen); return 0; } @@ -435,7 +441,7 @@ if (tdma->tdma_bintval != ts->tdma_bintval) { if (!TDMA_BINTVAL_VALID(tdma->tdma_bintval)) { if (ppsratecheck(&ts->tdma_lastprint, &ts->tdma_fails, 1)) - printf("%s: bad beacon interval %u\n", + kprintf("%s: bad beacon interval %u\n", __func__, tdma->tdma_bintval); return 0; } @@ -450,7 +456,7 @@ if (isclr(tdma->tdma_inuse, slot)) break; if (slot <= 0) { - printf("%s: no free slot, slotcnt %u inuse: 0x%x\n", + kprintf("%s: no free slot, slotcnt %u inuse: 0x%x\n", __func__, tdma->tdma_slotcnt, tdma->tdma_inuse[0]); /* XXX need to do something better */ @@ -612,7 +618,7 @@ "slot %u collision rxtsf %llu tsf %llu\n", tdma->tdma_slot, (unsigned long long) le64toh(ni->ni_tstamp.tsf), - vap->iv_bss->ni_tstamp.tsf); + (unsigned long long) vap->iv_bss->ni_tstamp.tsf); setbit(ts->tdma_inuse, tdma->tdma_slot); (void) tdma_update(vap, tdma, ni, 1); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_wds.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan/ieee80211_wds.c 2016-06-08 13:40:34.000000000 -0700 @@ -55,11 +55,11 @@ #include -#include -#include -#include +#include +#include +#include #ifdef IEEE80211_SUPPORT_SUPERG -#include +#include #endif static void wds_vattach(struct ieee80211vap *); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_acl.c 2016-03-14 16:15:53.000000000 -0700 +++ ./wlan_acl/ieee80211_acl.c 2016-06-08 13:40:34.000000000 -0700 @@ -54,7 +54,7 @@ #include #include -#include +#include enum { ACL_POLICY_OPEN = 0, /* open, don't check ACL's */ @@ -100,8 +100,13 @@ { struct aclstate *as; +#if defined(__DragonFly__) + as = (struct aclstate *) kmalloc(sizeof(struct aclstate), + M_80211_ACL, M_INTWAIT | M_ZERO); +#else as = (struct aclstate *) IEEE80211_MALLOC(sizeof(struct aclstate), M_80211_ACL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (as == NULL) return 0; ACL_LOCK_INIT(as, "acl"); @@ -176,8 +181,13 @@ struct acl *acl, *new; int hash; +#if defined(__DragonFly__) + new = (struct acl *) kmalloc(sizeof(struct acl), + M_80211_ACL, M_INTWAIT | M_ZERO); +#else new = (struct acl *) IEEE80211_MALLOC(sizeof(struct acl), M_80211_ACL, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (new == NULL) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_ACL, "ACL: add %s failed, no memory\n", ether_sprintf(mac)); @@ -304,8 +314,13 @@ ireq->i_len = space; /* return required space */ return 0; /* NB: must not error */ } +#if defined(__DragonFly__) + ap = (struct ieee80211req_maclist *) kmalloc(space, + M_TEMP, M_INTWAIT); +#else ap = (struct ieee80211req_maclist *) IEEE80211_MALLOC(space, M_TEMP, IEEE80211_M_NOWAIT); +#endif if (ap == NULL) return ENOMEM; i = 0; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_crypto_ccmp.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan_ccmp/ieee80211_crypto_ccmp.c 2017-01-16 21:27:43.000000000 -0800 @@ -48,7 +48,7 @@ #include #include -#include +#include #include @@ -98,8 +98,13 @@ { struct ccmp_ctx *ctx; +#if defined(__DragonFly__) + ctx = (struct ccmp_ctx *) kmalloc(sizeof(struct ccmp_ctx), + M_80211_CRYPTO, M_INTWAIT | M_ZERO); +#else ctx = (struct ccmp_ctx *) IEEE80211_MALLOC(sizeof(struct ccmp_ctx), M_80211_CRYPTO, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ctx == NULL) { vap->iv_stats.is_crypto_nomem++; return NULL; @@ -176,7 +181,7 @@ if (m == NULL) return 0; ivp = mtod(m, uint8_t *); - ovbcopy(ivp + ccmp.ic_header, ivp, hdrlen); + bcopy(ivp + ccmp.ic_header, ivp, hdrlen); ivp += hdrlen; ccmp_setiv(k, ivp); @@ -264,7 +269,7 @@ /* * Copy up 802.11 header and strip crypto bits. */ - ovbcopy(mtod(m, void *), mtod(m, uint8_t *) + ccmp.ic_header, hdrlen); + bcopy(mtod(m, void *), mtod(m, uint8_t *) + ccmp.ic_header, hdrlen); m_adj(m, ccmp.ic_header); m_adj(m, -ccmp.ic_trailer); --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_crypto_tkip.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan_tkip/ieee80211_crypto_tkip.c 2016-06-08 13:40:34.000000000 -0700 @@ -49,7 +49,7 @@ #include #include -#include +#include static void *tkip_attach(struct ieee80211vap *, struct ieee80211_key *); static void tkip_detach(struct ieee80211_key *); @@ -110,8 +110,13 @@ { struct tkip_ctx *ctx; +#if defined(__DragonFly__) + ctx = (struct tkip_ctx *) kmalloc(sizeof(struct tkip_ctx), + M_80211_CRYPTO, M_INTWAIT | M_ZERO); +#else ctx = (struct tkip_ctx *) IEEE80211_MALLOC(sizeof(struct tkip_ctx), M_80211_CRYPTO, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ctx == NULL) { vap->iv_stats.is_crypto_nomem++; return NULL; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_crypto_wep.c 2017-01-17 13:55:20.000000000 -0800 +++ ./wlan_wep/ieee80211_crypto_wep.c 2017-01-16 21:27:43.000000000 -0800 @@ -45,7 +45,7 @@ #include #include -#include +#include static void *wep_attach(struct ieee80211vap *, struct ieee80211_key *); static void wep_detach(struct ieee80211_key *); @@ -89,8 +89,13 @@ { struct wep_ctx *ctx; +#if defined(__DragonFly__) + ctx = (struct wep_ctx *) kmalloc(sizeof(struct wep_ctx), + M_80211_CRYPTO, M_INTWAIT | M_ZERO); +#else ctx = (struct wep_ctx *) IEEE80211_MALLOC(sizeof(struct wep_ctx), M_80211_CRYPTO, IEEE80211_M_NOWAIT | IEEE80211_M_ZERO); +#endif if (ctx == NULL) { vap->iv_stats.is_crypto_nomem++; return NULL; @@ -192,7 +197,7 @@ if (m == NULL) return 0; ivp = mtod(m, uint8_t *); - ovbcopy(ivp + wep.ic_header, ivp, hdrlen); + bcopy(ivp + wep.ic_header, ivp, hdrlen); ivp += hdrlen; wep_setiv(k, ivp); @@ -247,7 +252,7 @@ /* * Copy up 802.11 header and strip crypto bits. */ - ovbcopy(mtod(m, void *), mtod(m, uint8_t *) + wep.ic_header, hdrlen); + bcopy(mtod(m, void *), mtod(m, uint8_t *) + wep.ic_header, hdrlen); m_adj(m, wep.ic_header); m_adj(m, -wep.ic_trailer); @@ -433,7 +438,7 @@ } off = hdrlen + wep.ic_header; - data_len = m->m_pkthdr.len - (off + wep.ic_trailer), + data_len = m->m_pkthdr.len - (off + wep.ic_trailer); /* Compute CRC32 over unencrypted data and apply RC4 to data */ crc = ~0; --- /Users/adrian/git/github/freebsd/freebsd/sys/net80211///ieee80211_xauth.c 2016-03-14 16:15:53.000000000 -0700 +++ ./wlan_xauth/ieee80211_xauth.c 2016-06-08 13:40:34.000000000 -0700 @@ -55,7 +55,7 @@ #include #include -#include +#include /* XXX number of references from net80211 layer; needed for module code */ static int nrefs = 0;