Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet Dedup: introduce tcp_urp_drop() and use it.



details:   https://anonhg.NetBSD.org/src/rev/ebfca330c201
branches:  trunk
changeset: 321615:ebfca330c201
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Mar 28 14:16:59 2018 +0000

description:
Dedup: introduce tcp_urp_drop() and use it.

diffstat:

 sys/netinet/tcp_input.c |  48 +++++++++++++++++++-----------------------------
 1 files changed, 19 insertions(+), 29 deletions(-)

diffs (97 lines):

diff -r 2feb6074f773 -r ebfca330c201 sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Wed Mar 28 13:50:14 2018 +0000
+++ b/sys/netinet/tcp_input.c   Wed Mar 28 14:16:59 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.389 2018/03/28 13:50:14 maxv Exp $     */
+/*     $NetBSD: tcp_input.c,v 1.390 2018/03/28 14:16:59 maxv Exp $     */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.389 2018/03/28 13:50:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.390 2018/03/28 14:16:59 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -337,6 +337,17 @@
        HTONS(th->th_urp);
 }
 
+static void
+tcp_urp_drop(struct tcphdr *th, int todrop, int *tiflags)
+{
+       if (th->th_urp > 1) {
+               th->th_urp -= todrop;
+       } else {
+               *tiflags &= ~TH_URG;
+               th->th_urp = 0;
+       }
+}
+
 #ifdef TCP_CSUM_COUNTERS
 #include <sys/device.h>
 
@@ -1008,14 +1019,9 @@
        if (todrop > 0) {
                if (tiflags & TH_SYN) {
                        tiflags &= ~TH_SYN;
-                       ++th->th_seq;
-                       if (th->th_urp > 1)
-                               --th->th_urp;
-                       else {
-                               tiflags &= ~TH_URG;
-                               th->th_urp = 0;
-                       }
-                       --todrop;
+                       th->th_seq++;
+                       tcp_urp_drop(th, 1, &tiflags);
+                       todrop--;
                }
                if (todrop > tlen ||
                    (todrop == tlen && (tiflags & TH_FIN) == 0)) {
@@ -1057,13 +1063,7 @@
 
                th->th_seq += todrop;
                tlen -= todrop;
-
-               if (th->th_urp > todrop)
-                       th->th_urp -= todrop;
-               else {
-                       tiflags &= ~TH_URG;
-                       th->th_urp = 0;
-               }
+               tcp_urp_drop(th, todrop, &tiflags);
        }
 
        /*
@@ -2264,12 +2264,7 @@
                if (tiflags & TH_SYN) {
                        tiflags &= ~TH_SYN;
                        th->th_seq++;
-                       if (th->th_urp > 1)
-                               th->th_urp--;
-                       else {
-                               tiflags &= ~TH_URG;
-                               th->th_urp = 0;
-                       }
+                       tcp_urp_drop(th, 1, &tiflags);
                        todrop--;
                }
                if (todrop > tlen ||
@@ -2310,12 +2305,7 @@
                hdroptlen += todrop;    /* drop from head afterwards */
                th->th_seq += todrop;
                tlen -= todrop;
-               if (th->th_urp > todrop)
-                       th->th_urp -= todrop;
-               else {
-                       tiflags &= ~TH_URG;
-                       th->th_urp = 0;
-               }
+               tcp_urp_drop(th, todrop, &tiflags);
        }
 
        /*



Home | Main Index | Thread Index | Old Index