Source-Changes-HG archive

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

[src/trunk]: src/sys split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT functio...



details:   https://anonhg.NetBSD.org/src/rev/5c47728889ee
branches:  trunk
changeset: 797852:5c47728889ee
user:      rtr <rtr%NetBSD.org@localhost>
date:      Thu Jul 31 03:39:35 2014 +0000

description:
split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions

   xxx_disconnect(struct socket *)
   xxx_shutdown(struct socket *)
   xxx_abort(struct socket *)

   - always KASSERT(solocked(so)) even if not implemented
   - replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
     with calls to pr_{disconnect,shutdown,abort}() respectively

rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().

   - {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
   - {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
   - unp_shutdown() -> unp_shutdown1()

patch reviewed by rmind

diffstat:

 sys/dev/bluetooth/bthidev.c         |   20 ++--
 sys/dev/bluetooth/btmagic.c         |   16 ++--
 sys/dev/bluetooth/btsco.c           |    8 +-
 sys/kern/uipc_socket.c              |   10 +-
 sys/kern/uipc_socket2.c             |    6 +-
 sys/kern/uipc_usrreq.c              |   72 ++++++++++++------
 sys/net/link_proto.c                |   37 ++++++++-
 sys/net/raw_usrreq.c                |   19 +---
 sys/net/rtsock.c                    |   53 ++++++++++++-
 sys/netatalk/ddp_usrreq.c           |   66 +++++++++++-----
 sys/netbt/hci_socket.c              |   73 ++++++++++++-----
 sys/netbt/l2cap.h                   |    6 +-
 sys/netbt/l2cap_socket.c            |   68 ++++++++++++----
 sys/netbt/l2cap_upper.c             |    8 +-
 sys/netbt/rfcomm.h                  |    6 +-
 sys/netbt/rfcomm_session.c          |    8 +-
 sys/netbt/rfcomm_socket.c           |   68 ++++++++++++----
 sys/netbt/rfcomm_upper.c            |    8 +-
 sys/netbt/sco.h                     |    4 +-
 sys/netbt/sco_socket.c              |   66 ++++++++++++----
 sys/netbt/sco_upper.c               |   10 +-
 sys/netinet/raw_ip.c                |   67 ++++++++++++----
 sys/netinet/tcp_usrreq.c            |  143 ++++++++++++++++++++++++++---------
 sys/netinet/tcp_var.h               |    4 +-
 sys/netinet/udp_usrreq.c            |   69 +++++++++++++---
 sys/netinet6/raw_ip6.c              |   71 ++++++++++++-----
 sys/netinet6/udp6_usrreq.c          |   86 +++++++++++++++------
 sys/netipsec/keysock.c              |   59 ++++++++++++++-
 sys/netmpls/mpls_proto.c            |   34 ++++++++-
 sys/netnatm/natm.c                  |   97 +++++++++++++++--------
 sys/rump/net/lib/libsockin/sockin.c |   45 +++++++++-
 sys/sys/protosw.h                   |   32 +++++++-
 sys/sys/un.h                        |    6 +-
 33 files changed, 988 insertions(+), 357 deletions(-)

diffs (truncated from 2710 to 300 lines):

diff -r bb33b793eb15 -r 5c47728889ee sys/dev/bluetooth/bthidev.c
--- a/sys/dev/bluetooth/bthidev.c       Thu Jul 31 02:54:46 2014 +0000
+++ b/sys/dev/bluetooth/bthidev.c       Thu Jul 31 03:39:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bthidev.c,v 1.27 2014/07/30 10:04:25 rtr Exp $ */
+/*     $NetBSD: bthidev.c,v 1.28 2014/07/31 03:39:35 rtr Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.27 2014/07/30 10:04:25 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.28 2014/07/31 03:39:35 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -370,14 +370,14 @@
 
        /* close interrupt channel */
        if (sc->sc_int != NULL) {
-               l2cap_disconnect(sc->sc_int, 0);
+               l2cap_disconnect_pcb(sc->sc_int, 0);
                l2cap_detach_pcb(&sc->sc_int);
                sc->sc_int = NULL;
        }
 
        /* close control channel */
        if (sc->sc_ctl != NULL) {
-               l2cap_disconnect(sc->sc_ctl, 0);
+               l2cap_disconnect_pcb(sc->sc_ctl, 0);
                l2cap_detach_pcb(&sc->sc_ctl);
                sc->sc_ctl = NULL;
        }
@@ -450,12 +450,12 @@
        switch (sc->sc_state) {
        case BTHID_CLOSED:
                if (sc->sc_int != NULL) {
-                       l2cap_disconnect(sc->sc_int, 0);
+                       l2cap_disconnect_pcb(sc->sc_int, 0);
                        break;
                }
 
                if (sc->sc_ctl != NULL) {
-                       l2cap_disconnect(sc->sc_ctl, 0);
+                       l2cap_disconnect_pcb(sc->sc_ctl, 0);
                        break;
                }
 
@@ -678,14 +678,14 @@
                        mutex_enter(bt_lock);
                        /* close interrupt channel */
                        if (sc->sc_int != NULL) {
-                               l2cap_disconnect(sc->sc_int, 0);
+                               l2cap_disconnect_pcb(sc->sc_int, 0);
                                l2cap_detach_pcb(&sc->sc_int);
                                sc->sc_int = NULL;
                        }
 
                        /* close control channel */
                        if (sc->sc_ctl != NULL) {
-                               l2cap_disconnect(sc->sc_ctl, 0);
+                               l2cap_disconnect_pcb(sc->sc_ctl, 0);
                                l2cap_detach_pcb(&sc->sc_ctl);
                                sc->sc_ctl = NULL;
                        }
@@ -939,10 +939,10 @@
                return;
 
        if (sc->sc_int != NULL)
-               l2cap_disconnect(sc->sc_int, 0);
+               l2cap_disconnect_pcb(sc->sc_int, 0);
 
        if (sc->sc_ctl != NULL)
-               l2cap_disconnect(sc->sc_ctl, 0);
+               l2cap_disconnect_pcb(sc->sc_ctl, 0);
 }
 
 /*
diff -r bb33b793eb15 -r 5c47728889ee sys/dev/bluetooth/btmagic.c
--- a/sys/dev/bluetooth/btmagic.c       Thu Jul 31 02:54:46 2014 +0000
+++ b/sys/dev/bluetooth/btmagic.c       Thu Jul 31 03:39:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: btmagic.c,v 1.9 2014/07/30 10:04:25 rtr Exp $  */
+/*     $NetBSD: btmagic.c,v 1.10 2014/07/31 03:39:35 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.9 2014/07/30 10:04:25 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.10 2014/07/31 03:39:35 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -413,14 +413,14 @@
 
        /* close interrupt channel */
        if (sc->sc_int != NULL) {
-               l2cap_disconnect(sc->sc_int, 0);
+               l2cap_disconnect_pcb(sc->sc_int, 0);
                l2cap_detach_pcb(&sc->sc_int);
                sc->sc_int = NULL;
        }
 
        /* close control channel */
        if (sc->sc_ctl != NULL) {
-               l2cap_disconnect(sc->sc_ctl, 0);
+               l2cap_disconnect_pcb(sc->sc_ctl, 0);
                l2cap_detach_pcb(&sc->sc_ctl);
                sc->sc_ctl = NULL;
        }
@@ -670,12 +670,12 @@
        switch (sc->sc_state) {
        case BTMAGIC_CLOSED:
                if (sc->sc_int != NULL) {
-                       l2cap_disconnect(sc->sc_int, 0);
+                       l2cap_disconnect_pcb(sc->sc_int, 0);
                        break;
                }
 
                if (sc->sc_ctl != NULL) {
-                       l2cap_disconnect(sc->sc_ctl, 0);
+                       l2cap_disconnect_pcb(sc->sc_ctl, 0);
                        break;
                }
                break;
@@ -1005,10 +1005,10 @@
                return;
 
        if (sc->sc_int != NULL)
-               l2cap_disconnect(sc->sc_int, 0);
+               l2cap_disconnect_pcb(sc->sc_int, 0);
 
        if (sc->sc_ctl != NULL)
-               l2cap_disconnect(sc->sc_ctl, 0);
+               l2cap_disconnect_pcb(sc->sc_ctl, 0);
 }
 
 /*
diff -r bb33b793eb15 -r 5c47728889ee sys/dev/bluetooth/btsco.c
--- a/sys/dev/bluetooth/btsco.c Thu Jul 31 02:54:46 2014 +0000
+++ b/sys/dev/bluetooth/btsco.c Thu Jul 31 03:39:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: btsco.c,v 1.31 2014/07/30 10:04:25 rtr Exp $   */
+/*     $NetBSD: btsco.c,v 1.32 2014/07/31 03:39:35 rtr Exp $   */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.31 2014/07/30 10:04:25 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.32 2014/07/31 03:39:35 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/audioio.h>
@@ -359,7 +359,7 @@
        mutex_enter(bt_lock);
        if (sc->sc_sco != NULL) {
                DPRINTF("sc_sco=%p\n", sc->sc_sco);
-               sco_disconnect(sc->sc_sco, 0);
+               sco_disconnect_pcb(sc->sc_sco, 0);
                sco_detach_pcb(&sc->sc_sco);
                sc->sc_sco = NULL;
        }
@@ -672,7 +672,7 @@
        KASSERT(mutex_owned(bt_lock));
 
        if (sc->sc_sco != NULL) {
-               sco_disconnect(sc->sc_sco, 0);
+               sco_disconnect_pcb(sc->sc_sco, 0);
                sco_detach_pcb(&sc->sc_sco);
        }
 
diff -r bb33b793eb15 -r 5c47728889ee sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Thu Jul 31 02:54:46 2014 +0000
+++ b/sys/kern/uipc_socket.c    Thu Jul 31 03:39:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.228 2014/07/30 10:04:26 rtr Exp $    */
+/*     $NetBSD: uipc_socket.c,v 1.229 2014/07/31 03:39:35 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.228 2014/07/30 10:04:26 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.229 2014/07/31 03:39:35 rtr Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_sock_counters.h"
@@ -853,8 +853,7 @@
        } else if (so->so_state & SS_ISDISCONNECTING) {
                error = EALREADY;
        } else {
-               error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
-                   PRU_DISCONNECT, NULL, NULL, NULL, NULL);
+               error = (*so->so_proto->pr_usrreqs->pr_disconnect)(so);
        }
        return (error);
 }
@@ -1611,8 +1610,7 @@
                error = 0;
        }
        if (how == SHUT_WR || how == SHUT_RDWR)
-               error = (*pr->pr_usrreqs->pr_generic)(so,
-                   PRU_SHUTDOWN, NULL, NULL, NULL, NULL);
+               error = (*pr->pr_usrreqs->pr_shutdown)(so);
 
        return error;
 }
diff -r bb33b793eb15 -r 5c47728889ee sys/kern/uipc_socket2.c
--- a/sys/kern/uipc_socket2.c   Thu Jul 31 02:54:46 2014 +0000
+++ b/sys/kern/uipc_socket2.c   Thu Jul 31 03:39:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket2.c,v 1.119 2014/05/19 02:51:24 rmind Exp $ */
+/*     $NetBSD: uipc_socket2.c,v 1.120 2014/07/31 03:39:35 rtr Exp $   */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.119 2014/05/19 02:51:24 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.120 2014/07/31 03:39:35 rtr Exp $");
 
 #include "opt_mbuftrace.h"
 #include "opt_sb_max.h"
@@ -437,7 +437,7 @@
  * socantsendmore: indicates that no more data will be sent on the
  * socket; it would normally be applied to a socket when the user
  * informs the system that no more data is to be sent, by the protocol
- * code (in case PRU_SHUTDOWN).
+ * code (in case pr_shutdown()).
  */
 void
 socantsendmore(struct socket *so)
diff -r bb33b793eb15 -r 5c47728889ee sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c    Thu Jul 31 02:54:46 2014 +0000
+++ b/sys/kern/uipc_usrreq.c    Thu Jul 31 03:39:35 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_usrreq.c,v 1.162 2014/07/30 10:04:26 rtr Exp $    */
+/*     $NetBSD: uipc_usrreq.c,v 1.163 2014/07/31 03:39:35 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.162 2014/07/30 10:04:26 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.163 2014/07/31 03:39:35 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -399,6 +399,9 @@
        KASSERT(req != PRU_BIND);
        KASSERT(req != PRU_LISTEN);
        KASSERT(req != PRU_CONNECT);
+       KASSERT(req != PRU_DISCONNECT);
+       KASSERT(req != PRU_SHUTDOWN);
+       KASSERT(req != PRU_ABORT);
        KASSERT(req != PRU_CONTROL);
        KASSERT(req != PRU_SENSE);
        KASSERT(req != PRU_PEERADDR);
@@ -420,15 +423,6 @@
                error = unp_connect2(so, (struct socket *)nam, PRU_CONNECT2);
                break;
 
-       case PRU_DISCONNECT:
-               unp_disconnect(unp);
-               break;
-
-       case PRU_SHUTDOWN:
-               socantsendmore(so);
-               unp_shutdown(unp);
-               break;
-
        case PRU_RCVD:
                switch (so->so_type) {
 
@@ -513,7 +507,7 @@
                        KASSERT(l != NULL);
                        error = unp_output(m, control, unp, l);
                        if (nam)
-                               unp_disconnect(unp);
+                               unp_disconnect1(unp);
                        break;
                }
 
@@ -578,13 +572,6 @@
                }
                break;



Home | Main Index | Thread Index | Old Index