mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
netstat: fix printing of TCP pcbs with -A
This change touches both kernel and netstat(1), but either of the changes
will fix printing pcb addresses with -A.
The thing is that historically netstat(1) treated TCP differently, and
printed tcpcb address instead of inpcb address. This is not documented
anywhere! With e68b379244 these two addresses became the same. It is
highly likely they will be the same for a long time, but it might be they
will start to differ again in a far future. My proposal is to stop
treating TCP differently with netstat(1) and right now is a good opportunity
to do that, since there will be no behavior change at all. The kernel
change to tcp_inptoxtp() will go into stable/14 to make it compatible with
netstat(1) binary from stable/13. We can drop it later, probably together
with in_ppcb pointer from inpcb. The in_ppcb in xinpcb will stay for size
compatibility.
Reviewed by: tuexen, rrs
Differential Revision: https://reviews.freebsd.org/D39736
This commit is contained in:
parent
4214005276
commit
8e813d07c6
2 changed files with 10 additions and 10 deletions
|
|
@ -3968,6 +3968,13 @@ tcp_inptoxtp(const struct inpcb *inp, struct xtcpcb *xt)
|
|||
|
||||
xt->xt_len = sizeof(struct xtcpcb);
|
||||
in_pcbtoxinpcb(inp, &xt->xt_inp);
|
||||
/*
|
||||
* TCP doesn't use inp_ppcb pointer, we embed inpcb into tcpcb.
|
||||
* Fixup the pointer that in_pcbtoxinpcb() has set. When printing
|
||||
* TCP netstat(1) used to use this pointer, so this fixup needs to
|
||||
* stay for stable/14.
|
||||
*/
|
||||
xt->xt_inp.inp_ppcb = (uintptr_t)tp;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -383,16 +383,9 @@ protopr(u_long off, const char *name, int af1, int proto)
|
|||
if (Lflag && so->so_qlimit == 0)
|
||||
continue;
|
||||
xo_open_instance("socket");
|
||||
if (Aflag) {
|
||||
if (istcp)
|
||||
xo_emit("{q:address/%*lx} ",
|
||||
2 * (int)sizeof(void *),
|
||||
(u_long)inp->inp_ppcb);
|
||||
else
|
||||
xo_emit("{q:address/%*lx} ",
|
||||
2 * (int)sizeof(void *),
|
||||
(u_long)so->so_pcb);
|
||||
}
|
||||
if (Aflag)
|
||||
xo_emit("{q:address/%*lx} ", 2 * (int)sizeof(void *),
|
||||
(u_long)so->so_pcb);
|
||||
#ifdef INET6
|
||||
if ((inp->inp_vflag & INP_IPV6) != 0)
|
||||
vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
|
||||
|
|
|
|||
Loading…
Reference in a new issue