Hi,

In the old times TCP timers were slow or fast pru requests.  TCP
debug sockets have still code for that.  Replace that with a timer
implementation.

ok?

bluhm

Index: sys/netinet/tcp_debug.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_debug.c,v
retrieving revision 1.25
diff -u -p -r1.25 tcp_debug.c
--- sys/netinet/tcp_debug.c     23 Jan 2018 20:41:42 -0000      1.25
+++ sys/netinet/tcp_debug.c     8 May 2018 15:22:22 -0000
@@ -194,9 +194,11 @@ tcp_trace(short act, short ostate, struc
                break;
 
        case TA_USER:
-               printf("%s", prurequests[req&0xff]);
-               if ((req & 0xff) == PRU_SLOWTIMO)
-                       printf("<%s>", tcptimers[req>>8]);
+               printf("%s", prurequests[req]);
+               break;
+
+       case TA_TIMER:
+               printf("%s", tcptimers[req]);
                break;
        }
        if (tp)
Index: sys/netinet/tcp_debug.h
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_debug.h,v
retrieving revision 1.10
diff -u -p -r1.10 tcp_debug.h
--- sys/netinet/tcp_debug.h     23 Jan 2018 20:41:42 -0000      1.10
+++ sys/netinet/tcp_debug.h     8 May 2018 15:22:22 -0000
@@ -93,10 +93,11 @@ struct      tcp_debug {
 #define        TA_USER         2
 #define        TA_RESPOND      3
 #define        TA_DROP         4
+#define        TA_TIMER        5
 
 #ifdef TANAMES
 const char *tanames[] =
-    { "input", "output", "user", "respond", "drop" };
+    { "input", "output", "user", "respond", "drop", "timer" };
 #endif /* TANAMES */
 
 #define        TCP_NDEBUG 100
Index: sys/netinet/tcp_timer.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/tcp_timer.c,v
retrieving revision 1.65
diff -u -p -r1.65 tcp_timer.c
--- sys/netinet/tcp_timer.c     8 May 2018 15:10:33 -0000       1.65
+++ sys/netinet/tcp_timer.c     8 May 2018 15:30:51 -0000
@@ -51,6 +51,7 @@
 #include <netinet/tcp_fsm.h>
 #include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
+#include <netinet/tcp_debug.h>
 #include <netinet/ip_icmp.h>
 #include <netinet/tcp_seq.h>
 
@@ -109,6 +110,7 @@ void
 tcp_timer_delack(void *arg)
 {
        struct tcpcb *tp = arg;
+       short ostate;
 
        /*
         * If tcp_output() wasn't able to transmit the ACK
@@ -122,8 +124,11 @@ tcp_timer_delack(void *arg)
                goto out;
        CLR((tp)->t_flags, TF_TMR_DELACK);
 
+       ostate = tp->t_state;
        tp->t_flags |= TF_ACKNOW;
        (void) tcp_output(tp);
+       if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
+               tcp_trace(TA_TIMER, ostate, tp, (caddr_t)0, TCPT_DELACK, 0);
  out:
        NET_UNLOCK();
 }
@@ -189,6 +194,7 @@ tcp_timer_rexmt(void *arg)
 {
        struct tcpcb *tp = arg;
        uint32_t rto;
+       short ostate;
 
        NET_LOCK();
        /* Ignore canceled timeouts or timeouts that have been rescheduled. */
@@ -233,6 +239,7 @@ tcp_timer_rexmt(void *arg)
                    tp->t_softerror : ETIMEDOUT);
                goto out;
        }
+       ostate = tp->t_state;
        tcpstat_inc(tcps_rexmttimeo);
        rto = TCP_REXMTVAL(tp);
        if (rto < tp->t_rttmin)
@@ -367,7 +374,8 @@ tcp_timer_rexmt(void *arg)
 #endif
        }
        (void) tcp_output(tp);
-
+       if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
+               tcp_trace(TA_TIMER, ostate, tp, (caddr_t)0, TCPT_REXMT, 0);
  out:
        NET_UNLOCK();
 }
@@ -377,6 +385,7 @@ tcp_timer_persist(void *arg)
 {
        struct tcpcb *tp = arg;
        uint32_t rto;
+       short ostate;
 
        NET_LOCK();
        /* Ignore canceled timeouts or timeouts that have been rescheduled. */
@@ -387,6 +396,8 @@ tcp_timer_persist(void *arg)
 
        if (TCP_TIMER_ISARMED(tp, TCPT_REXMT))
                goto out;
+
+       ostate = tp->t_state;
        tcpstat_inc(tcps_persisttimeo);
        /*
         * Hack: if the peer is dead/unreachable, we do not
@@ -409,6 +420,8 @@ tcp_timer_persist(void *arg)
        tp->t_force = 1;
        (void) tcp_output(tp);
        tp->t_force = 0;
+       if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
+               tcp_trace(TA_TIMER, ostate, tp, (caddr_t)0, TCPT_PERSIST, 0);
  out:
        NET_UNLOCK();
 }
@@ -417,6 +430,7 @@ void
 tcp_timer_keep(void *arg)
 {
        struct tcpcb *tp = arg;
+       short ostate;
 
        NET_LOCK();
        /* Ignore canceled timeouts or timeouts that have been rescheduled. */
@@ -425,6 +439,7 @@ tcp_timer_keep(void *arg)
                goto out;
        CLR((tp)->t_flags, TF_TMR_KEEP);
 
+       ostate = tp->t_state;
        tcpstat_inc(tcps_keeptimeo);
        if (TCPS_HAVEESTABLISHED(tp->t_state) == 0)
                goto dropit;
@@ -452,6 +467,8 @@ tcp_timer_keep(void *arg)
                TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepintvl);
        } else
                TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle);
+       if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)
+               tcp_trace(TA_TIMER, ostate, tp, (caddr_t)0, TCPT_KEEP, 0);
  out:
        NET_UNLOCK();
        return;
@@ -466,6 +483,7 @@ void
 tcp_timer_2msl(void *arg)
 {
        struct tcpcb *tp = arg;
+       short ostate;
 
        NET_LOCK();
        /* Ignore canceled timeouts or timeouts that have been rescheduled. */
@@ -474,6 +492,7 @@ tcp_timer_2msl(void *arg)
                goto out;
        CLR((tp)->t_flags, TF_TMR_2MSL);
 
+       ostate = tp->t_state;
        tcp_timer_freesack(tp);
 
        if (tp->t_state != TCPS_TIME_WAIT &&
@@ -481,7 +500,8 @@ tcp_timer_2msl(void *arg)
                TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_keepintvl);
        else
                tp = tcp_close(tp);
-
+       if (tp && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG))
+               tcp_trace(TA_TIMER, ostate, tp, (caddr_t)0, TCPT_2MSL, 0);
  out:
        NET_UNLOCK();
 }
Index: usr.sbin/trpt/trpt.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/usr.sbin/trpt/trpt.c,v
retrieving revision 1.36
diff -u -p -r1.36 trpt.c
--- usr.sbin/trpt/trpt.c        26 Apr 2018 12:42:51 -0000      1.36
+++ usr.sbin/trpt/trpt.c        8 May 2018 17:28:58 -0000
@@ -308,7 +308,7 @@ tcp_trace(short act, short ostate, struc
     struct tcpiphdr *ti, struct tcpipv6hdr *ti6, int req)
 {
        tcp_seq seq, ack;
-       int flags, len, win, timer;
+       int flags, len, win;
        struct tcphdr *th;
        char hbuf[INET6_ADDRSTRLEN];
 
@@ -376,11 +376,10 @@ tcp_trace(short act, short ostate, struc
                }
                break;
        case TA_USER:
-               timer = req >> 8;
-               req &= 0xff;
                printf("%s", prurequests[req]);
-               if (req == PRU_SLOWTIMO || req == PRU_FASTTIMO)
-                       printf("<%s>", tcptimers[timer]);
+               break;
+       case TA_TIMER:
+               printf("%s", tcptimers[req]);
                break;
        }
        printf(" -> %s", tcpstates[tp->t_state]);

Reply via email to