summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravos <avos@FreeBSD.org>2016-03-01 06:47:21 +0000
committeravos <avos@FreeBSD.org>2016-03-01 06:47:21 +0000
commit34baac6c87c50280c75fceea9a322dc6911a6daf (patch)
tree1b0923a59d9097ca6a532a8fdfe429500c999e24
parentb0c32dfce5d841baeb471e44c38123707f37e96e (diff)
downloadFreeBSD-src-34baac6c87c50280c75fceea9a322dc6911a6daf.zip
FreeBSD-src-34baac6c87c50280c75fceea9a322dc6911a6daf.tar.gz
net80211: eliminate copy-paste nearby ieee80211_check_rxseq()
Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D4043
-rw-r--r--sys/net80211/ieee80211_adhoc.c19
-rw-r--r--sys/net80211/ieee80211_hostap.c19
-rw-r--r--sys/net80211/ieee80211_input.h26
-rw-r--r--sys/net80211/ieee80211_mesh.c19
-rw-r--r--sys/net80211/ieee80211_sta.c19
-rw-r--r--sys/net80211/ieee80211_wds.c17
6 files changed, 26 insertions, 93 deletions
diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c
index aa568b6..a9334d0 100644
--- a/sys/net80211/ieee80211_adhoc.c
+++ b/sys/net80211/ieee80211_adhoc.c
@@ -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;
}
}
diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c
index 2dd1f68..1e356dc 100644
--- a/sys/net80211/ieee80211_hostap.c
+++ b/sys/net80211/ieee80211_hostap.c
@@ -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;
}
}
diff --git a/sys/net80211/ieee80211_input.h b/sys/net80211/ieee80211_input.h
index 72fd25b..d051fdb 100644
--- a/sys/net80211/ieee80211_input.h
+++ b/sys/net80211/ieee80211_input.h
@@ -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
diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c
index 40253c0..80e2af3 100644
--- a/sys/net80211/ieee80211_mesh.c
+++ b/sys/net80211/ieee80211_mesh.c
@@ -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
diff --git a/sys/net80211/ieee80211_sta.c b/sys/net80211/ieee80211_sta.c
index 0c0296a..9f6a4d4 100644
--- a/sys/net80211/ieee80211_sta.c
+++ b/sys/net80211/ieee80211_sta.c
@@ -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;
}
}
diff --git a/sys/net80211/ieee80211_wds.c b/sys/net80211/ieee80211_wds.c
index a9384d4..03d9c60 100644
--- a/sys/net80211/ieee80211_wds.c
+++ b/sys/net80211/ieee80211_wds.c
@@ -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:
OpenPOWER on IntegriCloud