git: a2e7dfca8649 - main - systat: clean up code assuming network classes
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 09 Nov 2021 15:36:09 UTC
The branch main has been updated by karels: URL: https://cgit.FreeBSD.org/src/commit/?id=a2e7dfca86497e535039a42cfc44cfc48209abf5 commit a2e7dfca86497e535039a42cfc44cfc48209abf5 Author: Mike Karels <karels@FreeBSD.org> AuthorDate: 2021-10-28 23:39:43 +0000 Commit: Mike Karels <karels@FreeBSD.org> CommitDate: 2021-11-09 15:35:16 +0000 systat: clean up code assuming network classes Similar to netstat, clean up code that uses inet_lnaof() to check for binding to "host 0" (lowest host on network) as a "network" bind. Such things don't happen, and current networks are seldom if ever found in /etc/networks. MFC after: 1 month Reviewers: tuexen Differential Revision: https://reviews.freebsd.org/D32720 --- usr.bin/systat/netstat.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index 8199d0c81586..96d4194db72d 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -206,7 +206,7 @@ again: next = &inpcb; if (!aflag) { if (inpcb.inp_vflag & INP_IPV4) { - if (inet_lnaof(inpcb.inp_laddr) == INADDR_ANY) + if (inpcb.inp_laddr.s_addr == INADDR_ANY) continue; } #ifdef INET6 @@ -303,8 +303,7 @@ fetchnetstat_sysctl(void) if (!aflag) { if (xip->inp_vflag & INP_IPV4) { - if (inet_lnaof(xip->inp_laddr) == - INADDR_ANY) + if (xip->inp_laddr.s_addr == INADDR_ANY) continue; } #ifdef INET6 @@ -584,7 +583,6 @@ inetname(struct sockaddr *sa) char *cp = 0; static char line[NI_MAXHOST]; struct hostent *hp; - struct netent *np; struct in_addr in; #ifdef INET6 @@ -601,19 +599,9 @@ inetname(struct sockaddr *sa) in = ((struct sockaddr_in *)sa)->sin_addr; if (!nflag && in.s_addr != INADDR_ANY) { - int net = inet_netof(in); - int lna = inet_lnaof(in); - - if (lna == INADDR_ANY) { - np = getnetbyaddr(net, AF_INET); - if (np) - cp = np->n_name; - } - if (cp == NULL) { - hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET); - if (hp) - cp = hp->h_name; - } + hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET); + if (hp) + cp = hp->h_name; } if (in.s_addr == INADDR_ANY) strcpy(line, "*");