lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1381837514-50660-5-git-send-email-wangkefeng.wang@huawei.com>
Date:	Tue, 15 Oct 2013 19:45:00 +0800
From:	Kefeng Wang <wangkefeng.wang@...wei.com>
To:	<linux-kernel@...r.kernel.org>
CC:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"David S. Miller" <davem@...emloft.net>,
	Pablo Neira Ayuso <pablo@...filter.org>,
	"Stephen Hemminger" <stephen@...workplumber.org>,
	Johannes Berg <johannes@...solutions.net>,
	"John W. Linville" <linville@...driver.com>,
	Stanislaw Gruszka <sgruszka@...hat.com>,
	Johannes Berg <johannes.berg@...el.com>,
	Francois Romieu <romieu@...zoreil.com>,
	"Ben Hutchings" <bhutchings@...arflare.com>,
	Chas Williams <chas@....nrl.navy.mil>,
	Marc Kleine-Budde <mkl@...gutronix.de>,
	Samuel Ortiz <samuel@...tiz.org>,
	Paul Mackerras <paulus@...ba.org>,
	Oliver Neukum <oneukum@...e.de>,
	Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
	"Boris Ostrovsky" <boris.ostrovsky@...cle.com>,
	David Vrabel <david.vrabel@...rix.com>,
	Rusty Russell <rusty@...tcorp.com.au>,
	"Michael S. Tsirkin" <mst@...hat.com>, <netfilter@...r.kernel.org>,
	<netdev@...r.kernel.org>, <linux-wireless@...r.kernel.org>,
	<guohanjun@...wei.com>
Subject: [PATCH 04/18] rt18192e: use wrapper functions of net_ratelimit() to simplify code

Wrapper functions net_ratelimited_function() and net_XXX_ratelimited()
are called to simplify code.

Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
---
 drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 13 +++----------
 drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 21 +++++----------------
 drivers/staging/rtl8192e/rtllib_rx.c         |  6 ++----
 3 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index e51cb49..0d089c1 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -275,10 +275,8 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet without ExtIV"
+		net_dbg_ratelimited("CCMP: received packet without ExtIV"
 			       " flag from %pM\n", hdr->addr2);
-		}
 		key->dot11RSNAStatsCCMPFormatErrors++;
 		return -2;
 	}
@@ -289,11 +287,9 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!key->key_set) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "CCMP: received packet from %pM"
+		net_dbg_ratelimited("CCMP: received packet from %pM"
 			       " with keyid=%d that does not have a configured"
 			       " key\n", hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 
@@ -338,10 +334,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		}
 
 		if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "CCMP: decrypt failed: STA="
-				" %pM\n", hdr->addr2);
-			}
+			net_dbg_ratelimited("CCMP: decrypt failed: STA= %pM\n", hdr->addr2);
 			key->dot11RSNAStatsCCMPDecryptErrors++;
 			return -5;
 		}
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 5cfd73b..c1f7683 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -396,10 +396,8 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 	pos = skb->data + hdr_len;
 	keyidx = pos[3];
 	if (!(keyidx & (1 << 5))) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet without ExtIV"
+		net_dbg_ratelimited("TKIP: received packet without ExtIV"
 			       " flag from %pM\n", hdr->addr2);
-		}
 		return -2;
 	}
 	keyidx >>= 6;
@@ -409,11 +407,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		return -6;
 	}
 	if (!tkey->key_set) {
-		if (net_ratelimit()) {
-			printk(KERN_DEBUG "TKIP: received packet from %pM"
+		net_dbg_ratelimited("TKIP: received packet from %pM"
 			       " with keyid=%d that does not have a configured"
 			       " key\n", hdr->addr2, keyidx);
-		}
 		return -3;
 	}
 	iv16 = (pos[0] << 8) | pos[2];
@@ -424,12 +420,10 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 		if ((iv32 < tkey->rx_iv32 ||
 		    (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) &&
 		    tkey->initialized) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "TKIP: replay detected: STA="
+			net_dbg_ratelimited("TKIP: replay detected: STA="
 				       " %pM previous TSC %08x%04x received "
 				      "TSC %08x%04x\n",hdr->addr2,
 				      tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
-			}
 			tkey->dot11RSNAStatsTKIPReplays++;
 			return -4;
 		}
@@ -448,11 +442,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 
 		crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
 		if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG ": TKIP: failed to decrypt "
+			net_dbg_ratelimited(": TKIP: failed to decrypt "
 				       "received packet from %pM\n",
 				       hdr->addr2);
-			}
 			return -7;
 		}
 
@@ -469,10 +461,7 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
 				 * next packet. */
 				tkey->rx_phase1_done = 0;
 			}
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "TKIP: ICV error detected: STA="
-				" %pM\n", hdr->addr2);
-			}
+			net_dbg_ratelimited("TKIP: ICV error detected: STA= %pM\n", hdr->addr2);
 			tkey->dot11RSNAStatsTKIPICVErrors++;
 			return -5;
 		}
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index 8aeaed5..4335611 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -870,8 +870,7 @@ static size_t rtllib_rx_get_hdrlen(struct rtllib_device *ieee,
 
 	hdrlen = rtllib_get_hdrlen(fc);
 	if (HTCCheck(ieee, skb->data)) {
-		if (net_ratelimit())
-			printk(KERN_INFO "%s: find HTCControl!\n", __func__);
+		net_info_ratelimited("%s: find HTCControl!\n", __func__);
 		hdrlen += 4;
 		rx_stats->bContainHTC = 1;
 	}
@@ -1439,8 +1438,7 @@ static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb,
 	}
 
 	if (HTCCheck(ieee, skb->data)) {
-		if (net_ratelimit())
-			printk(KERN_INFO "%s: Find HTCControl!\n", __func__);
+		net_info_ratelimited("%s: Find HTCControl!\n", __func__);
 		hdrlen += 4;
 	}
 
-- 
1.8.2.1


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ