diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2024-03-29 19:16:59 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2024-03-29 19:18:32 +0000 |
commit | 1a8d176432e76d7725ed1ac0b44f63ac6cc82397 (patch) | |
tree | c389b7bc620a773b887a5737c3c4ccbec5d4af46 /usr.bin | |
parent | de2a4e80d7d36651eaa688405ba72562cb7bc87c (diff) | |
download | src-1a8d176432e76d7725ed1ac0b44f63ac6cc82397.tar.gz src-1a8d176432e76d7725ed1ac0b44f63ac6cc82397.zip |
inpcb: fully retire inp_ppcb pointer
Before a protocol specific control block started to embed inpcb in self
(see 0aa120d52f3c, e68b3792440c, 483fe96511ec) this pointer used to point
at it.
Retain kf_sock_inpcb field in the struct kinfo_file in <sys/user.h>. The
exp-run detected a minimal use of the field in ports:
* sysutils/lsof - patched upstream
* net-mgmt/netdata - patch accepted upstream
* emulators/qemu-user-static - upstream master branch seems not using
the field anymore
We can keep the field around for some time, but eventually it may be
reused for something else.
PR: 277659 (exp-run)
Reviewed by: tuexen
Differential Revision: https://reviews.freebsd.org/D44491
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/fstat/fstat.c | 15 | ||||
-rw-r--r-- | usr.bin/systat/netstat.c | 28 |
2 files changed, 18 insertions, 25 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 328e35e9138f..e5d0755062d0 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -400,11 +400,10 @@ print_socket_info(struct procstat *procstat, struct filestat *fst) /* * protocol specific formatting * - * Try to find interesting things to print. For tcp, the interesting - * thing is the address of the tcpcb, for udp and others, just the - * inpcb (socket pcb). For unix domain, its the address of the socket - * pcb and the address of the connected pcb (if connected). Otherwise - * just print the protocol number and address of the socket itself. + * Try to find interesting things to print. For internet and unix + * sockets, its the address of the socket pcb. For unix it is also the + * address of the connected pcb (if connected). Otherwise just print + * the protocol number and address of the socket itself. * The idea is not to duplicate netstat, but to make available enough * information for further analysis. */ @@ -417,11 +416,7 @@ print_socket_info(struct procstat *procstat, struct filestat *fst) printf(" %s", pe->p_name); else printf(" %d", sock.proto); - if (sock.proto == IPPROTO_TCP ) { - if (sock.inp_ppcb != 0) - printf(" %lx", (u_long)sock.inp_ppcb); - } - else if (sock.so_pcb != 0) + if (sock.so_pcb != 0) printf(" %lx", (u_long)sock.so_pcb); if (!sflg) break; diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index bc4acabe4eda..6d188bf1dd0d 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -168,12 +168,11 @@ fetchnetstat(void) static void fetchnetstat_kvm(void) { - struct inpcb *next; struct netinfo *p; struct inpcbhead head; - struct inpcb inpcb; struct socket sockb; struct tcpcb tcpcb; + struct inpcb *inpcb; void *off; int istcp; @@ -195,32 +194,31 @@ fetchnetstat_kvm(void) } again: KREAD(off, &head, sizeof (struct inpcbhead)); - LIST_FOREACH(next, &head, inp_list) { - KREAD(next, &inpcb, sizeof (inpcb)); - next = &inpcb; + LIST_FOREACH(inpcb, &head, inp_list) { + KREAD(inpcb, &tcpcb, istcp ? sizeof(tcpcb) : sizeof(inpcb)); + inpcb = (struct inpcb *)&tcpcb; if (!aflag) { - if (inpcb.inp_vflag & INP_IPV4) { - if (inpcb.inp_laddr.s_addr == INADDR_ANY) + if (inpcb->inp_vflag & INP_IPV4) { + if (inpcb->inp_laddr.s_addr == INADDR_ANY) continue; } #ifdef INET6 - else if (inpcb.inp_vflag & INP_IPV6) { - if (memcmp(&inpcb.in6p_laddr, + else if (inpcb->inp_vflag & INP_IPV6) { + if (memcmp(&inpcb->in6p_laddr, &in6addr_any, sizeof(in6addr_any)) == 0) continue; } #endif } - if (nhosts && !checkhost(&inpcb.inp_inc)) + if (nhosts && !checkhost(&inpcb->inp_inc)) continue; - if (nports && !checkport(&inpcb.inp_inc)) + if (nports && !checkport(&inpcb->inp_inc)) continue; if (istcp) { - KREAD(inpcb.inp_socket, &sockb, sizeof (sockb)); - KREAD(inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb)); - enter_kvm(&inpcb, &sockb, tcpcb.t_state, "tcp"); + KREAD(inpcb->inp_socket, &sockb, sizeof (sockb)); + enter_kvm(inpcb, &sockb, tcpcb.t_state, "tcp"); } else - enter_kvm(&inpcb, &sockb, 0, "udp"); + enter_kvm(inpcb, &sockb, 0, "udp"); } if (istcp && (protos&UDP)) { istcp = 0; |