Source-Changes-HG archive

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

[src/trunk]: src/sys * split PRU_SENSE functionality out of xxx_usrreq() swit...



details:   https://anonhg.NetBSD.org/src/rev/797e277b6915
branches:  trunk
changeset: 797111:797e277b6915
user:      rtr <rtr%NetBSD.org@localhost>
date:      Sun Jul 06 03:33:33 2014 +0000

description:
* split PRU_SENSE functionality out of xxx_usrreq() switches and place into
  separate xxx_stat(struct socket *, struct stat *) functions.
* replace calls using pr_generic with req == PRU_SENSE with pr_stat().

further change will follow that cleans up the pattern used to extract the
pcb and test for its presence.

reviewed by rmind

diffstat:

 sys/kern/sys_socket.c      |   7 ++--
 sys/kern/uipc_usrreq.c     |  62 ++++++++++++++++++++++++++-------------------
 sys/net/raw_usrreq.c       |  12 ++------
 sys/net/rtsock.c           |  12 +++++++-
 sys/netatalk/ddp_usrreq.c  |  27 +++++++++++++------
 sys/netbt/hci_socket.c     |  21 +++++++++++---
 sys/netbt/l2cap_socket.c   |  21 +++++++++++---
 sys/netbt/rfcomm_socket.c  |  21 +++++++++++---
 sys/netbt/sco_socket.c     |  21 +++++++++++---
 sys/netinet/raw_ip.c       |  27 +++++++++++++------
 sys/netinet/tcp_usrreq.c   |  25 ++++++++++--------
 sys/netinet/udp_usrreq.c   |  27 +++++++++++++------
 sys/netinet6/raw_ip6.c     |  19 ++++++++-----
 sys/netinet6/udp6_usrreq.c |  25 ++++++++++++-----
 sys/netipsec/keysock.c     |  13 ++++++++-
 sys/netnatm/natm.c         |  24 +++++++++++++----
 sys/sys/protosw.h          |  13 ++++++++-
 17 files changed, 254 insertions(+), 123 deletions(-)

diffs (truncated from 1100 to 300 lines):

diff -r 7ecebbc749f3 -r 797e277b6915 sys/kern/sys_socket.c
--- a/sys/kern/sys_socket.c     Sun Jul 06 01:19:45 2014 +0000
+++ b/sys/kern/sys_socket.c     Sun Jul 06 03:33:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_socket.c,v 1.71 2014/07/01 05:49:18 rtr Exp $      */
+/*     $NetBSD: sys_socket.c,v 1.72 2014/07/06 03:33:33 rtr Exp $      */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.71 2014/07/01 05:49:18 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.72 2014/07/06 03:33:33 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -239,8 +239,7 @@
        ub->st_mode = S_IFSOCK;
 
        solock(so);
-       error = (*so->so_proto->pr_usrreqs->pr_generic)(so, PRU_SENSE,
-           (struct mbuf *)ub, NULL, NULL, curlwp);
+       error = (*so->so_proto->pr_usrreqs->pr_stat)(so, ub);
        sounlock(so);
 
        return error;
diff -r 7ecebbc749f3 -r 797e277b6915 sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c    Sun Jul 06 01:19:45 2014 +0000
+++ b/sys/kern/uipc_usrreq.c    Sun Jul 06 03:33:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_usrreq.c,v 1.155 2014/07/01 05:49:18 rtr Exp $    */
+/*     $NetBSD: uipc_usrreq.c,v 1.156 2014/07/06 03:33:33 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.155 2014/07/01 05:49:18 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.156 2014/07/06 03:33:33 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -377,6 +377,7 @@
        KASSERT(req != PRU_ATTACH);
        KASSERT(req != PRU_DETACH);
        KASSERT(req != PRU_CONTROL);
+       KASSERT(req != PRU_SENSE);
 
        KASSERT(solocked(so));
        unp = sotounpcb(so);
@@ -627,30 +628,6 @@
                unp_detach(so);
                break;
 
-       case PRU_SENSE:
-               ((struct stat *) m)->st_blksize = so->so_snd.sb_hiwat;
-               switch (so->so_type) {
-               case SOCK_SEQPACKET: /* FALLTHROUGH */
-               case SOCK_STREAM:
-                       if (unp->unp_conn == 0) 
-                               break;
-
-                       so2 = unp->unp_conn->unp_socket;
-                       KASSERT(solocked2(so, so2));
-                       ((struct stat *) m)->st_blksize += so2->so_rcv.sb_cc;
-                       break;
-               default:
-                       break;
-               }
-               ((struct stat *) m)->st_dev = NODEV;
-               if (unp->unp_ino == 0)
-                       unp->unp_ino = unp_ino++;
-               ((struct stat *) m)->st_atimespec =
-                   ((struct stat *) m)->st_mtimespec =
-                   ((struct stat *) m)->st_ctimespec = unp->unp_ctime;
-               ((struct stat *) m)->st_ino = unp->unp_ino;
-               return (0);
-
        case PRU_RCVOOB:
                error = EOPNOTSUPP;
                break;
@@ -871,6 +848,38 @@
        return EOPNOTSUPP;
 }
 
+static int
+unp_stat(struct socket *so, struct stat *ub)
+{
+       struct unpcb *unp;
+       struct socket *so2;
+
+       unp = sotounpcb(so);
+       if (unp == NULL)
+               return EINVAL;
+
+       ub->st_blksize = so->so_snd.sb_hiwat;
+       switch (so->so_type) {
+       case SOCK_SEQPACKET: /* FALLTHROUGH */
+       case SOCK_STREAM:
+               if (unp->unp_conn == 0) 
+                       break;
+
+               so2 = unp->unp_conn->unp_socket;
+               KASSERT(solocked2(so, so2));
+               ub->st_blksize += so2->so_rcv.sb_cc;
+               break;
+       default:
+               break;
+       }
+       ub->st_dev = NODEV;
+       if (unp->unp_ino == 0)
+               unp->unp_ino = unp_ino++;
+       ub->st_atimespec = ub->st_mtimespec = ub->st_ctimespec = unp->unp_ctime;
+       ub->st_ino = unp->unp_ino;
+       return (0);
+}
+
 /*
  * Allocate the new sockaddr.  We have to allocate one
  * extra byte so that we can ensure that the pathname
@@ -1817,5 +1826,6 @@
        .pr_attach      = unp_attach,
        .pr_detach      = unp_detach,
        .pr_ioctl       = unp_ioctl,
+       .pr_stat        = unp_stat,
        .pr_generic     = unp_usrreq,
 };
diff -r 7ecebbc749f3 -r 797e277b6915 sys/net/raw_usrreq.c
--- a/sys/net/raw_usrreq.c      Sun Jul 06 01:19:45 2014 +0000
+++ b/sys/net/raw_usrreq.c      Sun Jul 06 03:33:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raw_usrreq.c,v 1.40 2014/06/22 08:10:18 rtr Exp $      */
+/*     $NetBSD: raw_usrreq.c,v 1.41 2014/07/06 03:33:33 rtr Exp $      */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_usrreq.c,v 1.40 2014/06/22 08:10:18 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_usrreq.c,v 1.41 2014/07/06 03:33:33 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -163,6 +163,7 @@
        KASSERT(req != PRU_ATTACH);
        KASSERT(req != PRU_DETACH);
        KASSERT(req != PRU_CONTROL);
+       KASSERT(req != PRU_SENSE);
 
        s = splsoftnet();
        KERNEL_LOCK(1, NULL);
@@ -237,13 +238,6 @@
                        raw_disconnect(rp);
                break;
 
-       case PRU_SENSE:
-               /*
-                * stat: don't bother with a blocksize.
-                */
-               error = 0;
-               break;
-
        /*
         * Not supported.
         */
diff -r 7ecebbc749f3 -r 797e277b6915 sys/net/rtsock.c
--- a/sys/net/rtsock.c  Sun Jul 06 01:19:45 2014 +0000
+++ b/sys/net/rtsock.c  Sun Jul 06 03:33:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.149 2014/07/01 05:49:18 rtr Exp $ */
+/*     $NetBSD: rtsock.c,v 1.150 2014/07/06 03:33:33 rtr 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.149 2014/07/01 05:49:18 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.150 2014/07/06 03:33:33 rtr Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -231,6 +231,12 @@
 }
 
 static int
+COMPATNAME(route_stat)(struct socket *so, struct stat *ub)
+{
+       return 0;
+}
+
+static int
 COMPATNAME(route_usrreq)(struct socket *so, int req, struct mbuf *m,
     struct mbuf *nam, struct mbuf *control, struct lwp *l)
 {
@@ -239,6 +245,7 @@
        KASSERT(req != PRU_ATTACH);
        KASSERT(req != PRU_DETACH);
        KASSERT(req != PRU_CONTROL);
+       KASSERT(req != PRU_SENSE);
 
        s = splsoftnet();
        error = raw_usrreq(so, req, m, nam, control, l);
@@ -1336,6 +1343,7 @@
        .pr_attach      = COMPATNAME(route_attach_wrapper),
        .pr_detach      = COMPATNAME(route_detach_wrapper),
        .pr_ioctl       = COMPATNAME(route_ioctl_wrapper),
+       .pr_stat        = COMPATNAME(route_stat_wrapper),
        .pr_generic     = COMPATNAME(route_usrreq_wrapper),
 };
 
diff -r 7ecebbc749f3 -r 797e277b6915 sys/netatalk/ddp_usrreq.c
--- a/sys/netatalk/ddp_usrreq.c Sun Jul 06 01:19:45 2014 +0000
+++ b/sys/netatalk/ddp_usrreq.c Sun Jul 06 03:33:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ddp_usrreq.c,v 1.47 2014/07/01 05:49:18 rtr Exp $       */
+/*     $NetBSD: ddp_usrreq.c,v 1.48 2014/07/06 03:33:33 rtr Exp $       */
 
 /*
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.47 2014/07/01 05:49:18 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.48 2014/07/06 03:33:33 rtr Exp $");
 
 #include "opt_mbuftrace.h"
 
@@ -85,6 +85,7 @@
        KASSERT(req != PRU_ATTACH);
        KASSERT(req != PRU_DETACH);
        KASSERT(req != PRU_CONTROL);
+       KASSERT(req != PRU_SENSE);
 
        ddp = sotoddpcb(so);
 
@@ -187,13 +188,6 @@
                 */
                return (EOPNOTSUPP);
 
-       case PRU_SENSE:
-               /*
-                * 1. Don't return block size.
-                * 2. Don't mfree.
-                */
-               return (0);
-
        default:
                error = EOPNOTSUPP;
        }
@@ -484,6 +478,19 @@
        return at_control(cmd, addr, ifp);
 }
 
+static int
+ddp_stat(struct socket *so, struct stat *ub)
+{
+       struct ddpcb   *ddp;
+
+       ddp = sotoddpcb(so);
+       if (ddp == NULL)
+               return EINVAL;
+
+       /* Don't return block size. */
+       return 0;
+}
+
 /*
  * For the moment, this just find the pcb with the correct local address.
  * In the future, this will actually do some real searching, so we can use
@@ -558,12 +565,14 @@
 #define        ddp_attach      ddp_attach_wrapper
 #define        ddp_detach      ddp_detach_wrapper
 #define        ddp_ioctl       ddp_ioctl_wrapper
+#define        ddp_stat        ddp_stat_wrapper
 #define        ddp_usrreq      ddp_usrreq_wrapper
 
 const struct pr_usrreqs ddp_usrreqs = {
        .pr_attach      = ddp_attach,
        .pr_detach      = ddp_detach,
        .pr_ioctl       = ddp_ioctl,
+       .pr_stat        = ddp_stat,
        .pr_generic     = ddp_usrreq,
 };
 
diff -r 7ecebbc749f3 -r 797e277b6915 sys/netbt/hci_socket.c
--- a/sys/netbt/hci_socket.c    Sun Jul 06 01:19:45 2014 +0000
+++ b/sys/netbt/hci_socket.c    Sun Jul 06 03:33:33 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hci_socket.c,v 1.26 2014/07/01 05:49:18 rtr Exp $      */
+/*     $NetBSD: hci_socket.c,v 1.27 2014/07/06 03:33:33 rtr Exp $      */
 



Home | Main Index | Thread Index | Old Index