Date: Mon, 18 Aug 2003 10:27:27 -0700 (PDT) From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 36361 for review Message-ID: <200308181727.h7IHRRTd012163@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=36361 Change 36361 by sam@sam_ebb on 2003/08/18 10:26:55 o correct packet length calculation for beacon frames (was too short but didn't matter since it was only used to choose between inline mbuf and cluster) o add a KASSERT to verify the beacon packet length is correct o don't discard control frames when in monitor mode; they'll get tossed in the 802.11 layer anyway and doing this allows listeners to see them o add a statistic to count control frames discarded in the driver o move the rx too short statistic to be near the control frames discarded statistic (requires recompile of athstats) Affected files ... .. //depot/projects/netperf/sys/dev/ath/if_ath.c#8 edit .. //depot/projects/netperf/sys/dev/ath/if_athioctl.h#3 edit Differences ... ==== //depot/projects/netperf/sys/dev/ath/if_ath.c#8 (text+ko) ==== @@ -996,7 +996,8 @@ * with this alignment (perhaps should assert). */ rs = &ni->ni_rates; - pktlen = 8 + 2 + 2+ 2+ni->ni_esslen + 2+rs->rs_nrates + 6; + pktlen = sizeof (struct ieee80211_frame) + + 8 + 2 + 2 + 2+ni->ni_esslen + 2+rs->rs_nrates + 6; if (rs->rs_nrates > IEEE80211_RATE_SIZE) pktlen += 2; if (pktlen <= MHLEN) @@ -1067,6 +1068,9 @@ } frm = ieee80211_add_xrates(frm, rs); m->m_pkthdr.len = m->m_len = frm - mtod(m, u_int8_t *); + KASSERT(m->m_pkthdr.len <= pktlen, + ("beacon bigger than expected, len %u calculated %u", + m->m_pkthdr.len, pktlen)); DPRINTF2(("ath_beacon_alloc: m %p len %u\n", m, m->m_len)); error = bus_dmamap_load_mbuf(sc->sc_dmat, bf->bf_dmamap, m, @@ -1086,7 +1090,6 @@ ds->ds_link = 0; ds->ds_data = bf->bf_segs[0].ds_addr; - /* XXX verify mbuf data area covers this roundup */ /* * Calculate rate code. * XXX everything at min xmit rate @@ -1110,6 +1113,7 @@ , 0 /* rts/cts duration */ ); /* NB: beacon's BufLen must be a multiple of 4 bytes */ + /* XXX verify mbuf data area covers this roundup */ ath_hal_filltxdesc(ah, ds , roundup(bf->bf_segs[0].ds_len, 4) /* buffer length */ , AH_TRUE /* first segment */ @@ -1128,12 +1132,13 @@ struct ath_hal *ah = sc->sc_ah; DPRINTF2(("%s: pending %u\n", __func__, pending)); - if (ic->ic_opmode == IEEE80211_M_STA || bf == NULL || bf->bf_m == NULL) { + if (ic->ic_opmode == IEEE80211_M_STA || + bf == NULL || bf->bf_m == NULL) { DPRINTF(("%s: ic_flags=%x bf=%p bf_m=%p\n", __func__, ic->ic_flags, bf, bf ? bf->bf_m : NULL)); return; } - /* update beacon to reflect PS poll state */ + /* TODO: update beacon to reflect PS poll state */ if (!ath_hal_stoptxdma(ah, sc->sc_bhalq)) { DPRINTF(("%s: beacon queue %u did not stop?", __func__, sc->sc_bhalq)); @@ -1522,6 +1527,7 @@ len = ds->ds_rxstat.rs_datalen; if (len < sizeof(struct ieee80211_frame)) { DPRINTF(("ath_rx_proc: short packet %d\n", len)); + sc->sc_stats.ast_rx_tooshort++; goto rx_next; } @@ -1530,11 +1536,13 @@ wh = mtod(m, struct ieee80211_frame *); if ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == - IEEE80211_FC0_TYPE_CTL) { + IEEE80211_FC0_TYPE_CTL && + ic->ic_opmode != IEEE80211_M_MONITOR) { /* - * Ignore control frame received in promisc mode. + * Discard control frame when not in monitor mode. */ DPRINTF(("ath_rx_proc: control frame\n")); + sc->sc_stats.ast_rx_ctl++; goto rx_next; } ==== //depot/projects/netperf/sys/dev/ath/if_athioctl.h#3 (text+ko) ==== @@ -73,12 +73,13 @@ u_int32_t ast_rx_nombuf; /* rx setup failed 'cuz no mbuf */ u_int32_t ast_rx_busdma; /* rx setup failed for dma resrcs */ u_int32_t ast_rx_orn; /* rx failed 'cuz of desc overrun */ - u_int32_t ast_rx_tooshort;/* rx failed 'cuz frame too short */ u_int32_t ast_rx_crcerr; /* rx failed 'cuz of bad CRC */ u_int32_t ast_rx_fifoerr; /* rx failed 'cuz of FIFO overrun */ u_int32_t ast_rx_badcrypt;/* rx failed 'cuz decryption */ u_int32_t ast_rx_phyerr; /* rx failed 'cuz of PHY err */ u_int32_t ast_rx_phy[32]; /* rx PHY error per-code counts */ + u_int32_t ast_rx_tooshort;/* rx discarded 'cuz frame too short */ + u_int32_t ast_rx_ctl; /* rx discarded 'cuz ctl frame */ u_int32_t ast_be_nombuf; /* beacon setup failed 'cuz no mbuf */ u_int32_t ast_per_cal; /* periodic calibration calls */ u_int32_t ast_per_calfail;/* periodic calibration failed */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308181727.h7IHRRTd012163>