From owner-freebsd-alpha Wed Jul 25 12:40:20 2001 Delivered-To: freebsd-alpha@freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 5763A37B406 for ; Wed, 25 Jul 2001 12:40:08 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f6PJe8J62517; Wed, 25 Jul 2001 12:40:08 -0700 (PDT) (envelope-from gnats) Received: from iatl0x01.coxmail.com (iatl0x02.coxmail.com [206.157.225.11]) by hub.freebsd.org (Postfix) with ESMTP id 8466937B403 for ; Wed, 25 Jul 2001 12:39:54 -0700 (PDT) (envelope-from pherman@tick.sc.omation.com) Received: from tick.sc.omation.com ([64.58.167.31]) by iatl0x01.coxmail.com (InterMail vK.4.03.02.00 201-232-124 license eaa2928f5bcba31507d4d280f1027278) with ESMTP id <20010725193952.CCEJ27239.iatl0x01@tick.sc.omation.com> for ; Wed, 25 Jul 2001 15:39:52 -0400 Received: (from pherman@localhost) by tick.sc.omation.com (8.11.3/8.11.3) id f6PJdqX06597; Wed, 25 Jul 2001 12:39:52 -0700 (PDT) (envelope-from pherman) Message-Id: <200107251939.f6PJdqX06597@tick.sc.omation.com> Date: Wed, 25 Jul 2001 12:39:52 -0700 (PDT) From: pherman@frenchfries.net Reply-To: pherman@frenchfries.net To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: alpha/29231: sockstat broken on alpha [patch] Sender: owner-freebsd-alpha@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 29231 >Category: alpha >Synopsis: sockstat broken on alpha [patch] >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-alpha >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jul 25 12:40:07 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Paul Herman >Release: FreeBSD 4.3-RELEASE alpha >Organization: >Environment: System: FreeBSD tick.sc.omation.com 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Tue Jun 5 12:34:59 PDT 2001 root@fw1.sc.omation.com:/usr/src/sys/compile/fw1 alpha >Description: sockstat prints only "?" for protocols & addresses when run on a 64-bit OS. >How-To-Repeat: 12:32:05{{ttyp0}pherman@arthur}~//> sockstat | head USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS root xterm 32538 3 ? ? ? root sshd 32537 3 ? ? ? root sshd 32537 4 ? ? ? root sshd 32537 6 ? ? ? bind named 28544 4 ? ? ? >Fix: The reason is because the socket addresses printed by "netstat -A" are 64-bit u_long on a 64-bit platform. fstat, however, prints them as ints which are always 32-bit. A second problem is that sockstat.pl is hardcoded to expect only 8-byte socket addresses. The following patch for -STABLE fixes this issue: Index: usr.bin/fstat/fstat.c =================================================================== RCS file: /home/ncvs/src/usr.bin/fstat/fstat.c,v retrieving revision 1.21.2.3 diff -u -r1.21.2.3 fstat.c --- usr.bin/fstat/fstat.c 2000/12/05 09:43:11 1.21.2.3 +++ usr.bin/fstat/fstat.c 2001/07/25 18:04:22 @@ -664,7 +664,7 @@ goto bad; } - printf("* pipe %8x <-> %8x", (int)pi, (int)pip.pipe_peer); + printf("* pipe %8lx <-> %8lx", (u_long)pi, (u_long)pip.pipe_peer); printf(" %6d", (int)pip.pipe_buffer.cnt); rw[0] = '\0'; if (flag & FREAD) @@ -762,16 +762,16 @@ (void *)so.so_pcb); goto bad; } - printf(" %x", (int)inpcb.inp_ppcb); + printf(" %lx", (u_long)inpcb.inp_ppcb); } } else if (so.so_pcb) - printf(" %x", (int)so.so_pcb); + printf(" %lx", (u_long)so.so_pcb); break; case AF_UNIX: /* print address of pcb and connected pcb */ if (so.so_pcb) { - printf(" %x", (int)so.so_pcb); + printf(" %lx", (u_long)so.so_pcb); if (kvm_read(kd, (u_long)so.so_pcb, (char *)&unpcb, sizeof(struct unpcb)) != sizeof(struct unpcb)){ dprintf(stderr, "can't read unpcb at %p\n", @@ -788,14 +788,14 @@ if (!(so.so_state & SS_CANTSENDMORE)) *cp++ = '>'; *cp = '\0'; - printf(" %s %x", shoconn, - (int)unpcb.unp_conn); + printf(" %s %lx", shoconn, + (u_long)unpcb.unp_conn); } } break; default: /* print protocol number and socket address */ - printf(" %d %x", proto.pr_protocol, (int)sock); + printf(" %d %lx", proto.pr_protocol, (u_long)sock); } printf("\n"); return; Index: usr.bin/sockstat/sockstat.pl =================================================================== RCS file: /home/ncvs/src/usr.bin/sockstat/sockstat.pl,v retrieving revision 1.6.2.4 diff -u -r1.6.2.4 sockstat.pl --- usr.bin/sockstat/sockstat.pl 2001/03/22 13:49:51 1.6.2.4 +++ usr.bin/sockstat/sockstat.pl 2001/07/25 19:15:26 @@ -57,7 +57,7 @@ die("exec(netstat): $!\n"); } while ($line = ) { - next unless ($line =~ m/^[0-9a-f]{8} /); + next unless ($line =~ m/^[0-9a-f]{8} /) || ($line =~ m/^[0-9a-f]{16} /); chomp($line); @fields = split(' ', $line); $netstat{$fields[0]} = [ @fields ]; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message