diff options
author | shin <shin@FreeBSD.org> | 2000-01-29 11:49:07 +0000 |
---|---|---|
committer | shin <shin@FreeBSD.org> | 2000-01-29 11:49:07 +0000 |
commit | 6ef0117870937300d348b9e1656da31c785d4811 (patch) | |
tree | e27a75220495f893354158262e283ad96eab1f48 /sys/netinet | |
parent | a904c172cd4507038d41a350161a95751929c67b (diff) | |
download | FreeBSD-src-6ef0117870937300d348b9e1656da31c785d4811.zip FreeBSD-src-6ef0117870937300d348b9e1656da31c785d4811.tar.gz |
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.
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/tcp_debug.c | 62 | ||||
-rw-r--r-- | sys/netinet/tcp_debug.h | 17 |
2 files changed, 67 insertions, 12 deletions
diff --git a/sys/netinet/tcp_debug.c b/sys/netinet/tcp_debug.c index 9cf0334..d84c37a 100644 --- a/sys/netinet/tcp_debug.c +++ b/sys/netinet/tcp_debug.c @@ -53,6 +53,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/protosw.h> +#include <sys/socket.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -96,6 +97,11 @@ tcp_trace(act, ostate, tp, ipgen, th, req) #ifdef INET6 isipv6 = (ipgen != NULL && ((struct ip *)ipgen)->ip_v == 6) ? 1 : 0; #endif /* INET6 */ + td->td_family = +#ifdef INET6 + (isipv6 != 0) ? AF_INET6 : +#endif + AF_INET; if (tcp_debx == TCP_NDEBUG) tcp_debx = 0; td->td_time = iptime(); @@ -106,18 +112,54 @@ tcp_trace(act, ostate, tp, ipgen, th, req) td->td_cb = *tp; else bzero((caddr_t)&td->td_cb, sizeof (*tp)); - if (ipgen) - bcopy((caddr_t)ipgen, td->td_ipgen, + if (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 - 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 - sizeof(struct ip)); - else - bzero((caddr_t)td->td_ipgen, sizeof (td->td_ipgen)); - if (th) - td->td_th = *th; - else - bzero((caddr_t)&td->td_th, sizeof (td->td_th)); + default: + bzero((caddr_t)td->td_ip6buf, sizeof(td->td_ip6buf)); + bzero((caddr_t)&td->td_ti.ti_i, + sizeof(td->td_ti.ti_i)); + break; + } + } 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; #ifdef TCPDEBUG if (tcpconsdebug == 0) diff --git a/sys/netinet/tcp_debug.h b/sys/netinet/tcp_debug.h index 9827539..773d3e4 100644 --- a/sys/netinet/tcp_debug.h +++ b/sys/netinet/tcp_debug.h @@ -42,8 +42,21 @@ struct tcp_debug { short td_act; short td_ostate; caddr_t td_tcb; - u_char td_ipgen[40]; /* the size must be of max ip header, now IPv6 */ - struct tcphdr td_th; + int td_family; + /* + * 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; struct tcpcb td_cb; }; |