CVS commit: src/sys

2017-12-05 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 07:40:16 UTC 2017

Modified Files:
src/sys/net: if_bridge.c if_etherip.c if_faith.c if_loop.c if_tun.c
if_vlan.c
src/sys/net/agr: if_agr.c
src/sys/netcan: if_canloop.c

Log Message:
Ensure to not turn on IFF_RUNNING of an interface until its initialization 
completes

And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)


To generate a diff of this commit:
cvs rdiff -u -r1.142 -r1.143 src/sys/net/if_bridge.c
cvs rdiff -u -r1.39 -r1.40 src/sys/net/if_etherip.c
cvs rdiff -u -r1.56 -r1.57 src/sys/net/if_faith.c
cvs rdiff -u -r1.99 -r1.100 src/sys/net/if_loop.c
cvs rdiff -u -r1.141 -r1.142 src/sys/net/if_tun.c
cvs rdiff -u -r1.115 -r1.116 src/sys/net/if_vlan.c
cvs rdiff -u -r1.42 -r1.43 src/sys/net/agr/if_agr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/netcan/if_canloop.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/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.142 src/sys/net/if_bridge.c:1.143
--- src/sys/net/if_bridge.c:1.142	Wed Dec  6 05:11:10 2017
+++ src/sys/net/if_bridge.c	Wed Dec  6 07:40:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.142 2017/12/06 05:11:10 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.143 2017/12/06 07:40:16 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.142 2017/12/06 05:11:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.143 2017/12/06 07:40:16 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -1328,14 +1328,13 @@ bridge_init(struct ifnet *ifp)
 {
 	struct bridge_softc *sc = ifp->if_softc;
 
-	if (ifp->if_flags & IFF_RUNNING)
-		return 0;
+	KASSERT((ifp->if_flags & IFF_RUNNING) == 0);
 
 	callout_reset(>sc_brcallout, bridge_rtable_prune_period * hz,
 	bridge_timer, sc);
+	bstp_initialization(sc);
 
 	ifp->if_flags |= IFF_RUNNING;
-	bstp_initialization(sc);
 	return 0;
 }
 
@@ -1349,15 +1348,12 @@ bridge_stop(struct ifnet *ifp, int disab
 {
 	struct bridge_softc *sc = ifp->if_softc;
 
-	if ((ifp->if_flags & IFF_RUNNING) == 0)
-		return;
+	KASSERT((ifp->if_flags & IFF_RUNNING) != 0);
+	ifp->if_flags &= ~IFF_RUNNING;
 
 	callout_stop(>sc_brcallout);
 	bstp_stop(sc);
-
 	bridge_rtflush(sc, IFBF_FLUSHDYN);
-
-	ifp->if_flags &= ~IFF_RUNNING;
 }
 
 /*

Index: src/sys/net/if_etherip.c
diff -u src/sys/net/if_etherip.c:1.39 src/sys/net/if_etherip.c:1.40
--- src/sys/net/if_etherip.c:1.39	Mon Oct 23 09:31:18 2017
+++ src/sys/net/if_etherip.c	Wed Dec  6 07:40:16 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_etherip.c,v 1.39 2017/10/23 09:31:18 msaitoh Exp $*/
+/*  $NetBSD: if_etherip.c,v 1.40 2017/12/06 07:40:16 ozaki-r Exp $*/
 
 /*
  *  Copyright (c) 2006, Hans Rosenfeld 
@@ -86,7 +86,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_etherip.c,v 1.39 2017/10/23 09:31:18 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_etherip.c,v 1.40 2017/12/06 07:40:16 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -549,12 +549,11 @@ etherip_set_tunnel(struct ifnet *ifp,
 	if (odst)
 		sockaddr_free(odst);
 
-	ifp->if_flags |= IFF_RUNNING;
-
 	sc->sc_si = softint_establish(SOFTINT_NET, etheripintr, sc);
 	if (sc->sc_si == NULL)
 		error = ENOMEM;
 
+	ifp->if_flags |= IFF_RUNNING;
 out:
 	splx(s);
 
@@ -569,6 +568,8 @@ etherip_delete_tunnel(struct ifnet *ifp)
 
 	s = splsoftnet();
 
+	ifp->if_flags &= ~IFF_RUNNING;
+
 	if (sc->sc_si) {
 		softint_disestablish(sc->sc_si);
 		sc->sc_si = NULL;
@@ -583,7 +584,6 @@ etherip_delete_tunnel(struct ifnet *ifp)
 		sc->sc_dst = NULL;
 	}
 
-	ifp->if_flags &= ~IFF_RUNNING;
 	splx(s);
 }
 

Index: src/sys/net/if_faith.c
diff -u src/sys/net/if_faith.c:1.56 src/sys/net/if_faith.c:1.57
--- src/sys/net/if_faith.c:1.56	Mon Oct 23 09:32:00 2017
+++ src/sys/net/if_faith.c	Wed Dec  6 07:40:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_faith.c,v 1.56 2017/10/23 09:32:00 msaitoh Exp $	*/
+/*	$NetBSD: if_faith.c,v 1.57 2017/12/06 07:40:16 ozaki-r Exp $	*/
 /*	$KAME: if_faith.c,v 1.21 2001/02/20 07:59:26 itojun Exp $	*/
 
 /*
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.56 2017/10/23 09:32:00 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_faith.c,v 1.57 2017/12/06 07:40:16 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -263,9 +263,9 @@ faithioctl(struct ifnet *ifp, u_long cmd
 	switch (cmd) {
 
 	case SIOCINITIFADDR:
-		ifp->if_flags |= IFF_UP | IFF_RUNNING;
 		ifa = (struct ifaddr *)data;
 		ifa->ifa_rtrequest = faithrtrequest;
+		ifp->if_flags |= IFF_UP | IFF_RUNNING;
 		/*
 		 * Everything else is done at a higher level.
 		 */

Index: src/sys/net/if_loop.c
diff -u src/sys/net/if_loop.c:1.99 

CVS commit: src/sys/net

2017-12-05 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 05:59:59 UTC 2017

Modified Files:
src/sys/net: if.c if.h if_vlan.c

Log Message:
Fix locking against myself on ifpromisc

vlan_unconfig_locked could be called with holding if_ioctl_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.401 -r1.402 src/sys/net/if.c
cvs rdiff -u -r1.245 -r1.246 src/sys/net/if.h
cvs rdiff -u -r1.114 -r1.115 src/sys/net/if_vlan.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/net/if.c
diff -u src/sys/net/if.c:1.401 src/sys/net/if.c:1.402
--- src/sys/net/if.c:1.401	Wed Dec  6 05:11:10 2017
+++ src/sys/net/if.c	Wed Dec  6 05:59:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.401 2017/12/06 05:11:10 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.402 2017/12/06 05:59:59 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.401 2017/12/06 05:11:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.402 2017/12/06 05:59:59 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2506,12 +2506,12 @@ if_slowtimo(void *arg)
  * Results are undefined if the "off" and "on" requests are not matched.
  */
 int
-ifpromisc(struct ifnet *ifp, int pswitch)
+ifpromisc_locked(struct ifnet *ifp, int pswitch)
 {
 	int pcount, ret = 0;
 	short nflags;
 
-	mutex_enter(ifp->if_ioctl_lock);
+	KASSERT(mutex_owned(ifp->if_ioctl_lock));
 
 	pcount = ifp->if_pcount;
 	if (pswitch) {
@@ -2534,10 +2534,21 @@ ifpromisc(struct ifnet *ifp, int pswitch
 		ifp->if_pcount = pcount;
 	}
 out:
-	mutex_exit(ifp->if_ioctl_lock);
 	return ret;
 }
 
+int
+ifpromisc(struct ifnet *ifp, int pswitch)
+{
+	int e;
+
+	mutex_enter(ifp->if_ioctl_lock);
+	e = ifpromisc_locked(ifp, pswitch);
+	mutex_exit(ifp->if_ioctl_lock);
+
+	return e;
+}
+
 /*
  * Map interface name to
  * interface structure pointer.

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.245 src/sys/net/if.h:1.246
--- src/sys/net/if.h:1.245	Wed Dec  6 05:11:10 2017
+++ src/sys/net/if.h	Wed Dec  6 05:59:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.245 2017/12/06 05:11:10 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.246 2017/12/06 05:59:59 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1015,6 +1015,7 @@ int	ifaddrpref_ioctl(struct socket *, u_
 extern int (*ifioctl)(struct socket *, u_long, void *, struct lwp *);
 int	ifioctl_common(struct ifnet *, u_long, void *);
 int	ifpromisc(struct ifnet *, int);
+int	ifpromisc_locked(struct ifnet *, int);
 int	if_addr_init(ifnet_t *, struct ifaddr *, bool);
 int	if_do_dad(struct ifnet *);
 int	if_mcast_op(ifnet_t *, const unsigned long, const struct sockaddr *);

Index: src/sys/net/if_vlan.c
diff -u src/sys/net/if_vlan.c:1.114 src/sys/net/if_vlan.c:1.115
--- src/sys/net/if_vlan.c:1.114	Wed Dec  6 05:11:10 2017
+++ src/sys/net/if_vlan.c	Wed Dec  6 05:59:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vlan.c,v 1.114 2017/12/06 05:11:10 ozaki-r Exp $	*/
+/*	$NetBSD: if_vlan.c,v 1.115 2017/12/06 05:59:59 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.114 2017/12/06 05:11:10 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.115 2017/12/06 05:59:59 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -255,6 +255,16 @@ vlan_safe_ifpromisc(struct ifnet *ifp, i
 	return e;
 }
 
+static inline int
+vlan_safe_ifpromisc_locked(struct ifnet *ifp, int pswitch)
+{
+	int e;
+	KERNEL_LOCK_UNLESS_NET_MPSAFE();
+	e = ifpromisc_locked(ifp, pswitch);
+	KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
+	return e;
+}
+
 void
 vlanattach(int n)
 {
@@ -387,7 +397,9 @@ vlan_clone_destroy(struct ifnet *ifp)
 	LIST_REMOVE(ifv, ifv_list);
 	mutex_exit(_list.lock);
 
+	mutex_enter(ifp->if_ioctl_lock);
 	vlan_unconfig(ifp);
+	mutex_exit(ifp->if_ioctl_lock);
 	if_detach(ifp);
 
 	psref_target_destroy(>ifv_mib->ifvm_psref, ifvm_psref_class);
@@ -549,6 +561,8 @@ vlan_unconfig(struct ifnet *ifp)
 	struct ifvlan_linkmib *nmib = NULL;
 	int error;
 
+	KASSERT(mutex_owned(ifp->if_ioctl_lock));
+
 	nmib = kmem_alloc(sizeof(*nmib), KM_SLEEP);
 
 	mutex_enter(>ifv_lock);
@@ -567,6 +581,7 @@ vlan_unconfig_locked(struct ifvlan *ifv,
 	struct ifvlan_linkmib *omib;
 	int error = 0;
 
+	KASSERT(mutex_owned(ifp->if_ioctl_lock));
 	KASSERT(mutex_owned(>ifv_lock));
 
 	omib = ifv->ifv_mib;
@@ -635,7 +650,7 @@ vlan_unconfig_locked(struct ifvlan *ifv,
 #endif
 
 	if ((ifp->if_flags & IFF_PROMISC) != 0)
-		vlan_safe_ifpromisc(ifp, 0);
+		vlan_safe_ifpromisc_locked(ifp, 0);
 	if_down(ifp);
 	ifp->if_flags &= ~(IFF_UP|IFF_RUNNING);
 	ifp->if_capabilities = 0;
@@ -806,6 +821,10 @@ vlan_ifdetach(struct ifnet *p)
 
 	i = 0;
 	LIST_FOREACH(ifv, _list.list, ifv_list) {
+		struct ifnet *ifp = >ifv_if;
+
+		/* Need if_ioctl_lock that 

CVS commit: src/sys/net

2017-12-05 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 05:11:10 UTC 2017

Modified Files:
src/sys/net: if.c if.h if_bridge.c if_vlan.c

Log Message:
Ensure to hold if_ioctl_lock when calling if_flags_set


To generate a diff of this commit:
cvs rdiff -u -r1.400 -r1.401 src/sys/net/if.c
cvs rdiff -u -r1.244 -r1.245 src/sys/net/if.h
cvs rdiff -u -r1.141 -r1.142 src/sys/net/if_bridge.c
cvs rdiff -u -r1.113 -r1.114 src/sys/net/if_vlan.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/net/if.c
diff -u src/sys/net/if.c:1.400 src/sys/net/if.c:1.401
--- src/sys/net/if.c:1.400	Wed Nov 22 10:19:14 2017
+++ src/sys/net/if.c	Wed Dec  6 05:11:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.400 2017/11/22 10:19:14 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.401 2017/12/06 05:11:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.400 2017/11/22 10:19:14 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.401 2017/12/06 05:11:10 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1322,9 +1322,6 @@ if_detach(struct ifnet *ifp)
 	psref_target_destroy(>if_psref, ifnet_psref_class);
 	PSLIST_ENTRY_DESTROY(ifp, if_pslist_entry);
 
-	mutex_obj_free(ifp->if_ioctl_lock);
-	ifp->if_ioctl_lock = NULL;
-
 	if (ifp->if_slowtimo != NULL && ifp->if_slowtimo_ch != NULL) {
 		ifp->if_slowtimo = NULL;
 		callout_halt(ifp->if_slowtimo_ch, NULL);
@@ -1353,6 +1350,10 @@ if_detach(struct ifnet *ifp)
 		carp_ifdetach(ifp);
 #endif
 
+	/* carp_ifdetach still uses the lock */
+	mutex_obj_free(ifp->if_ioctl_lock);
+	ifp->if_ioctl_lock = NULL;
+
 	/*
 	 * Rip all the addresses off the interface.  This should make
 	 * all of the routes go away.
@@ -2507,9 +2508,11 @@ if_slowtimo(void *arg)
 int
 ifpromisc(struct ifnet *ifp, int pswitch)
 {
-	int pcount, ret;
+	int pcount, ret = 0;
 	short nflags;
 
+	mutex_enter(ifp->if_ioctl_lock);
+
 	pcount = ifp->if_pcount;
 	if (pswitch) {
 		/*
@@ -2518,11 +2521,11 @@ ifpromisc(struct ifnet *ifp, int pswitch
 		 * consult IFF_PROMISC when it is brought up.
 		 */
 		if (ifp->if_pcount++ != 0)
-			return 0;
+			goto out;
 		nflags = ifp->if_flags | IFF_PROMISC;
 	} else {
 		if (--ifp->if_pcount > 0)
-			return 0;
+			goto out;
 		nflags = ifp->if_flags & ~IFF_PROMISC;
 	}
 	ret = if_flags_set(ifp, nflags);
@@ -2530,6 +2533,8 @@ ifpromisc(struct ifnet *ifp, int pswitch
 	if (ret != 0) {
 		ifp->if_pcount = pcount;
 	}
+out:
+	mutex_exit(ifp->if_ioctl_lock);
 	return ret;
 }
 
@@ -3402,6 +3407,8 @@ if_flags_set(ifnet_t *ifp, const short f
 {
 	int rc;
 
+	KASSERT(mutex_owned(ifp->if_ioctl_lock));
+
 	if (ifp->if_setflags != NULL)
 		rc = (*ifp->if_setflags)(ifp, flags);
 	else {
@@ -3450,6 +3457,30 @@ if_mcast_op(ifnet_t *ifp, const unsigned
 	return rc;
 }
 
+int
+if_enable_vlan_mtu(struct ifnet *ifp)
+{
+	int error;
+
+	mutex_enter(ifp->if_ioctl_lock);
+	error= ether_enable_vlan_mtu(ifp);
+	mutex_exit(ifp->if_ioctl_lock);
+
+	return error;
+}
+
+int
+if_disable_vlan_mtu(struct ifnet *ifp)
+{
+	int error;
+
+	mutex_enter(ifp->if_ioctl_lock);
+	error= ether_disable_vlan_mtu(ifp);
+	mutex_exit(ifp->if_ioctl_lock);
+
+	return error;
+}
+
 static void
 sysctl_sndq_setup(struct sysctllog **clog, const char *ifname,
 struct ifaltq *ifq)

Index: src/sys/net/if.h
diff -u src/sys/net/if.h:1.244 src/sys/net/if.h:1.245
--- src/sys/net/if.h:1.244	Wed Nov 22 03:03:18 2017
+++ src/sys/net/if.h	Wed Dec  6 05:11:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.h,v 1.244 2017/11/22 03:03:18 ozaki-r Exp $	*/
+/*	$NetBSD: if.h,v 1.245 2017/12/06 05:11:10 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -1020,6 +1020,8 @@ int	if_do_dad(struct ifnet *);
 int	if_mcast_op(ifnet_t *, const unsigned long, const struct sockaddr *);
 int	if_flags_set(struct ifnet *, const short);
 int	if_clone_list(int, char *, int *);
+int	if_enable_vlan_mtu(struct ifnet *);
+int	if_disable_vlan_mtu(struct ifnet *);
 
 struct	ifnet *ifunit(const char *);
 struct	ifnet *if_get(const char *, struct psref *);

Index: src/sys/net/if_bridge.c
diff -u src/sys/net/if_bridge.c:1.141 src/sys/net/if_bridge.c:1.142
--- src/sys/net/if_bridge.c:1.141	Fri Nov 17 07:52:07 2017
+++ src/sys/net/if_bridge.c	Wed Dec  6 05:11:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.141 2017/11/17 07:52:07 ozaki-r Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.142 2017/12/06 05:11:10 ozaki-r Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.141 2017/11/17 07:52:07 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.142 2017/12/06 05:11:10 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -772,7 +772,8 @@ bridge_ioctl_add(struct bridge_softc *sc
 		}
 		/* FALLTHROUGH */
 	case 

CVS commit: src/sys/net/agr

2017-12-05 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 04:37:00 UTC 2017

Modified Files:
src/sys/net/agr: if_agr.c if_agrether.c if_agrsubr.c if_agrsubr.h

Log Message:
Simplify; share agr_vlan_add and agr_vlan_del (NFCI)


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/net/agr/if_agr.c
cvs rdiff -u -r1.9 -r1.10 src/sys/net/agr/if_agrether.c
cvs rdiff -u -r1.10 -r1.11 src/sys/net/agr/if_agrsubr.c
cvs rdiff -u -r1.4 -r1.5 src/sys/net/agr/if_agrsubr.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/net/agr/if_agr.c
diff -u src/sys/net/agr/if_agr.c:1.41 src/sys/net/agr/if_agr.c:1.42
--- src/sys/net/agr/if_agr.c:1.41	Sat Jan 28 22:56:09 2017
+++ src/sys/net/agr/if_agr.c	Wed Dec  6 04:37:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_agr.c,v 1.41 2017/01/28 22:56:09 maya Exp $	*/
+/*	$NetBSD: if_agr.c,v 1.42 2017/12/06 04:37:00 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.41 2017/01/28 22:56:09 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.42 2017/12/06 04:37:00 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -254,62 +254,6 @@ agrport_ioctl(struct agr_port *port, u_l
 /*
  * INTERNAL FUNCTIONS
  */
-
-/*
- * Enable vlan hardware assist for the specified port.
- */
-static int
-agr_vlan_add(struct agr_port *port, void *arg)
-{
-	struct ifnet *ifp = port->port_ifp;
-	struct ethercom *ec_port = (void *)ifp;
-	int error=0;
-
-	if (ec_port->ec_nvlans++ == 0 &&
-	(ec_port->ec_capabilities & ETHERCAP_VLAN_MTU) != 0) {
-		struct ifnet *p = port->port_ifp;
-		/*
-		 * Enable Tx/Rx of VLAN-sized frames.
-		 */
-		ec_port->ec_capenable |= ETHERCAP_VLAN_MTU;
-		if (p->if_flags & IFF_UP) {
-			error = if_flags_set(p, p->if_flags);
-			if (error) {
-if (ec_port->ec_nvlans-- == 1)
-	ec_port->ec_capenable &=
-	~ETHERCAP_VLAN_MTU;
-return (error);
-			}
-		}
-	}
-
-	return error;
-}
-
-/*
- * Disable vlan hardware assist for the specified port.
- */
-static int
-agr_vlan_del(struct agr_port *port, void *arg)
-{
-	struct ethercom *ec_port = (void *)port->port_ifp;
-
-	/* Disable vlan support */
-	if (ec_port->ec_nvlans-- == 1) {
-		/*
-		 * Disable Tx/Rx of VLAN-sized frames.
-		 */
-		ec_port->ec_capenable &= ~ETHERCAP_VLAN_MTU;
-		if (port->port_ifp->if_flags & IFF_UP) {
-			(void)if_flags_set(port->port_ifp,
-			port->port_ifp->if_flags);
-		}
-	}
-
-	return 0;
-}
-
-
 /*
  * Check for vlan attach/detach.
  * ec->ec_nvlans is directly modified by the vlan driver.
@@ -332,8 +276,9 @@ agr_vlan_check(struct ifnet *ifp, struct
 		agr_port_foreach(sc, agr_vlan_add, NULL);
 		sc->sc_nvlans = ec->ec_nvlans;
 	} else if (ec->ec_nvlans == 0) {
+		bool force_zero = false;
 		/* vlan removed */
-		agr_port_foreach(sc, agr_vlan_del, NULL);
+		agr_port_foreach(sc, agr_vlan_del, _zero);
 		sc->sc_nvlans = 0;
 	}
 }

Index: src/sys/net/agr/if_agrether.c
diff -u src/sys/net/agr/if_agrether.c:1.9 src/sys/net/agr/if_agrether.c:1.10
--- src/sys/net/agr/if_agrether.c:1.9	Wed Oct 19 01:49:50 2011
+++ src/sys/net/agr/if_agrether.c	Wed Dec  6 04:37:00 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_agrether.c,v 1.9 2011/10/19 01:49:50 dyoung Exp $	*/
+/*	$NetBSD: if_agrether.c,v 1.10 2017/12/06 04:37:00 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_agrether.c,v 1.9 2011/10/19 01:49:50 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agrether.c,v 1.10 2017/12/06 04:37:00 ozaki-r Exp $");
 
 #include 
 #include 
@@ -166,23 +166,10 @@ agrether_portinit(struct agr_softc *sc, 
 	}
 
 	/* Enable vlan support */
-	if ((ec->ec_nvlans > 0) && 
-	 ec_port->ec_nvlans++ == 0 &&
-	(ec_port->ec_capabilities & ETHERCAP_VLAN_MTU) != 0) {
-		struct ifnet *p = port->port_ifp;
-		/*
-		 * Enable Tx/Rx of VLAN-sized frames.
-		 */
-		ec_port->ec_capenable |= ETHERCAP_VLAN_MTU;
-		if (p->if_flags & IFF_UP) {
-			error = if_flags_set(p, p->if_flags);
-			if (error) {
-if (ec_port->ec_nvlans-- == 1)
-	ec_port->ec_capenable &=
-	~ETHERCAP_VLAN_MTU;
-return (error);
-			}
-		}
+	if (ec->ec_nvlans > 0) {
+		error = agr_vlan_add(port, NULL);
+		if (error != 0)
+			return error;
 	}
 	/* XXX ETHERCAP_JUMBO_MTU */
 
@@ -225,16 +212,9 @@ agrether_portfini(struct agr_softc *sc, 
 	}
 
 	if (ec_port->ec_nvlans > 0) {
+		bool force = true;
 		/* Disable vlan support */
-		ec_port->ec_nvlans = 0;
-		/*
-		 * Disable Tx/Rx of VLAN-sized frames.
-		 */
-		ec_port->ec_capenable &= ~ETHERCAP_VLAN_MTU;
-		if (port->port_ifp->if_flags & IFF_UP) {
-			(void)if_flags_set(port->port_ifp,
-			port->port_ifp->if_flags);
-		}
+		agr_vlan_del(port, );
 	}
 
 	memset(, 0, sizeof(ifr));

Index: src/sys/net/agr/if_agrsubr.c
diff -u src/sys/net/agr/if_agrsubr.c:1.10 src/sys/net/agr/if_agrsubr.c:1.11
--- 

CVS commit: src/sys/dev/iscsi

2017-12-05 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 04:29:58 UTC 2017

Modified Files:
src/sys/dev/iscsi: iscsi_ioctl.c

Log Message:
Fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/iscsi/iscsi_ioctl.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/dev/iscsi/iscsi_ioctl.c
diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.28 src/sys/dev/iscsi/iscsi_ioctl.c:1.29
--- src/sys/dev/iscsi/iscsi_ioctl.c:1.28	Sun Dec  3 19:07:10 2017
+++ src/sys/dev/iscsi/iscsi_ioctl.c	Wed Dec  6 04:29:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: iscsi_ioctl.c,v 1.28 2017/12/03 19:07:10 christos Exp $	*/
+/*	$NetBSD: iscsi_ioctl.c,v 1.29 2017/12/06 04:29:58 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc.
@@ -443,7 +443,7 @@ ref_session(session_t *sess)
 	int rc = 1;
 
 	mutex_enter(_cleanup_mtx);
-	KASSERT(session != NULL);
+	KASSERT(sess != NULL);
 	if (sess->s_refcount <= CCBS_PER_SESSION) {
 		sess->s_refcount++;
 		rc = 0;



CVS commit: src/sys/compat/netbsd32

2017-12-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 04:12:25 UTC 2017

Modified Files:
src/sys/compat/netbsd32: netbsd32_compat_60.c

Log Message:
don't forget to convert the timespec.
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/compat/netbsd32/netbsd32_compat_60.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/compat/netbsd32/netbsd32_compat_60.c
diff -u src/sys/compat/netbsd32/netbsd32_compat_60.c:1.2 src/sys/compat/netbsd32/netbsd32_compat_60.c:1.3
--- src/sys/compat/netbsd32/netbsd32_compat_60.c:1.2	Thu Aug 21 02:40:35 2014
+++ src/sys/compat/netbsd32/netbsd32_compat_60.c	Tue Dec  5 23:12:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: netbsd32_compat_60.c,v 1.2 2014/08/21 06:40:35 maxv Exp $	*/
+/*	$NetBSD: netbsd32_compat_60.c,v 1.3 2017/12/06 04:12:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_60.c,v 1.2 2014/08/21 06:40:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_60.c,v 1.3 2017/12/06 04:12:25 christos Exp $");
 
 #include 
 #include 
@@ -71,6 +71,7 @@ compat_60_netbsd32__lwp_park(struct lwp 
 		error = copyin(SCARG_P32(uap, ts), , sizeof ts32);
 		if (error != 0)
 			return error;
+		netbsd32_to_timespec(, );
 		tsp = 
 	}
 



CVS commit: src/sys/dev/pci/ixgbe

2017-12-05 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec  6 04:08:50 UTC 2017

Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h ixgbe_82598.c ixgbe_82598.h
ixgbe_82599.c ixgbe_82599.h ixgbe_api.c ixgbe_api.h ixgbe_common.c
ixgbe_common.h ixgbe_dcb.c ixgbe_dcb.h ixgbe_dcb_82598.c
ixgbe_dcb_82598.h ixgbe_dcb_82599.c ixgbe_dcb_82599.h ixgbe_mbx.c
ixgbe_mbx.h ixgbe_osdep.h ixgbe_phy.c ixgbe_phy.h ixgbe_rss.h
ixgbe_type.h ixgbe_vf.c ixgbe_vf.h ixgbe_x540.c ixgbe_x540.h ixv.c

Log Message:
Sync with FreeBSD's r326022. All of the following changes have no influence
to netbsd:
- Check ETHERCAP_VLAN_HWTAGGING in ixgbe_setup_vlan_hw_support(). This change
  has no influence to netbsd because it's enabled by default and NetBSD has
  no API to disable it.
- Fix for netmap module.
- Remove never defined UDP_IPV4_EX
- Add SPDX-License-Identifier


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/pci/ixgbe/ixgbe_82598.c \
src/sys/dev/pci/ixgbe/ixgbe_phy.h
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/pci/ixgbe/ixgbe_82598.h \
src/sys/dev/pci/ixgbe/ixgbe_x540.h
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/ixgbe/ixgbe_82599.c \
src/sys/dev/pci/ixgbe/ixgbe_common.c
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/ixgbe/ixgbe_82599.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb.c
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/ixgbe/ixgbe_api.c
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/pci/ixgbe/ixgbe_api.h \
src/sys/dev/pci/ixgbe/ixgbe_vf.h
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/pci/ixgbe/ixgbe_common.h \
src/sys/dev/pci/ixgbe/ixgbe_mbx.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/pci/ixgbe/ixgbe_dcb.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.c \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82598.h \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.c \
src/sys/dev/pci/ixgbe/ixgbe_dcb_82599.h
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pci/ixgbe/ixgbe_mbx.h \
src/sys/dev/pci/ixgbe/ixgbe_x540.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/pci/ixgbe/ixgbe_osdep.h
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ixgbe/ixgbe_phy.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/pci/ixgbe/ixgbe_rss.h
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/pci/ixgbe/ixgbe_type.h
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.74 -r1.75 src/sys/dev/pci/ixgbe/ixv.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/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.114 src/sys/dev/pci/ixgbe/ixgbe.c:1.115
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.114	Fri Nov 24 08:36:22 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Wed Dec  6 04:08:50 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.114 2017/11/24 08:36:22 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.115 2017/12/06 04:08:50 msaitoh Exp $ */
 
 /**
 
@@ -272,6 +272,9 @@ DRIVER_MODULE(ix, pci, ix_driver, ix_dev
 
 MODULE_DEPEND(ix, pci, 1, 1, 1);
 MODULE_DEPEND(ix, ether, 1, 1, 1);
+#ifdef DEV_NETMAP
+MODULE_DEPEND(ix, netmap, 1, 1, 1);
+#endif
 #endif
 
 /*
@@ -498,9 +501,6 @@ ixgbe_initialize_rss_mapping(struct adap
 		mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_EX_TCP;
 	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4)
 		mrqc |= IXGBE_MRQC_RSS_FIELD_IPV4_UDP;
-	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV4_EX)
-		device_printf(adapter->dev, "%s: RSS_HASHTYPE_RSS_UDP_IPV4_EX defined, but not supported\n",
-		__func__);
 	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6)
 		mrqc |= IXGBE_MRQC_RSS_FIELD_IPV6_UDP;
 	if (rss_hash_config & RSS_HASHTYPE_RSS_UDP_IPV6_EX)
@@ -2185,15 +2185,17 @@ ixgbe_setup_vlan_hw_support(struct adapt
 		return;
 
 	/* Setup the queues for vlans */
-	for (i = 0; i < adapter->num_queues; i++) {
-		rxr = >rx_rings[i];
-		/* On 82599 the VLAN enable is per/queue in RXDCTL */
-		if (hw->mac.type != ixgbe_mac_82598EB) {
-			ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
-			ctrl |= IXGBE_RXDCTL_VME;
-			IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
+	if (ec->ec_capenable & ETHERCAP_VLAN_HWTAGGING) {
+		for (i = 0; i < adapter->num_queues; i++) {
+			rxr = >rx_rings[i];
+			/* On 82599 the VLAN enable is per/queue in RXDCTL */
+			if (hw->mac.type != ixgbe_mac_82598EB) {
+ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxr->me));
+ctrl |= IXGBE_RXDCTL_VME;
+IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxr->me), ctrl);
+			}
+			rxr->vtag_strip = TRUE;
 		}
-		rxr->vtag_strip = TRUE;
 	}
 
 	if ((ec->ec_capenable & ETHERCAP_VLAN_HWFILTER) == 0)

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.28 src/sys/dev/pci/ixgbe/ixgbe.h:1.29
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.28	Wed Nov 22 15:15:09 2017
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Wed Dec  6 04:08:50 2017
@@ -1,6 +1,7 @@
-/* $NetBSD: ixgbe.h,v 1.28 

CVS commit: src/sys/net

2017-12-05 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Dec  6 04:00:07 UTC 2017

Modified Files:
src/sys/net: if_ethersubr.c

Log Message:
Use kmem_alloc instead of kmem_intr_alloc in ether_addmulti

ether_addmulti is now not called in softint thanks to wqinput that
pulled input routines of ICMP out of softint.


To generate a diff of this commit:
cvs rdiff -u -r1.247 -r1.248 src/sys/net/if_ethersubr.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/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.247 src/sys/net/if_ethersubr.c:1.248
--- src/sys/net/if_ethersubr.c:1.247	Wed Nov 22 04:27:57 2017
+++ src/sys/net/if_ethersubr.c	Wed Dec  6 04:00:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.247 2017/11/22 04:27:57 msaitoh Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.248 2017/12/06 04:00:07 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.247 2017/11/22 04:27:57 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.248 2017/12/06 04:00:07 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1005,7 +1005,7 @@ ether_ifdetach(struct ifnet *ifp)
 	ETHER_LOCK(ec);
 	while ((enm = LIST_FIRST(>ec_multiaddrs)) != NULL) {
 		LIST_REMOVE(enm, enm_list);
-		kmem_intr_free(enm, sizeof(*enm));
+		kmem_free(enm, sizeof(*enm));
 		ec->ec_multicnt--;
 	}
 	ETHER_UNLOCK(ec);
@@ -1223,8 +1223,7 @@ ether_addmulti(const struct sockaddr *sa
 	int error = 0;
 
 	/* Allocate out of lock */
-	/* XXX still can be called in softint */
-	enm = kmem_intr_alloc(sizeof(*enm), KM_SLEEP);
+	enm = kmem_alloc(sizeof(*enm), KM_SLEEP);
 	if (enm == NULL)
 		return ENOBUFS;
 
@@ -1269,7 +1268,7 @@ ether_addmulti(const struct sockaddr *sa
 out:
 	ETHER_UNLOCK(ec);
 	if (enm != NULL)
-		kmem_intr_free(enm, sizeof(*enm));
+		kmem_free(enm, sizeof(*enm));
 	return error;
 }
 
@@ -1311,7 +1310,7 @@ ether_delmulti(const struct sockaddr *sa
 	ec->ec_multicnt--;
 	ETHER_UNLOCK(ec);
 
-	kmem_intr_free(enm, sizeof(*enm));
+	kmem_free(enm, sizeof(*enm));
 	/*
 	 * Return ENETRESET to inform the driver that the list has changed
 	 * and its reception filter should be adjusted accordingly.



CVS commit: src/sys/conf

2017-12-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 02:08:03 UTC 2017

Modified Files:
src/sys/conf: dts.mk

Log Message:
use -@ like bsd.klinks.mk


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/conf/dts.mk

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

Modified files:

Index: src/sys/conf/dts.mk
diff -u src/sys/conf/dts.mk:1.6 src/sys/conf/dts.mk:1.7
--- src/sys/conf/dts.mk:1.6	Mon Dec  4 21:57:37 2017
+++ src/sys/conf/dts.mk	Tue Dec  5 21:08:03 2017
@@ -1,4 +1,4 @@
-# $NetBSD: dts.mk,v 1.6 2017/12/05 02:57:37 christos Exp $
+# $NetBSD: dts.mk,v 1.7 2017/12/06 02:08:03 christos Exp $
 
 DTSARCH?=${MACHINE_CPU}
 DTSGNUARCH?=${DTSARCH}
@@ -6,9 +6,9 @@ DTSPADDING?=1024
 
 .if !make(obj) && !make(clean) && !make(cleandir)
 .BEGIN:
-	@mkdir -p dts
+	-@mkdir -p dts
 .for _arch in ${DTSGNUARCH}
-	@ln -sf ${S:S@^../@../../@}/external/gpl2/dts/dist/arch/${_arch}/boot/dts dts/${_arch}
+	-@ln -sf ${S:S@^../@../../@}/external/gpl2/dts/dist/arch/${_arch}/boot/dts dts/${_arch}
 .endfor
 .endif
 



CVS commit: src/share/mk

2017-12-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Dec  6 02:06:45 UTC 2017

Modified Files:
src/share/mk: bsd.klinks.mk

Log Message:
remove multiple copies of the same logic.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/share/mk/bsd.klinks.mk

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

Modified files:

Index: src/share/mk/bsd.klinks.mk
diff -u src/share/mk/bsd.klinks.mk:1.13 src/share/mk/bsd.klinks.mk:1.14
--- src/share/mk/bsd.klinks.mk:1.13	Sun Aug 10 01:57:31 2014
+++ src/share/mk/bsd.klinks.mk	Tue Dec  5 21:06:45 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: bsd.klinks.mk,v 1.13 2014/08/10 05:57:31 matt Exp $
+#	$NetBSD: bsd.klinks.mk,v 1.14 2017/12/06 02:06:45 christos Exp $
 #
 
 .include 
@@ -7,81 +7,50 @@ KLINK_MACHINE?=	${MACHINE}
 
 # Default values
 .if !defined(S)
-.if defined(NETBSDSRCDIR)
+.   if defined(NETBSDSRCDIR)
 S=	${NETBSDSRCDIR}/sys
-.elif defined(BSDSRCDIR)
+.   elif defined(BSDSRCDIR)
 S=	${BSDSRCDIR}/sys
-.else
+.   else
 S=	/sys
+.   endif
 .endif
-.endif
 
-CLEANFILES+=	machine ${MACHINE_CPU} ${KLINK_MACHINE}
+KLINKFILES+=	${MACHINE_CPU} ${KLINK_MACHINE}
+
 .if ${KLINK_MACHINE} == "sun2" || ${KLINK_MACHINE} == "sun3"
-CLEANFILES+=	sun68k
+KLINKFILES+=	sun68k
 .elif ${KLINK_MACHINE} == "sparc64"
-CLEANFILES+=	sparc
+KLINKFILES+=	sparc
 .elif ${KLINK_MACHINE} == "i386"
-CLEANFILES+=	x86
+KLINKFILES+=	x86
 .elif ${KLINK_MACHINE} == "amd64"
-CLEANFILES+=	x86 i386
+KLINKFILES+=	x86 i386
 .elif ${KLINK_MACHINE} == "evbmips"
-CLEANFILES+=	algor sbmips
+KLINKFILES+=	algor sbmips
 .elif ${MACHINE_CPU} == "aarch64"
-CLEANFILES+=	arm
-.endif
-
-.if defined(XEN_BUILD) || ${KLINK_MACHINE} == "xen"
-CLEANFILES+=	xen xen-ma/machine # xen-ma
+KLINKFILES+=	arm
+.elif defined(XEN_BUILD) || ${KLINK_MACHINE} == "xen"
+KLINKFILES+=	xen
+CLEANFILES+=	xen-ma/machine # xen-ma
 CPPFLAGS+=	-I${.OBJDIR}/xen-ma
-.if ${MACHINE_CPU} == "i386"
-CLEANFILES+=	x86
-.endif
 .endif
 
+CLEANFILES+= machine ${KLINKFILES}
+
 # XXX.  This should be done a better way.  It's @'d to reduce visual spew.
 # XXX   .BEGIN is used to make sure the links are done before anything else.
 .if !make(obj) && !make(clean) && !make(cleandir)
 .BEGIN:
 	-@rm -f machine && \
 	ln -s $S/arch/${KLINK_MACHINE}/include machine
-	-@rm -f ${KLINK_MACHINE} && \
-	ln -s $S/arch/${KLINK_MACHINE}/include ${KLINK_MACHINE}
-	-@if [ -d $S/arch/${MACHINE_CPU} ]; then \
-	rm -f ${MACHINE_CPU} && \
-	ln -s $S/arch/${MACHINE_CPU}/include ${MACHINE_CPU}; \
-	 fi
-# XXX. it gets worse..
-.if ${KLINK_MACHINE} == "sun2" || ${KLINK_MACHINE} == "sun3"
-	-@rm -f sun68k && \
-	ln -s $S/arch/sun68k/include sun68k
-.endif
-.if ${KLINK_MACHINE} == "sparc64"
-	-@rm -f sparc && \
-	ln -s $S/arch/sparc/include sparc
-.endif
-.if ${KLINK_MACHINE} == "amd64"
-	-@rm -f i386 && \
-	ln -s $S/arch/i386/include i386
-.endif
-.if ${MACHINE_CPU} == "i386" || ${MACHINE_CPU} == "x86_64"
-	-@rm -f x86 && \
-	ln -s $S/arch/x86/include x86
-.endif
-.if ${MACHINE_CPU} == "aarch64"
-	-@rm -f arm && \
-	ln -s $S/arch/arm/include arm
-.endif
-.if defined(XEN_BUILD) || ${KLINK_MACHINE} == "xen"
-	-@rm -f xen && \
-	ln -s $S/arch/xen/include xen
+.   for kl in ${KLINKFILES}
+	-@if [ -d $S/arch/${kl}/include ]; then \
+	rm -f ${kl} && ln -s $S/arch/${kl}/include ${kl}; \
+	fi
+.   endfor
+.   if defined(XEN_BUILD) || ${KLINK_MACHINE} == "xen"
 	-@rm -rf xen-ma && mkdir xen-ma && \
 	ln -s ../${XEN_BUILD:U${MACHINE_ARCH}} xen-ma/machine
-.endif
-.if ${KLINK_MACHINE} == "evbmips"
-	-@rm -f algor && \
-	ln -s $S/arch/algor/include algor
-	-@rm -f sbmips && \
-	ln -s $S/arch/sbmips/include sbmips
-.endif
+.   endif
 .endif



CVS commit: src/games/fortune/datfiles

2017-12-05 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Dec  5 22:51:59 UTC 2017

Modified Files:
src/games/fortune/datfiles: fortunes

Log Message:
Add new fortune entry with a quote from Jozef Pilsudski

This quote is a longer form of "the dogs bark, but the caravan goes on"
and compares Poles and Lithuanians (historical meanings used from the time
of country union of both nations).

Today is the 150th birthday anniversary of Jozef Pilsudski (1867-1935).


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/games/fortune/datfiles/fortunes

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

Modified files:

Index: src/games/fortune/datfiles/fortunes
diff -u src/games/fortune/datfiles/fortunes:1.66 src/games/fortune/datfiles/fortunes:1.67
--- src/games/fortune/datfiles/fortunes:1.66	Sat Nov 18 20:48:50 2017
+++ src/games/fortune/datfiles/fortunes	Tue Dec  5 22:51:59 2017
@@ -16220,3 +16220,15 @@ Information wants to be free and also ex
 %
 I haven't slept for ten days, because that would be too long.
 -- Mitch Hedberg
+%
+You, the Poles, have a funny nature. When the people going along the
+road are attacked by a dog with its insistent and noisy barking, you
+immediately feel like jumping off the vehicle, standing on all fours
+and starting to bark back at it. We, in the Vilnius region, let the
+dog bark because that is what its canine nature is like but we do not
+stop out journey because of its canine barking and without any war
+against dogs we calmly continue our journey until we reach our
+destination. It seems that you care more about barking more than the
+dog does and about winning the war with any lousy puppy than about
+reaching the destination quickly.
+-- Jozef Pilsudski



CVS commit: src/sys/arch/amd64/conf

2017-12-05 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Dec  5 21:00:27 UTC 2017

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Add missing wsbell, commented out with a note that it's apparently only
a module by default.

This way people making their own configs have half a prayer of
realizing they might need to turn it on, instead of just not getting
beeps any more for no clear reason.

XXX: Wasn't the agreement after the last round of module flamage that
XXX: things shouldn't be module-only in GENERIC?


To generate a diff of this commit:
cvs rdiff -u -r1.472 -r1.473 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.472 src/sys/arch/amd64/conf/GENERIC:1.473
--- src/sys/arch/amd64/conf/GENERIC:1.472	Tue Dec  5 20:32:24 2017
+++ src/sys/arch/amd64/conf/GENERIC	Tue Dec  5 21:00:26 2017
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.472 2017/12/05 20:32:24 dholland Exp $
+# $NetBSD: GENERIC,v 1.473 2017/12/05 21:00:26 dholland Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.472 $"
+#ident		"GENERIC-$Revision: 1.473 $"
 
 maxusers	64		# estimated number of users
 
@@ -1117,6 +1117,7 @@ audio*	at audiobus?
 # The spkr driver provides a simple tone interface to the built in speaker.
 spkr*	at pcppi?		# PC speaker
 spkr*	at audio?		# PC speaker (synthesized)
+#wsbell* at spkr?		# Bell for wscons display (module by default)
 
 # MPU 401 UARTs
 #mpu*	at isa? port 0x330 irq 9	# MPU401 or compatible card



CVS commit: src/sys/arch/amd64/conf

2017-12-05 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Tue Dec  5 20:32:24 UTC 2017

Modified Files:
src/sys/arch/amd64/conf: GENERIC

Log Message:
Sort the file system options by which fs they apply to.


To generate a diff of this commit:
cvs rdiff -u -r1.471 -r1.472 src/sys/arch/amd64/conf/GENERIC

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

Modified files:

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.471 src/sys/arch/amd64/conf/GENERIC:1.472
--- src/sys/arch/amd64/conf/GENERIC:1.471	Sat Dec  2 13:03:15 2017
+++ src/sys/arch/amd64/conf/GENERIC	Tue Dec  5 20:32:24 2017
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.471 2017/12/02 13:03:15 maxv Exp $
+# $NetBSD: GENERIC,v 1.472 2017/12/05 20:32:24 dholland Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.471 $"
+#ident		"GENERIC-$Revision: 1.472 $"
 
 maxusers	64		# estimated number of users
 
@@ -164,19 +164,22 @@ file-system	PTYFS		# /dev/ptm support
 #file-system	NILFS		# experimental - NTT's NiLFS(2)
 
 # File system options
+# ffs
 options 	QUOTA		# legacy UFS quotas
 options 	QUOTA2		# new, in-filesystem UFS quotas
-#options 	DISKLABEL_EI	# disklabel Endian Independent support
 options 	FFS_EI		# FFS Endian Independent support
 options 	WAPBL		# File system journaling support
 # Note that UFS_DIRHASH is suspected of causing kernel memory corruption.
 # It is not recommended for general use.
 #options 	UFS_DIRHASH	# UFS Large Directory Hashing - Experimental
-options 	NFSSERVER	# Network File System server
-#options 	EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
-# immutable) behave as system flags.
 #options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
 options 	UFS_EXTATTR	# Extended attribute support for UFS1
+# ext2fs
+#options 	EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
+# immutable) behave as system flags.
+# other
+#options 	DISKLABEL_EI	# disklabel Endian Independent support
+options 	NFSSERVER	# Network File System server
 
 # Networking options
 #options 	GATEWAY		# packet forwarding



CVS commit: othersrc/external/bsd/agcre/dist

2017-12-05 Thread Alistair G. Crooks
Module Name:othersrc
Committed By:   agc
Date:   Tue Dec  5 20:01:06 UTC 2017

Modified Files:
othersrc/external/bsd/agcre/dist: exec.c
othersrc/external/bsd/agcre/dist/tests: 85.expected

Log Message:
initialise the input counter prior to making the first mark - fixes
REG_STARTEND searching

fix up a UTF-8 test results file


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 othersrc/external/bsd/agcre/dist/exec.c
cvs rdiff -u -r1.1 -r1.2 othersrc/external/bsd/agcre/dist/tests/85.expected

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

Modified files:

Index: othersrc/external/bsd/agcre/dist/exec.c
diff -u othersrc/external/bsd/agcre/dist/exec.c:1.2 othersrc/external/bsd/agcre/dist/exec.c:1.3
--- othersrc/external/bsd/agcre/dist/exec.c:1.2	Sun Dec  3 21:25:56 2017
+++ othersrc/external/bsd/agcre/dist/exec.c	Tue Dec  5 20:01:06 2017
@@ -446,9 +446,10 @@ agcre_regexec(agcre_re_t *agcre, const v
 	re->gen += 1;
 	prevflags = re->flags;
 	re->flags |= flags;
+	in.c = in.so;
 	addthread(re, current, newthread(re->prog, ctx), , 0, 1);
 	ret = AGCRE_REG_FAILURE;
-	for (in.ch = BOL, in.c = in.so ;  ; in.c += in.bytes) {
+	for (in.ch = BOL ;  ; in.c += in.bytes) {
 		if (current->nthreads == 0) {
 			break;
 		}

Index: othersrc/external/bsd/agcre/dist/tests/85.expected
diff -u othersrc/external/bsd/agcre/dist/tests/85.expected:1.1 othersrc/external/bsd/agcre/dist/tests/85.expected:1.2
--- othersrc/external/bsd/agcre/dist/tests/85.expected:1.1	Wed Aug 16 23:38:13 2017
+++ othersrc/external/bsd/agcre/dist/tests/85.expected	Tue Dec  5 20:01:06 2017
@@ -7,250 +7,11 @@ Nicer typography in plain text files:
   ║   • ‘single’ and “double” quotes ║
   ║   • Latin-1 apostrophe and accents: '´`  ║
 Combining characters:
-
-  STARGΛ̊TE SG-1, a = v̇ = r̈, a⃑ ⊥ b⃑
-
 Greek (in Polytonic):
-
-  The Greek anthem:
-
-  Σὲ γνωρίζω ἀπὸ τὴν κόψη
-  τοῦ σπαθιοῦ τὴν τρομερή,
-  σὲ γνωρίζω ἀπὸ τὴν ὄψη
-  ποὺ μὲ βία μετράει τὴ γῆ.
-
-  ᾿Απ᾿ τὰ κόκκαλα βγαλμένη
-  τῶν ῾Ελλήνων τὰ ἱερά
-  καὶ σὰν πρῶτα ἀνδρειωμένη
-  χαῖρε, ὦ χαῖρε, ᾿Ελευθεριά!
-
   From a speech of Demosthenes in the 4th century BC:
-
-  Οὐχὶ ταὐτὰ παρίσταταί μοι γιγνώσκειν, ὦ ἄνδρες ᾿Αθηναῖοι,
-  ὅταν τ᾿ εἰς τὰ πράγματα ἀποβλέψω καὶ ὅταν πρὸς τοὺς
-  λόγους οὓς ἀκούω· τοὺς μὲν γὰρ λόγους περὶ τοῦ
-  τιμωρήσασθαι Φίλιππον ὁρῶ γιγνομένους, τὰ δὲ πράγματ᾿
-  εἰς τοῦτο προήκοντα,  ὥσθ᾿ ὅπως μὴ πεισόμεθ᾿ αὐτοὶ
-  πρότερον κακῶς σκέψασθαι δέον. οὐδέν οὖν ἄλλο μοι δοκοῦσιν
-  οἱ τὰ τοιαῦτα λέγοντες ἢ τὴν ὑπόθεσιν, περὶ ἧς βουλεύεσθαι,
-  οὐχὶ τὴν οὖσαν παριστάντες ὑμῖν ἁμαρτάνειν. ἐγὼ δέ, ὅτι μέν
-  ποτ᾿ ἐξῆν τῇ πόλει καὶ τὰ αὑτῆς ἔχειν ἀσφαλῶς καὶ Φίλιππον
-  τιμωρήσασθαι, καὶ μάλ᾿ ἀκριβῶς οἶδα· ἐπ᾿ ἐμοῦ γάρ, οὐ πάλαι
-  γέγονεν ταῦτ᾿ ἀμφότερα· νῦν μέντοι πέπεισμαι τοῦθ᾿ ἱκανὸν
-  προλαβεῖν ἡμῖν εἶναι τὴν πρώτην, ὅπως τοὺς συμμάχους
-  σώσομεν. ἐὰν γὰρ τοῦτο βεβαίως ὑπάρξῃ, τότε καὶ περὶ τοῦ
-  τίνα τιμωρήσεταί τις καὶ ὃν τρόπον ἐξέσται σκοπεῖν· πρὶν δὲ
-  τὴν ἀρχὴν ὀρθῶς ὑποθέσθαι, μάταιον ἡγοῦμαι περὶ τῆς
-  τελευτῆς ὁντινοῦν ποιεῖσθαι λόγον.
-
-  Δημοσθένους, Γ´ ᾿Ολυνθιακὸς
-
-Georgian:
-
   From a Unicode conference invitation:
-
-  გთხოვთ ახლავე გაიაროთ რეგისტრაცია Unicode-ის მეათე საერთაშორისო
-  კონფერენციაზე დასასწრებად, რომელიც გაიმართება 10-12 მარტს,
-  ქ. მაინცში, გერმანიაში. კონფერენცია შეჰკრებს ერთად მსოფლიოს
-  ექსპერტებს ისეთ დარგებში როგორიცაა ინტერნეტი და Unicode-ი,
-  ინტერნაციონალიზაცია და ლოკალიზაცია, Unicode-ის გამოყენება
-  ოპერაციულ სისტემებსა, და გამოყენებით პროგრამებში, შრიფტებში,
-  ტექსტების დამუშავებასა და მრავალენოვან კომპიუტერულ სისტემებში.
-
-Russian:
-
   From a Unicode conference invitation:
-
-  Зарегистрируйтесь сейчас на Десятую Международную Конференцию по
-  Unicode, которая состоится 10-12 марта 1997 года в Майнце в Германии.
-  Конференция соберет широкий круг экспертов по  вопросам глобального
-  Интернета и Unicode, локализации и интернационализации, воплощению и
-  применению Unicode в различных операционных системах и программных
-  приложениях, шрифтах, верстке и многоязычных компьютерных системах.
-
-Thai (UCS Level 2):
-
   Excerpt from a poetry on The Romance of The Three Kingdoms (a Chinese
-  classic 'San Gua'):
-
-  [|]
-๏ แผ่นดินฮั่นเสื่อมโทรมแสนสังเวช  พระปกเกศกองบู๊กู้ขึ้นใหม่
-  สิบสองกษัตริย์ก่อนหน้าแลถัดไป   สององค์ไซร้โง่เขลาเบาปัญญา
-ทรงนับถือขันทีเป็นที่พึ่ง   บ้านเมืองจึงวิปริตเป็นนักหนา
-  โฮจิ๋นเรียกทัพทั่วหัวเมืองมา หมายจะฆ่ามดชั่วตัวสำคัญ
-เหมือนขับไสไล่เสือจากเคหา  รับหมาป่าเข้ามาเลยอาสัญ
-  ฝ่ายอ้องอุ้นยุแยกให้แตกกัน  ใช้สาวนั้นเป็นชนวนชื่นชวนใจ
-พลันลิฉุยกุยกีกลับก่อเหตุ  ช่างอาเพศจริงหนาฟ้าร้องไห้
-  ต้องรบราฆ่าฟันจนบรรลัย   ฤๅหาใครค้ำชูกู้บรรลังก์ ฯ
-
-  (The above is a two-column text. If combining characters are handled
-  correctly, the lines of the second column should be 

CVS commit: src/etc

2017-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec  5 19:17:11 UTC 2017

Modified Files:
src/etc: MAKEDEV.tmpl

Log Message:
make a few more drm nodes


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/etc/MAKEDEV.tmpl

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

Modified files:

Index: src/etc/MAKEDEV.tmpl
diff -u src/etc/MAKEDEV.tmpl:1.187 src/etc/MAKEDEV.tmpl:1.188
--- src/etc/MAKEDEV.tmpl:1.187	Sat Nov 25 16:31:03 2017
+++ src/etc/MAKEDEV.tmpl	Tue Dec  5 19:17:11 2017
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: MAKEDEV.tmpl,v 1.187 2017/11/25 16:31:03 jmcneill Exp $
+#	$NetBSD: MAKEDEV.tmpl,v 1.188 2017/12/05 19:17:11 jmcneill Exp $
 #
 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -835,7 +835,7 @@ all)
 	makedev drvctl
 	makedev video
 	makedev dtv
-	makedev drm0
+	makedev drm0 drm1 drm2 drm3
 	makedev altmem
 	makedev zfs
 	makedev lua



CVS commit: src/sys/external/bsd/drm2/drm

2017-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec  5 19:13:53 UTC 2017

Modified Files:
src/sys/external/bsd/drm2/drm: drm_drv.c

Log Message:
drm_stat: fix device minor calculation, ok riastradh@


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/external/bsd/drm2/drm/drm_drv.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/external/bsd/drm2/drm/drm_drv.c
diff -u src/sys/external/bsd/drm2/drm/drm_drv.c:1.19 src/sys/external/bsd/drm2/drm/drm_drv.c:1.20
--- src/sys/external/bsd/drm2/drm/drm_drv.c:1.19	Thu Nov 30 20:25:55 2017
+++ src/sys/external/bsd/drm2/drm/drm_drv.c	Tue Dec  5 19:13:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: drm_drv.c,v 1.19 2017/11/30 20:25:55 christos Exp $	*/
+/*	$NetBSD: drm_drv.c,v 1.20 2017/12/05 19:13:52 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.19 2017/11/30 20:25:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_drv.c,v 1.20 2017/12/05 19:13:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -586,7 +586,7 @@ drm_stat(struct file *fp, struct stat *s
 	struct drm_file *const file = fp->f_data;
 	struct drm_minor *const dminor = file->minor;
 	const dev_t devno = makedev(cdevsw_lookup_major(_cdevsw),
-	64*dminor->index + dminor->type);
+	64*dminor->type + dminor->index);
 
 	(void)memset(st, 0, sizeof(*st));
 



CVS commit: src/sys/dev/pckbport

2017-12-05 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec  5 18:04:21 UTC 2017

Modified Files:
src/sys/dev/pckbport: synaptics.c

Log Message:
Add hw.synaptics.movement_enable sysctl. Default value is 1, but if set
to 0 disables movement events from the touchpad.

While here, fixup a few sysctl nodenum comparisons in
pms_sysctl_synaptics_verify to compare against node numbers instead of
values.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/pckbport/synaptics.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/dev/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.35 src/sys/dev/pckbport/synaptics.c:1.36
--- src/sys/dev/pckbport/synaptics.c:1.35	Tue Nov  7 12:39:07 2017
+++ src/sys/dev/pckbport/synaptics.c	Tue Dec  5 18:04:21 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.35 2017/11/07 12:39:07 ryoon Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.36 2017/12/05 18:04:21 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.35 2017/11/07 12:39:07 ryoon Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.36 2017/12/05 18:04:21 jmcneill Exp $");
 
 #include 
 #include 
@@ -118,6 +118,7 @@ static int synaptics_scale_y = 16;
 static int synaptics_max_speed_x = 32;
 static int synaptics_max_speed_y = 32;
 static int synaptics_movement_threshold = 4;
+static int synaptics_movement_enable = 1;
 
 /* Sysctl nodes. */
 static int synaptics_button_boundary_nodenum;
@@ -140,6 +141,7 @@ static int synaptics_scale_y_nodenum;
 static int synaptics_max_speed_x_nodenum;
 static int synaptics_max_speed_y_nodenum;
 static int synaptics_movement_threshold_nodenum;
+static int synaptics_movement_enable_nodenum;
 
 static int
 synaptics_poll_cmd(struct pms_softc *psc, ...)
@@ -714,6 +716,18 @@ pms_sysctl_synaptics(struct sysctllog **
 
 	if ((rc = sysctl_createv(clog, 0, NULL, ,
 	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
+	CTLTYPE_INT, "movement_enable",
+	SYSCTL_DESCR("Enable movement reporting"),
+	pms_sysctl_synaptics_verify, 0,
+	_movement_enable,
+	0, CTL_HW, root_num, CTL_CREATE,
+	CTL_EOL)) != 0)
+		goto err;
+
+	synaptics_movement_enable_nodenum = node->sysctl_num;
+
+	if ((rc = sysctl_createv(clog, 0, NULL, ,
+	CTLFLAG_PERMANENT | CTLFLAG_READWRITE,
 	CTLTYPE_INT, "button_boundary",
 	SYSCTL_DESCR("Top edge of button area"),
 	pms_sysctl_synaptics_verify, 0,
@@ -808,16 +822,20 @@ pms_sysctl_synaptics_verify(SYSCTLFN_ARG
 		if (t < 0 || t > (SYNAPTICS_EDGE_MAX / 4))
 			return (EINVAL);
 	} else
-	if (node.sysctl_num == synaptics_button_boundary) {
+	if (node.sysctl_num == synaptics_button_boundary_nodenum) {
 		if (t < 0 || t < SYNAPTICS_EDGE_BOTTOM || 
 		t > SYNAPTICS_EDGE_TOP)
 			return (EINVAL);
 	} else
-	if (node.sysctl_num == synaptics_button2 ||
-	node.sysctl_num == synaptics_button3) {
+	if (node.sysctl_num == synaptics_button2_nodenum ||
+	node.sysctl_num == synaptics_button3_nodenum) {
 		if (t < SYNAPTICS_EDGE_LEFT || t > SYNAPTICS_EDGE_RIGHT)
 			return (EINVAL);
 	} else
+	if (node.sysctl_num == synaptics_movement_enable_nodenum) {
+		if (t < 0 || t > 1)
+			return (EINVAL);
+	} else
 		return (EINVAL);
 
 	*(int *)rnode->sysctl_data = t;
@@ -1558,7 +1576,7 @@ pms_synaptics_process_packet(struct pms_
 	 * Do movement processing IFF we have a single finger and no palm or
 	 * a secondary finger and no palm.
 	 */
-	if (palm == 0) {
+	if (palm == 0 && synaptics_movement_enable) {
 		if (fingers == 1) {
 			synaptics_movement(sc, sp, sp->sp_finger, , );
 		} else {