Bug 20681

Summary: [PATCH] show service names in netstat and sockstat
Product: Base System Reporter: Peter Pentchev <roam>
Component: binAssignee: Dag-Erling Smørgrav <des>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Peter Pentchev 2000-08-17 13:40:01 UTC
Sometimes it is helpful to be able to see port numbers resolved to
service names without attempting to resolve host and network addresses.

The attached patch adds a -S flag to netstat, which overrides the -n
flag for service names (hosts and networks are still shown numerically).

Also included is a trivial patch to the sockstat Perl script, which
makes use of the netstat -S flag, showing service names in sockstat,
which was the whole reason I started doing this at all :)

How-To-Repeat: 
N/A
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-22 16:18:12 UTC
Responsible Changed
From-To: freebsd-bugs->des

Personally, I wouldn't add these options, but DES maintains 
one of these utilities, and whatever decision he makes for 
sockstat probably makes sense for netstat.
Comment 2 assar freebsd_committer freebsd_triage 2001-06-16 00:59:11 UTC
Is this patch ok?

/assar

Index: sockstat.pl
===================================================================
RCS file: /home/ncvs/src/usr.bin/sockstat/sockstat.pl,v
retrieving revision 1.11
diff -u -w -u -w -r1.11 sockstat.pl
--- sockstat.pl	2000/10/13 16:25:37	1.11
+++ sockstat.pl	2001/06/15 23:58:36
@@ -53,7 +53,7 @@
     if (!defined($pid = open(PIPE, "-|"))) {
 	die("open(netstat): $!\n");
     } elsif ($pid == 0) {
-	exec("/usr/bin/netstat", "-Aan");
+	exec("/usr/bin/netstat", "-AaS");
 	die("exec(netstat): $!\n");
     }
     while ($line = <PIPE>) {
Comment 3 des 2001-06-16 01:26:36 UTC
Assar Westerlund <assar@freebsd.org> writes:
> Is this patch ok?

No.  Sockstat purposedly does not resolve host or port names.  Hiding
a port number behind the first few letters of a name which more often
than not bears no relation to the traffic actually passing through the
port is simply idiotic.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org
Comment 4 Peter Pentchev 2001-06-16 01:29:58 UTC
On Sat, Jun 16, 2001 at 02:26:36AM +0200, Dag-Erling Smorgrav wrote:
> Assar Westerlund <assar@freebsd.org> writes:
> > Is this patch ok?
> 
> No.  Sockstat purposedly does not resolve host or port names.  Hiding
> a port number behind the first few letters of a name which more often
> than not bears no relation to the traffic actually passing through the
> port is simply idiotic.

Actually, yes, this is true for high ports..

G'luck,
Peter

-- 
If you think this sentence is confusing, then change one pig.
Comment 5 assar freebsd_committer freebsd_triage 2001-06-16 01:39:24 UTC
Dag-Erling Smorgrav <des@ofug.org> writes:
> Assar Westerlund <assar@freebsd.org> writes:
> > Is this patch ok?
> 
> No.  Sockstat purposedly does not resolve host or port names.  Hiding
> a port number behind the first few letters of a name which more often
> than not bears no relation to the traffic actually passing through the
> port is simply idiotic.

Ok, I will close the PR noting that the netstat option has appeared
and that sockstat will not be changed.

/assar
Comment 6 assar freebsd_committer freebsd_triage 2001-06-16 01:40:14 UTC
State Changed
From-To: open->closed

the netstat option -S has been added 
sockstat will not be changed