Module Name:    src
Committed By:   maxv
Date:           Thu Mar 22 20:48:38 UTC 2018

Modified Files:
        src/sys/netinet: tcp_input.c

Log Message:
Don't call tcp_input_checksum again, it was already called earlier, no
need to checksum twice.

Then call tcp_fields_to_host a bit earlier, so that we don't need to call
it in each branch.


To generate a diff of this commit:
cvs rdiff -u -r1.383 -r1.384 src/sys/netinet/tcp_input.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.383 src/sys/netinet/tcp_input.c:1.384
--- src/sys/netinet/tcp_input.c:1.383	Thu Mar  1 06:08:43 2018
+++ src/sys/netinet/tcp_input.c	Thu Mar 22 20:48:38 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.383 2018/03/01 06:08:43 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.384 2018/03/22 20:48:38 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.383 2018/03/01 06:08:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.384 2018/03/22 20:48:38 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1505,6 +1505,8 @@ findpcb:
 #endif
 	}
 
+	tcp_fields_to_host(th);
+
 	/*
 	 * If the state is CLOSED (i.e., TCB does not exist) then
 	 * all data in the incoming segment is discarded.
@@ -1529,27 +1531,19 @@ findpcb:
 #endif
 	else if (vestige.valid) {
 		/* We do not support the resurrection of vtw tcpcps. */
-		if (tcp_input_checksum(af, m, th, toff, off, tlen))
-			goto badcsum;
-
-		tcp_fields_to_host(th);
 		tcp_vtw_input(th, &vestige, m, tlen);
 		m = NULL;
 		goto drop;
 	}
 
-	if (tp == NULL) {
-		tcp_fields_to_host(th);
+	if (tp == NULL)
 		goto dropwithreset_ratelim;
-	}
 	if (tp->t_state == TCPS_CLOSED)
 		goto drop;
 
 	KASSERT(so->so_lock == softnet_lock);
 	KASSERT(solocked(so));
 
-	tcp_fields_to_host(th);
-
 	/* Unscale the window into a 32-bit value. */
 	if ((tiflags & TH_SYN) == 0)
 		tiwin = th->th_win << tp->snd_scale;

Reply via email to