Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src-draft/trunk]: src/sys/net80211 Consolidate debug output.



details:   https://anonhg.NetBSD.org/src-all/rev/91dc78d945a0
branches:  trunk
changeset: 376968:91dc78d945a0
user:      Martin Husemann <martin%NetBSD.org@localhost>
date:      Mon Dec 28 20:06:13 2020 +0100

description:
Consolidate debug output.

Do not mix the various debug macros/note functions with printf, so
if our debug output does not go to the kernel console we still get
complete, reasonable messages - and there is not console spamming.

Mark these functions as printflike and fix argument errors.

Move uses of ether_sprintf() to ether_snprintf() and create a similar
function for formatting SSIDs.

diffstat:

 sys/net80211/ieee80211.h          |    2 +
 sys/net80211/ieee80211_adhoc.c    |   24 +++--
 sys/net80211/ieee80211_crypto.c   |    2 +-
 sys/net80211/ieee80211_hostap.c   |   19 ++-
 sys/net80211/ieee80211_hwmp.c     |  167 +++++++++++++++++++++++++++----------
 sys/net80211/ieee80211_input.c    |   10 +-
 sys/net80211/ieee80211_mesh.c     |   43 +++++++--
 sys/net80211/ieee80211_node.c     |   10 +-
 sys/net80211/ieee80211_output.c   |   14 ++-
 sys/net80211/ieee80211_proto.c    |   34 +++++--
 sys/net80211/ieee80211_proto.h    |    2 +-
 sys/net80211/ieee80211_scan.c     |   23 ++--
 sys/net80211/ieee80211_scan.h     |    3 +-
 sys/net80211/ieee80211_scan_sta.c |   10 +-
 sys/net80211/ieee80211_scan_sw.c  |    2 +-
 sys/net80211/ieee80211_sta.c      |   19 ++-
 sys/net80211/ieee80211_var.h      |    9 +-
 17 files changed, 270 insertions(+), 123 deletions(-)

diffs (truncated from 916 to 300 lines):

diff -r f6cf87f6d4fc -r 91dc78d945a0 sys/net80211/ieee80211.h
--- a/sys/net80211/ieee80211.h  Sun Dec 20 12:38:00 2020 +0100
+++ b/sys/net80211/ieee80211.h  Mon Dec 28 20:06:13 2020 +0100
@@ -37,6 +37,7 @@
  */
 
 #define        IEEE80211_ADDR_LEN      6               /* size of 802.11 address */
+#define        IEEE80211_ADDR_PRINT_LEN        (3*IEEE80211_ADDR_LEN+1)
 /* is 802.11 address multicast/broadcast? */
 #define        IEEE80211_IS_MULTICAST(_a)      (*(_a) & 0x01)
 
@@ -220,6 +221,7 @@ struct ieee80211_qosframe_addr4 {
        (IEEE80211_SEQ_SUB(b, a+1) < IEEE80211_SEQ_BA_RANGE-1)
 
 #define        IEEE80211_NWID_LEN                      32
+#define        IEEE80211_NWID_PRINT_LEN                (2*IEEE80211_NWID_LEN+10)
 #define        IEEE80211_MESHID_LEN                    32
 
 #define        IEEE80211_QOS_CTL_LEN                   2
diff -r f6cf87f6d4fc -r 91dc78d945a0 sys/net80211/ieee80211_adhoc.c
--- a/sys/net80211/ieee80211_adhoc.c    Sun Dec 20 12:38:00 2020 +0100
+++ b/sys/net80211/ieee80211_adhoc.c    Mon Dec 28 20:06:13 2020 +0100
@@ -249,15 +249,18 @@ adhoc_newstate(struct ieee80211vap *vap,
                case IEEE80211_S_SCAN:
 #ifdef IEEE80211_DEBUG
                        if (ieee80211_msg_debug(vap)) {
+                               char ssid[IEEE80211_NWID_PRINT_LEN];
+
                                ieee80211_note(vap,
-                                   "synchronized with %s ssid ",
-                                   ether_sprintf(ni->ni_bssid));
-                               ieee80211_print_essid(vap->iv_bss->ni_essid,
-                                   ni->ni_esslen);
-                               /* XXX MCS/HT */
-                               printf(" channel %d start %uMb\n",
+                                   "synchronized with %s ssid %s channel"
+                                   " %d start %uMb\n",
+                                   ether_sprintf(ni->ni_bssid),
+                                   ieee80211_sprint_essid(ssid,
+                                       vap->iv_bss->ni_essid,
+                                       ni->ni_esslen),
                                    ieee80211_chan2ieee(ic, ic->ic_curchan),
                                    IEEE80211_RATE2MBS(ni->ni_txrate));
+                               /* XXX MCS/HT */
                        }
 #endif
                        break;
@@ -731,12 +734,15 @@ adhoc_recv_mgmt(struct ieee80211_node *n
        frm = (uint8_t *)&wh[1];
        efrm = mtod(m0, uint8_t *) + m0->m_len;
 
+#ifdef IEEE80211_DEBUG
+       char addr2[IEEE80211_ADDR_PRINT_LEN], macaddr[IEEE80211_ADDR_PRINT_LEN];
+#endif
        IEEE80211_DPRINTF(vap, IEEE80211_MSG_INPUT | IEEE80211_MSG_DEBUG,
-           "%s: recv mgmt frame, addr2=%6D, ni=%p (%6D) fc=%.02x %.02x\n",
+           "%s: recv mgmt frame, addr2=%s, ni=%p (%s) fc=%.02x %.02x\n",
            __func__,
-           wh->i_addr2, ":",
+           ether_snprintf(addr2, sizeof(addr2), wh->i_addr2),
            ni,
-           ni->ni_macaddr, ":",
+           ether_snprintf(macaddr, sizeof(macaddr), ni->ni_macaddr),
            wh->i_fc[0],
            wh->i_fc[1]);
        switch (subtype) {
diff -r f6cf87f6d4fc -r 91dc78d945a0 sys/net80211/ieee80211_crypto.c
--- a/sys/net80211/ieee80211_crypto.c   Sun Dec 20 12:38:00 2020 +0100
+++ b/sys/net80211/ieee80211_crypto.c   Mon Dec 28 20:06:13 2020 +0100
@@ -699,7 +699,7 @@ ieee80211_crypto_decap(struct ieee80211_
        cip = k->wk_cipher;
        if (m->m_len < hdrlen + cip->ic_header) {
                IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr2,
-                   "frame is too short (%d < %u) for crypto decap",
+                   "%s frame is too short (%d < %u) for crypto decap",
                    cip->ic_name, m->m_len, hdrlen + cip->ic_header);
                vap->iv_stats.is_rx_tooshort++;
                *key = NULL;
diff -r f6cf87f6d4fc -r 91dc78d945a0 sys/net80211/ieee80211_hostap.c
--- a/sys/net80211/ieee80211_hostap.c   Sun Dec 20 12:38:00 2020 +0100
+++ b/sys/net80211/ieee80211_hostap.c   Mon Dec 28 20:06:13 2020 +0100
@@ -325,15 +325,19 @@ hostap_newstate(struct ieee80211vap *vap
 #ifdef IEEE80211_DEBUG
                        if (ieee80211_msg_debug(vap)) {
                                struct ieee80211_node *ni = vap->iv_bss;
+                               char str_ssid[IEEE80211_NWID_PRINT_LEN],
+                                   str_bssid[IEEE80211_ADDR_PRINT_LEN];
+
                                ieee80211_note(vap,
-                                   "synchronized with %s ssid ",
-                                   ether_sprintf(ni->ni_bssid));
-                               ieee80211_print_essid(ni->ni_essid,
-                                   ni->ni_esslen);
-                               /* XXX MCS/HT */
-                               printf(" channel %d start %uMb\n",
+                                   "synchronized with %s ssid %s channel "
+                                   "%d start %uMb\n",
+                                   ether_snprintf(str_bssid, sizeof(str_bssid),
+                                       ni->ni_bssid),
+                                   ieee80211_sprint_essid(str_ssid,
+                                       ni->ni_essid, ni->ni_esslen),
                                    ieee80211_chan2ieee(ic, ic->ic_curchan),
                                    IEEE80211_RATE2MBS(ni->ni_txrate));
+                               /* XXX MCS/HT */
                        }
 #endif
                        break;
@@ -1739,7 +1743,8 @@ htcapmismatch(struct ieee80211_node *ni,
        int reassoc, int resp)
 {
        IEEE80211_NOTE_MAC(ni->ni_vap, IEEE80211_MSG_ANY, wh->i_addr2,
-           "deny %s request, %s missing HT ie", reassoc ? "reassoc" : "assoc");
+           "deny %s request, missing HT ie",
+           reassoc ? "reassoc" : "assoc");
        /* XXX no better code */
        IEEE80211_SEND_MGMT(ni, resp, IEEE80211_STATUS_MISSING_HT_CAPS);
        ieee80211_node_leave(ni);
diff -r f6cf87f6d4fc -r 91dc78d945a0 sys/net80211/ieee80211_hwmp.c
--- a/sys/net80211/ieee80211_hwmp.c     Sun Dec 20 12:38:00 2020 +0100
+++ b/sys/net80211/ieee80211_hwmp.c     Mon Dec 28 20:06:13 2020 +0100
@@ -937,9 +937,14 @@ hwmp_update_transmitter(struct ieee80211
        if (rttran == NULL) {
                rttran = ieee80211_mesh_rt_add(vap, ni->ni_macaddr);
                if (rttran == NULL) {
+#ifdef IEEE80211_DEBUG
+                       char macaddr[IEEE80211_ADDR_PRINT_LEN];
                        IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                           "unable to add path to transmitter %6D of %s",
-                           ni->ni_macaddr, ":", hwmp_frame);
+                           "unable to add path to transmitter %s of %s",
+                           ether_snprintf(macaddr, sizeof(macaddr),
+                               ni->ni_macaddr),
+                            hwmp_frame);
+#endif
                        vap->iv_stats.is_mesh_rtaddfailed++;
                        return;
                }
@@ -948,11 +953,17 @@ hwmp_update_transmitter(struct ieee80211
        if (!(rttran->rt_flags & IEEE80211_MESHRT_FLAGS_VALID) ||
            rttran->rt_metric > metric)
        {
+#ifdef IEEE80211_DEBUG
+               char macaddr[IEEE80211_ADDR_PRINT_LEN];
                IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                   "%s path to transmitter %6D of %s, metric %d:%d",
+                   "%s path to transmitter %s of %s, metric %d:%d",
                    rttran->rt_flags & IEEE80211_MESHRT_FLAGS_VALID ?
-                   "prefer" : "update", ni->ni_macaddr, ":", hwmp_frame,
+                   "prefer" : "update", 
+                   ether_snprintf(macaddr, sizeof(macaddr),
+                               ni->ni_macaddr),
+                   hwmp_frame,
                    rttran->rt_metric, metric);
+#endif
                IEEE80211_ADDR_COPY(rttran->rt_nexthop, ni->ni_macaddr);
                rttran->rt_metric = metric;
                rttran->rt_nhops  = 1;
@@ -985,9 +996,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
        if (IEEE80211_ADDR_EQ(vap->iv_myaddr, preq->preq_origaddr))
                return;
 
+#ifdef IEEE80211_DEBUG
+       char targ[IEEE80211_ADDR_PRINT_LEN], orig[IEEE80211_ADDR_PRINT_LEN];
        IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-           "received PREQ, orig %6D, targ(0) %6D", preq->preq_origaddr, ":",
-           PREQ_TADDR(0), ":");
+           "received PREQ, orig %s, targ(0) %s",
+           ether_snprintf(orig, sizeof(orig), preq->preq_origaddr),
+           ether_snprintf(targ, sizeof(targ), PREQ_TADDR(0)));
+#endif
 
        /*
         * Acceptance criteria: (if the PREQ is not for us or not broadcast,
@@ -1029,14 +1044,23 @@ hwmp_recv_preq(struct ieee80211vap *vap,
        if (rtorig == NULL) {
                rtorig = ieee80211_mesh_rt_add(vap, preq->preq_origaddr);
                if (rtorig == NULL) {
+#ifdef IEEE80211_DEBUG
+                       char targstr[IEEE80211_ADDR_PRINT_LEN];
                        IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                           "unable to add orig path to %6D",
-                           preq->preq_origaddr, ":");
+                           "unable to add orig path to %s",
+                           ether_snprintf(targstr, sizeof(targstr),
+                               preq->preq_origaddr));
+#endif
                        vap->iv_stats.is_mesh_rtaddfailed++;
                        return;
                }
+#ifdef IEEE80211_DEBUG
+               char origstr[IEEE80211_ADDR_PRINT_LEN];
                IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                   "adding originator %6D", preq->preq_origaddr, ":");
+                   "adding originator %s",
+                   ether_snprintf(origstr, sizeof(origstr),
+                       preq->preq_origaddr));
+#endif
        }
        hrorig = IEEE80211_MESH_ROUTE_PRIV(rtorig, struct ieee80211_hwmp_route);
 
@@ -1065,12 +1089,15 @@ hwmp_recv_preq(struct ieee80211vap *vap,
            !HWMP_SEQ_EQ(hrtarg->hr_seq, PREQ_TSEQ(0))) ||
            (rtorig->rt_flags & IEEE80211_MESHRT_FLAGS_VALID &&
            preqid >= preq->preq_id)) {
+#ifdef IEEE80211_DEBUG
+               char addr[IEEE80211_ADDR_PRINT_LEN];
                IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                   "discard PREQ from %6D, old seqno %u <= %u,"
+                   "discard PREQ from %s, old seqno %u <= %u,"
                    " or old preqid %u < %u",
-                   preq->preq_origaddr, ":",
+                   ether_snprintf(addr, sizeof(addr), preq->preq_origaddr),
                    preq->preq_origseq, hrorig->hr_seq,
                    preq->preq_id, preqid);
+#endif
                return;
        }
 
@@ -1101,8 +1128,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
                IEEE80211_ADDR_COPY(prep.prep_targetaddr, vap->iv_myaddr);
                if (rttarg != NULL && /* if NULL it means we are the target */
                    rttarg->rt_flags & IEEE80211_MESHRT_FLAGS_PROXY) {
+#ifdef IEEE80211_DEBUG
+                       char addr[IEEE80211_ADDR_PRINT_LEN];
                        IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                           "reply for proxy %6D", rttarg->rt_dest, ":");
+                           "reply for proxy %s",
+                           ether_snprintf(addr, sizeof(addr),
+                               rttarg->rt_dest));
+#endif
                        prep.prep_flags |= IEEE80211_MESHPREP_FLAGS_AE;
                        IEEE80211_ADDR_COPY(prep.prep_target_ext_addr,
                            rttarg->rt_dest);
@@ -1121,8 +1153,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
                IEEE80211_ADDR_COPY(prep.prep_origaddr, preq->preq_origaddr);
                prep.prep_origseq = preq->preq_origseq;
 
+#ifdef IEEE80211_DEBUG
+               char repaddr[IEEE80211_ADDR_PRINT_LEN];
                IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                   "reply to %6D", preq->preq_origaddr, ":");
+                   "reply to %s",
+                   ether_snprintf(repaddr, sizeof(repaddr),
+                       preq->preq_origaddr));
+#endif
                hwmp_send_prep(vap, wh->i_addr2, &prep);
                return;
        }
@@ -1134,9 +1171,13 @@ hwmp_recv_preq(struct ieee80211vap *vap,
                        rtorig_ext = ieee80211_mesh_rt_add(vap,
                            preq->preq_orig_ext_addr);
                        if (rtorig_ext == NULL) {
+#ifdef IEEE80211_DEBUG
+                               char addr[IEEE80211_ADDR_PRINT_LEN];
                                IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                                   "unable to add orig ext proxy to %6D",
-                                   preq->preq_orig_ext_addr, ":");
+                                   "unable to add orig ext proxy to %s",
+                                   ether_snprintf(addr, sizeof(addr),
+                                       preq->preq_orig_ext_addr));
+#endif
                                vap->iv_stats.is_mesh_rtaddfailed++;
                                return;
                        }
@@ -1152,8 +1193,12 @@ hwmp_recv_preq(struct ieee80211vap *vap,
         */
        if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr) &&
            (PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) {
+#ifdef IEEE80211_DEBUG
+               char addr[IEEE80211_ADDR_PRINT_LEN];
                IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                   "root mesh station @ %6D", preq->preq_origaddr, ":");
+                   "root mesh station @ %s",
+                   ether_snprintf(addr, sizeof(addr), preq->preq_origaddr));
+#endif
 
                /* Check if root is a mesh gate, mark it */
                if (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_GATE) {
@@ -1212,10 +1257,14 @@ hwmp_recv_preq(struct ieee80211vap *vap,
                        if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO) &&
                            !IEEE80211_ADDR_EQ(PREQ_TADDR(0), broadcastaddr)) {
                                struct ieee80211_meshprep_ie prep;
+#ifdef IEEE80211_DEBUG
+                               char addr[IEEE80211_ADDR_PRINT_LEN];
 
                                IEEE80211_NOTE(vap, IEEE80211_MSG_HWMP, ni,
-                                   "intermediate reply for PREQ from %6D",
-                                   preq->preq_origaddr, ":");
+                                   "intermediate reply for PREQ from %s",
+                                   ether_snprintf(addr, sizeof(addr),
+                                       preq->preq_origaddr));
+#endif
                                prep.prep_flags = 0;
                                prep.prep_hopcount = rttarg->rt_nhops;
                                prep.prep_ttl = ms->ms_ttl;
@@ -1238,9 +1287,12 @@ hwmp_recv_preq(struct ieee80211vap *vap,
                        }
                }
 
+#ifdef IEEE80211_DEBUG



Home | Main Index | Thread Index | Old Index