Date: Sat, 19 Apr 1997 16:17:32 -0700 (PDT) From: Chris Timmons <skynyrd@opus.cts.cwu.edu> To: FreeBSD-gnats-submit@freebsd.org Subject: i386/3353: NTOHS(x) related compiler warnings and libpcap disfunction Message-ID: <199704192317.QAA03006@opus.cts.cwu.edu> Resent-Message-ID: <199704192320.QAA21804@freefall.freebsd.org>
index | next in thread | raw e-mail
>Number: 3353
>Category: i386
>Synopsis: NTOHS(x) related compiler warnings and libpcap disfunction
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Apr 19 16:20:01 PDT 1997
>Last-Modified:
>Originator: Chris Timmons
>Organization:
Central Washington University
>Release: FreeBSD 3.0-CURRENT i386
>Environment:
3.0-CURRENT from today (world rebuilt)
>Description:
tcpdump(1) does not correctly process target ports for monitoring which are
specified symbolically on the command line. Given the command line:
tcpdump -d port time
the BPF packet matching code should be looking for 0x25 but instead looks
for port 0x2500 - indicating a missed call to ntohs (on the value returned
by getservbyname()):
[snippet from the above tcpdump output]
(009) jeq #0x2500 jt 12 jf 10
tcpdump relies on pcap(3) to call getservbyname(), and coincidentally
interesting compilation warnings are issued when libpcap is built
during make world:
/usr/src/lib/libpcap/../../contrib/libpcap/nametoaddr.c:
In function `pcap_nametoaddr':
/usr/src/lib/libpcap/../../contrib/libpcap/nametoaddr.c:89:
warning: statement with no effect
/usr/src/lib/libpcap/../../contrib/libpcap/nametoaddr.c:
In function `pcap_nametoport':
/usr/src/lib/libpcap/../../contrib/libpcap/nametoaddr.c:125:
warning: statement with no effect
/usr/src/lib/libpcap/../../contrib/libpcap/nametoaddr.c:141:
warning: statement with no effect
Line 125 of nametoaddr.c is a call to the NTOHS macro defined
in sys/i386/include:
123 sp = getservbyname(name, (char *)0);
124 if (sp != NULL) {
125 NTOHS(sp->s_port);
126 *port = sp->s_port;
cc -E -c ../../contrib/libpcap/nametoaddr.c yields this
(ostensibly correct per endian.h) expansion for line 125:
(( sp->s_port ) =
__extension__ ({ register u_short __X = ( (u_short)( sp->s_port ) );
__asm ("xchgb %h1, %b1"
: "=q" (__X)
: "0" (__X));
__X; }) ) ;
>How-To-Repeat:
I tried to reduce this to a simple test case, using NTOHS() in the same
way that libpcap does; I couldn't reproduce it. So for now,
cd /usr/src/lib/libpcap
make
to get the compiler warnings, and use
tcpdump -d udp port time to see the end result.
>Fix:
unknown, but I'm going to review the #includes in
src/contrib/nametoaddr.c to see if there is perhaps
some heinous recursion or something else which might
be confusing the compiler??? HELP!!!!
>Audit-Trail:
>Unformatted:
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199704192317.QAA03006>
