Adjust userland commands for struct inpcb integration
Only kvm users are affected.
This commit is contained in:
parent
2fd9c36db0
commit
1fc70a0860
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: fstat.c,v 1.115 2022/06/19 11:31:19 simonb Exp $ */
|
/* $NetBSD: fstat.c,v 1.116 2022/10/28 05:24:07 ozaki-r Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1988, 1993
|
* Copyright (c) 1988, 1993
|
||||||
|
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1993\
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95";
|
static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: fstat.c,v 1.115 2022/06/19 11:31:19 simonb Exp $");
|
__RCSID("$NetBSD: fstat.c,v 1.116 2022/10/28 05:24:07 ozaki-r Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -1062,9 +1062,6 @@ socktrans(struct file *f, struct socket *sock, int i)
|
||||||
struct protosw proto;
|
struct protosw proto;
|
||||||
struct domain dom;
|
struct domain dom;
|
||||||
struct inpcb inpcb;
|
struct inpcb inpcb;
|
||||||
#ifdef INET6
|
|
||||||
struct in6pcb in6pcb;
|
|
||||||
#endif
|
|
||||||
struct unpcb unpcb;
|
struct unpcb unpcb;
|
||||||
struct ddpcb ddpcb;
|
struct ddpcb ddpcb;
|
||||||
int len;
|
int len;
|
||||||
|
@ -1150,15 +1147,15 @@ socktrans(struct file *f, struct socket *sock, int i)
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
if (so.so_pcb == NULL)
|
if (so.so_pcb == NULL)
|
||||||
break;
|
break;
|
||||||
if (kvm_read(kd, (u_long)so.so_pcb, (char *)&in6pcb,
|
if (kvm_read(kd, (u_long)so.so_pcb, (char *)&inpcb,
|
||||||
sizeof(in6pcb)) != sizeof(in6pcb)) {
|
sizeof(inpcb)) != sizeof(inpcb)) {
|
||||||
dprintf("can't read in6pcb at %p", so.so_pcb);
|
dprintf("can't read inpcb at %p", so.so_pcb);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
inet6_addrstr(lbuf, sizeof(lbuf), &in6pcb.in6p_laddr,
|
inet6_addrstr(lbuf, sizeof(lbuf), &inpcb.inp_laddr6,
|
||||||
ntohs(in6pcb.in6p_lport), isdgram);
|
ntohs(inpcb.inp_lport), isdgram);
|
||||||
inet6_addrstr(fbuf, sizeof(fbuf), &in6pcb.in6p_faddr,
|
inet6_addrstr(fbuf, sizeof(fbuf), &inpcb.inp_faddr6,
|
||||||
ntohs(in6pcb.in6p_fport), isdgram);
|
ntohs(inpcb.inp_fport), isdgram);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: inet.c,v 1.117 2022/09/21 07:59:19 msaitoh Exp $ */
|
/* $NetBSD: inet.c,v 1.118 2022/10/28 05:24:07 ozaki-r Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1988, 1993
|
* Copyright (c) 1983, 1988, 1993
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
|
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: inet.c,v 1.117 2022/09/21 07:59:19 msaitoh Exp $");
|
__RCSID("$NetBSD: inet.c,v 1.118 2022/10/28 05:24:07 ozaki-r Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ static struct kinfo_pcb *
|
||||||
getpcblist_kmem(u_long off, const char *name, size_t *len)
|
getpcblist_kmem(u_long off, const char *name, size_t *len)
|
||||||
{
|
{
|
||||||
struct inpcbtable table;
|
struct inpcbtable table;
|
||||||
struct inpcb_hdr *next, *prev;
|
struct inpcb *next, *prev;
|
||||||
struct inpcb inpcb;
|
struct inpcb inpcb;
|
||||||
struct tcpcb tcpcb;
|
struct tcpcb tcpcb;
|
||||||
struct socket sockb;
|
struct socket sockb;
|
||||||
|
@ -1084,8 +1084,8 @@ tcp_dump(u_long off, const char *name, u_long pcbaddr)
|
||||||
printf("State: %d", tcpcb.t_state);
|
printf("State: %d", tcpcb.t_state);
|
||||||
else
|
else
|
||||||
printf("State: %s", tcpstates[tcpcb.t_state]);
|
printf("State: %s", tcpstates[tcpcb.t_state]);
|
||||||
printf(", flags 0x%x, inpcb 0x%lx, in6pcb 0x%lx\n\n", tcpcb.t_flags,
|
printf(", flags 0x%x, inpcb 0x%lx\n\n", tcpcb.t_flags,
|
||||||
(u_long)tcpcb.t_inpcb, (u_long)tcpcb.t_in6pcb);
|
(u_long)tcpcb.t_inpcb);
|
||||||
|
|
||||||
printf("rxtshift %d, rxtcur %d, dupacks %d\n", tcpcb.t_rxtshift,
|
printf("rxtshift %d, rxtcur %d, dupacks %d\n", tcpcb.t_rxtshift,
|
||||||
tcpcb.t_rxtcur, tcpcb.t_dupacks);
|
tcpcb.t_rxtcur, tcpcb.t_dupacks);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: inet6.c,v 1.82 2022/09/21 07:59:19 msaitoh Exp $ */
|
/* $NetBSD: inet6.c,v 1.83 2022/10/28 05:24:07 ozaki-r Exp $ */
|
||||||
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
|
/* BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
|
static char sccsid[] = "@(#)inet.c 8.4 (Berkeley) 4/20/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: inet6.c,v 1.82 2022/09/21 07:59:19 msaitoh Exp $");
|
__RCSID("$NetBSD: inet6.c,v 1.83 2022/10/28 05:24:07 ozaki-r Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ extern const char * const tcptimers[];
|
||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
|
|
||||||
struct in6pcb in6pcb;
|
struct inpcb inpcb;
|
||||||
#ifdef TCP6
|
#ifdef TCP6
|
||||||
struct tcp6cb tcp6cb;
|
struct tcp6cb tcp6cb;
|
||||||
#else
|
#else
|
||||||
|
@ -287,7 +287,7 @@ getpcblist_kmem(u_long off, const char *name, size_t *len)
|
||||||
{
|
{
|
||||||
struct socket sockb;
|
struct socket sockb;
|
||||||
struct inpcbtable table;
|
struct inpcbtable table;
|
||||||
struct inpcb_hdr *next, *prev;
|
struct inpcb *next, *prev;
|
||||||
int istcp = strcmp(name, "tcp6") == 0;
|
int istcp = strcmp(name, "tcp6") == 0;
|
||||||
struct kinfo_pcb *pcblist;
|
struct kinfo_pcb *pcblist;
|
||||||
size_t size = 100, i;
|
size_t size = 100, i;
|
||||||
|
@ -309,33 +309,33 @@ getpcblist_kmem(u_long off, const char *name, size_t *len)
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (next != TAILQ_END(head)) {
|
while (next != TAILQ_END(head)) {
|
||||||
kread((u_long)next, (char *)&in6pcb, sizeof in6pcb);
|
kread((u_long)next, (char *)&inpcb, sizeof inpcb);
|
||||||
next = TAILQ_NEXT(&in6pcb, in6p_queue);
|
next = TAILQ_NEXT(&inpcb, inp_queue);
|
||||||
prev = next;
|
prev = next;
|
||||||
|
|
||||||
if (in6pcb.in6p_af != AF_INET6)
|
if (inpcb.inp_af != AF_INET6)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
kread((u_long)in6pcb.in6p_socket, (char *)&sockb,
|
kread((u_long)inpcb.inp_socket, (char *)&sockb,
|
||||||
sizeof (sockb));
|
sizeof (sockb));
|
||||||
if (istcp) {
|
if (istcp) {
|
||||||
#ifdef TCP6
|
#ifdef TCP6
|
||||||
kread((u_long)in6pcb.in6p_ppcb,
|
kread((u_long)inpcb.inp_ppcb,
|
||||||
(char *)&tcp6cb, sizeof (tcp6cb));
|
(char *)&tcp6cb, sizeof (tcp6cb));
|
||||||
#else
|
#else
|
||||||
kread((u_long)in6pcb.in6p_ppcb,
|
kread((u_long)inpcb.inp_ppcb,
|
||||||
(char *)&tcpcb, sizeof (tcpcb));
|
(char *)&tcpcb, sizeof (tcpcb));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
pcblist[i].ki_ppcbaddr =
|
pcblist[i].ki_ppcbaddr =
|
||||||
istcp ? (uintptr_t) in6pcb.in6p_ppcb : (uintptr_t) prev;
|
istcp ? (uintptr_t) inpcb.inp_ppcb : (uintptr_t) prev;
|
||||||
pcblist[i].ki_rcvq = (uint64_t)sockb.so_rcv.sb_cc;
|
pcblist[i].ki_rcvq = (uint64_t)sockb.so_rcv.sb_cc;
|
||||||
pcblist[i].ki_sndq = (uint64_t)sockb.so_snd.sb_cc;
|
pcblist[i].ki_sndq = (uint64_t)sockb.so_snd.sb_cc;
|
||||||
sin6.sin6_addr = in6pcb.in6p_laddr;
|
sin6.sin6_addr = inpcb.inp_laddr6;
|
||||||
sin6.sin6_port = in6pcb.in6p_lport;
|
sin6.sin6_port = inpcb.inp_lport;
|
||||||
memcpy(&pcblist[i].ki_s, &sin6, sizeof(sin6));
|
memcpy(&pcblist[i].ki_s, &sin6, sizeof(sin6));
|
||||||
sin6.sin6_addr = in6pcb.in6p_faddr;
|
sin6.sin6_addr = inpcb.inp_faddr6;
|
||||||
sin6.sin6_port = in6pcb.in6p_fport;
|
sin6.sin6_port = inpcb.inp_fport;
|
||||||
memcpy(&pcblist[i].ki_d, &sin6, sizeof(sin6));
|
memcpy(&pcblist[i].ki_d, &sin6, sizeof(sin6));
|
||||||
pcblist[i].ki_tstate = tcpcb.t_state;
|
pcblist[i].ki_tstate = tcpcb.t_state;
|
||||||
if (i++ == size) {
|
if (i++ == size) {
|
||||||
|
@ -1431,7 +1431,7 @@ inet6print(const struct in6_addr *in6, int port, const char *proto)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
inet6name(const struct in6_addr *in6p)
|
inet6name(const struct in6_addr *inp)
|
||||||
{
|
{
|
||||||
char *cp;
|
char *cp;
|
||||||
static char line[NI_MAXHOST];
|
static char line[NI_MAXHOST];
|
||||||
|
@ -1451,8 +1451,8 @@ inet6name(const struct in6_addr *in6p)
|
||||||
domain[0] = 0;
|
domain[0] = 0;
|
||||||
}
|
}
|
||||||
cp = 0;
|
cp = 0;
|
||||||
if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(in6p)) {
|
if (!numeric_addr && !IN6_IS_ADDR_UNSPECIFIED(inp)) {
|
||||||
hp = gethostbyaddr((const char *)in6p, sizeof(*in6p), AF_INET6);
|
hp = gethostbyaddr((const char *)inp, sizeof(*inp), AF_INET6);
|
||||||
if (hp) {
|
if (hp) {
|
||||||
if ((cp = strchr(hp->h_name, '.')) &&
|
if ((cp = strchr(hp->h_name, '.')) &&
|
||||||
!strcmp(cp + 1, domain))
|
!strcmp(cp + 1, domain))
|
||||||
|
@ -1460,7 +1460,7 @@ inet6name(const struct in6_addr *in6p)
|
||||||
cp = hp->h_name;
|
cp = hp->h_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IN6_IS_ADDR_UNSPECIFIED(in6p))
|
if (IN6_IS_ADDR_UNSPECIFIED(inp))
|
||||||
strlcpy(line, "*", sizeof(line));
|
strlcpy(line, "*", sizeof(line));
|
||||||
else if (cp)
|
else if (cp)
|
||||||
strlcpy(line, cp, sizeof(line));
|
strlcpy(line, cp, sizeof(line));
|
||||||
|
@ -1468,7 +1468,7 @@ inet6name(const struct in6_addr *in6p)
|
||||||
memset(&sin6, 0, sizeof(sin6));
|
memset(&sin6, 0, sizeof(sin6));
|
||||||
sin6.sin6_len = sizeof(sin6);
|
sin6.sin6_len = sizeof(sin6);
|
||||||
sin6.sin6_family = AF_INET6;
|
sin6.sin6_family = AF_INET6;
|
||||||
sin6.sin6_addr = *in6p;
|
sin6.sin6_addr = *inp;
|
||||||
inet6_getscopeid(&sin6,
|
inet6_getscopeid(&sin6,
|
||||||
INET6_IS_ADDR_LINKLOCAL | INET6_IS_ADDR_MC_LINKLOCAL);
|
INET6_IS_ADDR_LINKLOCAL | INET6_IS_ADDR_MC_LINKLOCAL);
|
||||||
if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len,
|
if (getnameinfo((struct sockaddr *)&sin6, sin6.sin6_len,
|
||||||
|
@ -1529,8 +1529,8 @@ tcp6_dump(u_long off, const char *name, u_long pcbaddr)
|
||||||
printf("State: %d", mypcb.t_state);
|
printf("State: %d", mypcb.t_state);
|
||||||
else
|
else
|
||||||
printf("State: %s", tcp6states[mypcb.t_state]);
|
printf("State: %s", tcp6states[mypcb.t_state]);
|
||||||
printf(", flags 0x%x, in6pcb 0x%lx\n\n", mypcb.t_flags,
|
printf(", flags 0x%x, inpcb 0x%lx\n\n", mypcb.t_flags,
|
||||||
(u_long)mypcb.t_in6pcb);
|
(u_long)mypcb.t_inpcb);
|
||||||
|
|
||||||
printf("rxtshift %d, rxtcur %d, dupacks %d\n", mypcb.t_rxtshift,
|
printf("rxtshift %d, rxtcur %d, dupacks %d\n", mypcb.t_rxtshift,
|
||||||
mypcb.t_rxtcur, mypcb.t_dupacks);
|
mypcb.t_rxtcur, mypcb.t_dupacks);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $ */
|
/* $NetBSD: sockstat.c,v 1.25 2022/10/28 05:24:07 ozaki-r Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005 The NetBSD Foundation, Inc.
|
* Copyright (c) 2005 The NetBSD Foundation, Inc.
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $");
|
__RCSID("$NetBSD: sockstat.c,v 1.25 2022/10/28 05:24:07 ozaki-r Exp $");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _KMEMUSER
|
#define _KMEMUSER
|
||||||
|
@ -47,7 +47,6 @@ __RCSID("$NetBSD: sockstat.c,v 1.24 2021/08/27 18:09:30 rillig Exp $");
|
||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
#include <netinet/ip.h>
|
#include <netinet/ip.h>
|
||||||
#include <netinet/in_pcb.h>
|
#include <netinet/in_pcb.h>
|
||||||
#include <netinet/in_pcb_hdr.h>
|
|
||||||
#include <netinet/tcp_fsm.h>
|
#include <netinet/tcp_fsm.h>
|
||||||
|
|
||||||
#define _KMEMUSER
|
#define _KMEMUSER
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: extern.h,v 1.48 2021/08/21 13:22:19 christos Exp $ */
|
/* $NetBSD: extern.h,v 1.49 2022/10/28 05:24:08 ozaki-r Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1991, 1993
|
* Copyright (c) 1991, 1993
|
||||||
|
@ -67,15 +67,11 @@ extern double etime;
|
||||||
extern bool showzero;
|
extern bool showzero;
|
||||||
|
|
||||||
struct inpcb;
|
struct inpcb;
|
||||||
#ifdef INET6
|
|
||||||
struct in6pcb;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int checkhost(struct inpcb *);
|
int checkhost(struct inpcb *);
|
||||||
int checkport(struct inpcb *);
|
int checkport(struct inpcb *);
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
int checkhost6(struct in6pcb *);
|
int checkhost6(struct inpcb *);
|
||||||
int checkport6(struct in6pcb *);
|
|
||||||
#endif
|
#endif
|
||||||
void closebufcache(WINDOW *);
|
void closebufcache(WINDOW *);
|
||||||
void closedf(WINDOW *);
|
void closedf(WINDOW *);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: netcmds.c,v 1.22 2021/10/30 11:31:51 nia Exp $ */
|
/* $NetBSD: netcmds.c,v 1.23 2022/10/28 05:24:08 ozaki-r Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1992, 1993
|
* Copyright (c) 1980, 1992, 1993
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)netcmds.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)netcmds.c 8.1 (Berkeley) 6/6/93";
|
||||||
#endif
|
#endif
|
||||||
__RCSID("$NetBSD: netcmds.c,v 1.22 2021/10/30 11:31:51 nia Exp $");
|
__RCSID("$NetBSD: netcmds.c,v 1.23 2022/10/28 05:24:08 ozaki-r Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -245,20 +245,6 @@ checkport(struct inpcb *inp)
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef INET6
|
|
||||||
int
|
|
||||||
checkport6(struct in6pcb *in6p)
|
|
||||||
{
|
|
||||||
struct pitem *p;
|
|
||||||
|
|
||||||
if (ports)
|
|
||||||
for (p = ports; p < ports+nports; p++)
|
|
||||||
if (p->port == in6p->in6p_lport || p->port == in6p->in6p_fport)
|
|
||||||
return (p->onoff);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
showports(void)
|
showports(void)
|
||||||
{
|
{
|
||||||
|
@ -354,7 +340,7 @@ checkhost(struct inpcb *inp)
|
||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
int
|
int
|
||||||
checkhost6(struct in6pcb *in6p)
|
checkhost6(struct inpcb *inp)
|
||||||
{
|
{
|
||||||
struct hitem *p;
|
struct hitem *p;
|
||||||
struct sockaddr_in6 *sin6;
|
struct sockaddr_in6 *sin6;
|
||||||
|
@ -364,8 +350,8 @@ checkhost6(struct in6pcb *in6p)
|
||||||
if (((struct sockaddr *)&p->addr)->sa_family != AF_INET6)
|
if (((struct sockaddr *)&p->addr)->sa_family != AF_INET6)
|
||||||
continue;
|
continue;
|
||||||
sin6 = (struct sockaddr_in6 *)&p->addr;
|
sin6 = (struct sockaddr_in6 *)&p->addr;
|
||||||
if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &in6p->in6p_laddr) ||
|
if (IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &inp->inp_laddr6) ||
|
||||||
IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &in6p->in6p_faddr))
|
IN6_ARE_ADDR_EQUAL(&sin6->sin6_addr, &inp->inp_faddr6))
|
||||||
return (p->onoff);
|
return (p->onoff);
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: netstat.c,v 1.30 2018/05/03 07:13:48 maxv Exp $ */
|
/* $NetBSD: netstat.c,v 1.31 2022/10/28 05:24:08 ozaki-r Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1980, 1992, 1993
|
* Copyright (c) 1980, 1992, 1993
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
|
||||||
#endif
|
#endif
|
||||||
__RCSID("$NetBSD: netstat.c,v 1.30 2018/05/03 07:13:48 maxv Exp $");
|
__RCSID("$NetBSD: netstat.c,v 1.31 2022/10/28 05:24:08 ozaki-r Exp $");
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -83,7 +83,7 @@ static const char *inetname(struct in_addr);
|
||||||
static void inetprint(struct in_addr *, int, const char *);
|
static void inetprint(struct in_addr *, int, const char *);
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
static void fetchnetstat6(void *, int);
|
static void fetchnetstat6(void *, int);
|
||||||
static void enter6(struct in6pcb *, struct socket *, int, const char *);
|
static void enter6(struct inpcb *, struct socket *, int, const char *);
|
||||||
static const char *inet6name(struct in6_addr *);
|
static const char *inet6name(struct in6_addr *);
|
||||||
static void inet6print(struct in6_addr *, int, const char *);
|
static void inet6print(struct in6_addr *, int, const char *);
|
||||||
#endif
|
#endif
|
||||||
|
@ -213,7 +213,7 @@ static void
|
||||||
fetchnetstat4(void *off, int istcp)
|
fetchnetstat4(void *off, int istcp)
|
||||||
{
|
{
|
||||||
struct inpcbtable pcbtable;
|
struct inpcbtable pcbtable;
|
||||||
struct inpcb_hdr **pprev, *next;
|
struct inpcb **pprev, *next;
|
||||||
struct netinfo *p;
|
struct netinfo *p;
|
||||||
struct inpcb inpcb, *inpcbp;
|
struct inpcb inpcb, *inpcbp;
|
||||||
struct socket sockb;
|
struct socket sockb;
|
||||||
|
@ -231,7 +231,7 @@ fetchnetstat4(void *off, int istcp)
|
||||||
error("Kernel state in transition");
|
error("Kernel state in transition");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pprev = &next->inph_queue.tqe_next;
|
pprev = &next->inp_queue.tqe_next;
|
||||||
next = inpcb.inp_queue.tqe_next;
|
next = inpcb.inp_queue.tqe_next;
|
||||||
|
|
||||||
if (inpcb.inp_af != AF_INET)
|
if (inpcb.inp_af != AF_INET)
|
||||||
|
@ -256,41 +256,41 @@ static void
|
||||||
fetchnetstat6(void *off, int istcp)
|
fetchnetstat6(void *off, int istcp)
|
||||||
{
|
{
|
||||||
struct inpcbtable pcbtable;
|
struct inpcbtable pcbtable;
|
||||||
struct inpcb_hdr **pprev, *next;
|
struct inpcb **pprev, *next;
|
||||||
struct netinfo *p;
|
struct netinfo *p;
|
||||||
struct socket sockb;
|
struct socket sockb;
|
||||||
struct tcpcb tcpcb;
|
struct tcpcb tcpcb;
|
||||||
struct in6pcb in6pcb, *in6pcbp;
|
struct inpcb inpcb, *inpcbp;
|
||||||
|
|
||||||
KREAD(off, &pcbtable, sizeof pcbtable);
|
KREAD(off, &pcbtable, sizeof pcbtable);
|
||||||
pprev = &((struct inpcbtable *)off)->inpt_queue.tqh_first;
|
pprev = &((struct inpcbtable *)off)->inpt_queue.tqh_first;
|
||||||
next = TAILQ_FIRST(&pcbtable.inpt_queue);
|
next = TAILQ_FIRST(&pcbtable.inpt_queue);
|
||||||
while (next != TAILQ_END(&pcbtable.inpt_queue)) {
|
while (next != TAILQ_END(&pcbtable.inpt_queue)) {
|
||||||
in6pcbp = (struct in6pcb *)next;
|
inpcbp = (struct inpcb *)next;
|
||||||
KREAD(in6pcbp, &in6pcb, sizeof (in6pcb));
|
KREAD(inpcbp, &inpcb, sizeof (inpcb));
|
||||||
if (in6pcb.in6p_queue.tqe_prev != pprev) {
|
if (inpcb.inp_queue.tqe_prev != pprev) {
|
||||||
for (p = netcb.ni_forw; p != nhead; p = p->ni_forw)
|
for (p = netcb.ni_forw; p != nhead; p = p->ni_forw)
|
||||||
p->ni_seen = 1;
|
p->ni_seen = 1;
|
||||||
error("Kernel state in transition");
|
error("Kernel state in transition");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pprev = &next->inph_queue.tqe_next;
|
pprev = &next->inp_queue.tqe_next;
|
||||||
next = in6pcb.in6p_queue.tqe_next;
|
next = inpcb.inp_queue.tqe_next;
|
||||||
|
|
||||||
if (in6pcb.in6p_af != AF_INET6)
|
if (inpcb.inp_af != AF_INET6)
|
||||||
continue;
|
continue;
|
||||||
if (!aflag && IN6_IS_ADDR_UNSPECIFIED(&in6pcb.in6p_laddr))
|
if (!aflag && IN6_IS_ADDR_UNSPECIFIED(&inpcb.inp_laddr6))
|
||||||
continue;
|
continue;
|
||||||
if (nhosts && !checkhost6(&in6pcb))
|
if (nhosts && !checkhost(&inpcb))
|
||||||
continue;
|
continue;
|
||||||
if (nports && !checkport6(&in6pcb))
|
if (nports && !checkport(&inpcb))
|
||||||
continue;
|
continue;
|
||||||
KREAD(in6pcb.in6p_socket, &sockb, sizeof (sockb));
|
KREAD(inpcb.inp_socket, &sockb, sizeof (sockb));
|
||||||
if (istcp) {
|
if (istcp) {
|
||||||
KREAD(in6pcb.in6p_ppcb, &tcpcb, sizeof (tcpcb));
|
KREAD(inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb));
|
||||||
enter6(&in6pcb, &sockb, tcpcb.t_state, "tcp");
|
enter6(&inpcb, &sockb, tcpcb.t_state, "tcp");
|
||||||
} else
|
} else
|
||||||
enter6(&in6pcb, &sockb, 0, "udp");
|
enter6(&inpcb, &sockb, 0, "udp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /*INET6*/
|
#endif /*INET6*/
|
||||||
|
@ -345,7 +345,7 @@ enter(struct inpcb *inp, struct socket *so, int state, const char *proto)
|
||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
static void
|
static void
|
||||||
enter6(struct in6pcb *in6p, struct socket *so, int state, const char *proto)
|
enter6(struct inpcb *inp, struct socket *so, int state, const char *proto)
|
||||||
{
|
{
|
||||||
struct netinfo *p;
|
struct netinfo *p;
|
||||||
|
|
||||||
|
@ -361,11 +361,11 @@ enter6(struct in6pcb *in6p, struct socket *so, int state, const char *proto)
|
||||||
continue;
|
continue;
|
||||||
if (!streq(proto, p->ni_proto))
|
if (!streq(proto, p->ni_proto))
|
||||||
continue;
|
continue;
|
||||||
if (p->ni_lport != in6p->in6p_lport ||
|
if (p->ni_lport != inp->inp_lport ||
|
||||||
!IN6_ARE_ADDR_EQUAL(&p->ni_laddr6, &in6p->in6p_laddr))
|
!IN6_ARE_ADDR_EQUAL(&p->ni_laddr6, &inp->inp_laddr6))
|
||||||
continue;
|
continue;
|
||||||
if (IN6_ARE_ADDR_EQUAL(&p->ni_faddr6, &in6p->in6p_faddr) &&
|
if (IN6_ARE_ADDR_EQUAL(&p->ni_faddr6, &inp->inp_faddr6) &&
|
||||||
p->ni_fport == in6p->in6p_fport)
|
p->ni_fport == inp->inp_fport)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (p == nhead) {
|
if (p == nhead) {
|
||||||
|
@ -378,10 +378,10 @@ enter6(struct in6pcb *in6p, struct socket *so, int state, const char *proto)
|
||||||
netcb.ni_forw->ni_prev = p;
|
netcb.ni_forw->ni_prev = p;
|
||||||
netcb.ni_forw = p;
|
netcb.ni_forw = p;
|
||||||
p->ni_line = -1;
|
p->ni_line = -1;
|
||||||
p->ni_laddr6 = in6p->in6p_laddr;
|
p->ni_laddr6 = inp->inp_laddr6;
|
||||||
p->ni_lport = in6p->in6p_lport;
|
p->ni_lport = inp->inp_lport;
|
||||||
p->ni_faddr6 = in6p->in6p_faddr;
|
p->ni_faddr6 = inp->inp_faddr6;
|
||||||
p->ni_fport = in6p->in6p_fport;
|
p->ni_fport = inp->inp_fport;
|
||||||
p->ni_proto = proto;
|
p->ni_proto = proto;
|
||||||
p->ni_flags = NIF_LACHG | NIF_FACHG;
|
p->ni_flags = NIF_LACHG | NIF_FACHG;
|
||||||
p->ni_family = AF_INET6;
|
p->ni_family = AF_INET6;
|
||||||
|
|
Loading…
Reference in New Issue