tcpdump icon indicating copy to clipboard operation
tcpdump copied to clipboard

Different behavior with zero-padded interface numbers

Open momo-trip opened this issue 5 months ago • 4 comments

Hi, is this tcpdump behavior a bug where interface index 9 fails with tcpdump -i 000000000000009 (14 zeros) but succeeds with tcpdump -i 0000000000000009 (15 zeros), despite both referring to the same interface?

Environment

  • OS: Ubuntu 22.04 LTS
  • Architecture: x86_64
  • tcpdump version:
$ ./tcpdump --version
tcpdump version 5.0.0-PRE-GIT
libpcap version 1.10.1 (with TPACKET_V3)
OpenSSL 3.0.2 15 Mar 2022
SMI-library: 0.4.8
64-bit build, 64-bit time_t

Issue

The same interface (index 9) produces different results based on zero-padding length. The threshold of 16 characters appears to be related to sizeof(ifr.ifr_name) (IFNAMSIZ).

Permission denied:

$ ./tcpdump -i 9                   # Permission denied
$ ./tcpdump -i 000000000000009     # Permission denied (15 characters total)

Works without sudo:

$ ./tcpdump -i 0000000000000009    # Works (16 characters total)
$ ./tcpdump -i dbus-session        # Works (interface name)

With sudo (different error):

$ sudo ./tcpdump -i 000000000000009
tcpdump: Failed to get session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

momo-trip avatar Jun 28 '25 05:06 momo-trip