From owner-freebsd-bugs Sat Apr 19 16:20:09 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id QAA21812 for bugs-outgoing; Sat, 19 Apr 1997 16:20:09 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id QAA21804; Sat, 19 Apr 1997 16:20:03 -0700 (PDT) Resent-Date: Sat, 19 Apr 1997 16:20:03 -0700 (PDT) Resent-Message-Id: <199704192320.QAA21804@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, skynyrd@opus.cts.cwu.edu Received: from pahtoh.cwu.edu (root@pahtoh.cwu.edu [198.104.65.27]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id QAA21707 for ; Sat, 19 Apr 1997 16:18:05 -0700 (PDT) Received: from opus.cts.cwu.edu (skynyrd@opus.cts.cwu.edu [198.104.92.71]) by pahtoh.cwu.edu (8.8.5/8.8.5) with ESMTP id QAA09055 for ; Sat, 19 Apr 1997 16:17:33 -0700 (PDT) Received: (from skynyrd@localhost) by opus.cts.cwu.edu (8.8.5/8.8.5) id QAA03006; Sat, 19 Apr 1997 16:17:32 -0700 (PDT) Message-Id: <199704192317.QAA03006@opus.cts.cwu.edu> Date: Sat, 19 Apr 1997 16:17:32 -0700 (PDT) From: Chris Timmons Reply-To: skynyrd@opus.cts.cwu.edu To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: i386/3353: NTOHS(x) related compiler warnings and libpcap disfunction Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >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: