Skip to contentSkip to conversation

mac80211: add debugfs file for mic failure

RFC In review Saravana 2 participants 2 messages Dec 4, 2012 mac80211

lore
Share & tools
lore

Saravana

author
#0 lore raw

RFC 1/1 mac80211: add debugfs file for mic failure

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).

---
 net/mac80211/debugfs_key.c |   20 ++++++++++++++++++++
 net/mac80211/key.h         |    3 +++
 net/mac80211/wpa.c         |    2 ++
 3 files changed, 25 insertions(+), 0 deletions(-)
net/mac80211/debugfs_key.c +20 -0
index 2d42354..1cc262e 100644
@@ -199,6 +199,25 @@ 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;
+
+	switch (key->conf.cipher) {
+	case WLAN_CIPHER_SUITE_TKIP:
+		len = scnprintf(buf, sizeof(buf), "%u\n",
+				key->u.tkip.mic_failures);
+		break;
+	default:
+		return 0;
+	}
+	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 +279,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);
 };
net/mac80211/key.h +3 -0
index 7cff0d3..382dc44 100644
@@ -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;
net/mac80211/wpa.c +2 -0
index 8bd2f5c..aad79f3 100644
@@ -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
maintainer
#1 lore raw
Quoted 18 lines · Saravana

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).

---
 net/mac80211/debugfs_key.c |   20 ++++++++++++++++++++
 net/mac80211/key.h         |    3 +++
 net/mac80211/wpa.c         |    2 ++
 3 files changed, 25 insertions(+), 0 deletions(-)
net/mac80211/debugfs_key.c +0 -0
index 2d42354..1cc262e 100644

net/mac80211/debugfs_key.c static ssize_t key_icverrors_read(struct file *file, char __user *userbuf, · line 203

Quoted 5 lines
net/mac80211/debugfs_key.c +2 -0
@@ -199,6 +199,25 @@ 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)

please fix indentation

net/mac80211/debugfs_key.c static ssize_t key_icverrors_read(struct file *file, char __user *userbuf, · line 216

Quoted 13 lines
net/mac80211/debugfs_key.c +13 -0
+{
+	struct ieee80211_key *key = file->private_data;
+	char buf[20];
+	int len;
+
+	switch (key->conf.cipher) {
+	case WLAN_CIPHER_SUITE_TKIP:
+		len = scnprintf(buf, sizeof(buf), "%u\n",
+				key->u.tkip.mic_failures);
+		break;
+	default:
+		return 0;
+	}

I think this should just be

if (key->conf.cipher != TKIP)

	return -EINVAL;

len = scnprintf(...)

net/mac80211/debugfs_key.c static ssize_t key_icverrors_read(struct file *file, char __user *userbuf, · line 217

Quoted 1 line
net/mac80211/debugfs_key.c +1 -0
+	return simple_read_from_buffer(userbuf, count, ppos, buf, len);

Other than that looks fine.

johannes