From nobody Sun Dec 26 17:35:17 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F2EEA1903D46; Sun, 26 Dec 2021 17:35:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JMScP5DXlz3JZG; Sun, 26 Dec 2021 17:35:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 93DF06B11; Sun, 26 Dec 2021 17:35:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BQHZHCr080784; Sun, 26 Dec 2021 17:35:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BQHZHgv080783; Sun, 26 Dec 2021 17:35:17 GMT (envelope-from git) Date: Sun, 26 Dec 2021 17:35:17 GMT Message-Id: <202112261735.1BQHZHgv080783@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 04435a1b145b - main - net80211: format debug functions as single line List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 04435a1b145b310f8be62dd453e2f0c69d764cca Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640540117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5ocVuuLt3wswK2/VGBRbtBsv3qIxe+AsjAMkWsV38is=; b=kfxGpUa8OpmTM50yPsXOtGnTBR0DLkYIyj6tnDntHj6p4yczKKtEqBK+u7hkqlhDTJDLTd 3x21fn6SH+KGggJABKqaU6gOf+L60WCqIepfWUBFyTEitA+tx3+yMo6Wga7+T2D0cjSVdD U+O1az3M/HrQ4bGxrObShPu/5QG85AJZn64wGGFLVbNSubupU6hH3JhRtmV6IM/q+r/VQp OSuQ2hAj4lKpGpt7zY0nLChK0o7pzp/1Wt0mI54bFi/HUyVql8g/rvxb+uMZhfW0sseZHe eaOhJzGWk3cmNJx+2tM9zg3JZpR8yzRCxfOWgvQeF9OH3JrRAdbXubSgoRD7/w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640540117; a=rsa-sha256; cv=none; b=XLc/TM1TYYjpwxMIM+iKuy8eSRJnB/0EVggr6eGSm94SqB5r5y+A3JD3mY/RAWsh7EaEuU sR/pusLD6iHIAreu9zUUSoOXogk2gJXCWFAZ8p0/RWZQN1SvSADqS+frjYonYf3KHToASS aMLkN7UofSnRiGKJ+vgrMmA8lPim2n0khlHDsp3o965Qp0uS4O2rQ5dsH0RpV4cyyXyW4p jynWF4gTkzX5bEJgoW71ZivBLiIcNFjC+jE4IOOyp4YUJIx99Zpp0ylQMUSRRhxD8zUxhU untRkrm/pZIymJSEQ4/xjE+DqaVWH+fka2IsR1SAWrtiWySc/sCooWU71vmpLg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=04435a1b145b310f8be62dd453e2f0c69d764cca commit 04435a1b145b310f8be62dd453e2f0c69d764cca Author: Bjoern A. Zeeb AuthorDate: 2021-12-26 17:24:04 +0000 Commit: Bjoern A. Zeeb CommitDate: 2021-12-26 17:24:04 +0000 net80211: format debug functions as single line Making use of the debug output was hard given debug lines were run in parts through vlog (if_printf) and in (multiple) parts through printf(s). Like some of the functions alreay have, use a local buffer to format the string and then use a single if_printf; in addition given these functions are debug-only, add an extra printf in case we find our buffers still to be too small so we can adjust for the future. We already found that 128 characters are to short for some log messages. Bump the buffer sizes collectively to 256 characters which also is the maximum of if_vlog() so getting longer would need further changes elsewhere. Sponsored by: The FreeBSD Foundation MFC after: 3 days --- sys/net80211/ieee80211_input.c | 76 +++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/sys/net80211/ieee80211_input.c b/sys/net80211/ieee80211_input.c index 66a5ba1c4035..516de781e23e 100644 --- a/sys/net80211/ieee80211_input.c +++ b/sys/net80211/ieee80211_input.c @@ -936,14 +936,18 @@ ieee80211_getbssid(const struct ieee80211vap *vap, void ieee80211_note(const struct ieee80211vap *vap, const char *fmt, ...) { - char buf[128]; /* XXX */ + char buf[256]; /* XXX */ va_list ap; + int len; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if_printf(vap->iv_ifp, "%s", buf); /* NB: no \n */ + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -951,14 +955,18 @@ ieee80211_note_frame(const struct ieee80211vap *vap, const struct ieee80211_frame *wh, const char *fmt, ...) { - char buf[128]; /* XXX */ + char buf[256]; /* XXX */ va_list ap; + int len; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if_printf(vap->iv_ifp, "[%s] %s\n", ether_sprintf(ieee80211_getbssid(vap, wh)), buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -966,13 +974,17 @@ ieee80211_note_mac(const struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN], const char *fmt, ...) { - char buf[128]; /* XXX */ + char buf[256]; /* XXX */ va_list ap; + int len; va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); if_printf(vap->iv_ifp, "[%s] %s\n", ether_sprintf(mac), buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -980,16 +992,21 @@ ieee80211_discard_frame(const struct ieee80211vap *vap, const struct ieee80211_frame *wh, const char *type, const char *fmt, ...) { + char buf[256]; /* XXX */ va_list ap; + int len; - if_printf(vap->iv_ifp, "[%s] discard ", - ether_sprintf(ieee80211_getbssid(vap, wh))); - printf("%s frame, ", type != NULL ? type : - ieee80211_mgt_subtype_name(wh->i_fc[0])); va_start(ap, fmt); - vprintf(fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - printf("\n"); + + if_printf(vap->iv_ifp, "[%s] discard %s frame, %s\n", + ether_sprintf(ieee80211_getbssid(vap, wh)), + type != NULL ? type : ieee80211_mgt_subtype_name(wh->i_fc[0]), + buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -997,18 +1014,20 @@ ieee80211_discard_ie(const struct ieee80211vap *vap, const struct ieee80211_frame *wh, const char *type, const char *fmt, ...) { + char buf[256]; /* XXX */ va_list ap; + int len; - if_printf(vap->iv_ifp, "[%s] discard ", - ether_sprintf(ieee80211_getbssid(vap, wh))); - if (type != NULL) - printf("%s information element, ", type); - else - printf("information element, "); va_start(ap, fmt); - vprintf(fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - printf("\n"); + + if_printf(vap->iv_ifp, "[%s] discard%s%s information element, %s\n", + ether_sprintf(ieee80211_getbssid(vap, wh)), + type != NULL ? " " : "", type != NULL ? type : "", buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } void @@ -1016,16 +1035,19 @@ ieee80211_discard_mac(const struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN], const char *type, const char *fmt, ...) { + char buf[256]; /* XXX */ va_list ap; + int len; - if_printf(vap->iv_ifp, "[%s] discard ", ether_sprintf(mac)); - if (type != NULL) - printf("%s frame, ", type); - else - printf("frame, "); va_start(ap, fmt); - vprintf(fmt, ap); + len = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - printf("\n"); + + if_printf(vap->iv_ifp, "[%s] discard%s%s frame, %s\n", + ether_sprintf(mac), + type != NULL ? " " : "", type != NULL ? type : "", buf); + + if (len >= sizeof(buf)) + printf("%s: XXX buffer too small: len = %d\n", __func__, len); } #endif /* IEEE80211_DEBUG */