git: e0bd174e0e36 - stable/14 - net80211: make use of IEEE80211_KEY_BITS for debug messages

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Fri, 18 Apr 2025 14:37:02 UTC
The branch stable/14 has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=e0bd174e0e369af59cc533f2d7bf6f231dc250df

commit e0bd174e0e369af59cc533f2d7bf6f231dc250df
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-03-14 23:43:17 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-04-18 14:35:59 +0000

    net80211: make use of IEEE80211_KEY_BITS for debug messages
    
    Use %b with IEEE80211_KEY_BITS for the debug logging in
    ieee80211_crypto.c rather than just printing the hex value, which
    makes some of the messages more obvious and avoids having the header
    file next to one at all times.
    
    Sponsored by:   The FreeBSD Foundation
    Reviewed by:    adrian
    Differential Revision: https://reviews.freebsd.org/D49369
    
    (cherry picked from commit 7513a0afe5fb26d30dbcae0347e43728e3511d3e)
---
 sys/net80211/ieee80211_crypto.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/sys/net80211/ieee80211_crypto.c b/sys/net80211/ieee80211_crypto.c
index 45316b43605a..bb7a612ac36c 100644
--- a/sys/net80211/ieee80211_crypto.c
+++ b/sys/net80211/ieee80211_crypto.c
@@ -391,14 +391,15 @@ ieee80211_crypto_newkey(struct ieee80211vap *vap,
 			 */
 			IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
 			    "%s: driver override for cipher %s, flags "
-			    "0x%x -> 0x%x\n", __func__, cip->ic_name,
-			    oflags, key->wk_flags);
+			    "%b -> %b\n", __func__, cip->ic_name,
+			    oflags, IEEE80211_KEY_BITS,
+			    key->wk_flags, IEEE80211_KEY_BITS);
 			keyctx = cip->ic_attach(vap, key);
 			if (keyctx == NULL) {
 				IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
 				    "%s: unable to attach cipher %s with "
-				    "flags 0x%x\n", __func__, cip->ic_name,
-				    key->wk_flags);
+				    "flags %b\n", __func__, cip->ic_name,
+				    key->wk_flags, IEEE80211_KEY_BITS);
 				key->wk_flags = oflags;	/* restore old flags */
 				vap->iv_stats.is_crypto_attachfail++;
 				return 0;
@@ -423,9 +424,9 @@ _ieee80211_crypto_delkey(struct ieee80211vap *vap, struct ieee80211_key *key)
 	KASSERT(key->wk_cipher != NULL, ("No cipher!"));
 
 	IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
-	    "%s: %s keyix %u flags 0x%x rsc %ju tsc %ju len %u\n",
+	    "%s: %s keyix %u flags %b rsc %ju tsc %ju len %u\n",
 	    __func__, key->wk_cipher->ic_name,
-	    key->wk_keyix, key->wk_flags,
+	    key->wk_keyix, key->wk_flags, IEEE80211_KEY_BITS,
 	    key->wk_keyrsc[IEEE80211_NONQOS_TID], key->wk_keytsc,
 	    key->wk_keylen);
 
@@ -491,9 +492,9 @@ ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key)
 	KASSERT(cip != NULL, ("No cipher!"));
 
 	IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
-	    "%s: %s keyix %u flags 0x%x mac %s rsc %ju tsc %ju len %u\n",
+	    "%s: %s keyix %u flags %b mac %s rsc %ju tsc %ju len %u\n",
 	    __func__, cip->ic_name, key->wk_keyix,
-	    key->wk_flags, ether_sprintf(key->wk_macaddr),
+	    key->wk_flags, IEEE80211_KEY_BITS, ether_sprintf(key->wk_macaddr),
 	    key->wk_keyrsc[IEEE80211_NONQOS_TID], key->wk_keytsc,
 	    key->wk_keylen);
 
@@ -511,9 +512,9 @@ ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key)
 	 */
 	if (!cip->ic_setkey(key)) {
 		IEEE80211_DPRINTF(vap, IEEE80211_MSG_CRYPTO,
-		    "%s: cipher %s rejected key index %u len %u flags 0x%x\n",
+		    "%s: cipher %s rejected key index %u len %u flags %b\n",
 		    __func__, cip->ic_name, key->wk_keyix,
-		    key->wk_keylen, key->wk_flags);
+		    key->wk_keylen, key->wk_flags, IEEE80211_KEY_BITS);
 		vap->iv_stats.is_crypto_setkey_cipher++;
 		return 0;
 	}