Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Use curlwp_bind and curlwp_bindx instead of open-coding ...



details:   https://anonhg.NetBSD.org/src/rev/78f71ba19a62
branches:  trunk
changeset: 816074:78f71ba19a62
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Jun 16 02:38:40 2016 +0000

description:
Use curlwp_bind and curlwp_bindx instead of open-coding LP_BOUND

diffstat:

 sys/compat/common/uipc_syscalls_40.c       |  12 +++++-----
 sys/compat/linux/common/linux_socket.c     |  12 +++++-----
 sys/compat/linux32/common/linux32_socket.c |  12 +++++-----
 sys/dist/pf/net/pf_if.c                    |  16 +++++++-------
 sys/kern/uipc_mbuf.c                       |   9 +++----
 sys/net/if.c                               |  33 ++++++++++++++---------------
 sys/net/rtsock.c                           |  11 ++++-----
 sys/netinet/ip_carp.c                      |   9 +++----
 sys/netinet6/raw_ip6.c                     |  10 +++-----
 sys/rump/net/lib/libshmif/if_shmem.c       |  10 ++++----
 sys/rump/net/lib/libvirtif/if_virt.c       |  10 ++++----
 11 files changed, 69 insertions(+), 75 deletions(-)

diffs (truncated from 594 to 300 lines):

diff -r 4ee12437df71 -r 78f71ba19a62 sys/compat/common/uipc_syscalls_40.c
--- a/sys/compat/common/uipc_syscalls_40.c      Thu Jun 16 02:34:33 2016 +0000
+++ b/sys/compat/common/uipc_syscalls_40.c      Thu Jun 16 02:38:40 2016 +0000
@@ -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 @@
        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 @@
                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 @@
                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 @@
 
 release_exit:
        psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-       curlwp->l_pflag ^= bound ^ LP_BOUND;
+       curlwp_bindx(bound);
        return error;
 }
 #endif
diff -r 4ee12437df71 -r 78f71ba19a62 sys/compat/linux/common/linux_socket.c
--- a/sys/compat/linux/common/linux_socket.c    Thu Jun 16 02:34:33 2016 +0000
+++ b/sys/compat/linux/common/linux_socket.c    Thu Jun 16 02:38:40 2016 +0000
@@ -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 @@
        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 @@
                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 @@
                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 @@
 
 release_exit:
        psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-       curlwp->l_pflag ^= bound ^ LP_BOUND;
+       curlwp_bindx(bound);
        return error;
 }
 
diff -r 4ee12437df71 -r 78f71ba19a62 sys/compat/linux32/common/linux32_socket.c
--- a/sys/compat/linux32/common/linux32_socket.c        Thu Jun 16 02:34:33 2016 +0000
+++ b/sys/compat/linux32/common/linux32_socket.c        Thu Jun 16 02:38:40 2016 +0000
@@ -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 @@
        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 @@
                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 @@
                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 @@
 
 release_exit:
        psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
-       curlwp->l_pflag ^= bound ^ LP_BOUND;
+       curlwp_bindx(bound);
        return error;
 }
 
diff -r 4ee12437df71 -r 78f71ba19a62 sys/dist/pf/net/pf_if.c
--- a/sys/dist/pf/net/pf_if.c   Thu Jun 16 02:34:33 2016 +0000
+++ b/sys/dist/pf/net/pf_if.c   Thu Jun 16 02:38:40 2016 +0000
@@ -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 @@
 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 @@
 
 #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 @@
                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 @@
        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 @@
                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);
diff -r 4ee12437df71 -r 78f71ba19a62 sys/kern/uipc_mbuf.c
--- a/sys/kern/uipc_mbuf.c      Thu Jun 16 02:34:33 2016 +0000
+++ b/sys/kern/uipc_mbuf.c      Thu Jun 16 02:38:40 2016 +0000
@@ -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 @@
        }
        /* 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 @@
                        psref_release(&psref, &ifp->if_psref,
                            ifnet_psref_class);
                }
-               curlwp->l_pflag ^= bound ^ LP_BOUND;
+               curlwp_bindx(bound);
        }
        splx(s);
        mbstat.m_drain++;
diff -r 4ee12437df71 -r 78f71ba19a62 sys/net/if.c
--- a/sys/net/if.c      Thu Jun 16 02:34:33 2016 +0000
+++ b/sys/net/if.c      Thu Jun 16 02:38:40 2016 +0000
@@ -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 @@
 {
        struct ifnet *ifp;
        int s;
-       int bound = curlwp->l_pflag & LP_BOUND;
-
-       curlwp->l_pflag |= LP_BOUND;
+       int bound = curlwp_bind();
+
        s = pserialize_read_enter();
        IFNET_READER_FOREACH(ifp) {
                struct psref psref;
@@ -954,7 +953,7 @@
                psref_release(&psref, &ifp->if_psref, ifnet_psref_class);
        }
        pserialize_read_exit(s);
-       curlwp->l_pflag ^= bound ^ LP_BOUND;



Home | Main Index | Thread Index | Old Index