Sorry in this just befor code freeze commit.
This is fix to usr.sbin/trpt and tcp_debug.[ch] I think of putting this after 4.0 but,,, -There was bug that when INET6 is defined, IPv4 socket is not traced by trpt. -I received request from a person who distribute a program which use tcp_debug interface and print performance statistics, that -leave comptibility with old program as much as possible -use same interface with other OSes So, I talked with itojun, and synced API with netbsd IPv6 extension. makeworld check, kernel build check(includes GENERIC) is done. But if there happen to any problem, please let me know and I soon backout this change.
This commit is contained in:
parent
cda4644c28
commit
ae8d522734
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56801
@ -53,6 +53,7 @@
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/protosw.h>
|
#include <sys/protosw.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
@ -96,6 +97,11 @@ tcp_trace(act, ostate, tp, ipgen, th, req)
|
|||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
isipv6 = (ipgen != NULL && ((struct ip *)ipgen)->ip_v == 6) ? 1 : 0;
|
isipv6 = (ipgen != NULL && ((struct ip *)ipgen)->ip_v == 6) ? 1 : 0;
|
||||||
#endif /* INET6 */
|
#endif /* INET6 */
|
||||||
|
td->td_family =
|
||||||
|
#ifdef INET6
|
||||||
|
(isipv6 != 0) ? AF_INET6 :
|
||||||
|
#endif
|
||||||
|
AF_INET;
|
||||||
if (tcp_debx == TCP_NDEBUG)
|
if (tcp_debx == TCP_NDEBUG)
|
||||||
tcp_debx = 0;
|
tcp_debx = 0;
|
||||||
td->td_time = iptime();
|
td->td_time = iptime();
|
||||||
@ -106,18 +112,54 @@ tcp_trace(act, ostate, tp, ipgen, th, req)
|
|||||||
td->td_cb = *tp;
|
td->td_cb = *tp;
|
||||||
else
|
else
|
||||||
bzero((caddr_t)&td->td_cb, sizeof (*tp));
|
bzero((caddr_t)&td->td_cb, sizeof (*tp));
|
||||||
if (ipgen)
|
if (ipgen) {
|
||||||
bcopy((caddr_t)ipgen, td->td_ipgen,
|
switch (td->td_family) {
|
||||||
|
case AF_INET:
|
||||||
|
bcopy((caddr_t)ipgen, (caddr_t)&td->td_ti.ti_i,
|
||||||
|
sizeof(td->td_ti.ti_i));
|
||||||
|
bzero((caddr_t)td->td_ip6buf, sizeof(td->td_ip6buf));
|
||||||
|
break;
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
isipv6 ? sizeof(struct ip6_hdr) :
|
case AF_INET6:
|
||||||
|
bcopy((caddr_t)ipgen, (caddr_t)td->td_ip6buf,
|
||||||
|
sizeof(td->td_ip6buf));
|
||||||
|
bzero((caddr_t)&td->td_ti.ti_i,
|
||||||
|
sizeof(td->td_ti.ti_i));
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
sizeof(struct ip));
|
default:
|
||||||
else
|
bzero((caddr_t)td->td_ip6buf, sizeof(td->td_ip6buf));
|
||||||
bzero((caddr_t)td->td_ipgen, sizeof (td->td_ipgen));
|
bzero((caddr_t)&td->td_ti.ti_i,
|
||||||
if (th)
|
sizeof(td->td_ti.ti_i));
|
||||||
td->td_th = *th;
|
break;
|
||||||
else
|
}
|
||||||
bzero((caddr_t)&td->td_th, sizeof (td->td_th));
|
} else {
|
||||||
|
bzero((caddr_t)&td->td_ti.ti_i, sizeof(td->td_ti.ti_i));
|
||||||
|
bzero((caddr_t)td->td_ip6buf, sizeof(td->td_ip6buf));
|
||||||
|
}
|
||||||
|
if (th) {
|
||||||
|
switch (td->td_family) {
|
||||||
|
case AF_INET:
|
||||||
|
td->td_ti.ti_t = *th;
|
||||||
|
bzero((caddr_t)&td->td_ti6.th, sizeof(td->td_ti6.th));
|
||||||
|
break;
|
||||||
|
#ifdef INET6
|
||||||
|
case AF_INET6:
|
||||||
|
td->td_ti6.th = *th;
|
||||||
|
bzero((caddr_t)&td->td_ti.ti_t,
|
||||||
|
sizeof(td->td_ti.ti_t));
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
bzero((caddr_t)&td->td_ti.ti_t,
|
||||||
|
sizeof(td->td_ti.ti_t));
|
||||||
|
bzero((caddr_t)&td->td_ti6.th, sizeof(td->td_ti6.th));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bzero((caddr_t)&td->td_ti.ti_t, sizeof(td->td_ti.ti_t));
|
||||||
|
bzero((caddr_t)&td->td_ti6.th, sizeof(td->td_ti6.th));
|
||||||
|
}
|
||||||
td->td_req = req;
|
td->td_req = req;
|
||||||
#ifdef TCPDEBUG
|
#ifdef TCPDEBUG
|
||||||
if (tcpconsdebug == 0)
|
if (tcpconsdebug == 0)
|
||||||
|
@ -42,8 +42,21 @@ struct tcp_debug {
|
|||||||
short td_act;
|
short td_act;
|
||||||
short td_ostate;
|
short td_ostate;
|
||||||
caddr_t td_tcb;
|
caddr_t td_tcb;
|
||||||
u_char td_ipgen[40]; /* the size must be of max ip header, now IPv6 */
|
int td_family;
|
||||||
struct tcphdr td_th;
|
/*
|
||||||
|
* Co-existense of td_ti and td_ti6 below is ugly, but it is necessary
|
||||||
|
* to achieve backword compatibility to some extent.
|
||||||
|
*/
|
||||||
|
struct tcpiphdr td_ti;
|
||||||
|
struct {
|
||||||
|
#if !defined(_KERNEL) && defined(INET6)
|
||||||
|
struct ip6_hdr ip6;
|
||||||
|
#else
|
||||||
|
u_char ip6buf[40]; /* sizeof(struct ip6_hdr) */
|
||||||
|
#endif
|
||||||
|
struct tcphdr th;
|
||||||
|
} td_ti6;
|
||||||
|
#define td_ip6buf td_ti6.ip6buf
|
||||||
short td_req;
|
short td_req;
|
||||||
struct tcpcb td_cb;
|
struct tcpcb td_cb;
|
||||||
};
|
};
|
||||||
|
@ -100,7 +100,7 @@ void dotrace __P((caddr_t));
|
|||||||
void klseek __P((int, off_t, int));
|
void klseek __P((int, off_t, int));
|
||||||
int numeric __P((caddr_t *, caddr_t *));
|
int numeric __P((caddr_t *, caddr_t *));
|
||||||
void tcp_trace __P((short, short, struct tcpcb *, struct tcpcb *,
|
void tcp_trace __P((short, short, struct tcpcb *, struct tcpcb *,
|
||||||
void *, struct tcphdr *, int));
|
int, void *, struct tcphdr *, int));
|
||||||
static void usage __P((void));
|
static void usage __P((void));
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -227,7 +227,7 @@ dotrace(tcpcb)
|
|||||||
{
|
{
|
||||||
register struct tcp_debug *td;
|
register struct tcp_debug *td;
|
||||||
register int i;
|
register int i;
|
||||||
int prev_debx = tcp_debx;
|
int prev_debx = tcp_debx, family;
|
||||||
|
|
||||||
again: if (--tcp_debx < 0)
|
again: if (--tcp_debx < 0)
|
||||||
tcp_debx = TCP_NDEBUG - 1;
|
tcp_debx = TCP_NDEBUG - 1;
|
||||||
@ -236,8 +236,27 @@ again: if (--tcp_debx < 0)
|
|||||||
if (tcpcb && td->td_tcb != tcpcb)
|
if (tcpcb && td->td_tcb != tcpcb)
|
||||||
continue;
|
continue;
|
||||||
ntime = ntohl(td->td_time);
|
ntime = ntohl(td->td_time);
|
||||||
tcp_trace(td->td_act, td->td_ostate, td->td_tcb, &td->td_cb,
|
#ifdef INET6
|
||||||
td->td_ipgen, &td->td_th, td->td_req);
|
family = td->td_family;
|
||||||
|
#else
|
||||||
|
family = AF_INET;
|
||||||
|
#endif
|
||||||
|
switch(family) {
|
||||||
|
case AF_INET:
|
||||||
|
tcp_trace(td->td_act, td->td_ostate,
|
||||||
|
(struct tcpcb *)td->td_tcb,
|
||||||
|
&td->td_cb, td->td_family, &td->td_ti.ti_i,
|
||||||
|
&td->td_ti.ti_t, td->td_req);
|
||||||
|
break;
|
||||||
|
#ifdef INET6
|
||||||
|
case AF_INET6:
|
||||||
|
tcp_trace(td->td_act, td->td_ostate,
|
||||||
|
(struct tcpcb *)td->td_tcb,
|
||||||
|
&td->td_cb, td->td_family, &td->td_ti6.ip6,
|
||||||
|
&td->td_ti6.th, td->td_req);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (i == tcp_debx)
|
if (i == tcp_debx)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -246,8 +265,27 @@ again: if (--tcp_debx < 0)
|
|||||||
if (tcpcb && td->td_tcb != tcpcb)
|
if (tcpcb && td->td_tcb != tcpcb)
|
||||||
continue;
|
continue;
|
||||||
ntime = ntohl(td->td_time);
|
ntime = ntohl(td->td_time);
|
||||||
tcp_trace(td->td_act, td->td_ostate, td->td_tcb, &td->td_cb,
|
#ifdef INET6
|
||||||
td->td_ipgen, &td->td_th, td->td_req);
|
family = td->td_family;
|
||||||
|
#else
|
||||||
|
family = AF_INET;
|
||||||
|
#endif
|
||||||
|
switch(family) {
|
||||||
|
case AF_INET:
|
||||||
|
tcp_trace(td->td_act, td->td_ostate,
|
||||||
|
(struct tcpcb *)td->td_tcb,
|
||||||
|
&td->td_cb, td->td_family, &td->td_ti.ti_i,
|
||||||
|
&td->td_ti.ti_t, td->td_req);
|
||||||
|
break;
|
||||||
|
#ifdef INET6
|
||||||
|
case AF_INET6:
|
||||||
|
tcp_trace(td->td_act, td->td_ostate,
|
||||||
|
(struct tcpcb *)td->td_tcb,
|
||||||
|
&td->td_cb, td->td_family, &td->td_ti6.ip6,
|
||||||
|
&td->td_ti6.th, td->td_req);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
done: if (follow) {
|
done: if (follow) {
|
||||||
prev_debx = tcp_debx + 1;
|
prev_debx = tcp_debx + 1;
|
||||||
@ -273,9 +311,10 @@ done: if (follow) {
|
|||||||
*/
|
*/
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
void
|
void
|
||||||
tcp_trace(act, ostate, atp, tp, ip, th, req)
|
tcp_trace(act, ostate, atp, tp, family, ip, th, req)
|
||||||
short act, ostate;
|
short act, ostate;
|
||||||
struct tcpcb *atp, *tp;
|
struct tcpcb *atp, *tp;
|
||||||
|
int family;
|
||||||
void *ip;
|
void *ip;
|
||||||
struct tcphdr *th;
|
struct tcphdr *th;
|
||||||
int req;
|
int req;
|
||||||
@ -290,12 +329,13 @@ tcp_trace(act, ostate, atp, tp, ip, th, req)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
switch (((struct ip *)ip)->ip_v) {
|
switch (family) {
|
||||||
case 4:
|
case AF_INET:
|
||||||
nopkt = 0;
|
nopkt = 0;
|
||||||
|
isipv6 = 0;
|
||||||
ip4 = (struct ip *)ip;
|
ip4 = (struct ip *)ip;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case AF_INET6:
|
||||||
nopkt = 0;
|
nopkt = 0;
|
||||||
isipv6 = 1;
|
isipv6 = 1;
|
||||||
ip6 = (struct ip6_hdr *)ip;
|
ip6 = (struct ip6_hdr *)ip;
|
||||||
|
Loading…
Reference in New Issue
Block a user