Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/uipc_socket.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.177.4.2.2.1.2.1 retrieving revision 1.179 diff -u -p -r1.177.4.2.2.1.2.1 -r1.179 --- src/sys/kern/uipc_socket.c 2010/04/21 00:28:18 1.177.4.2.2.1.2.1 +++ src/sys/kern/uipc_socket.c 2009/01/14 18:09:00 1.179 @@ -1,11 +1,11 @@ -/* $NetBSD: uipc_socket.c,v 1.177.4.2.2.1.2.1 2010/04/21 00:28:18 matt Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.179 2009/01/14 18:09:00 christos Exp $ */ /*- - * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. + * Copyright (c) 2002, 2007, 2008 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of Wasabi Systems, Inc, and by Andrew Doran. + * by Jason R. Thorpe of Wasabi Systems, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -63,8 +63,9 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.177.4.2.2.1.2.1 2010/04/21 00:28:18 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.179 2009/01/14 18:09:00 christos Exp $"); +#include "opt_compat_netbsd.h" #include "opt_sock_counters.h" #include "opt_sosend_loan.h" #include "opt_mbuftrace.h" @@ -92,6 +93,12 @@ __KERNEL_RCSID(0, "$NetBSD: uipc_socket. #include #include +#ifdef COMPAT_50 +#include +#define SO_OSNDTIMEO 0x1005 +#define SO_ORCVTIMEO 0x1006 +#endif + #include MALLOC_DEFINE(M_SOOPTS, "soopts", "socket options"); @@ -150,6 +157,9 @@ static kcondvar_t socurkva_cv; static size_t sodopendfree(void); static size_t sodopendfreel(void); +static void sysctl_kern_somaxkva_setup(void); +static struct sysctllog *socket_sysctllog; + static vsize_t sokvareserve(struct socket *so, vsize_t len) { @@ -423,6 +433,8 @@ void soinit(void) { + sysctl_kern_somaxkva_setup(); + mutex_init(&so_pendfree_lock, MUTEX_DEFAULT, IPL_VM); softnet_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE); cv_init(&socurkva_cv, "sokva"); @@ -669,7 +681,7 @@ soclose(struct socket *so) if ((so->so_state & SS_ISDISCONNECTING) && so->so_nbio) goto drop; while (so->so_state & SS_ISCONNECTED) { - error = sowait(so, true, so->so_linger * hz); + error = sowait(so, so->so_linger * hz); if (error) break; } @@ -1536,20 +1548,6 @@ soshutdown(struct socket *so, int how) return error; } -int -sodrain(struct socket *so) -{ - int error; - - solock(so); - so->so_state |= SS_ISDRAINING; - cv_broadcast(&so->so_cv); - error = soshutdown(so, SHUT_RDWR); - sounlock(so); - - return error; -} - void sorflush(struct socket *so) { @@ -1585,11 +1583,11 @@ sorflush(struct socket *so) static int sosetopt1(struct socket *so, const struct sockopt *sopt) { - int error, optval; + int error = 0, optval, opt; struct linger l; struct timeval tv; - switch (sopt->sopt_name) { + switch ((opt = sopt->sopt_name)) { case SO_ACCEPTFILTER: error = accept_filt_setopt(so, sopt); @@ -1627,9 +1625,9 @@ sosetopt1(struct socket *so, const struc if (error) break; if (optval) - so->so_options |= sopt->sopt_name; + so->so_options |= opt; else - so->so_options &= ~sopt->sopt_name; + so->so_options &= ~opt; break; case SO_SNDBUF: @@ -1650,7 +1648,7 @@ sosetopt1(struct socket *so, const struc break; } - switch (sopt->sopt_name) { + switch (opt) { case SO_SNDBUF: if (sbreserve(&so->so_snd, (u_long)optval, so) == 0) { error = ENOBUFS; @@ -1687,9 +1685,22 @@ sosetopt1(struct socket *so, const struc } break; +#ifdef COMPAT_50 + case SO_OSNDTIMEO: + case SO_ORCVTIMEO: { + struct timeval50 otv; + error = sockopt_get(sopt, &otv, sizeof(otv)); + timeval50_to_timeval(&otv, &tv); + opt = opt == SO_OSNDTIMEO ? SO_SNDTIMEO : SO_RCVTIMEO; + error = 1; + /*FALLTHROUGH*/ + } +#endif /* COMPAT_50 */ + case SO_SNDTIMEO: case SO_RCVTIMEO: - error = sockopt_get(sopt, &tv, sizeof(tv)); + if (error) + error = sockopt_get(sopt, &tv, sizeof(tv)); solock(so); if (error) break; @@ -1703,7 +1714,7 @@ sosetopt1(struct socket *so, const struc if (optval == 0 && tv.tv_usec != 0) optval = 1; - switch (sopt->sopt_name) { + switch (opt) { case SO_SNDTIMEO: so->so_snd.sb_timeo = optval; break; @@ -1776,11 +1787,11 @@ so_setsockopt(struct lwp *l, struct sock static int sogetopt1(struct socket *so, struct sockopt *sopt) { - int error, optval; + int error, optval, opt; struct linger l; struct timeval tv; - switch (sopt->sopt_name) { + switch ((opt = sopt->sopt_name)) { case SO_ACCEPTFILTER: error = accept_filt_getopt(so, sopt); @@ -1802,8 +1813,7 @@ sogetopt1(struct socket *so, struct sock case SO_BROADCAST: case SO_OOBINLINE: case SO_TIMESTAMP: - error = sockopt_setint(sopt, - (so->so_options & sopt->sopt_name) ? 1 : 0); + error = sockopt_setint(sopt, (so->so_options & opt) ? 1 : 0); break; case SO_TYPE: @@ -1831,9 +1841,25 @@ sogetopt1(struct socket *so, struct sock error = sockopt_setint(sopt, so->so_rcv.sb_lowat); break; +#ifdef COMPAT_50 + case SO_OSNDTIMEO: + case SO_ORCVTIMEO: { + struct timeval50 otv; + + optval = (opt == SO_OSNDTIMEO ? + so->so_snd.sb_timeo : so->so_rcv.sb_timeo); + + otv.tv_sec = optval / hz; + otv.tv_usec = (optval % hz) * tick; + + error = sockopt_set(sopt, &otv, sizeof(otv)); + break; + } +#endif /* COMPAT_50 */ + case SO_SNDTIMEO: case SO_RCVTIMEO: - optval = (sopt->sopt_name == SO_SNDTIMEO ? + optval = (opt == SO_SNDTIMEO ? so->so_snd.sb_timeo : so->so_rcv.sb_timeo); tv.tv_sec = optval / hz; @@ -2043,7 +2069,7 @@ sohasoutofband(struct socket *so) { fownsignal(so->so_pgid, SIGURG, POLL_PRI, POLLPRI|POLLRDBAND, so); - selnotify(&so->so_rcv.sb_sel, POLLPRI | POLLRDBAND, NOTE_SUBMIT); + selnotify(&so->so_rcv.sb_sel, POLLPRI | POLLRDBAND, 0); } static void @@ -2274,16 +2300,18 @@ sysctl_kern_somaxkva(SYSCTLFN_ARGS) return (error); } -SYSCTL_SETUP(sysctl_kern_somaxkva_setup, "sysctl kern.somaxkva setup") +static void +sysctl_kern_somaxkva_setup() { - sysctl_createv(clog, 0, NULL, NULL, + KASSERT(socket_sysctllog == NULL); + sysctl_createv(&socket_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT, CTLTYPE_NODE, "kern", NULL, NULL, 0, NULL, 0, CTL_KERN, CTL_EOL); - sysctl_createv(clog, 0, NULL, NULL, + sysctl_createv(&socket_sysctllog, 0, NULL, NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "somaxkva", SYSCTL_DESCR("Maximum amount of kernel memory to be "