sys unistd includes
several kernel files have a dependency on unistd.h but fail to include it. (indirect include through file.h, which i'd like to eliminate.) if you need the file, include it. and udf_subr.c at least is one file that doesn't need unistd.h for reference, here's the sys/file.h diff, then the big .c diff. Index: sys/file.h === RCS file: /cvs/src/sys/sys/file.h,v retrieving revision 1.32 diff -u -p -r1.32 file.h --- sys/file.h 10 Jul 2014 14:33:18 - 1.32 +++ sys/file.h 2 Nov 2014 03:51:12 - @@ -33,7 +33,6 @@ */ #include sys/fcntl.h -#include sys/unistd.h #ifdef _KERNEL #include sys/queue.h Index: kern/kern_fork.c === RCS file: /cvs/src/sys/kern/kern_fork.c,v retrieving revision 1.174 diff -u -p -r1.174 kern_fork.c --- kern/kern_fork.c8 Sep 2014 01:47:06 - 1.174 +++ kern/kern_fork.c2 Nov 2014 03:55:10 - @@ -59,6 +59,7 @@ #include sys/mman.h #include sys/ptrace.h #include sys/atomic.h +#include sys/unistd.h #include sys/syscallargs.h Index: kern/spec_vnops.c === RCS file: /cvs/src/sys/kern/spec_vnops.c,v retrieving revision 1.79 diff -u -p -r1.79 spec_vnops.c --- kern/spec_vnops.c 13 Sep 2014 16:06:37 - 1.79 +++ kern/spec_vnops.c 2 Nov 2014 03:53:50 - @@ -51,6 +51,7 @@ #include sys/dkio.h #include sys/malloc.h #include sys/specdev.h +#include sys/unistd.h #define v_lastr v_specinfo-si_lastr Index: kern/vfs_lockf.c === RCS file: /cvs/src/sys/kern/vfs_lockf.c,v retrieving revision 1.17 diff -u -p -r1.17 vfs_lockf.c --- kern/vfs_lockf.c10 Apr 2012 09:07:20 - 1.17 +++ kern/vfs_lockf.c2 Nov 2014 03:52:03 - @@ -44,6 +44,7 @@ #include sys/pool.h #include sys/fcntl.h #include sys/lockf.h +#include sys/unistd.h struct pool lockfpool; Index: kern/vfs_syscalls.c === RCS file: /cvs/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.211 diff -u -p -r1.211 vfs_syscalls.c --- kern/vfs_syscalls.c 22 Oct 2014 21:43:16 - 1.211 +++ kern/vfs_syscalls.c 2 Nov 2014 03:54:10 - @@ -55,6 +55,7 @@ #include sys/dkio.h #include sys/disklabel.h #include sys/ktrace.h +#include sys/unistd.h #include sys/syscallargs.h Index: kern/vfs_vnops.c === RCS file: /cvs/src/sys/kern/vfs_vnops.c,v retrieving revision 1.78 diff -u -p -r1.78 vfs_vnops.c --- kern/vfs_vnops.c13 Jul 2014 15:00:40 - 1.78 +++ kern/vfs_vnops.c2 Nov 2014 03:54:27 - @@ -56,6 +56,7 @@ #include sys/poll.h #include sys/filedesc.h #include sys/specdev.h +#include sys/unistd.h int vn_read(struct file *, off_t *, struct uio *, struct ucred *); int vn_write(struct file *, off_t *, struct uio *, struct ucred *); Index: isofs/cd9660/cd9660_vnops.c === RCS file: /cvs/src/sys/isofs/cd9660/cd9660_vnops.c,v retrieving revision 1.67 diff -u -p -r1.67 cd9660_vnops.c --- isofs/cd9660/cd9660_vnops.c 14 Sep 2014 14:17:25 - 1.67 +++ isofs/cd9660/cd9660_vnops.c 2 Nov 2014 03:55:49 - @@ -56,6 +56,7 @@ #include sys/cdio.h #include sys/poll.h #include sys/specdev.h +#include sys/unistd.h #include miscfs/fifofs/fifo.h Index: isofs/udf/udf_subr.c === RCS file: /cvs/src/sys/isofs/udf/udf_subr.c,v retrieving revision 1.22 diff -u -p -r1.22 udf_subr.c --- isofs/udf/udf_subr.c16 Apr 2011 03:21:16 - 1.22 +++ isofs/udf/udf_subr.c2 Nov 2014 03:49:30 - @@ -36,7 +36,6 @@ #include sys/mount.h #include sys/vnode.h #include sys/dirent.h -#include sys/unistd.h #include sys/disklabel.h #include isofs/udf/ecma167-udf.h Index: isofs/udf/udf_vnops.c === RCS file: /cvs/src/sys/isofs/udf/udf_vnops.c,v retrieving revision 1.55 diff -u -p -r1.55 udf_vnops.c --- isofs/udf/udf_vnops.c 12 Jul 2014 18:50:00 - 1.55 +++ isofs/udf/udf_vnops.c 2 Nov 2014 03:55:33 - @@ -46,9 +46,9 @@ #include sys/vnode.h #include sys/dirent.h #include sys/queue.h -#include sys/unistd.h #include sys/endian.h #include sys/specdev.h +#include sys/unistd.h #include isofs/udf/ecma167-udf.h #include isofs/udf/udf.h Index: miscfs/fifofs/fifo_vnops.c === RCS file: /cvs/src/sys/miscfs/fifofs/fifo_vnops.c,v retrieving revision 1.42 diff -u -p -r1.42 fifo_vnops.c --- miscfs/fifofs/fifo_vnops.c 9 Oct 2014 16:36:36 - 1.42 +++ miscfs/fifofs/fifo_vnops.c 2 Nov 2014 03:53:38 - @@ -47,6 +47,8 @@ #include sys/malloc.h #include sys/poll.h #include sys/un.h +#include
Re: sys unistd includes
On Sun, Nov 02, 2014 at 01:08:46AM -0500, Ted Unangst wrote: several kernel files have a dependency on unistd.h but fail to include it. (indirect include through file.h, which i'd like to eliminate.) if you need the file, include it. and udf_subr.c at least is one file that doesn't need unistd.h for reference, here's the sys/file.h diff, then the big .c diff. The diff looks good though you seem to have missed some according to a run of include-what-you-use: missing removals kern/kern_event.c nfs/nfs_kq.c missing additions kern/tty.c for _POSIX_VDISABLE You might want to do builds on a least a few platforms to test as different platforms have different indirect includes...
Re: ressl: two way fds extention
On Sat, 1 Nov 2014, Jan Klemkow wrote: On Fri, Oct 31, 2014 at 09:18:26PM -0700, Doug Hogan wrote: On Sat, Nov 01, 2014 at 03:07:24AM +0100, Jan Klemkow wrote: Index: tls_client.c === RCS file: /cvs/src/lib/libtls/tls_client.c,v retrieving revision 1.1 diff -u -p -r1.1 tls_client.c --- tls_client.c 31 Oct 2014 13:46:17 - 1.1 +++ tls_client.c 1 Nov 2014 01:50:56 - @@ -123,6 +123,13 @@ err: int tls_connect_socket(struct tls *ctx, int socket, const char *hostname) { + return tls_connect_fds(ctx, socket, socket, hostname); +} This changes the behavior of tls_connect_socket() and tls_connect(). Joel's diff set ctx-socket = socket before calling tls_connect_fds() so it would behave the same. When you call tls_close(ctx), it will close ctx-socket in the existing code and Joel's diff. I don't think you want to change the semantics like this. I think either tls_connect_fds() is the special case where you need to manually close the sockets or tls_close() should close everything. With the above change, even people calling tls_connect() will need to save one of the fd_(read|write) before calling tls_close() and then close the fd afterward. Oh, sorry. This is my fault. I experimented a little bit and forgot this part. I corrected it in the diff below. Additionally I add some extra information about the closing behavior inside of the manpage. Thanks. I've just committed a slightly different version of this. Thanks, Jan Index: tls.c === RCS file: /cvs/src/lib/libtls/tls.c,v retrieving revision 1.1 diff -u -p -r1.1 tls.c --- tls.c 31 Oct 2014 13:46:17 - 1.1 +++ tls.c 1 Nov 2014 11:59:36 - @@ -217,6 +217,8 @@ tls_reset(struct tls *ctx) ctx-ssl_conn = NULL; ctx-ssl_ctx = NULL; + ctx-fd_read = -1; + ctx-fd_write = -1; ctx-socket = -1; ctx-err = 0; @@ -290,6 +292,8 @@ tls_close(struct tls *ctx) tls_set_error(ctx, close); goto err; } + ctx-fd_read = -1; + ctx-fd_write = -1; ctx-socket = -1; } Index: tls.h === RCS file: /cvs/src/lib/libtls/tls.h,v retrieving revision 1.1 diff -u -p -r1.1 tls.h --- tls.h 31 Oct 2014 13:46:17 - 1.1 +++ tls.h 1 Nov 2014 11:59:36 - @@ -66,6 +66,8 @@ void tls_free(struct tls *ctx); int tls_accept_socket(struct tls *ctx, struct tls **cctx, int socket); int tls_connect(struct tls *ctx, const char *host, const char *port); +int tls_connect_fds(struct tls *ctx, int fd_read, int fd_write, +const char *hostname); int tls_connect_socket(struct tls *ctx, int s, const char *hostname); int tls_read(struct tls *ctx, void *buf, size_t buflen, size_t *outlen); int tls_write(struct tls *ctx, const void *buf, size_t buflen, size_t *outlen); Index: tls_client.c === RCS file: /cvs/src/lib/libtls/tls_client.c,v retrieving revision 1.1 diff -u -p -r1.1 tls_client.c --- tls_client.c 31 Oct 2014 13:46:17 - 1.1 +++ tls_client.c 1 Nov 2014 11:59:36 - @@ -123,6 +123,15 @@ err: int tls_connect_socket(struct tls *ctx, int socket, const char *hostname) { + ctx-socket = socket; + + return tls_connect_fds(ctx, socket, socket, hostname); +} + +int +tls_connect_fds(struct tls *ctx, int fd_read, int fd_write, +const char *hostname) +{ union { struct in_addr ip4; struct in6_addr ip6; } addrbuf; X509 *cert = NULL; int ret; @@ -132,7 +141,13 @@ tls_connect_socket(struct tls *ctx, int goto err; } - ctx-socket = socket; + if (fd_read 0 || fd_write 0) { + tls_set_error(ctx, invalid file descriptors); + return (-1); + } + + ctx-fd_read = fd_read; + ctx-fd_write = fd_write; if ((ctx-ssl_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) { tls_set_error(ctx, ssl context failure); @@ -166,7 +181,8 @@ tls_connect_socket(struct tls *ctx, int tls_set_error(ctx, ssl connection failure); goto err; } - if (SSL_set_fd(ctx-ssl_conn, ctx-socket) != 1) { + if (SSL_set_rfd(ctx-ssl_conn, ctx-fd_read) != 1 || + SSL_set_wfd(ctx-ssl_conn, ctx-fd_write) != 1) { tls_set_error(ctx, ssl file descriptor failure); goto err; } Index: tls_init.3 === RCS file: /cvs/src/lib/libtls/tls_init.3,v retrieving revision 1.1 diff -u -p -r1.1 tls_init.3 --- tls_init.331 Oct 2014 13:46:17 - 1.1 +++ tls_init.31 Nov 2014 11:59:36 - @@
[no subject]
Envoyé depuis Windows Mail
Re: socket splicing thread
On 31 Oct 2014, at 22:37, Alexander Bluhm alexander.bl...@gmx.net wrote: On Fri, Oct 31, 2014 at 02:50:00PM +1000, David Gwynne wrote: so without splicing, the payloads from multiple tcp packets (at least all of the ones in a single softnet run?) get bundled up into a buffer that userland reads and then writes out again in a single go. right? you're suggesting the taskq as a way to defer output till after the current softnet call has processed all its packets and queued all the tcp packet payloads onto the socket? Exactly. its worth remembering there are other memory costs too. i think a kthread (the thing taskqs run on) is 5 pages amd64, so 20KB. We can delay the creation of the sosplice thread until user-land tries to splice for the first time. I would like to get in the sosplice pool in first. The user-land part was missing in my previous diff. Updated diff that actually can do make build. ok? the pool change seems fine. bluhm Index: sys/kern/kern_sysctl.c === RCS file: /data/mirror/openbsd/cvs/src/sys/kern/kern_sysctl.c,v retrieving revision 1.267 diff -u -p -u -p -r1.267 kern_sysctl.c --- sys/kern/kern_sysctl.c17 Oct 2014 01:51:39 - 1.267 +++ sys/kern/kern_sysctl.c31 Oct 2014 10:23:44 - @@ -1062,11 +1062,12 @@ fill_file(struct kinfo_file *kf, struct kf-so_family = so-so_proto-pr_domain-dom_family; kf-so_rcv_cc = so-so_rcv.sb_cc; kf-so_snd_cc = so-so_snd.sb_cc; - if (so-so_splice) { + if (isspliced(so)) { if (show_pointers) - kf-so_splice = PTRTOINT64(so-so_splice); - kf-so_splicelen = so-so_splicelen; - } else if (so-so_spliceback) + kf-so_splice = + PTRTOINT64(so-so_sp-ssp_socket); + kf-so_splicelen = so-so_sp-ssp_len; + } else if (issplicedback(so)) kf-so_splicelen = -1; if (!so-so_pcb) break; Index: sys/kern/uipc_socket.c === RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_socket.c,v retrieving revision 1.133 diff -u -p -u -p -r1.133 uipc_socket.c --- sys/kern/uipc_socket.c9 Sep 2014 02:07:17 - 1.133 +++ sys/kern/uipc_socket.c31 Oct 2014 10:23:44 - @@ -80,12 +80,19 @@ int somaxconn = SOMAXCONN; int sominconn = SOMINCONN; struct pool socket_pool; +#ifdef SOCKET_SPLICE +struct pool sosplice_pool; +#endif void soinit(void) { pool_init(socket_pool, sizeof(struct socket), 0, 0, 0, sockpl, NULL); +#ifdef SOCKET_SPLICE + pool_init(sosplice_pool, sizeof(struct sosplice), 0, 0, 0, sosppl, + NULL); +#endif } /* @@ -157,7 +164,7 @@ solisten(struct socket *so, int backlog) if (so-so_state (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING)) return (EOPNOTSUPP); #ifdef SOCKET_SPLICE - if (so-so_splice || so-so_spliceback) + if (isspliced(so) || issplicedback(so)) return (EOPNOTSUPP); #endif /* SOCKET_SPLICE */ s = splsoftnet(); @@ -199,10 +206,15 @@ sofree(struct socket *so) return; } #ifdef SOCKET_SPLICE - if (so-so_spliceback) - sounsplice(so-so_spliceback, so, so-so_spliceback != so); - if (so-so_splice) - sounsplice(so, so-so_splice, 0); + if (so-so_sp) { + if (issplicedback(so)) + sounsplice(so-so_sp-ssp_soback, so, + so-so_sp-ssp_soback != so); + if (isspliced(so)) + sounsplice(so, so-so_sp-ssp_socket, 0); + pool_put(sosplice_pool, so-so_sp); + so-so_sp = NULL; + } #endif /* SOCKET_SPLICE */ sbrelease(so-so_snd); sorflush(so); @@ -647,7 +659,7 @@ restart: m = so-so_rcv.sb_mb; #ifdef SOCKET_SPLICE - if (so-so_splice) + if (isspliced(so)) m = NULL; #endif /* SOCKET_SPLICE */ /* @@ -669,7 +681,7 @@ restart: #ifdef DIAGNOSTIC if (m == NULL so-so_rcv.sb_cc) #ifdef SOCKET_SPLICE - if (so-so_splice == NULL) + if (!isspliced(so)) #endif /* SOCKET_SPLICE */ panic(receive 1); #endif @@ -1021,6 +1033,12 @@ sorflush(struct socket *so) } #ifdef SOCKET_SPLICE + +#define so_splicelen so_sp-ssp_len +#define so_splicemax so_sp-ssp_max +#define so_idletvso_sp-ssp_idletv +#define so_idletoso_sp-ssp_idleto + int sosplice(struct socket *so, int fd, off_t max, struct timeval *tv) { @@ -1035,6 +1053,8 @@ sosplice(struct socket *so, int fd, off_ if ((so-so_state (SS_ISCONNECTED|SS_ISCONNECTING)) == 0