Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet - use full sized segments unless we actually hav...



details:   https://anonhg.NetBSD.org/src/rev/bac2b1a1caa3
branches:  trunk
changeset: 574874:bac2b1a1caa3
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Mar 16 00:38:27 2005 +0000

description:
- use full sized segments unless we actually have SACKs to send.
- avoid TSO duplicate D-SACK.
- send SACKs regardless of TF_ACKNOW.
- don't clear rcv_sack_num when transmitting.

discussed on tech-net@.

diffstat:

 sys/netinet/tcp_output.c |  29 ++++++++++++++++++++++-------
 sys/netinet/tcp_sack.c   |  16 +++++++++++++---
 sys/netinet/tcp_subr.c   |   7 ++-----
 sys/netinet/tcp_var.h    |   3 ++-
 4 files changed, 39 insertions(+), 16 deletions(-)

diffs (168 lines):

diff -r b97d6bf474c8 -r bac2b1a1caa3 sys/netinet/tcp_output.c
--- a/sys/netinet/tcp_output.c  Tue Mar 15 23:46:09 2005 +0000
+++ b/sys/netinet/tcp_output.c  Wed Mar 16 00:38:27 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_output.c,v 1.126 2005/03/12 07:53:08 yamt Exp $    */
+/*     $NetBSD: tcp_output.c,v 1.127 2005/03/16 00:38:27 yamt Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -140,7 +140,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.126 2005/03/12 07:53:08 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.127 2005/03/16 00:38:27 yamt Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -550,11 +550,13 @@
        struct tcphdr *th;
        u_char opt[MAX_TCPOPTLEN];
        unsigned optlen, hdrlen;
+       unsigned int sack_optlen;
        int idle, sendalot, txsegsize, rxsegsize;
+       int txsegsize_nosack;
        int maxburst = TCP_MAXBURST;
        int af;         /* address family on the wire */
        int iphdrlen;
-       int use_tso;
+       int has_tso, use_tso;
        int sack_rxmit;
        int sack_bytes_rxmt;
        struct sackhole *p;
@@ -612,7 +614,7 @@
         * - If there is not an IPsec policy that prevents it
         * - If the interface can do it
         */
-       use_tso = tp->t_inpcb != NULL &&
+       has_tso = tp->t_inpcb != NULL &&
 #if defined(IPSEC) || defined(FAST_IPSEC)
                  IPSEC_PCB_SKIP_IPSEC(tp->t_inpcb->inp_sp,
                                       IPSEC_DIR_OUTBOUND) &&
@@ -667,7 +669,17 @@
                }
        }
 
+       txsegsize_nosack = txsegsize;
 again:
+       sack_optlen = tcp_sack_optlen(tp);
+       if (sack_optlen && (tp->rcv_sack_flags & TCPSACK_HAVED) != 0) {
+               /* don't duplicate D-SACK. */
+               use_tso = 0;
+       } else {
+               use_tso = has_tso;
+       }
+       txsegsize = txsegsize_nosack - sack_optlen;
+
        /*
         * Determine length of data that should be transmitted, and
         * flags that should be used.  If there is some data or critical
@@ -1064,8 +1076,7 @@
        /*
         * Tack on the SACK block if it is necessary.
         */
-       if (TCP_SACK_ENABLED(tp) && (tp->t_flags & TF_ACKNOW)
-                       && (tp->rcv_sack_num > 0)) {
+       if (sack_optlen) {
                int sack_len, i;
                u_char *bp = (u_char *)(opt + optlen);
                u_int32_t *lp = (u_int32_t *)(bp + 4);
@@ -1079,7 +1090,11 @@
                        *lp++ = htonl(tp->rcv_sack_block[i].left);
                        *lp++ = htonl(tp->rcv_sack_block[i].right);
                }
-               tp->rcv_sack_num = 0;
+               if ((tp->rcv_sack_flags & TCPSACK_HAVED) != 0) {
+                       tp->rcv_sack_flags &= ~TCPSACK_HAVED;
+                       tcp_update_sack_list(tp);
+               }
+               KASSERT(sack_len + 2 == sack_optlen);
                optlen += sack_len + 2;
        }
 
diff -r b97d6bf474c8 -r bac2b1a1caa3 sys/netinet/tcp_sack.c
--- a/sys/netinet/tcp_sack.c    Tue Mar 15 23:46:09 2005 +0000
+++ b/sys/netinet/tcp_sack.c    Wed Mar 16 00:38:27 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_sack.c,v 1.8 2005/03/08 11:27:14 yamt Exp $ */
+/* $NetBSD: tcp_sack.c,v 1.9 2005/03/16 00:38:27 yamt Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -109,7 +109,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.8 2005/03/08 11:27:14 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_sack.c,v 1.9 2005/03/16 00:38:27 yamt Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -191,7 +191,6 @@
        if (tp->rcv_sack_flags & TCPSACK_HAVED) {
                tp->rcv_sack_block[0].left = tp->rcv_dsack_block.left;
                tp->rcv_sack_block[0].right = tp->rcv_dsack_block.right;
-               tp->rcv_sack_flags &= ~TCPSACK_HAVED;
                i++;
        }
 
@@ -553,3 +552,14 @@
 
        return;
 }
+
+int
+tcp_sack_optlen(struct tcpcb *tp)
+{
+
+       if (!TCP_SACK_ENABLED(tp) || tp->rcv_sack_num == 0) {
+               return 0;
+       }
+
+       return tp->rcv_sack_num * 8 + 2 + 2;
+}
diff -r b97d6bf474c8 -r bac2b1a1caa3 sys/netinet/tcp_subr.c
--- a/sys/netinet/tcp_subr.c    Tue Mar 15 23:46:09 2005 +0000
+++ b/sys/netinet/tcp_subr.c    Wed Mar 16 00:38:27 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_subr.c,v 1.185 2005/03/09 04:24:12 simonb Exp $    */
+/*     $NetBSD: tcp_subr.c,v 1.186 2005/03/16 00:38:27 yamt Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -98,7 +98,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.185 2005/03/09 04:24:12 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.186 2005/03/16 00:38:27 yamt Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -2195,8 +2195,5 @@
                optlen += TCPOLEN_SIGNATURE + 2;
 #endif /* TCP_SIGNATURE */
 
-       if (tp->t_flags & TF_WILL_SACK)
-               optlen += 8 * TCP_SACK_MAX + 4;
-
        return optlen;
 }
diff -r b97d6bf474c8 -r bac2b1a1caa3 sys/netinet/tcp_var.h
--- a/sys/netinet/tcp_var.h     Tue Mar 15 23:46:09 2005 +0000
+++ b/sys/netinet/tcp_var.h     Wed Mar 16 00:38:27 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_var.h,v 1.121 2005/03/09 04:51:56 atatat Exp $     */
+/*     $NetBSD: tcp_var.h,v 1.122 2005/03/16 00:38:27 yamt Exp $       */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -852,6 +852,7 @@
 void    tcp_sack_adjust(struct tcpcb *tp);
 struct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt);
 void    tcp_sack_newack(struct tcpcb *, struct tcphdr *);
+int     tcp_sack_optlen(struct tcpcb *);
 
 
 int     syn_cache_add(struct sockaddr *, struct sockaddr *,



Home | Main Index | Thread Index | Old Index