Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet Use a callout for the delayed ACK timer, and del...



details:   https://anonhg.NetBSD.org/src/rev/8666038a3a65
branches:  trunk
changeset: 514745:8666038a3a65
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Sep 10 04:24:24 2001 +0000

description:
Use a callout for the delayed ACK timer, and delete tcp_fasttimo().
Expose the delayed ACK timer as net.inet.tcp.delack_ticks.

diffstat:

 sys/netinet/in_proto.c   |   4 ++--
 sys/netinet/tcp_output.c |  18 +++++++++++-------
 sys/netinet/tcp_subr.c   |   8 ++++++--
 sys/netinet/tcp_timer.c  |  33 ++++++++++++++++++---------------
 sys/netinet/tcp_timer.h  |   4 +++-
 sys/netinet/tcp_var.h    |  48 ++++++++++++++++++++++++++++--------------------
 6 files changed, 68 insertions(+), 47 deletions(-)

diffs (267 lines):

diff -r d9764c8c8736 -r 8666038a3a65 sys/netinet/in_proto.c
--- a/sys/netinet/in_proto.c    Mon Sep 10 03:22:24 2001 +0000
+++ b/sys/netinet/in_proto.c    Mon Sep 10 04:24:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_proto.c,v 1.48 2001/03/21 19:22:28 thorpej Exp $    */
+/*     $NetBSD: in_proto.c,v 1.49 2001/09/10 04:24:24 thorpej Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -168,7 +168,7 @@
 { SOCK_STREAM, &inetdomain,    IPPROTO_TCP,    PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN|PR_ABRTACPTDIS,
   tcp_input,   0,              tcp_ctlinput,   tcp_ctloutput,
   tcp_usrreq,
-  tcp_init,    tcp_fasttimo,   tcp_slowtimo,   tcp_drain,      tcp_sysctl
+  tcp_init,    0,              tcp_slowtimo,   tcp_drain,      tcp_sysctl
 },
 { SOCK_RAW,    &inetdomain,    IPPROTO_RAW,    PR_ATOMIC|PR_ADDR,
   rip_input,   rip_output,     0,              rip_ctloutput,
diff -r d9764c8c8736 -r 8666038a3a65 sys/netinet/tcp_output.c
--- a/sys/netinet/tcp_output.c  Mon Sep 10 03:22:24 2001 +0000
+++ b/sys/netinet/tcp_output.c  Mon Sep 10 04:24:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_output.c,v 1.70 2001/07/31 02:25:22 thorpej Exp $  */
+/*     $NetBSD: tcp_output.c,v 1.71 2001/09/10 04:24:24 thorpej Exp $  */
 
 /*
 %%% portions-copyright-nrl-95
@@ -1090,13 +1090,17 @@
                        if (tp->t_in6pcb)
                                tcp6_quench(tp->t_in6pcb, 0);
 #endif
-                       return (0);
+                       error = 0;
+               } else if ((error == EHOSTUNREACH || error == ENETDOWN) &&
+                   TCPS_HAVERCVDSYN(tp->t_state)) {
+                       tp->t_softerror = error;
+                       error = 0;
                }
-               if ((error == EHOSTUNREACH || error == ENETDOWN)
-                   && TCPS_HAVERCVDSYN(tp->t_state)) {
-                       tp->t_softerror = error;
-                       return (0);
-               }
+
+               /* Restart the delayed ACK timer, if necessary. */
+               if (tp->t_flags & TF_DELACK)
+                       TCP_RESTART_DELACK(tp);
+
                return (error);
        }
        tcpstat.tcps_sndtotal++;
diff -r d9764c8c8736 -r 8666038a3a65 sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c    Mon Sep 10 03:22:24 2001 +0000
+++ b/sys/netinet/tcp_subr.c    Mon Sep 10 04:24:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_subr.c,v 1.114 2001/07/23 15:20:41 itojun Exp $    */
+/*     $NetBSD: tcp_subr.c,v 1.115 2001/09/10 04:24:24 thorpej Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -239,7 +239,9 @@
 #ifdef INET6
        tcb6.in6p_next = tcb6.in6p_prev = &tcb6;
 #endif
-       LIST_INIT(&tcp_delacks);
+
+       if (tcp_delack_ticks == 0)
+               tcp_delack_ticks = TCP_DELACK_TICKS;
 
        hlen = sizeof(struct ip) + sizeof(struct tcphdr);
 #ifdef INET6
@@ -806,6 +808,8 @@
        tp->t_segsz = tcp_mssdflt;
        LIST_INIT(&tp->t_sc);
 
+       callout_init(&tp->t_delack_ch);
+
        tp->t_flags = 0;
        if (tcp_do_rfc1323 && tcp_do_win_scale)
                tp->t_flags |= TF_REQ_SCALE;
diff -r d9764c8c8736 -r 8666038a3a65 sys/netinet/tcp_timer.c
--- a/sys/netinet/tcp_timer.c   Mon Sep 10 03:22:24 2001 +0000
+++ b/sys/netinet/tcp_timer.c   Mon Sep 10 04:24:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_timer.c,v 1.48 2000/10/19 20:23:00 itojun Exp $    */
+/*     $NetBSD: tcp_timer.c,v 1.49 2001/09/10 04:24:25 thorpej Exp $   */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -111,6 +111,7 @@
 #include <sys/socketvar.h>
 #include <sys/protosw.h>
 #include <sys/errno.h>
+#include <sys/kernel.h>
 
 #include <net/if.h>
 #include <net/route.h>
@@ -142,28 +143,30 @@
 int    tcp_maxpersistidle = TCPTV_KEEP_IDLE;   /* max idle time in persist */
 int    tcp_maxidle;
 
-struct tcp_delack_head tcp_delacks;
+/*
+ * Time to delay the ACK.  This is initialized in tcp_init(), unless
+ * its patched.
+ */
+int    tcp_delack_ticks = 0;
 
 /*
- * Fast timeout routine for processing delayed acks
+ * Callout to process delayed ACKs for a TCPCB.
  */
 void
-tcp_fasttimo()
+tcp_delack(void *arg)
 {
-       struct tcpcb *tp, *ntp;
+       struct tcpcb *tp = arg;
        int s;
 
+       /*
+        * If tcp_output() wasn't able to transmit the ACK
+        * for whatever reason, it will restart the delayed
+        * ACK callout.
+        */
+
        s = splsoftnet();
-       for (tp = tcp_delacks.lh_first; tp != NULL; tp = ntp) {
-               /*
-                * If tcp_output() can't transmit the ACK for whatever
-                * reason, it will remain on the queue for the next
-                * time the heartbeat ticks.
-                */
-               ntp = tp->t_delack.le_next;
-               tp->t_flags |= TF_ACKNOW;
-               (void) tcp_output(tp);
-       }
+       tp->t_flags |= TF_ACKNOW;
+       (void) tcp_output(tp);
        splx(s);
 }
 
diff -r d9764c8c8736 -r 8666038a3a65 sys/netinet/tcp_timer.h
--- a/sys/netinet/tcp_timer.h   Mon Sep 10 03:22:24 2001 +0000
+++ b/sys/netinet/tcp_timer.h   Mon Sep 10 04:24:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_timer.h,v 1.10 1998/09/10 10:47:00 mouse Exp $     */
+/*     $NetBSD: tcp_timer.h,v 1.11 2001/09/10 04:24:25 thorpej Exp $   */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -108,6 +108,8 @@
 
 #define        TCP_MAXRXTSHIFT 12                      /* maximum retransmits */
 
+#define        TCP_DELACK_TICKS (hz / PR_FASTHZ)       /* time to delay ACK */
+
 #ifdef TCPTIMERS
 char *tcptimers[] =
     { "REXMT", "PERSIST", "KEEP", "2MSL" };
diff -r d9764c8c8736 -r 8666038a3a65 sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h     Mon Sep 10 03:22:24 2001 +0000
+++ b/sys/netinet/tcp_var.h     Mon Sep 10 04:24:24 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_var.h,v 1.82 2001/07/31 00:57:45 thorpej Exp $     */
+/*     $NetBSD: tcp_var.h,v 1.83 2001/09/10 04:24:25 thorpej Exp $     */
 
 /*
 %%% portions-copyright-nrl-98
@@ -125,6 +125,8 @@
  * Kernel variables for tcp.
  */
 
+#include <sys/callout.h>
+
 /*
  * Tcp control block, one per tcp; fields:
  */
@@ -160,7 +162,7 @@
        struct  mbuf *t_template;       /* skeletal packet for transmit */
        struct  inpcb *t_inpcb;         /* back pointer to internet pcb */
        struct  in6pcb *t_in6pcb;       /* back pointer to internet pcb */
-       LIST_ENTRY(tcpcb) t_delack;     /* delayed ACK queue */
+       struct  callout t_delack_ch;    /* delayed ACK callout */
 /*
  * The following fields are used as in the protocol specification.
  * See RFC783, Dec. 1981, page 21.
@@ -298,25 +300,29 @@
 /*
  * Queue for delayed ACK processing.
  */
-LIST_HEAD(tcp_delack_head, tcpcb);
 #ifdef _KERNEL
-extern struct tcp_delack_head tcp_delacks;
+extern int tcp_delack_ticks;
+void   tcp_delack(void *);
+
+#define TCP_RESTART_DELACK(tp)                                         \
+       callout_reset(&(tp)->t_delack_ch, tcp_delack_ticks,             \
+           tcp_delack, tp)
 
-#define        TCP_SET_DELACK(tp) \
-do { \
-       if (((tp)->t_flags & TF_DELACK) == 0) { \
-               (tp)->t_flags |= TF_DELACK; \
-               LIST_INSERT_HEAD(&tcp_delacks, (tp), t_delack); \
-       } \
-} while (0)
+#define        TCP_SET_DELACK(tp)                                              \
+do {                                                                   \
+       if (((tp)->t_flags & TF_DELACK) == 0) {                         \
+               (tp)->t_flags |= TF_DELACK;                             \
+               TCP_RESTART_DELACK(tp);                                 \
+       }                                                               \
+} while (/*CONSTCOND*/0)
 
-#define        TCP_CLEAR_DELACK(tp) \
-do { \
-       if ((tp)->t_flags & TF_DELACK) { \
-               (tp)->t_flags &= ~TF_DELACK; \
-               LIST_REMOVE((tp), t_delack); \
-       } \
-} while (0)
+#define        TCP_CLEAR_DELACK(tp)                                            \
+do {                                                                   \
+       if ((tp)->t_flags & TF_DELACK) {                                \
+               (tp)->t_flags &= ~TF_DELACK;                            \
+               callout_stop(&(tp)->t_delack_ch);                       \
+       }                                                               \
+} while (/*CONSTCOND*/0)
 #endif /* _KERNEL */
 
 /*
@@ -551,7 +557,8 @@
 #define        TCPCTL_RSTRATELIMIT     23      /* RST rate limit */
 #endif
 #define        TCPCTL_RSTPPSLIMIT      24      /* RST pps limit */
-#define        TCPCTL_MAXID            25
+#define        TCPCTL_DELACK_TICKS     25      /* # ticks to delay ACK */
+#define        TCPCTL_MAXID            26
 
 #define        TCPCTL_NAMES { \
        { 0, 0 }, \
@@ -579,6 +586,7 @@
        { "log_refused",CTLTYPE_INT }, \
        { 0, 0 }, \
        { "rstppslimit", CTLTYPE_INT }, \
+       { "delack_ticks", CTLTYPE_INT }, \
 }
 
 #ifdef _KERNEL
@@ -637,6 +645,7 @@
        { 1, 0, &tcp_log_refused },             \
        { 0 },                                  \
        { 1, 0, &tcp_rst_ppslim },              \
+       { 1, 0, &tcp_delack_ticks },            \
 }
 
 int     tcp_attach __P((struct socket *));
@@ -656,7 +665,6 @@
            u_char *, int, struct tcphdr *, struct tcp_opt_info *));
 void    tcp_drain __P((void));
 void    tcp_established __P((struct tcpcb *));
-void    tcp_fasttimo __P((void));
 void    tcp_init __P((void));
 #ifdef INET6
 int     tcp6_input __P((struct mbuf **, int *, int));



Home | Main Index | Thread Index | Old Index