linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saravana <saravanad@posedge.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH v2] mac80211: add debug file for mic failure
Date: Tue, 04 Dec 2012 19:47:42 +0530	[thread overview]
Message-ID: <50BE0606.3000103@posedge.com> (raw)

The mic failure count will provide the number of mic failure that 
have happened without a countermeasure being started. Once the 
countermeasure is started, the counter will be reset to 0.
This count will be helpful when the consecutive 
mic failure occur at intervals greater than 60 seconds regularly(frequently).

Signed-off-by: Saravana <saravanad@posedge.com>
---
 net/mac80211/debugfs_key.c |   17 +++++++++++++++++
 net/mac80211/key.h         |    3 +++
 net/mac80211/wpa.c         |    2 ++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index 2d42354..65ecfee 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -199,6 +199,22 @@ static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
 }
 KEY_OPS(icverrors);
 
+static ssize_t key_mic_failures_read(struct file *file, char __user *userbuf,
+					size_t count, loff_t *ppos)
+{
+	struct ieee80211_key *key = file->private_data;
+	char buf[20];
+	int len;
+
+	if (key->conf.cipher != WLAN_CIPHER_SUITE_TKIP)
+		return -EINVAL;
+	len = scnprintf(buf, sizeof(buf), "%u\n",
+			key->u.tkip.mic_failures);
+
+	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+}
+KEY_OPS(mic_failures);
+
 static ssize_t key_key_read(struct file *file, char __user *userbuf,
 			    size_t count, loff_t *ppos)
 {
@@ -260,6 +276,7 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key)
 	DEBUGFS_ADD(rx_spec);
 	DEBUGFS_ADD(replays);
 	DEBUGFS_ADD(icverrors);
+	DEBUGFS_ADD(mic_failures);
 	DEBUGFS_ADD(key);
 	DEBUGFS_ADD(ifindex);
 };
diff --git a/net/mac80211/key.h b/net/mac80211/key.h
index 7cff0d3..382dc44 100644
--- a/net/mac80211/key.h
+++ b/net/mac80211/key.h
@@ -81,6 +81,9 @@ struct ieee80211_key {
 
 			/* last received RSC */
 			struct tkip_ctx rx[IEEE80211_NUM_TIDS];
+
+			/* number of mic failures */
+			u32 mic_failures;
 		} tkip;
 		struct {
 			atomic64_t tx_pn;
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index 8bd2f5c..aad79f3 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -161,6 +161,8 @@ update_iv:
 	return RX_CONTINUE;
 
 mic_fail:
+
+	rx->key->u.tkip.mic_failures++;
 	/*
 	 * In some cases the key can be unset - e.g. a multicast packet, in
 	 * a driver that supports HW encryption. Send up the key idx only if

             reply	other threads:[~2012-12-04 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 14:17 Saravana [this message]
2012-12-04 14:57 ` [PATCH v2] mac80211: add debug file for mic failure Johannes Berg
2012-12-04 19:07   ` Johannes Berg
2012-12-05  6:54     ` Saravana
2012-12-05  8:44       ` Johannes Berg
2012-12-05  9:28         ` Saravana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50BE0606.3000103@posedge.com \
    --to=saravanad@posedge.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).