net80211: eliminate copy-paste nearby ieee80211_check_rxseq()
Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D4043
This commit is contained in:
parent
b431335d25
commit
1ffa8d7ef1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=296254
@ -302,7 +302,6 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,6 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,12 +164,14 @@ ishtinfooui(const uint8_t *frm)
|
||||
* 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 @@ ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh)
|
||||
/* 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 @@ ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh)
|
||||
*/
|
||||
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 @@ ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh)
|
||||
* 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 @@ ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh)
|
||||
*/
|
||||
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
|
||||
|
@ -1537,7 +1537,6 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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 @@ mesh_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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
|
||||
|
@ -538,7 +538,6 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -416,7 +416,6 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m,
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user