Source-Changes-HG archive

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

[src/trunk]: src/sys split PRU_SENDOOB and PRU_RCVOOB function out of pr_gene...



details:   https://anonhg.NetBSD.org/src/rev/ebec5a0e2c6f
branches:  trunk
changeset: 330835:ebec5a0e2c6f
user:      rtr <rtr%NetBSD.org@localhost>
date:      Wed Jul 23 13:17:18 2014 +0000

description:
split PRU_SENDOOB and PRU_RCVOOB function out of pr_generic() usrreq
switches and put into separate functions
  xxx_sendoob(struct socket *, struct mbuf *, struct mbuf *)
  xxx_recvoob(struct socket *, struct mbuf *, int)

  - always KASSERT(solocked(so)) even if request is not implemented

  - replace calls to pr_generic() with req = PRU_{SEND,RCV}OOB with
    calls to pr_{send,recv}oob() respectively.

there is still some tweaking of m_freem(m) and m_freem(control) to come
for consistency.  not performed with this commit for clarity.

reviewed by rmind

diffstat:

 sys/dev/kttcp.c                     |   16 +-
 sys/kern/uipc_socket.c              |   16 +-
 sys/kern/uipc_usrreq.c              |   39 +++++--
 sys/net/raw_usrreq.c                |   21 +---
 sys/net/rtsock.c                    |   28 +++++-
 sys/netatalk/ddp_usrreq.c           |   31 +++++-
 sys/netbt/hci_socket.c              |   33 +++++-
 sys/netbt/l2cap_socket.c            |   33 +++++-
 sys/netbt/rfcomm_socket.c           |   35 +++++-
 sys/netbt/sco_socket.c              |   33 +++++-
 sys/netinet/raw_ip.c                |   39 +++++--
 sys/netinet/tcp_usrreq.c            |  184 +++++++++++++++++++++++++++--------
 sys/netinet/udp_usrreq.c            |   41 +++++--
 sys/netinet6/raw_ip6.c              |   31 +++++-
 sys/netinet6/udp6_usrreq.c          |   33 +++++-
 sys/netipsec/keysock.c              |   29 +++++-
 sys/netmpls/mpls_proto.c            |   24 ++++-
 sys/netnatm/natm.c                  |   28 ++++-
 sys/rump/net/lib/libsockin/sockin.c |   22 +++-
 sys/sys/protosw.h                   |   24 ++++-
 20 files changed, 587 insertions(+), 153 deletions(-)

diffs (truncated from 1628 to 300 lines):

diff -r 272e679ce60d -r ebec5a0e2c6f sys/dev/kttcp.c
--- a/sys/dev/kttcp.c   Wed Jul 23 11:43:29 2014 +0000
+++ b/sys/dev/kttcp.c   Wed Jul 23 13:17:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kttcp.c,v 1.33 2014/05/18 14:46:15 rmind Exp $ */
+/*     $NetBSD: kttcp.c,v 1.34 2014/07/23 13:17:18 rtr Exp $   */
 
 /*
  * Copyright (c) 2002 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kttcp.c,v 1.33 2014/05/18 14:46:15 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kttcp.c,v 1.34 2014/07/23 13:17:18 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -319,9 +319,12 @@
                                so->so_options |= SO_DONTROUTE;
                        if (resid > 0)
                                so->so_state |= SS_MORETOCOME;
-                       error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
-                           (flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND,
-                           top, NULL, NULL, l);
+                       if (flags & MSG_OOB)
+                               error = (*so->so_proto->pr_usrreqs->pr_sendoob)(so,
+                                   top, NULL);
+                       else
+                               error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
+                                   PRU_SEND, top, NULL, NULL, l);
                        if (dontroute)
                                so->so_options &= ~SO_DONTROUTE;
                        if (resid > 0)
@@ -367,8 +370,7 @@
        if (flags & MSG_OOB) {
                m = m_get(M_WAIT, MT_DATA);
                solock(so);
-               error = (*pr->pr_usrreqs->pr_generic)(so, PRU_RCVOOB, m,
-                   (struct mbuf *)(long)(flags & MSG_PEEK), NULL, NULL);
+               error = (*pr->pr_usrreqs->pr_recvoob)(so, m, flags & MSG_PEEK);
                sounlock(so);
                if (error)
                        goto bad;
diff -r 272e679ce60d -r ebec5a0e2c6f sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Wed Jul 23 11:43:29 2014 +0000
+++ b/sys/kern/uipc_socket.c    Wed Jul 23 13:17:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.225 2014/07/09 14:41:42 rtr Exp $    */
+/*     $NetBSD: uipc_socket.c,v 1.226 2014/07/23 13:17:18 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.225 2014/07/09 14:41:42 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.226 2014/07/23 13:17:18 rtr Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_sock_counters.h"
@@ -1053,9 +1053,12 @@
                                so->so_options |= SO_DONTROUTE;
                        if (resid > 0)
                                so->so_state |= SS_MORETOCOME;
-                       error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
-                           (flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND,
-                           top, addr, control, curlwp);
+                       if (flags & MSG_OOB)
+                               error = (*so->so_proto->pr_usrreqs->pr_sendoob)(so,
+                                   top, control);
+                       else
+                               error = (*so->so_proto->pr_usrreqs->pr_generic)(so,
+                                   PRU_SEND, top, addr, control, curlwp);
                        if (dontroute)
                                so->so_options &= ~SO_DONTROUTE;
                        if (resid > 0)
@@ -1167,8 +1170,7 @@
        if (flags & MSG_OOB) {
                m = m_get(M_WAIT, MT_DATA);
                solock(so);
-               error = (*pr->pr_usrreqs->pr_generic)(so, PRU_RCVOOB, m,
-                   (struct mbuf *)(long)(flags & MSG_PEEK), NULL, l);
+               error = (*pr->pr_usrreqs->pr_recvoob)(so, m, flags & MSG_PEEK);
                sounlock(so);
                if (error)
                        goto bad;
diff -r 272e679ce60d -r ebec5a0e2c6f sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c    Wed Jul 23 11:43:29 2014 +0000
+++ b/sys/kern/uipc_usrreq.c    Wed Jul 23 13:17:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_usrreq.c,v 1.159 2014/07/09 14:41:42 rtr Exp $    */
+/*     $NetBSD: uipc_usrreq.c,v 1.160 2014/07/23 13:17:18 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.159 2014/07/09 14:41:42 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.160 2014/07/23 13:17:18 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -366,6 +366,25 @@
 }
 
 static int
+unp_recvoob(struct socket *so, struct mbuf *m, int flags)
+{
+       KASSERT(solocked(so));
+
+       return EOPNOTSUPP;
+}
+
+static int
+unp_sendoob(struct socket *so, struct mbuf *m, struct mbuf * control)
+{
+       KASSERT(solocked(so));
+
+       m_freem(m);
+       m_freem(control);
+
+       return EOPNOTSUPP;
+}
+
+static int
 unp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
     struct mbuf *control, struct lwp *l)
 {
@@ -381,11 +400,13 @@
        KASSERT(req != PRU_SENSE);
        KASSERT(req != PRU_PEERADDR);
        KASSERT(req != PRU_SOCKADDR);
+       KASSERT(req != PRU_RCVOOB);
+       KASSERT(req != PRU_SENDOOB);
 
        KASSERT(solocked(so));
        unp = sotounpcb(so);
 
-       KASSERT(!control || (req == PRU_SEND || req == PRU_SENDOOB));
+       KASSERT(!control || req == PRU_SEND);
        if (unp == NULL) {
                error = EINVAL;
                goto release;
@@ -581,16 +602,6 @@
                unp_detach(so);
                break;
 
-       case PRU_RCVOOB:
-               error = EOPNOTSUPP;
-               break;
-
-       case PRU_SENDOOB:
-               m_freem(control);
-               m_freem(m);
-               error = EOPNOTSUPP;
-               break;
-
        default:
                panic("piusrreq");
        }
@@ -1862,5 +1873,7 @@
        .pr_stat        = unp_stat,
        .pr_peeraddr    = unp_peeraddr,
        .pr_sockaddr    = unp_sockaddr,
+       .pr_recvoob     = unp_recvoob,
+       .pr_sendoob     = unp_sendoob,
        .pr_generic     = unp_usrreq,
 };
diff -r 272e679ce60d -r ebec5a0e2c6f sys/net/raw_usrreq.c
--- a/sys/net/raw_usrreq.c      Wed Jul 23 11:43:29 2014 +0000
+++ b/sys/net/raw_usrreq.c      Wed Jul 23 13:17:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: raw_usrreq.c,v 1.43 2014/07/09 14:41:42 rtr Exp $      */
+/*     $NetBSD: raw_usrreq.c,v 1.44 2014/07/23 13:17:18 rtr Exp $      */
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: raw_usrreq.c,v 1.43 2014/07/09 14:41:42 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: raw_usrreq.c,v 1.44 2014/07/23 13:17:18 rtr Exp $");
 
 #include <sys/param.h>
 #include <sys/mbuf.h>
@@ -167,11 +167,13 @@
        KASSERT(req != PRU_SENSE);
        KASSERT(req != PRU_PEERADDR);
        KASSERT(req != PRU_SOCKADDR);
+       KASSERT(req != PRU_RCVOOB);
+       KASSERT(req != PRU_SENDOOB);
 
        s = splsoftnet();
        KERNEL_LOCK(1, NULL);
 
-       KASSERT(!control || (req == PRU_SEND || req == PRU_SENDOOB));
+       KASSERT(!control || req == PRU_SEND);
        if (rp == NULL) {
                error = EINVAL;
                goto release;
@@ -241,19 +243,6 @@
                        raw_disconnect(rp);
                break;
 
-       /*
-        * Not supported.
-        */
-       case PRU_RCVOOB:
-               error = EOPNOTSUPP;
-               break;
-
-       case PRU_SENDOOB:
-               m_freem(control);
-               m_freem(m);
-               error = EOPNOTSUPP;
-               break;
-
        default:
                panic("raw_usrreq");
        }
diff -r 272e679ce60d -r ebec5a0e2c6f sys/net/rtsock.c
--- a/sys/net/rtsock.c  Wed Jul 23 11:43:29 2014 +0000
+++ b/sys/net/rtsock.c  Wed Jul 23 13:17:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rtsock.c,v 1.155 2014/07/09 14:41:42 rtr Exp $ */
+/*     $NetBSD: rtsock.c,v 1.156 2014/07/23 13:17:18 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.155 2014/07/09 14:41:42 rtr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtsock.c,v 1.156 2014/07/23 13:17:18 rtr Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -281,6 +281,26 @@
 }
 
 static int
+COMPATNAME(route_recvoob)(struct socket *so, struct mbuf *m, int flags)
+{
+       KASSERT(solocked(so));
+
+       return EOPNOTSUPP;
+}
+
+static int
+COMPATNAME(route_sendoob)(struct socket *so, struct mbuf *m,
+    struct mbuf *control)
+{
+       KASSERT(solocked(so));
+
+       m_freem(m);
+       m_freem(control);
+
+       return EOPNOTSUPP;
+}
+
+static int
 COMPATNAME(route_usrreq)(struct socket *so, int req, struct mbuf *m,
     struct mbuf *nam, struct mbuf *control, struct lwp *l)
 {
@@ -293,6 +313,8 @@
        KASSERT(req != PRU_SENSE);
        KASSERT(req != PRU_PEERADDR);
        KASSERT(req != PRU_SOCKADDR);
+       KASSERT(req != PRU_RCVOOB);
+       KASSERT(req != PRU_SENDOOB);
 
        s = splsoftnet();
        error = raw_usrreq(so, req, m, nam, control, l);
@@ -1394,6 +1416,8 @@
        .pr_stat        = COMPATNAME(route_stat_wrapper),
        .pr_peeraddr    = COMPATNAME(route_peeraddr_wrapper),
        .pr_sockaddr    = COMPATNAME(route_sockaddr_wrapper),
+       .pr_recvoob     = COMPATNAME(route_recvoob_wrapper),
+       .pr_sendoob     = COMPATNAME(route_sendoob_wrapper),
        .pr_generic     = COMPATNAME(route_usrreq_wrapper),
 };
 
diff -r 272e679ce60d -r ebec5a0e2c6f sys/netatalk/ddp_usrreq.c
--- a/sys/netatalk/ddp_usrreq.c Wed Jul 23 11:43:29 2014 +0000
+++ b/sys/netatalk/ddp_usrreq.c Wed Jul 23 13:17:18 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ddp_usrreq.c,v 1.53 2014/07/09 14:41:42 rtr Exp $       */
+/*     $NetBSD: ddp_usrreq.c,v 1.54 2014/07/23 13:17:18 rtr Exp $       */
 
 /*
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
@@ -27,7 +27,7 @@
  */
 



Home | Main Index | Thread Index | Old Index