Module Name:    src
Committed By:   maxv
Date:           Mon Feb 12 08:08:28 UTC 2018

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

Log Message:
Remove the 'm' argument from syn_cache_respond(); all it does with it is
freeing it, so free in the caller instead.


To generate a diff of this commit:
cvs rdiff -u -r1.376 -r1.377 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.182 -r1.183 src/sys/netinet/tcp_var.h

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.376 src/sys/netinet/tcp_input.c:1.377
--- src/sys/netinet/tcp_input.c:1.376	Mon Feb 12 08:03:42 2018
+++ src/sys/netinet/tcp_input.c	Mon Feb 12 08:08:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.376 2018/02/12 08:03:42 maxv Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.377 2018/02/12 08:08:28 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.376 2018/02/12 08:03:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.377 2018/02/12 08:08:28 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3749,7 +3749,7 @@ syn_cache_timer(void *arg)
 		goto dropit;
 
 	TCP_STATINC(TCP_STAT_SC_RETRANSMITTED);
-	(void) syn_cache_respond(sc, NULL);
+	(void)syn_cache_respond(sc);
 
 	/* Advance the timer back-off. */
 	sc->sc_rxtshift++;
@@ -3884,7 +3884,8 @@ syn_cache_get(struct sockaddr *src, stru
 	if ((th->th_ack != sc->sc_iss + 1) ||
 	    SEQ_LEQ(th->th_seq, sc->sc_irs) ||
 	    SEQ_GT(th->th_seq, sc->sc_irs + 1 + sc->sc_win)) {
-		(void) syn_cache_respond(sc, m);
+		m_freem(m);
+		(void)syn_cache_respond(sc);
 		splx(s);
 		return ((struct socket *)(-1));
 	}
@@ -4302,7 +4303,8 @@ syn_cache_add(struct sockaddr *src, stru
 			sc->sc_ipopts = ipopts;
 		}
 		sc->sc_timestamp = tb.ts_recent;
-		if (syn_cache_respond(sc, m) == 0) {
+		m_freem(m);
+		if (syn_cache_respond(sc) == 0) {
 			uint64_t *tcps = TCP_STAT_GETREF();
 			tcps[TCP_STAT_SNDACKS]++;
 			tcps[TCP_STAT_SNDTOTAL]++;
@@ -4411,7 +4413,8 @@ syn_cache_add(struct sockaddr *src, stru
 		sc->sc_flags |= SCF_SIGNATURE;
 #endif
 	sc->sc_tp = tp;
-	if (syn_cache_respond(sc, m) == 0) {
+	m_freem(m);
+	if (syn_cache_respond(sc) == 0) {
 		uint64_t *tcps = TCP_STAT_GETREF();
 		tcps[TCP_STAT_SNDACKS]++;
 		tcps[TCP_STAT_SNDTOTAL]++;
@@ -4438,7 +4441,7 @@ syn_cache_add(struct sockaddr *src, stru
  */
 
 int
-syn_cache_respond(struct syn_cache *sc, struct mbuf *m)
+syn_cache_respond(struct syn_cache *sc)
 {
 #ifdef INET6
 	struct rtentry *rt = NULL;
@@ -4453,6 +4456,7 @@ syn_cache_respond(struct syn_cache *sc, 
 #endif
 	struct tcpcb *tp = NULL;
 	struct tcphdr *th;
+	struct mbuf *m;
 	u_int hlen;
 #ifdef TCP_SIGNATURE
 	struct secasvar *sav = NULL;
@@ -4470,8 +4474,6 @@ syn_cache_respond(struct syn_cache *sc, 
 		break;
 #endif
 	default:
-		if (m)
-			m_freem(m);
 		return (EAFNOSUPPORT);
 	}
 
@@ -4481,8 +4483,6 @@ syn_cache_respond(struct syn_cache *sc, 
 	/*
 	 * Create the IP+TCP header from scratch.
 	 */
-	if (m)
-		m_freem(m);
 #ifdef DIAGNOSTIC
 	if (max_linkhdr + tlen > MCLBYTES)
 		return ENOBUFS;

Index: src/sys/netinet/tcp_var.h
diff -u src/sys/netinet/tcp_var.h:1.182 src/sys/netinet/tcp_var.h:1.183
--- src/sys/netinet/tcp_var.h:1.182	Fri Jan 19 07:53:01 2018
+++ src/sys/netinet/tcp_var.h	Mon Feb 12 08:08:28 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_var.h,v 1.182 2018/01/19 07:53:01 ozaki-r Exp $	*/
+/*	$NetBSD: tcp_var.h,v 1.183 2018/02/12 08:08:28 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -968,7 +968,7 @@ struct syn_cache *syn_cache_lookup(const
 		struct syn_cache_head **);
 void	 syn_cache_reset(struct sockaddr *, struct sockaddr *,
 		struct tcphdr *);
-int	 syn_cache_respond(struct syn_cache *, struct mbuf *);
+int	 syn_cache_respond(struct syn_cache *);
 void	 syn_cache_cleanup(struct tcpcb *);
 
 int	 tcp_input_checksum(int, struct mbuf *, const struct tcphdr *, int, int,

Reply via email to