Index: head/sys/net80211/ieee80211_adhoc.c =================================================================== --- head/sys/net80211/ieee80211_adhoc.c +++ head/sys/net80211/ieee80211_adhoc.c @@ -302,7 +302,6 @@ int hdrspace, need_tap = 1; /* mbuf need to be tapped. */ uint8_t dir, type, subtype, qos; uint8_t *bssid; - uint16_t rxseq; if (m->m_flags & M_AMPDU_MPDU) { /* @@ -421,24 +420,8 @@ if (IEEE80211_QOS_HAS_SEQ(wh) && TID_TO_WME_AC(tid) >= WME_AC_VI) ic->ic_wme.wme_hipri_traffic++; - rxseq = le16toh(*(uint16_t *)wh->i_seq); - if (! ieee80211_check_rxseq(ni, wh)) { - /* duplicate, discard */ - IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, - bssid, "duplicate", - "seqno <%u,%u> fragno <%u,%u> tid %u", - rxseq >> IEEE80211_SEQ_SEQ_SHIFT, - ni->ni_rxseqs[tid] >> - IEEE80211_SEQ_SEQ_SHIFT, - rxseq & IEEE80211_SEQ_FRAG_MASK, - ni->ni_rxseqs[tid] & - IEEE80211_SEQ_FRAG_MASK, - tid); - vap->iv_stats.is_rx_dup++; - IEEE80211_NODE_STAT(ni, rx_dup); + if (! ieee80211_check_rxseq(ni, wh, bssid)) goto out; - } - ni->ni_rxseqs[tid] = rxseq; } } Index: head/sys/net80211/ieee80211_hostap.c =================================================================== --- head/sys/net80211/ieee80211_hostap.c +++ head/sys/net80211/ieee80211_hostap.c @@ -485,7 +485,6 @@ int hdrspace, need_tap = 1; /* mbuf need to be tapped. */ uint8_t dir, type, subtype, qos; uint8_t *bssid; - uint16_t rxseq; if (m->m_flags & M_AMPDU_MPDU) { /* @@ -573,24 +572,8 @@ if (IEEE80211_QOS_HAS_SEQ(wh) && TID_TO_WME_AC(tid) >= WME_AC_VI) ic->ic_wme.wme_hipri_traffic++; - rxseq = le16toh(*(uint16_t *)wh->i_seq); - if (! ieee80211_check_rxseq(ni, wh)) { - /* duplicate, discard */ - IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, - bssid, "duplicate", - "seqno <%u,%u> fragno <%u,%u> tid %u", - rxseq >> IEEE80211_SEQ_SEQ_SHIFT, - ni->ni_rxseqs[tid] >> - IEEE80211_SEQ_SEQ_SHIFT, - rxseq & IEEE80211_SEQ_FRAG_MASK, - ni->ni_rxseqs[tid] & - IEEE80211_SEQ_FRAG_MASK, - tid); - vap->iv_stats.is_rx_dup++; - IEEE80211_NODE_STAT(ni, rx_dup); + if (! ieee80211_check_rxseq(ni, wh, bssid)) goto out; - } - ni->ni_rxseqs[tid] = rxseq; } } Index: head/sys/net80211/ieee80211_input.h =================================================================== --- head/sys/net80211/ieee80211_input.h +++ head/sys/net80211/ieee80211_input.h @@ -164,12 +164,14 @@ * but a retransmit since the initial packet didn't make it. */ static __inline int -ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh) +ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh, + uint8_t *bssid) { #define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0) #define SEQ_EQ(a,b) ((int)((a)-(b)) == 0) #define SEQNO(a) ((a) >> IEEE80211_SEQ_SEQ_SHIFT) #define FRAGNO(a) ((a) & IEEE80211_SEQ_FRAG_MASK) + struct ieee80211vap *vap = ni->ni_vap; uint16_t rxseq; uint8_t type, subtype; uint8_t tid; @@ -198,7 +200,7 @@ /* HT nodes currently doing RX AMPDU are always valid */ if ((ni->ni_flags & IEEE80211_NODE_HT) && (rap->rxa_flags & IEEE80211_AGGR_RUNNING)) - return 1; + goto ok; } /* @@ -216,7 +218,7 @@ */ if (SEQ_EQ(rxseq, ni->ni_rxseqs[tid]) && (wh->i_fc[1] & IEEE80211_FC1_RETRY)) - return 0; + goto fail; /* * Treat any subsequent frame as fine if the last seen frame * is 4095 and it's not a retransmit for the same sequence @@ -224,7 +226,7 @@ * fragments w/ sequence number 4095. It shouldn't be seen * in practice, but see the comment above for further info. */ - return 1; + goto ok; } /* @@ -233,9 +235,23 @@ */ if ((wh->i_fc[1] & IEEE80211_FC1_RETRY) && SEQ_LEQ(rxseq, ni->ni_rxseqs[tid])) - return 0; + goto fail; + +ok: + ni->ni_rxseqs[tid] = rxseq; return 1; + +fail: + /* duplicate, discard */ + IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, bssid, "duplicate", + "seqno <%u,%u> fragno <%u,%u> tid %u", + SEQNO(rxseq), SEQNO(ni->ni_rxseqs[tid]), + FRAGNO(rxseq), FRAGNO(ni->ni_rxseqs[tid]), tid); + vap->iv_stats.is_rx_dup++; + IEEE80211_NODE_STAT(ni, rx_dup); + + return 0; #undef SEQ_LEQ #undef SEQ_EQ #undef SEQNO Index: head/sys/net80211/ieee80211_mesh.c =================================================================== --- head/sys/net80211/ieee80211_mesh.c +++ head/sys/net80211/ieee80211_mesh.c @@ -1537,7 +1537,6 @@ uint32_t seq; const uint8_t *addr; uint8_t qos[2]; - ieee80211_seq rxseq; KASSERT(ni != NULL, ("null node")); ni->ni_inact = ni->ni_inact_reload; @@ -1582,24 +1581,8 @@ if (IEEE80211_QOS_HAS_SEQ(wh) && TID_TO_WME_AC(tid) >= WME_AC_VI) ic->ic_wme.wme_hipri_traffic++; - rxseq = le16toh(*(uint16_t *)wh->i_seq); - if (! ieee80211_check_rxseq(ni, wh)) { - /* duplicate, discard */ - IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, - wh->i_addr1, "duplicate", - "seqno <%u,%u> fragno <%u,%u> tid %u", - rxseq >> IEEE80211_SEQ_SEQ_SHIFT, - ni->ni_rxseqs[tid] >> - IEEE80211_SEQ_SEQ_SHIFT, - rxseq & IEEE80211_SEQ_FRAG_MASK, - ni->ni_rxseqs[tid] & - IEEE80211_SEQ_FRAG_MASK, - tid); - vap->iv_stats.is_rx_dup++; - IEEE80211_NODE_STAT(ni, rx_dup); + if (! ieee80211_check_rxseq(ni, wh, wh->i_addr1)) goto out; - } - ni->ni_rxseqs[tid] = rxseq; } } #ifdef IEEE80211_DEBUG Index: head/sys/net80211/ieee80211_sta.c =================================================================== --- head/sys/net80211/ieee80211_sta.c +++ head/sys/net80211/ieee80211_sta.c @@ -538,7 +538,6 @@ int hdrspace, need_tap = 1; /* mbuf need to be tapped. */ uint8_t dir, type, subtype, qos; uint8_t *bssid; - uint16_t rxseq; if (m->m_flags & M_AMPDU_MPDU) { /* @@ -630,24 +629,8 @@ if (IEEE80211_QOS_HAS_SEQ(wh) && TID_TO_WME_AC(tid) >= WME_AC_VI) ic->ic_wme.wme_hipri_traffic++; - rxseq = le16toh(*(uint16_t *)wh->i_seq); - if (! ieee80211_check_rxseq(ni, wh)) { - /* duplicate, discard */ - IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, - bssid, "duplicate", - "seqno <%u,%u> fragno <%u,%u> tid %u", - rxseq >> IEEE80211_SEQ_SEQ_SHIFT, - ni->ni_rxseqs[tid] >> - IEEE80211_SEQ_SEQ_SHIFT, - rxseq & IEEE80211_SEQ_FRAG_MASK, - ni->ni_rxseqs[tid] & - IEEE80211_SEQ_FRAG_MASK, - tid); - vap->iv_stats.is_rx_dup++; - IEEE80211_NODE_STAT(ni, rx_dup); + if (! ieee80211_check_rxseq(ni, wh, bssid)) goto out; - } - ni->ni_rxseqs[tid] = rxseq; } } Index: head/sys/net80211/ieee80211_wds.c =================================================================== --- head/sys/net80211/ieee80211_wds.c +++ head/sys/net80211/ieee80211_wds.c @@ -416,7 +416,6 @@ struct ether_header *eh; int hdrspace, need_tap = 1; /* mbuf need to be tapped. */ uint8_t dir, type, subtype, qos; - uint16_t rxseq; if (m->m_flags & M_AMPDU_MPDU) { /* @@ -494,22 +493,8 @@ if (IEEE80211_QOS_HAS_SEQ(wh) && TID_TO_WME_AC(tid) >= WME_AC_VI) ic->ic_wme.wme_hipri_traffic++; - rxseq = le16toh(*(uint16_t *)wh->i_seq); - if (! ieee80211_check_rxseq(ni, wh)) { - /* duplicate, discard */ - IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT, - wh->i_addr1, "duplicate", - "seqno <%u,%u> fragno <%u,%u> tid %u", - rxseq >> IEEE80211_SEQ_SEQ_SHIFT, - ni->ni_rxseqs[tid] >> IEEE80211_SEQ_SEQ_SHIFT, - rxseq & IEEE80211_SEQ_FRAG_MASK, - ni->ni_rxseqs[tid] & IEEE80211_SEQ_FRAG_MASK, - tid); - vap->iv_stats.is_rx_dup++; - IEEE80211_NODE_STAT(ni, rx_dup); + if (! ieee80211_check_rxseq(ni, wh, wh->i_addr1)) goto out; - } - ni->ni_rxseqs[tid] = rxseq; } switch (type) { case IEEE80211_FC0_TYPE_DATA: