Module Name:    src
Committed By:   ozaki-r
Date:           Thu Jun 16 02:38:40 UTC 2016

Modified Files:
        src/sys/compat/common: uipc_syscalls_40.c
        src/sys/compat/linux/common: linux_socket.c
        src/sys/compat/linux32/common: linux32_socket.c
        src/sys/dist/pf/net: pf_if.c
        src/sys/kern: uipc_mbuf.c
        src/sys/net: if.c rtsock.c
        src/sys/netinet: ip_carp.c
        src/sys/netinet6: raw_ip6.c
        src/sys/rump/net/lib/libshmif: if_shmem.c
        src/sys/rump/net/lib/libvirtif: if_virt.c

Log Message:
Use curlwp_bind and curlwp_bindx instead of open-coding LP_BOUND


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/compat/common/uipc_syscalls_40.c
cvs rdiff -u -r1.128 -r1.129 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.22 -r1.23 src/sys/compat/linux32/common/linux32_socket.c
cvs rdiff -u -r1.27 -r1.28 src/sys/dist/pf/net/pf_if.c
cvs rdiff -u -r1.167 -r1.168 src/sys/kern/uipc_mbuf.c
cvs rdiff -u -r1.338 -r1.339 src/sys/net/if.c
cvs rdiff -u -r1.189 -r1.190 src/sys/net/rtsock.c
cvs rdiff -u -r1.67 -r1.68 src/sys/netinet/ip_carp.c
cvs rdiff -u -r1.144 -r1.145 src/sys/netinet6/raw_ip6.c
cvs rdiff -u -r1.67 -r1.68 src/sys/rump/net/lib/libshmif/if_shmem.c
cvs rdiff -u -r1.52 -r1.53 src/sys/rump/net/lib/libvirtif/if_virt.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/common/uipc_syscalls_40.c
diff -u src/sys/compat/common/uipc_syscalls_40.c:1.9 src/sys/compat/common/uipc_syscalls_40.c:1.10
--- src/sys/compat/common/uipc_syscalls_40.c:1.9	Thu May 12 02:24:16 2016
+++ src/sys/compat/common/uipc_syscalls_40.c	Thu Jun 16 02:38:40 2016
@@ -1,9 +1,9 @@
-/*	$NetBSD: uipc_syscalls_40.c,v 1.9 2016/05/12 02:24:16 ozaki-r Exp $	*/
+/*	$NetBSD: uipc_syscalls_40.c,v 1.10 2016/06/16 02:38:40 ozaki-r Exp $	*/
 
 /* written by Pavel Cahyna, 2006. Public domain. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.9 2016/05/12 02:24:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls_40.c,v 1.10 2016/06/16 02:38:40 ozaki-r Exp $");
 
 /*
  * System call interface to the socket abstraction.
@@ -40,7 +40,7 @@ compat_ifconf(u_long cmd, void *data)
 	const int sz = (int)sizeof(ifr);
 	const bool docopy = ifc->ifc_req != NULL;
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound;
 	struct psref psref;
 
 	if (docopy) {
@@ -48,7 +48,7 @@ compat_ifconf(u_long cmd, void *data)
 		ifrp = ifc->ifc_req;
 	}
 
-	curlwp->l_pflag |= LP_BOUND;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
@@ -121,7 +121,7 @@ compat_ifconf(u_long cmd, void *data)
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 
 	if (docopy)
 		ifc->ifc_len -= space;
@@ -131,7 +131,7 @@ compat_ifconf(u_long cmd, void *data)
 
 release_exit:
 	psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 	return error;
 }
 #endif

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.128 src/sys/compat/linux/common/linux_socket.c:1.129
--- src/sys/compat/linux/common/linux_socket.c:1.128	Wed Jun 15 06:01:21 2016
+++ src/sys/compat/linux/common/linux_socket.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.128 2016/06/15 06:01:21 ozaki-r Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.129 2016/06/16 02:38:40 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.128 2016/06/15 06:01:21 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.129 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1124,7 +1124,7 @@ linux_getifconf(struct lwp *l, register_
 	const int sz = (int)sizeof(ifr);
 	bool docopy;
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound;
 	struct psref psref;
 
 	error = copyin(data, &ifc, sizeof(ifc));
@@ -1137,7 +1137,7 @@ linux_getifconf(struct lwp *l, register_
 		ifrp = ifc.ifc_req;
 	}
 
-	curlwp->l_pflag |= LP_BOUND;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
@@ -1172,7 +1172,7 @@ linux_getifconf(struct lwp *l, register_
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 
 	if (docopy)
 		ifc.ifc_len -= space;
@@ -1183,7 +1183,7 @@ linux_getifconf(struct lwp *l, register_
 
 release_exit:
 	psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 	return error;
 }
 

Index: src/sys/compat/linux32/common/linux32_socket.c
diff -u src/sys/compat/linux32/common/linux32_socket.c:1.22 src/sys/compat/linux32/common/linux32_socket.c:1.23
--- src/sys/compat/linux32/common/linux32_socket.c:1.22	Wed Jun 15 06:01:21 2016
+++ src/sys/compat/linux32/common/linux32_socket.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux32_socket.c,v 1.22 2016/06/15 06:01:21 ozaki-r Exp $ */
+/*	$NetBSD: linux32_socket.c,v 1.23 2016/06/16 02:38:40 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.22 2016/06/15 06:01:21 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_socket.c,v 1.23 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -425,7 +425,7 @@ linux32_getifconf(struct lwp *l, registe
 	const int sz = (int)sizeof(ifr);
 	bool docopy;
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound;
 	struct psref psref;
 
 	error = copyin(data, &ifc, sizeof(ifc));
@@ -438,7 +438,7 @@ linux32_getifconf(struct lwp *l, registe
 		ifrp = NETBSD32PTR64(ifc.ifc_req);
 	}
 
-	curlwp->l_pflag |= LP_BOUND;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
@@ -473,7 +473,7 @@ linux32_getifconf(struct lwp *l, registe
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 
 	if (docopy)
 		ifc.ifc_len -= space;
@@ -484,7 +484,7 @@ linux32_getifconf(struct lwp *l, registe
 
 release_exit:
 	psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 	return error;
 }
 

Index: src/sys/dist/pf/net/pf_if.c
diff -u src/sys/dist/pf/net/pf_if.c:1.27 src/sys/dist/pf/net/pf_if.c:1.28
--- src/sys/dist/pf/net/pf_if.c:1.27	Thu May 12 02:24:16 2016
+++ src/sys/dist/pf/net/pf_if.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: pf_if.c,v 1.27 2016/05/12 02:24:16 ozaki-r Exp $	*/
+/*	$NetBSD: pf_if.c,v 1.28 2016/06/16 02:38:40 ozaki-r Exp $	*/
 /*	$OpenBSD: pf_if.c,v 1.47 2007/07/13 09:17:48 markus Exp $ */
 
 /*
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.27 2016/05/12 02:24:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pf_if.c,v 1.28 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -101,7 +101,7 @@ void
 pfi_initialize(void)
 {
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound;
 
 	if (pfi_all != NULL)	/* already initialized */
 		return;
@@ -122,7 +122,7 @@ pfi_initialize(void)
 
 #ifdef __NetBSD__
 	ifnet_t *ifp;
-	curlwp->l_pflag |= LP_BOUND;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		struct psref psref;
@@ -136,7 +136,7 @@ pfi_initialize(void)
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 
 	pfil_add_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
 	pfil_add_hook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
@@ -150,12 +150,12 @@ pfi_destroy(void)
 	struct pfi_kif *p;
 	ifnet_t *ifp;
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound;
 
 	pfil_remove_hook(pfil_ifaddr_wrapper, NULL, PFIL_IFADDR, if_pfil);
 	pfil_remove_hook(pfil_ifnet_wrapper, NULL, PFIL_IFNET, if_pfil);
 
-	curlwp->l_pflag |= LP_BOUND;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		struct psref psref;
@@ -169,7 +169,7 @@ pfi_destroy(void)
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 
 	while ((p = RB_MIN(pfi_ifhead, &pfi_ifs))) {
 		RB_REMOVE(pfi_ifhead, &pfi_ifs, p);

Index: src/sys/kern/uipc_mbuf.c
diff -u src/sys/kern/uipc_mbuf.c:1.167 src/sys/kern/uipc_mbuf.c:1.168
--- src/sys/kern/uipc_mbuf.c:1.167	Fri Jun 10 13:31:44 2016
+++ src/sys/kern/uipc_mbuf.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_mbuf.c,v 1.167 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: uipc_mbuf.c,v 1.168 2016/06/16 02:38:40 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.167 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_mbuf.c,v 1.168 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mbuftrace.h"
@@ -558,8 +558,7 @@ m_reclaim(void *arg, int flags)
 	}
 	/* XXX we cannot use psref in H/W interrupt */
 	if (!cpu_intr_p()) {
-		int bound = curlwp->l_pflag & LP_BOUND;
-		curlwp->l_pflag |= LP_BOUND;
+		int bound = curlwp_bind();
 		IFNET_READER_FOREACH(ifp) {
 			struct psref psref;
 
@@ -572,7 +571,7 @@ m_reclaim(void *arg, int flags)
 			psref_release(&psref, &ifp->if_psref,
 			    ifnet_psref_class);
 		}
-		curlwp->l_pflag ^= bound ^ LP_BOUND;
+		curlwp_bindx(bound);
 	}
 	splx(s);
 	mbstat.m_drain++;

Index: src/sys/net/if.c
diff -u src/sys/net/if.c:1.338 src/sys/net/if.c:1.339
--- src/sys/net/if.c:1.338	Fri Jun 10 13:31:44 2016
+++ src/sys/net/if.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.338 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: if.c,v 1.339 2016/06/16 02:38:40 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.338 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.339 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -941,9 +941,8 @@ if_attachdomain(void)
 {
 	struct ifnet *ifp;
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound = curlwp_bind();
 
-	curlwp->l_pflag |= LP_BOUND;
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		struct psref psref;
@@ -954,7 +953,7 @@ if_attachdomain(void)
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 }
 
 static void
@@ -2478,7 +2477,7 @@ doifioctl(struct socket *so, u_long cmd,
 #endif
 	int r;
 	struct psref psref;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound;
 
 	switch (cmd) {
 #ifdef COMPAT_OIFREQ
@@ -2510,7 +2509,7 @@ doifioctl(struct socket *so, u_long cmd,
 	switch (cmd) {
 	case SIOCIFCREATE:
 	case SIOCIFDESTROY:
-		curlwp->l_pflag |= LP_BOUND;
+		bound = curlwp_bind();
 		if (l != NULL) {
 			ifp = if_get(ifr->ifr_name, &psref);
 			error = kauth_authorize_network(l->l_cred,
@@ -2520,7 +2519,7 @@ doifioctl(struct socket *so, u_long cmd,
 			if (ifp != NULL)
 				if_put(ifp, &psref);
 			if (error != 0) {
-				curlwp->l_pflag ^= bound ^ LP_BOUND;
+				curlwp_bindx(bound);
 				return error;
 			}
 		}
@@ -2529,7 +2528,7 @@ doifioctl(struct socket *so, u_long cmd,
 			if_clone_create(ifr->ifr_name) :
 			if_clone_destroy(ifr->ifr_name);
 		mutex_exit(&if_clone_mtx);
-		curlwp->l_pflag ^= bound ^ LP_BOUND;
+		curlwp_bindx(bound);
 		return r;
 
 	case SIOCIFGCLONERS:
@@ -2540,10 +2539,10 @@ doifioctl(struct socket *so, u_long cmd,
 		}
 	}
 
-	curlwp->l_pflag |= LP_BOUND;
+	bound = curlwp_bind();
 	ifp = if_get(ifr->ifr_name, &psref);
 	if (ifp == NULL) {
-		curlwp->l_pflag ^= bound ^ LP_BOUND;
+		curlwp_bindx(bound);
 		return ENXIO;
 	}
 
@@ -2617,7 +2616,7 @@ doifioctl(struct socket *so, u_long cmd,
 	mutex_exit(ifp->if_ioctl_lock);
 out:
 	if_put(ifp, &psref);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 	return error;
 }
 
@@ -2661,7 +2660,7 @@ ifconf(u_long cmd, void *data)
 	const int sz = (int)sizeof(struct ifreq);
 	const bool docopy = ifc->ifc_req != NULL;
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound;
 	struct psref psref;
 
 	if (docopy) {
@@ -2669,7 +2668,7 @@ ifconf(u_long cmd, void *data)
 		ifrp = ifc->ifc_req;
 	}
 
-	curlwp->l_pflag |= LP_BOUND;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		psref_acquire(&psref, &ifp->if_psref, ifnet_psref_class);
@@ -2719,7 +2718,7 @@ ifconf(u_long cmd, void *data)
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 
 	if (docopy) {
 		KASSERT(0 <= space && space <= ifc->ifc_len);
@@ -2732,7 +2731,7 @@ ifconf(u_long cmd, void *data)
 
 release_exit:
 	psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 	return error;
 }
 

Index: src/sys/net/rtsock.c
diff -u src/sys/net/rtsock.c:1.189 src/sys/net/rtsock.c:1.190
--- src/sys/net/rtsock.c:1.189	Fri Jun 10 13:27:16 2016
+++ src/sys/net/rtsock.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtsock.c,v 1.189 2016/06/10 13:27:16 ozaki-r Exp $	*/
+/*	$NetBSD: rtsock.c,v 1.190 2016/06/16 02:38:40 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.189 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.190 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1460,11 +1460,10 @@ sysctl_iflist(int af, struct rt_walkarg 
 	int	len, error = 0;
 	int s;
 	struct psref psref;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound = curlwp_bind();
 
 	memset(&info, 0, sizeof(info));
 
-	curlwp->l_pflag |= LP_BOUND;
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		if (w->w_arg && w->w_arg != ifp->if_index)
@@ -1560,13 +1559,13 @@ sysctl_iflist(int af, struct rt_walkarg 
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 
 	return 0;
 
 release_exit:
 	psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 	return error;
 }
 

Index: src/sys/netinet/ip_carp.c
diff -u src/sys/netinet/ip_carp.c:1.67 src/sys/netinet/ip_carp.c:1.68
--- src/sys/netinet/ip_carp.c:1.67	Fri Jun 10 13:31:44 2016
+++ src/sys/netinet/ip_carp.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_carp.c,v 1.67 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: ip_carp.c,v 1.68 2016/06/16 02:38:40 ozaki-r Exp $	*/
 /*	$OpenBSD: ip_carp.c,v 1.113 2005/11/04 08:11:54 mcbride Exp $	*/
 
 /*
@@ -33,7 +33,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.67 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_carp.c,v 1.68 2016/06/16 02:38:40 ozaki-r Exp $");
 
 /*
  * TODO:
@@ -933,9 +933,8 @@ carp_send_ad_all(void)
 	struct carp_if *cif;
 	struct carp_softc *vh;
 	int s;
-	int bound = curlwp->l_pflag & LP_BOUND;
+	int bound = curlwp_bind();
 
-	curlwp->l_pflag |= LP_BOUND;
 	s = pserialize_read_enter();
 	IFNET_READER_FOREACH(ifp) {
 		struct psref psref;
@@ -956,7 +955,7 @@ carp_send_ad_all(void)
 		psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
 	}
 	pserialize_read_exit(s);
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 }
 
 

Index: src/sys/netinet6/raw_ip6.c
diff -u src/sys/netinet6/raw_ip6.c:1.144 src/sys/netinet6/raw_ip6.c:1.145
--- src/sys/netinet6/raw_ip6.c:1.144	Fri Jun 10 13:31:44 2016
+++ src/sys/netinet6/raw_ip6.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: raw_ip6.c,v 1.144 2016/06/10 13:31:44 ozaki-r Exp $	*/
+/*	$NetBSD: raw_ip6.c,v 1.145 2016/06/16 02:38:40 ozaki-r Exp $	*/
 /*	$KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $	*/
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.144 2016/06/10 13:31:44 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.145 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -387,9 +387,7 @@ rip6_output(struct mbuf *m, struct socke
 	int type, code;		/* for ICMPv6 output statistics only */
 	int scope_ambiguous = 0;
 	struct in6_addr *in6a;
-	int bound = curlwp->l_pflag & LP_BOUND;
-
-	curlwp->l_pflag |= LP_BOUND;
+	int bound = curlwp_bind();
 
 	in6p = sotoin6pcb(so);
 
@@ -536,7 +534,7 @@ rip6_output(struct mbuf *m, struct socke
 		ip6_clearpktopts(&opt, -1);
 		m_freem(control);
 	}
-	curlwp->l_pflag ^= bound ^ LP_BOUND;
+	curlwp_bindx(bound);
 	return error;
 }
 

Index: src/sys/rump/net/lib/libshmif/if_shmem.c
diff -u src/sys/rump/net/lib/libshmif/if_shmem.c:1.67 src/sys/rump/net/lib/libshmif/if_shmem.c:1.68
--- src/sys/rump/net/lib/libshmif/if_shmem.c:1.67	Fri Jun 10 13:27:16 2016
+++ src/sys/rump/net/lib/libshmif/if_shmem.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_shmem.c,v 1.67 2016/06/10 13:27:16 ozaki-r Exp $	*/
+/*	$NetBSD: if_shmem.c,v 1.68 2016/06/16 02:38:40 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2009, 2010 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.67 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_shmem.c,v 1.68 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -764,14 +764,14 @@ shmif_rcv(void *arg)
 		}
 
 		if (passup) {
-			int bound = curlwp->l_pflag & LP_BOUND;
+			int bound;
 			ifp->if_ipackets++;
 			KERNEL_LOCK(1, NULL);
 			/* Prevent LWP migrations between CPUs for psref(9) */
-			curlwp->l_pflag |= LP_BOUND;
+			bound = curlwp_bind();
 			bpf_mtap(ifp, m);
 			if_input(ifp, m);
-			curlwp->l_pflag ^= bound ^ LP_BOUND;
+			curlwp_bindx(bound);
 			KERNEL_UNLOCK_ONE(NULL);
 			m = NULL;
 		}

Index: src/sys/rump/net/lib/libvirtif/if_virt.c
diff -u src/sys/rump/net/lib/libvirtif/if_virt.c:1.52 src/sys/rump/net/lib/libvirtif/if_virt.c:1.53
--- src/sys/rump/net/lib/libvirtif/if_virt.c:1.52	Fri Jun 10 13:27:17 2016
+++ src/sys/rump/net/lib/libvirtif/if_virt.c	Thu Jun 16 02:38:40 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_virt.c,v 1.52 2016/06/10 13:27:17 ozaki-r Exp $	*/
+/*	$NetBSD: if_virt.c,v 1.53 2016/06/16 02:38:40 ozaki-r Exp $	*/
 
 /*
  * Copyright (c) 2008, 2013 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.52 2016/06/10 13:27:17 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_virt.c,v 1.53 2016/06/16 02:38:40 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -374,15 +374,15 @@ VIF_DELIVERPKT(struct virtif_sc *sc, str
 	}
 
 	if (passup) {
-		int bound = curlwp->l_pflag & LP_BOUND;
+		int bound;
 		ifp->if_ipackets++;
 		m_set_rcvif(m, ifp);
 		KERNEL_LOCK(1, NULL);
 		/* Prevent LWP migrations between CPUs for psref(9) */
-		curlwp->l_pflag |= LP_BOUND;
+		bound = curlwp_bind();
 		bpf_mtap(ifp, m);
 		if_input(ifp, m);
-		curlwp->l_pflag ^= bound ^ LP_BOUND;
+		curlwp_bindx(bound);
 		KERNEL_UNLOCK_LAST(NULL);
 	} else {
 		m_freem(m);

Reply via email to