[Bug 298382] /usr/sbin/tcpdump: information how to enable monitor mode may print some garbage

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 11 Sep 2026 00:37:05 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=298382

            Bug ID: 298382
           Summary: /usr/sbin/tcpdump: information how to enable monitor
                    mode may print some garbage
           Product: Base System
           Version: 16.0-CURRENT
          Hardware: Any
               URL: https://github.com/the-tcpdump-group/tcpdump/pull/1462
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: saper@saper.info
                CC: wireless@FreeBSD.org

__FreeBSD_version 1600020 (main as of 067ae9850f05a27239c28ae5819e4016e997cff2)

may print the following for the wlandevs that are 8 characters long:

# tcpdump -I -i wlan0 
tcpdump: wlan0 is not a monitor mode VAPTo create a new monitor mode VAP use:
  ifconfig wlan1 create wlandev brcmfmac}·>ÿA3 wlanmode monitor
and use wlan1 as the tcpdump interface

after "brcmfmac" comes random garbage

The message should look like this:

tcpdump: wlan0 is not a monitor mode VAP
To create a new monitor mode VAP use:
  ifconfig wlan1 create wlandev brcmfmac0 wlanmode monitor
and use wlan1 as the tcpdump interface

The following upstream patch fixes the problem:

https://github.com/the-tcpdump-group/tcpdump/pull/1462

For our local tree:

diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index 0c07899a2f58..1d8c2372826b 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -1439,13 +1439,14 @@ open_interface(const char *device, netdissect_options
*ndo, char *ebuf)
 #ifdef __FreeBSD__
                else if (status == PCAP_ERROR_RFMON_NOTSUP &&
                    strncmp(device, "wlan", 4) == 0) {
-                       char parent[8], newdev[8];
+                       char parent[16], newdev[8];
                        char sysctl[32];
-                       size_t s = sizeof(parent);
+                       size_t s = sizeof(parent)-1;

                        snprintf(sysctl, sizeof(sysctl),
                            "net.wlan.%d.%%parent", atoi(device + 4));
                        sysctlbyname(sysctl, parent, &s, NULL, 0);
+                       parent[15] = '\0';
                        strlcpy(newdev, device, sizeof(newdev));
                        /* Suggest a new wlan device. */
                        /* FIXME: incrementing the index this way is not going
to work well
@@ -1453,7 +1454,7 @@ open_interface(const char *device, netdissect_options
*ndo, char *ebuf)
                         * specific case would be an error message that looks a
bit odd.
                         */
                        newdev[strlen(newdev)-1]++;
-                       error("%s is not a monitor mode VAP"
+                       error("%s is not a monitor mode VAP\n"
                            "To create a new monitor mode VAP use:\n"
                            "  ifconfig %s create wlandev %s wlanmode
monitor\n"
                            "and use %s as the tcpdump interface",

-- 
You are receiving this mail because:
You are on the CC list for the bug.