Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys split PRU_BIND and PRU_LISTEN function out of pr_generic...
details: https://anonhg.NetBSD.org/src/rev/35c14595c11f
branches: trunk
changeset: 330857:35c14595c11f
user: rtr <rtr%NetBSD.org@localhost>
date: Thu Jul 24 15:12:03 2014 +0000
description:
split PRU_BIND and PRU_LISTEN function out of pr_generic() usrreq
switches and put into separate functions
xxx_bind(struct socket *, struct mbuf *)
xxx_listen(struct socket *)
- always KASSERT(solocked(so)) even if not implemented
- replace calls to pr_generic() with req = PRU_BIND with call to
pr_bind()
- replace calls to pr_generic() with req = PRU_LISTEN with call to
pr_listen()
- drop struct lwp * parameter from at_pcbsetaddr(), in_pcbbind() and
unp_bind() and always use curlwp.
rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_{bind,listen}() PRUs
- l2cap_{bind,listen}() -> l2cap_{bind,listen}_pcb()
- sco_{bind,listen}() -> sco_{bind,listen}_pcb()
- rfcomm_{bind,listen}() -> rfcomm_{bind,listen}_pcb()
patch reviewed by rmind
welcome to netbsd 6.99.48
diffstat:
sys/dev/bluetooth/bthidev.c | 18 +-
sys/dev/bluetooth/btmagic.c | 18 +-
sys/dev/bluetooth/btsco.c | 10 +-
sys/kern/uipc_socket.c | 10 +-
sys/kern/uipc_usrreq.c | 55 +++++---
sys/net/link_proto.c | 37 +++++-
sys/net/raw_usrreq.c | 8 +-
sys/net/rtsock.c | 26 +++-
sys/netatalk/ddp_usrreq.c | 42 ++++-
sys/netbt/hci_socket.c | 65 ++++++---
sys/netbt/l2cap.h | 8 +-
sys/netbt/l2cap_socket.c | 60 ++++++--
sys/netbt/l2cap_upper.c | 12 +-
sys/netbt/rfcomm.h | 8 +-
sys/netbt/rfcomm_session.c | 6 +-
sys/netbt/rfcomm_socket.c | 60 ++++++--
sys/netbt/rfcomm_upper.c | 14 +-
sys/netbt/sco.h | 6 +-
sys/netbt/sco_socket.c | 60 ++++++--
sys/netbt/sco_upper.c | 12 +-
sys/netinet/in_pcb.c | 12 +-
sys/netinet/in_pcb.h | 4 +-
sys/netinet/raw_ip.c | 85 ++++++++----
sys/netinet/tcp_usrreq.c | 228 +++++++++++++++++++++++++++++++----
sys/netinet/udp_usrreq.c | 47 +++++-
sys/netinet6/in6_pcb.c | 12 +-
sys/netinet6/in6_pcb.h | 4 +-
sys/netinet6/raw_ip6.c | 96 ++++++++------
sys/netinet6/udp6_usrreq.c | 41 +++++-
sys/netipsec/keysock.c | 26 +++-
sys/netmpls/mpls_proto.c | 24 +++-
sys/netnatm/natm.c | 28 +++-
sys/rump/net/lib/libsockin/sockin.c | 37 +++-
sys/sys/param.h | 4 +-
sys/sys/protosw.h | 22 +++-
sys/sys/un.h | 4 +-
36 files changed, 868 insertions(+), 341 deletions(-)
diffs (truncated from 2689 to 300 lines):
diff -r 8fe1b4ccb09d -r 35c14595c11f sys/dev/bluetooth/bthidev.c
--- a/sys/dev/bluetooth/bthidev.c Thu Jul 24 15:11:09 2014 +0000
+++ b/sys/dev/bluetooth/bthidev.c Thu Jul 24 15:12:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bthidev.c,v 1.25 2014/05/20 18:25:54 rmind Exp $ */
+/* $NetBSD: bthidev.c,v 1.26 2014/07/24 15:12:03 rtr Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.25 2014/05/20 18:25:54 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.26 2014/07/24 15:12:03 rtr Exp $");
#include <sys/param.h>
#include <sys/condvar.h>
@@ -508,11 +508,11 @@
return err;
sa.bt_psm = sc->sc_ctlpsm;
- err = l2cap_bind(sc->sc_ctl_l, &sa);
+ err = l2cap_bind_pcb(sc->sc_ctl_l, &sa);
if (err)
return err;
- err = l2cap_listen(sc->sc_ctl_l);
+ err = l2cap_listen_pcb(sc->sc_ctl_l);
if (err)
return err;
@@ -528,11 +528,11 @@
return err;
sa.bt_psm = sc->sc_intpsm;
- err = l2cap_bind(sc->sc_int_l, &sa);
+ err = l2cap_bind_pcb(sc->sc_int_l, &sa);
if (err)
return err;
- err = l2cap_listen(sc->sc_int_l);
+ err = l2cap_listen_pcb(sc->sc_int_l);
if (err)
return err;
@@ -569,9 +569,9 @@
}
bdaddr_copy(&sa.bt_bdaddr, &sc->sc_laddr);
- err = l2cap_bind(sc->sc_ctl, &sa);
+ err = l2cap_bind_pcb(sc->sc_ctl, &sa);
if (err) {
- aprint_error_dev(sc->sc_dev, "l2cap_bind failed (%d)\n", err);
+ aprint_error_dev(sc->sc_dev, "l2cap_bind_pcb failed (%d)\n", err);
return err;
}
@@ -747,7 +747,7 @@
sa.bt_family = AF_BLUETOOTH;
bdaddr_copy(&sa.bt_bdaddr, &sc->sc_laddr);
- err = l2cap_bind(sc->sc_int, &sa);
+ err = l2cap_bind_pcb(sc->sc_int, &sa);
if (err)
goto fail;
diff -r 8fe1b4ccb09d -r 35c14595c11f sys/dev/bluetooth/btmagic.c
--- a/sys/dev/bluetooth/btmagic.c Thu Jul 24 15:11:09 2014 +0000
+++ b/sys/dev/bluetooth/btmagic.c Thu Jul 24 15:12:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: btmagic.c,v 1.7 2014/05/20 18:25:54 rmind Exp $ */
+/* $NetBSD: btmagic.c,v 1.8 2014/07/24 15:12:03 rtr Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -85,7 +85,7 @@
*****************************************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.7 2014/05/20 18:25:54 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.8 2014/07/24 15:12:03 rtr Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -472,11 +472,11 @@
return err;
sa.bt_psm = L2CAP_PSM_HID_CNTL;
- err = l2cap_bind(sc->sc_ctl_l, &sa);
+ err = l2cap_bind_pcb(sc->sc_ctl_l, &sa);
if (err)
return err;
- err = l2cap_listen(sc->sc_ctl_l);
+ err = l2cap_listen_pcb(sc->sc_ctl_l);
if (err)
return err;
@@ -492,11 +492,11 @@
return err;
sa.bt_psm = L2CAP_PSM_HID_INTR;
- err = l2cap_bind(sc->sc_int_l, &sa);
+ err = l2cap_bind_pcb(sc->sc_int_l, &sa);
if (err)
return err;
- err = l2cap_listen(sc->sc_int_l);
+ err = l2cap_listen_pcb(sc->sc_int_l);
if (err)
return err;
@@ -534,9 +534,9 @@
}
bdaddr_copy(&sa.bt_bdaddr, &sc->sc_laddr);
- err = l2cap_bind(sc->sc_ctl, &sa);
+ err = l2cap_bind_pcb(sc->sc_ctl, &sa);
if (err) {
- printf("%s: l2cap_bind failed (%d)\n",
+ printf("%s: l2cap_bind_pcb failed (%d)\n",
device_xname(sc->sc_dev), err);
return err;
}
@@ -824,7 +824,7 @@
sa.bt_family = AF_BLUETOOTH;
bdaddr_copy(&sa.bt_bdaddr, &sc->sc_laddr);
- err = l2cap_bind(sc->sc_int, &sa);
+ err = l2cap_bind_pcb(sc->sc_int, &sa);
if (err)
goto fail;
diff -r 8fe1b4ccb09d -r 35c14595c11f sys/dev/bluetooth/btsco.c
--- a/sys/dev/bluetooth/btsco.c Thu Jul 24 15:11:09 2014 +0000
+++ b/sys/dev/bluetooth/btsco.c Thu Jul 24 15:12:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: btsco.c,v 1.29 2014/05/20 18:25:54 rmind Exp $ */
+/* $NetBSD: btsco.c,v 1.30 2014/07/24 15:12:03 rtr Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.29 2014/05/20 18:25:54 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.30 2014/07/24 15:12:03 rtr Exp $");
#include <sys/param.h>
#include <sys/audioio.h>
@@ -592,13 +592,13 @@
if (err)
goto done;
- err = sco_bind(sc->sc_sco_l, &sa);
+ err = sco_bind_pcb(sc->sc_sco_l, &sa);
if (err) {
sco_detach_pcb(&sc->sc_sco_l);
goto done;
}
- err = sco_listen(sc->sc_sco_l);
+ err = sco_listen_pcb(sc->sc_sco_l);
if (err) {
sco_detach_pcb(&sc->sc_sco_l);
goto done;
@@ -610,7 +610,7 @@
if (err)
goto done;
- err = sco_bind(sc->sc_sco, &sa);
+ err = sco_bind_pcb(sc->sc_sco, &sa);
if (err) {
sco_detach_pcb(&sc->sc_sco);
goto done;
diff -r 8fe1b4ccb09d -r 35c14595c11f sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c Thu Jul 24 15:11:09 2014 +0000
+++ b/sys/kern/uipc_socket.c Thu Jul 24 15:12:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.226 2014/07/23 13:17:18 rtr Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.227 2014/07/24 15:12:03 rtr Exp $ */
/*-
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.226 2014/07/23 13:17:18 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.227 2014/07/24 15:12:03 rtr Exp $");
#include "opt_compat_netbsd.h"
#include "opt_sock_counters.h"
@@ -629,8 +629,7 @@
int error;
solock(so);
- error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
- PRU_BIND, NULL, nam, NULL, l);
+ error = (*so->so_proto->pr_usrreqs->pr_bind)(so, nam);
sounlock(so);
return error;
}
@@ -646,8 +645,7 @@
sounlock(so);
return EINVAL;
}
- error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
- PRU_LISTEN, NULL, NULL, NULL, l);
+ error = (*so->so_proto->pr_usrreqs->pr_listen)(so);
if (error != 0) {
sounlock(so);
return error;
diff -r 8fe1b4ccb09d -r 35c14595c11f sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Thu Jul 24 15:11:09 2014 +0000
+++ b/sys/kern/uipc_usrreq.c Thu Jul 24 15:12:03 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.160 2014/07/23 13:17:18 rtr Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.161 2014/07/24 15:12:03 rtr Exp $ */
/*-
* Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.160 2014/07/23 13:17:18 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.161 2014/07/24 15:12:03 rtr Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -396,6 +396,8 @@
KASSERT(req != PRU_ATTACH);
KASSERT(req != PRU_DETACH);
KASSERT(req != PRU_ACCEPT);
+ KASSERT(req != PRU_BIND);
+ KASSERT(req != PRU_LISTEN);
KASSERT(req != PRU_CONTROL);
KASSERT(req != PRU_SENSE);
KASSERT(req != PRU_PEERADDR);
@@ -413,21 +415,6 @@
}
switch (req) {
- case PRU_BIND:
- KASSERT(l != NULL);
- error = unp_bind(so, nam, l);
- break;
-
- case PRU_LISTEN:
- /*
- * If the socket can accept a connection, it must be
- * locked by uipc_lock.
- */
- unp_resetlock(so);
- if (unp->unp_vnode == NULL)
- error = EINVAL;
- break;
-
case PRU_CONNECT:
KASSERT(l != NULL);
error = unp_connect(so, nam, l);
@@ -947,7 +934,7 @@
}
int
-unp_bind(struct socket *so, struct mbuf *nam, struct lwp *l)
+unp_bind(struct socket *so, struct mbuf *nam)
{
struct sockaddr_un *sun;
struct unpcb *unp;
@@ -960,6 +947,11 @@
proc_t *p;
unp = sotounpcb(so);
+
+ KASSERT(solocked(so));
+ KASSERT(unp != NULL);
+ KASSERT(nam != NULL);
+
if (unp->unp_vnode != NULL)
return (EINVAL);
if ((unp->unp_flags & UNP_BUSY) != 0) {
@@ -972,7 +964,7 @@
unp->unp_flags |= UNP_BUSY;
sounlock(so);
- p = l->l_proc;
+ p = curlwp->l_proc;
sun = makeun(nam, &addrlen);
pb = pathbuf_create(sun->sun_path);
@@ -1016,8 +1008,8 @@
unp->unp_addrlen = addrlen;
unp->unp_addr = sun;
unp->unp_connid.unp_pid = p->p_pid;
- unp->unp_connid.unp_euid = kauth_cred_geteuid(l->l_cred);
- unp->unp_connid.unp_egid = kauth_cred_getegid(l->l_cred);
Home |
Main Index |
Thread Index |
Old Index