Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Add SOCK_SEQPACKET to PL_LOCAL sockets. Based on pa...
details: https://anonhg.NetBSD.org/src/rev/5435ea224c42
branches: trunk
changeset: 765512:5435ea224c42
user: manu <manu%NetBSD.org@localhost>
date: Sun May 29 03:32:46 2011 +0000
description:
Add SOCK_SEQPACKET to PL_LOCAL sockets. Based on patch from Jesse Off,
submitted 8 years ago:
http://mail-index.netbsd.org/tech-kern/2003/04/14/0006.html
diffstat:
sys/kern/uipc_domain.c | 17 +++++++++++++++--
sys/kern/uipc_proto.c | 11 +++++++++--
sys/kern/uipc_usrreq.c | 50 ++++++++++++++++++++++++++++++++++++++++----------
3 files changed, 64 insertions(+), 14 deletions(-)
diffs (214 lines):
diff -r 33f529409878 -r 5435ea224c42 sys/kern/uipc_domain.c
--- a/sys/kern/uipc_domain.c Sun May 29 01:14:31 2011 +0000
+++ b/sys/kern/uipc_domain.c Sun May 29 03:32:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_domain.c,v 1.85 2009/10/03 20:24:39 elad Exp $ */
+/* $NetBSD: uipc_domain.c,v 1.86 2011/05/29 03:32:46 manu Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.85 2009/10/03 20:24:39 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.86 2011/05/29 03:32:46 manu Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -518,6 +518,12 @@
CTL_NET, PF_LOCAL, SOCK_STREAM, CTL_EOL);
sysctl_createv(&domain_sysctllog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "seqpacket",
+ SYSCTL_DESCR("SOCK_SEQPACKET settings"),
+ NULL, 0, NULL, 0,
+ CTL_NET, PF_LOCAL, SOCK_SEQPACKET, CTL_EOL);
+ sysctl_createv(&domain_sysctllog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
CTLTYPE_NODE, "dgram",
SYSCTL_DESCR("SOCK_DGRAM settings"),
NULL, 0, NULL, 0,
@@ -532,6 +538,13 @@
sysctl_createv(&domain_sysctllog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRUCT, "pcblist",
+ SYSCTL_DESCR("SOCK_SEQPACKET protocol control "
+ "block list"),
+ sysctl_unpcblist, 0, NULL, 0,
+ CTL_NET, PF_LOCAL, SOCK_SEQPACKET, CTL_CREATE, CTL_EOL);
+ sysctl_createv(&domain_sysctllog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_STRUCT, "pcblist",
SYSCTL_DESCR("SOCK_DGRAM protocol control block list"),
sysctl_unpcblist, 0, NULL, 0,
CTL_NET, PF_LOCAL, SOCK_DGRAM, CTL_CREATE, CTL_EOL);
diff -r 33f529409878 -r 5435ea224c42 sys/kern/uipc_proto.c
--- a/sys/kern/uipc_proto.c Sun May 29 01:14:31 2011 +0000
+++ b/sys/kern/uipc_proto.c Sun May 29 03:32:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_proto.c,v 1.21 2008/04/24 11:38:36 ad Exp $ */
+/* $NetBSD: uipc_proto.c,v 1.22 2011/05/29 03:32:46 manu Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_proto.c,v 1.21 2008/04/24 11:38:36 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_proto.c,v 1.22 2011/05/29 03:32:46 manu Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@@ -65,6 +65,13 @@
.pr_ctloutput = uipc_ctloutput,
.pr_usrreq = uipc_usrreq,
}, {
+ .pr_type = SOCK_SEQPACKET,
+ .pr_domain = &unixdomain,
+ .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_RIGHTS|PR_LISTEN|
+ PR_ATOMIC,
+ .pr_ctloutput = uipc_ctloutput,
+ .pr_usrreq = uipc_usrreq,
+ }, {
.pr_input = raw_input,
.pr_ctlinput = raw_ctlinput,
.pr_usrreq = raw_usrreq,
diff -r 33f529409878 -r 5435ea224c42 sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Sun May 29 01:14:31 2011 +0000
+++ b/sys/kern/uipc_usrreq.c Sun May 29 03:32:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.133 2010/11/19 06:44:43 dholland Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.134 2011/05/29 03:32:46 manu 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.133 2010/11/19 06:44:43 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.134 2011/05/29 03:32:46 manu Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -124,7 +124,7 @@
* Unix communications domain.
*
* TODO:
- * SEQPACKET, RDM
+ * RDM
* rethink name space problems
* need a proper out-of-band
*
@@ -487,6 +487,7 @@
panic("uipc 1");
/*NOTREACHED*/
+ case SOCK_SEQPACKET: /* FALLTHROUGH */
case SOCK_STREAM:
#define rcv (&so->so_rcv)
#define snd (&so2->so_snd)
@@ -567,6 +568,7 @@
break;
}
+ case SOCK_SEQPACKET: /* FALLTHROUGH */
case SOCK_STREAM:
#define rcv (&so2->so_rcv)
#define snd (&so->so_snd)
@@ -579,7 +581,7 @@
if (unp->unp_conn->unp_flags & UNP_WANTCRED) {
/*
* Credentials are passed only once on
- * SOCK_STREAM.
+ * SOCK_STREAM and SOCK_SEQPACKET.
*/
unp->unp_conn->unp_flags &= ~UNP_WANTCRED;
control = unp_addsockcred(l, control);
@@ -592,8 +594,19 @@
if (control) {
if (sbappendcontrol(rcv, m, control) != 0)
control = NULL;
- } else
- sbappend(rcv, m);
+ } else {
+ switch(so->so_type) {
+ case SOCK_SEQPACKET:
+ sbappendrecord(rcv, m);
+ break;
+ case SOCK_STREAM:
+ sbappend(rcv, m);
+ break;
+ default:
+ panic("uipc_usrreq");
+ break;
+ }
+ }
snd->sb_mbmax -=
rcv->sb_mbcnt - unp->unp_conn->unp_mbcnt;
unp->unp_conn->unp_mbcnt = rcv->sb_mbcnt;
@@ -629,10 +642,18 @@
case PRU_SENSE:
((struct stat *) m)->st_blksize = so->so_snd.sb_hiwat;
- if (so->so_type == SOCK_STREAM && unp->unp_conn != 0) {
+ 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)
@@ -767,6 +788,7 @@
int error;
switch (so->so_type) {
+ case SOCK_SEQPACKET: /* FALLTHROUGH */
case SOCK_STREAM:
if (so->so_lock == NULL) {
/*
@@ -1093,6 +1115,7 @@
soisconnected(so);
break;
+ case SOCK_SEQPACKET: /* FALLTHROUGH */
case SOCK_STREAM:
unp2->unp_conn = unp;
if (req == PRU_CONNECT &&
@@ -1150,6 +1173,7 @@
so->so_state &= ~SS_ISCONNECTED;
break;
+ case SOCK_SEQPACKET: /* FALLTHROUGH */
case SOCK_STREAM:
KASSERT(solocked2(so, unp2->unp_socket));
soisdisconnected(so);
@@ -1171,9 +1195,15 @@
{
struct socket *so;
- if (unp->unp_socket->so_type == SOCK_STREAM && unp->unp_conn &&
- (so = unp->unp_conn->unp_socket))
- socantrcvmore(so);
+ switch(unp->unp_socket->so_type) {
+ case SOCK_SEQPACKET: /* FALLTHROUGH */
+ case SOCK_STREAM:
+ if (unp->unp_conn && (so = unp->unp_conn->unp_socket))
+ socantrcvmore(so);
+ break;
+ default:
+ break;
+ }
}
bool
Home |
Main Index |
Thread Index |
Old Index