CVS commit: [netbsd-9] src/sys/netinet

2019-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 18:22:14 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: if_arp.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #300):

sys/netinet/if_arp.c: revision 1.289

ARP: Don't defend ARP probes.

We should let the nature of ARP takes it's course here when our address
is neither tentative nor duplicated.
This allows the host to work with ARP ping, which was broken in r1.279.


To generate a diff of this commit:
cvs rdiff -u -r1.282.2.4 -r1.282.2.5 src/sys/netinet/if_arp.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/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.282.2.4 src/sys/netinet/if_arp.c:1.282.2.5
--- src/sys/netinet/if_arp.c:1.282.2.4	Mon Sep 30 15:55:40 2019
+++ src/sys/netinet/if_arp.c	Fri Oct 11 18:22:14 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.282.2.4 2019/09/30 15:55:40 martin Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.282.2.5 2019/10/11 18:22:14 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.4 2019/09/30 15:55:40 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.5 2019/10/11 18:22:14 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1157,15 +1157,17 @@ in_arpinput(struct mbuf *m)
 	/*
 	 * DAD check, RFC 5227.
 	 * Collision on sender address is always a duplicate.
-	 * Collision on target address is only a duplicate IF
-	 * the sender address is the null host (ie a DAD probe) AND
-	 * the message was broadcast - if it's unicast then it's
-	 * a valid Unicast Poll from RFC 1122.
+	 * Collision on target address is only a duplicate
+	 * IF the sender address is the null host (ie a DAD probe)
+	 * AND the message was broadcast
+	 * AND our address is either tentative or duplicated
+	 * If it was unicast then it's a valid Unicast Poll from RFC 1122.
 	 */
 	if (do_dad &&
 	(in_hosteq(isaddr, myaddr) ||
 	(in_nullhost(isaddr) && in_hosteq(itaddr, myaddr) &&
-	 m->m_flags & M_BCAST)))
+	 m->m_flags & M_BCAST &&
+	 ia->ia4_flags & (IN_IFF_TENTATIVE | IN_IFF_DUPLICATED
 	{
 		struct sockaddr_dl sdl, *sdlp;
 



CVS commit: [netbsd-9] src/sys/netinet

2019-10-11 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 11 18:22:14 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: if_arp.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #300):

sys/netinet/if_arp.c: revision 1.289

ARP: Don't defend ARP probes.

We should let the nature of ARP takes it's course here when our address
is neither tentative nor duplicated.
This allows the host to work with ARP ping, which was broken in r1.279.


To generate a diff of this commit:
cvs rdiff -u -r1.282.2.4 -r1.282.2.5 src/sys/netinet/if_arp.c

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



CVS commit: [netbsd-9] src/sys/netinet

2019-09-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 10 16:19:00 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: tcp_input.c tcp_subr.c tcp_timer.h
tcp_usrreq.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #193):

sys/netinet/tcp_timer.h: revision 1.30
sys/netinet/tcp_input.c: revision 1.415
sys/netinet/tcp_usrreq.c: revision 1.225
sys/netinet/tcp_subr.c: revision 1.283

Clamp tcp timer quantities to reasonable ranges.


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.414.2.1 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.282 -r1.282.4.1 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.29 -r1.29.8.1 src/sys/netinet/tcp_timer.h
cvs rdiff -u -r1.224 -r1.224.4.1 src/sys/netinet/tcp_usrreq.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.414 src/sys/netinet/tcp_input.c:1.414.2.1
--- src/sys/netinet/tcp_input.c:1.414	Sat Jun  1 15:18:42 2019
+++ src/sys/netinet/tcp_input.c	Tue Sep 10 16:18:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.414 2019/06/01 15:18:42 kamil Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.414.2.1 2019/09/10 16:18:59 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.414 2019/06/01 15:18:42 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.414.2.1 2019/09/10 16:18:59 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -3379,7 +3379,7 @@ tcp_xmit_timer(struct tcpcb *tp, uint32_
 		if (__predict_false(tcp_rttlocal) && tcp_msl_enable
 		&& tp->t_srtt > tcp_msl_remote_threshold
 		&& tp->t_msl  < tcp_msl_remote) {
-			tp->t_msl = tcp_msl_remote;
+			tp->t_msl = MIN(tcp_msl_remote, TCP_MAXMSL);
 		}
 	} else {
 		/*
@@ -3647,7 +3647,7 @@ syn_cache_timer(void *arg)
 	 * than the keep alive timer would allow, expire it.
 	 */
 	sc->sc_rxttot += sc->sc_rxtcur;
-	if (sc->sc_rxttot >= tcp_keepinit)
+	if (sc->sc_rxttot >= MIN(tcp_keepinit, TCP_TIMER_MAXTICKS))
 		goto dropit;
 
 	TCP_STATINC(TCP_STAT_SC_RETRANSMITTED);

Index: src/sys/netinet/tcp_subr.c
diff -u src/sys/netinet/tcp_subr.c:1.282 src/sys/netinet/tcp_subr.c:1.282.4.1
--- src/sys/netinet/tcp_subr.c:1.282	Thu Dec 27 16:59:17 2018
+++ src/sys/netinet/tcp_subr.c	Tue Sep 10 16:19:00 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_subr.c,v 1.282 2018/12/27 16:59:17 maxv Exp $	*/
+/*	$NetBSD: tcp_subr.c,v 1.282.4.1 2019/09/10 16:19:00 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -91,7 +91,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.282 2018/12/27 16:59:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.282.4.1 2019/09/10 16:19:00 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -948,11 +948,12 @@ tcp_tcpcb_template(void)
 	TCPTV_MIN, TCPTV_REXMTMAX);
 
 	/* Keep Alive */
-	tp->t_keepinit = tcp_keepinit;
-	tp->t_keepidle = tcp_keepidle;
-	tp->t_keepintvl = tcp_keepintvl;
-	tp->t_keepcnt = tcp_keepcnt;
-	tp->t_maxidle = tp->t_keepcnt * tp->t_keepintvl;
+	tp->t_keepinit = MIN(tcp_keepinit, TCP_TIMER_MAXTICKS);
+	tp->t_keepidle = MIN(tcp_keepidle, TCP_TIMER_MAXTICKS);
+	tp->t_keepintvl = MIN(tcp_keepintvl, TCP_TIMER_MAXTICKS);
+	tp->t_keepcnt = MAX(1, MIN(tcp_keepcnt, TCP_TIMER_MAXTICKS));
+	tp->t_maxidle = tp->t_keepcnt * MIN(tp->t_keepintvl,
+	TCP_TIMER_MAXTICKS/tp->t_keepcnt);
 
 	/* MSL */
 	tp->t_msl = TCPTV_MSL;
@@ -2012,6 +2013,9 @@ tcp_established(struct tcpcb *tp)
 		break;
 	}
 
+	/* Clamp to a reasonable range.  */
+	tp->t_msl = MIN(tp->t_msl, TCP_MAXMSL);
+
 #ifdef INET6
 	/* The !tp->t_inpcb lets the compiler know it can't be v4 *and* v6 */
 	while (!tp->t_inpcb && tp->t_in6pcb) {
@@ -2041,6 +2045,9 @@ tcp_established(struct tcpcb *tp)
 		tp->t_msl = tcp_msl_remote ? tcp_msl_remote : TCPTV_MSL;
 		break;
 	}
+
+	/* Clamp to a reasonable range.  */
+	tp->t_msl = MIN(tp->t_msl, TCP_MAXMSL);
 #endif
 
 	tp->t_state = TCPS_ESTABLISHED;

Index: src/sys/netinet/tcp_timer.h
diff -u src/sys/netinet/tcp_timer.h:1.29 src/sys/netinet/tcp_timer.h:1.29.8.1
--- src/sys/netinet/tcp_timer.h:1.29	Fri Jan 19 07:53:01 2018
+++ src/sys/netinet/tcp_timer.h	Tue Sep 10 16:18:59 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_timer.h,v 1.29 2018/01/19 07:53:01 ozaki-r Exp $	*/
+/*	$NetBSD: tcp_timer.h,v 1.29.8.1 2019/09/10 16:18:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2005 The NetBSD Foundation, Inc.
@@ -165,6 +165,12 @@ const char *tcptimers[] =
 #define	TCP_TIMER_ISARMED(tp, timer)	\
 	callout_active(&(tp)->t_timer[(timer)])
 
+#define	TCP_TIMER_MAXTICKS		  \
+	(INT_MAX / (hz / PR_SLOWHZ))
+
+#define	TCP_MAXMSL			  \
+	(TCP_TIMER_MAXTICKS / 2)
+
 /*
  * Force a time value to be in a certain range.
  */

Index: src/sys/netinet/tcp_usrreq.c
diff -u 

CVS commit: [netbsd-9] src/sys/netinet

2019-09-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Sep 10 16:19:00 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: tcp_input.c tcp_subr.c tcp_timer.h
tcp_usrreq.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #193):

sys/netinet/tcp_timer.h: revision 1.30
sys/netinet/tcp_input.c: revision 1.415
sys/netinet/tcp_usrreq.c: revision 1.225
sys/netinet/tcp_subr.c: revision 1.283

Clamp tcp timer quantities to reasonable ranges.


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.414.2.1 src/sys/netinet/tcp_input.c
cvs rdiff -u -r1.282 -r1.282.4.1 src/sys/netinet/tcp_subr.c
cvs rdiff -u -r1.29 -r1.29.8.1 src/sys/netinet/tcp_timer.h
cvs rdiff -u -r1.224 -r1.224.4.1 src/sys/netinet/tcp_usrreq.c

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



CVS commit: [netbsd-9] src/sys/netinet

2019-09-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  5 08:34:11 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: if_arp.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #170):

sys/netinet/if_arp.c: revision 1.287

inet: Send RTM_MISS when we fail to resolve an address.

Takes the same approach as when adding a new address - we no longer
announce the new lladdr right away but we announce the result.

This will either be RTM_ADD or RTM_MISS.
RTM_DELETE is only sent if we have a lladdr assigned OR gc'ed.

This tells us when a new lladdr has been added (RTM_ADD),
changed (RTM_CHANGE), deleted (RTM_DELETED) or has failed to been
resolved (RTM_MISS). The latter case can be interpreted as unreachable.


To generate a diff of this commit:
cvs rdiff -u -r1.282.2.2 -r1.282.2.3 src/sys/netinet/if_arp.c

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



CVS commit: [netbsd-9] src/sys/netinet

2019-09-05 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Sep  5 08:34:11 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: if_arp.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #170):

sys/netinet/if_arp.c: revision 1.287

inet: Send RTM_MISS when we fail to resolve an address.

Takes the same approach as when adding a new address - we no longer
announce the new lladdr right away but we announce the result.

This will either be RTM_ADD or RTM_MISS.
RTM_DELETE is only sent if we have a lladdr assigned OR gc'ed.

This tells us when a new lladdr has been added (RTM_ADD),
changed (RTM_CHANGE), deleted (RTM_DELETED) or has failed to been
resolved (RTM_MISS). The latter case can be interpreted as unreachable.


To generate a diff of this commit:
cvs rdiff -u -r1.282.2.2 -r1.282.2.3 src/sys/netinet/if_arp.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/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.282.2.2 src/sys/netinet/if_arp.c:1.282.2.3
--- src/sys/netinet/if_arp.c:1.282.2.2	Sun Sep  1 14:04:37 2019
+++ src/sys/netinet/if_arp.c	Thu Sep  5 08:34:11 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.282.2.2 2019/09/01 14:04:37 martin Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.282.2.3 2019/09/05 08:34:11 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.2 2019/09/01 14:04:37 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.3 2019/09/05 08:34:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -308,6 +308,17 @@ arptimer(void *arg)
 	if (lle->la_flags & LLE_LINKED) {
 		size_t pkts_dropped;
 
+		if (lle->la_flags & LLE_VALID) {
+			struct in_addr *in;
+			struct sockaddr_in sin;
+			const char *lladdr;
+
+			in = >r_l3addr.addr4;
+			sockaddr_in_init(, in, 0);
+			lladdr = (const char *)>ll_addr;
+			rt_clonedmsg(RTM_DELETE, sintosa(), lladdr, ifp);
+		}
+
 		LLE_REMREF(lle);
 		pkts_dropped = llentry_free(lle);
 		ARP_STATADD(ARP_STAT_DFRDROPPED, pkts_dropped);
@@ -738,14 +749,8 @@ notfound:
 			rt_unref(_rt);
 		if (la == NULL)
 			ARP_STATINC(ARP_STAT_ALLOCFAIL);
-		else {
-			struct sockaddr_in sin;
-
+		else
 			arp_init_llentry(ifp, la);
-			sockaddr_in_init(, >r_l3addr.addr4, 0);
-			if (rt != NULL)
-rt_clonedmsg(RTM_ADD, sintosa(), NULL, ifp);
-		}
 	} else if (LLE_TRY_UPGRADE(la) == 0) {
 		create_lookup = "lookup";
 		LLE_RUNLOCK(la);
@@ -845,9 +850,16 @@ notfound:
 
 	if (renew) {
 		const uint8_t *enaddr = CLLADDR(ifp->if_sadl);
+		struct sockaddr_in sin;
+
 		la->la_expire = time_uptime;
 		arp_settimer(la, arpt_down);
 		la->la_asked++;
+
+		sockaddr_in_init(, >r_l3addr.addr4, 0);
+		if (error != EWOULDBLOCK)
+			rt_clonedmsg(RTM_MISS, sintosa(), NULL, ifp);
+
 		LLE_WUNLOCK(la);
 
 		if (rt != NULL) {
@@ -855,11 +867,8 @@ notfound:
 			(rt->rt_ifa->ifa_addr)->sin_addr,
 			(dst)->sin_addr, enaddr);
 		} else {
-			struct sockaddr_in sin;
 			struct rtentry *_rt;
 
-			sockaddr_in_init(, >r_l3addr.addr4, 0);
-
 			/* XXX */
 			_rt = rtalloc1((struct sockaddr *), 0);
 			if (_rt == NULL)
@@ -1000,7 +1009,7 @@ in_arpinput(struct mbuf *m)
 #endif
 	struct sockaddr sa;
 	struct in_addr isaddr, itaddr, myaddr;
-	int op;
+	int op, rt_cmd;
 	void *tha;
 	uint64_t *arps;
 	struct psref psref, psref_ia;
@@ -1210,7 +1219,9 @@ in_arpinput(struct mbuf *m)
 "for %s by %s\n",
 IN_PRINT(ipbuf, ), llastr);
 		}
-	}
+		rt_cmd = RTM_CHANGE;
+	} else
+		rt_cmd = la->la_flags & LLE_VALID ? 0 : RTM_ADD;
 
 	KASSERT(ifp->if_sadl->sdl_alen == ifp->if_addrlen);
 
@@ -1252,6 +1263,13 @@ in_arpinput(struct mbuf *m)
 	la->la_asked = 0;
 	/* rt->rt_flags &= ~RTF_REJECT; */
 
+	if (rt_cmd != 0) {
+		struct sockaddr_in sin;
+
+		sockaddr_in_init(, >r_l3addr.addr4, 0);
+		rt_clonedmsg(rt_cmd, sintosa(), ar_sha(ah), ifp);
+	}
+
 	if (la->la_hold != NULL) {
 		int n = la->la_numheld;
 		struct mbuf *m_hold, *m_hold_next;



CVS commit: [netbsd-9] src/sys/netinet

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 14:04:37 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: if_arp.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #147):

sys/netinet/if_arp.c: revision 1.285
sys/netinet/if_arp.c: revision 1.286

ARP: remove unused sysctl entry log_unknown_network

ARP: change default sysctl entry log_movements to 0
IP address sharing is a thing and shouldn't cause needless diagnostics
by default.


To generate a diff of this commit:
cvs rdiff -u -r1.282.2.1 -r1.282.2.2 src/sys/netinet/if_arp.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/if_arp.c
diff -u src/sys/netinet/if_arp.c:1.282.2.1 src/sys/netinet/if_arp.c:1.282.2.2
--- src/sys/netinet/if_arp.c:1.282.2.1	Mon Aug 26 13:42:36 2019
+++ src/sys/netinet/if_arp.c	Sun Sep  1 14:04:37 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_arp.c,v 1.282.2.1 2019/08/26 13:42:36 martin Exp $	*/
+/*	$NetBSD: if_arp.c,v 1.282.2.2 2019/09/01 14:04:37 martin Exp $	*/
 
 /*
  * Copyright (c) 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.1 2019/08/26 13:42:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.282.2.2 2019/09/01 14:04:37 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -209,10 +209,9 @@ static struct ifnet *myip_ifp = NULL;
 
 static int arp_drainwanted;
 
-static int log_movements = 1;
+static int log_movements = 0;
 static int log_permanent_modify = 1;
 static int log_wrong_iface = 1;
-static int log_unknown_network = 1;
 
 DOMAIN_DEFINE(arpdomain);	/* forward declare and add to link set */
 
@@ -2071,13 +2070,6 @@ sysctl_net_inet_arp_setup(struct sysctll
 
 	sysctl_createv(clog, 0, NULL, NULL,
 			CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
-			CTLTYPE_INT, "log_unknown_network",
-			SYSCTL_DESCR("log ARP packets from non-local network"),
-			NULL, 0, _unknown_network, 0,
-			CTL_NET,PF_INET, node->sysctl_num, CTL_CREATE, CTL_EOL);
-
-	sysctl_createv(clog, 0, NULL, NULL,
-			CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
 			CTLTYPE_INT, "debug",
 			SYSCTL_DESCR("Enable ARP DAD debug output"),
 			NULL, 0, _debug, 0,



CVS commit: [netbsd-9] src/sys/netinet

2019-09-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep  1 14:04:37 UTC 2019

Modified Files:
src/sys/netinet [netbsd-9]: if_arp.c

Log Message:
Pull up following revision(s) (requested by roy in ticket #147):

sys/netinet/if_arp.c: revision 1.285
sys/netinet/if_arp.c: revision 1.286

ARP: remove unused sysctl entry log_unknown_network

ARP: change default sysctl entry log_movements to 0
IP address sharing is a thing and shouldn't cause needless diagnostics
by default.


To generate a diff of this commit:
cvs rdiff -u -r1.282.2.1 -r1.282.2.2 src/sys/netinet/if_arp.c

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