summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_debug.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-05-07 14:05:23 +0000
committerrwatson <rwatson@FreeBSD.org>2007-05-07 14:05:23 +0000
commitb5347099c71ca28992bc03be90894512fd1094fe (patch)
treecac0760c00a945dc57b609d689651ae985c94237 /sys/netinet/tcp_debug.c
parentd225f06201839b7d80704cdd34336bed810f046d (diff)
downloadFreeBSD-src-b5347099c71ca28992bc03be90894512fd1094fe.zip
FreeBSD-src-b5347099c71ca28992bc03be90894512fd1094fe.tar.gz
Rather than selectively zeroing fields in the tcp_debug structure
throughout tcp_trace(), zero the entire structure up front. Minor style fixes.
Diffstat (limited to 'sys/netinet/tcp_debug.c')
-rw-r--r--sys/netinet/tcp_debug.c57
1 files changed, 15 insertions, 42 deletions
diff --git a/sys/netinet/tcp_debug.c b/sys/netinet/tcp_debug.c
index 636c379..5957993 100644
--- a/sys/netinet/tcp_debug.c
+++ b/sys/netinet/tcp_debug.c
@@ -108,85 +108,58 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen,
mtx_lock(&tcp_debug_mtx);
td = &tcp_debug[tcp_debx++];
-
+ if (tcp_debx == TCP_NDEBUG)
+ tcp_debx = 0;
+ bzero(td, sizeof(*td));
#ifdef INET6
isipv6 = (ipgen != NULL && ((struct ip *)ipgen)->ip_v == 6) ? 1 : 0;
#endif /* INET6 */
td->td_family =
#ifdef INET6
- (isipv6 != 0) ? AF_INET6 :
+ (isipv6 != 0) ? AF_INET6 :
#endif
- AF_INET;
- if (tcp_debx == TCP_NDEBUG)
- tcp_debx = 0;
+ AF_INET;
td->td_time = iptime();
td->td_act = act;
td->td_ostate = ostate;
td->td_tcb = (caddr_t)tp;
- if (tp)
+ if (tp != NULL)
td->td_cb = *tp;
- else
- bzero((caddr_t)&td->td_cb, sizeof (*tp));
- if (ipgen) {
+ if (ipgen != NULL) {
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));
+ bcopy(ipgen, &td->td_ti.ti_i, sizeof(td->td_ti.ti_i));
break;
#ifdef INET6
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));
+ bcopy(ipgen, td->td_ip6buf, sizeof(td->td_ip6buf));
break;
#endif
- 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) {
+ if (th != NULL) {
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;
mtx_unlock(&tcp_debug_mtx);
#ifdef TCPDEBUG
if (tcpconsdebug == 0)
return;
- if (tp)
+ if (tp != NULL)
printf("%p %s:", tp, tcpstates[ostate]);
else
printf("???????? ");
printf("%s ", tanames[act]);
switch (act) {
-
case TA_INPUT:
case TA_OUTPUT:
case TA_DROP:
@@ -196,9 +169,9 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen,
ack = th->th_ack;
len =
#ifdef INET6
- isipv6 ? ((struct ip6_hdr *)ipgen)->ip6_plen :
+ isipv6 ? ((struct ip6_hdr *)ipgen)->ip6_plen :
#endif
- ((struct ip *)ipgen)->ip_len;
+ ((struct ip *)ipgen)->ip_len;
if (act == TA_OUTPUT) {
seq = ntohl(seq);
ack = ntohl(ack);
@@ -231,11 +204,11 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen,
printf("<%s>", tcptimers[req>>8]);
break;
}
- if (tp)
+ if (tp != NULL)
printf(" -> %s", tcpstates[tp->t_state]);
/* print out internal state of tp !?! */
printf("\n");
- if (tp == 0)
+ if (tp == NULL)
return;
printf(
"\trcv_(nxt,wnd,up) (%lx,%lx,%lx) snd_(una,nxt,max) (%lx,%lx,%lx)\n",
OpenPOWER on IntegriCloud