Home | History | Annotate | Line # | Download | only in libsockin
sockin.c revision 1.4.2.1
      1  1.4.2.1    skrll /*	$NetBSD: sockin.c,v 1.4.2.1 2009/01/19 13:20:29 skrll Exp $	*/
      2      1.1    pooka 
      3      1.1    pooka /*
      4      1.1    pooka  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
      5      1.1    pooka  *
      6      1.1    pooka  * Redistribution and use in source and binary forms, with or without
      7      1.1    pooka  * modification, are permitted provided that the following conditions
      8      1.1    pooka  * are met:
      9      1.1    pooka  * 1. Redistributions of source code must retain the above copyright
     10      1.1    pooka  *    notice, this list of conditions and the following disclaimer.
     11      1.1    pooka  * 2. Redistributions in binary form must reproduce the above copyright
     12      1.1    pooka  *    notice, this list of conditions and the following disclaimer in the
     13      1.1    pooka  *    documentation and/or other materials provided with the distribution.
     14      1.1    pooka  *
     15      1.1    pooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     16      1.1    pooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17      1.1    pooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18      1.1    pooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19      1.1    pooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20      1.1    pooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21      1.1    pooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22      1.1    pooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23      1.1    pooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24      1.1    pooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25      1.1    pooka  * SUCH DAMAGE.
     26      1.1    pooka  */
     27      1.1    pooka 
     28  1.4.2.1    skrll #include <sys/cdefs.h>
     29  1.4.2.1    skrll __KERNEL_RCSID(0, "$NetBSD: sockin.c,v 1.4.2.1 2009/01/19 13:20:29 skrll Exp $");
     30  1.4.2.1    skrll 
     31      1.1    pooka #include <sys/param.h>
     32      1.1    pooka #include <sys/condvar.h>
     33      1.1    pooka #include <sys/domain.h>
     34      1.1    pooka #include <sys/kmem.h>
     35      1.1    pooka #include <sys/kthread.h>
     36      1.1    pooka #include <sys/mbuf.h>
     37      1.1    pooka #include <sys/mutex.h>
     38      1.1    pooka #include <sys/poll.h>
     39      1.1    pooka #include <sys/protosw.h>
     40      1.1    pooka #include <sys/queue.h>
     41      1.1    pooka #include <sys/socket.h>
     42      1.1    pooka #include <sys/socketvar.h>
     43      1.1    pooka #include <sys/time.h>
     44      1.1    pooka 
     45  1.4.2.1    skrll #include <net/radix.h>
     46  1.4.2.1    skrll 
     47      1.1    pooka #include <netinet/in.h>
     48      1.1    pooka #include <netinet/in_systm.h>
     49      1.1    pooka #include <netinet/ip.h>
     50      1.1    pooka 
     51      1.1    pooka #include <rump/rumpuser.h>
     52      1.1    pooka 
     53      1.1    pooka /*
     54      1.1    pooka  * An inet communication domain which uses the socket interface.
     55      1.1    pooka  * Currently supports only IPv4 UDP, but could easily be extended to
     56      1.1    pooka  * support IPv6 and TCP by adding more stuff to the protosw.
     57      1.1    pooka  */
     58      1.1    pooka 
     59      1.1    pooka DOMAIN_DEFINE(sockindomain);
     60      1.1    pooka 
     61      1.1    pooka static void	sockin_init(void);
     62      1.1    pooka static int	sockin_usrreq(struct socket *, int, struct mbuf *,
     63      1.1    pooka 			      struct mbuf *, struct mbuf *, struct lwp *);
     64  1.4.2.1    skrll static int	sockin_ctloutput(int op, struct socket *, struct sockopt *);
     65      1.1    pooka 
     66      1.1    pooka const struct protosw sockinsw[] = {
     67      1.2    pooka {
     68      1.2    pooka 	.pr_type = SOCK_DGRAM,
     69      1.1    pooka 	.pr_domain = &sockindomain,
     70      1.1    pooka 	.pr_protocol = IPPROTO_UDP,
     71      1.1    pooka 	.pr_flags = PR_ATOMIC|PR_ADDR,
     72      1.1    pooka 	.pr_usrreq = sockin_usrreq,
     73  1.4.2.1    skrll 	.pr_ctloutput = sockin_ctloutput,
     74      1.2    pooka },
     75      1.2    pooka {
     76      1.2    pooka 	.pr_type = SOCK_STREAM,
     77      1.2    pooka 	.pr_domain = &sockindomain,
     78      1.2    pooka 	.pr_protocol = IPPROTO_TCP,
     79      1.2    pooka 	.pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN|PR_ABRTACPTDIS,
     80      1.2    pooka 	.pr_usrreq = sockin_usrreq,
     81  1.4.2.1    skrll 	.pr_ctloutput = sockin_ctloutput,
     82      1.1    pooka }};
     83      1.1    pooka 
     84      1.1    pooka struct domain sockindomain = {
     85      1.1    pooka 	.dom_family = PF_INET,
     86      1.1    pooka 	.dom_name = "socket_inet",
     87      1.2    pooka 	.dom_init = sockin_init,
     88      1.1    pooka 	.dom_externalize = NULL,
     89      1.1    pooka 	.dom_dispose = NULL,
     90      1.1    pooka 	.dom_protosw = sockinsw,
     91      1.4  minskim 	.dom_protoswNPROTOSW = &sockinsw[__arraycount(sockinsw)],
     92  1.4.2.1    skrll 	.dom_rtattach = rn_inithead,
     93  1.4.2.1    skrll 	.dom_rtoffset = 32,
     94  1.4.2.1    skrll 	.dom_maxrtkey = sizeof(struct sockaddr_in),
     95      1.1    pooka 	.dom_ifattach = NULL,
     96      1.1    pooka 	.dom_ifdetach = NULL,
     97      1.1    pooka 	.dom_ifqueues = { NULL },
     98      1.1    pooka 	.dom_link = { NULL },
     99      1.1    pooka 	.dom_mowner = MOWNER_INIT("",""),
    100      1.1    pooka 	.dom_rtcache = { NULL },
    101      1.1    pooka 	.dom_sockaddr_cmp = NULL
    102      1.1    pooka };
    103      1.1    pooka 
    104      1.1    pooka /* only for testing */
    105      1.1    pooka #if 0
    106      1.1    pooka #define SOCKIN_NOTHREAD
    107      1.1    pooka #endif
    108      1.1    pooka 
    109      1.3    pooka #define SO2S(so) ((intptr_t)(so->so_internal))
    110      1.2    pooka #define SOCKIN_SBSIZE 65536
    111      1.1    pooka 
    112  1.4.2.1    skrll struct sockin_unit {
    113  1.4.2.1    skrll 	struct socket *su_so;
    114  1.4.2.1    skrll 
    115  1.4.2.1    skrll 	LIST_ENTRY(sockin_unit) su_entries;
    116  1.4.2.1    skrll };
    117  1.4.2.1    skrll static LIST_HEAD(, sockin_unit) su_ent = LIST_HEAD_INITIALIZER(su_ent);
    118  1.4.2.1    skrll static kmutex_t su_mtx;
    119  1.4.2.1    skrll static bool rebuild;
    120  1.4.2.1    skrll static int nsock;
    121  1.4.2.1    skrll 
    122  1.4.2.1    skrll static int
    123  1.4.2.1    skrll registersock(struct socket *so, int news)
    124  1.4.2.1    skrll {
    125  1.4.2.1    skrll 	struct sockin_unit *su;
    126  1.4.2.1    skrll 
    127  1.4.2.1    skrll 	su = kmem_alloc(sizeof(*su), KM_NOSLEEP);
    128  1.4.2.1    skrll 	if (!su)
    129  1.4.2.1    skrll 		return ENOMEM;
    130  1.4.2.1    skrll 
    131  1.4.2.1    skrll 	so->so_internal = (void *)(intptr_t)news;
    132  1.4.2.1    skrll 	su->su_so = so;
    133  1.4.2.1    skrll 
    134  1.4.2.1    skrll 	mutex_enter(&su_mtx);
    135  1.4.2.1    skrll 	LIST_INSERT_HEAD(&su_ent, su, su_entries);
    136  1.4.2.1    skrll 	nsock++;
    137  1.4.2.1    skrll 	rebuild = true;
    138  1.4.2.1    skrll 	mutex_exit(&su_mtx);
    139  1.4.2.1    skrll 
    140  1.4.2.1    skrll 	return 0;
    141  1.4.2.1    skrll }
    142  1.4.2.1    skrll 
    143      1.1    pooka static void
    144      1.1    pooka sockin_process(struct socket *so)
    145      1.1    pooka {
    146      1.1    pooka 	struct sockaddr_in from;
    147      1.1    pooka 	struct iovec io;
    148      1.1    pooka 	struct msghdr rmsg;
    149      1.1    pooka 	struct mbuf *m;
    150      1.1    pooka 	ssize_t n;
    151      1.1    pooka 	size_t plen;
    152      1.1    pooka 	int error;
    153      1.1    pooka 
    154      1.1    pooka 	plen = IP_MAXPACKET;
    155      1.1    pooka 	m = m_gethdr(M_WAIT, MT_DATA);
    156      1.1    pooka 	MEXTMALLOC(m, plen, M_WAIT);
    157      1.1    pooka 
    158      1.1    pooka 	memset(&rmsg, 0, sizeof(rmsg));
    159      1.1    pooka 	io.iov_base = mtod(m, void *);
    160      1.1    pooka 	io.iov_len = plen;
    161      1.1    pooka 	rmsg.msg_iov = &io;
    162      1.1    pooka 	rmsg.msg_iovlen = 1;
    163      1.1    pooka 	rmsg.msg_name = (struct sockaddr *)&from;
    164      1.1    pooka 	rmsg.msg_namelen = sizeof(from);
    165      1.1    pooka 
    166      1.1    pooka 	n = rumpuser_net_recvmsg(SO2S(so), &rmsg, 0, &error);
    167      1.1    pooka 	if (n <= 0) {
    168      1.1    pooka 		m_freem(m);
    169      1.1    pooka 		return;
    170      1.1    pooka 	}
    171      1.1    pooka 	m->m_len = m->m_pkthdr.len = n;
    172      1.1    pooka 
    173      1.2    pooka 	if (so->so_proto->pr_type == SOCK_DGRAM) {
    174      1.2    pooka 		if (!sbappendaddr(&so->so_rcv, rmsg.msg_name, m, NULL)) {
    175      1.2    pooka 			m_freem(m);
    176      1.2    pooka 		}
    177      1.2    pooka 	} else {
    178      1.2    pooka 		sbappendstream(&so->so_rcv, m);
    179      1.1    pooka 	}
    180      1.2    pooka 
    181      1.1    pooka 	sorwakeup(so);
    182      1.1    pooka }
    183      1.1    pooka 
    184  1.4.2.1    skrll #ifndef SOCKIN_NOTHREAD
    185  1.4.2.1    skrll static void
    186  1.4.2.1    skrll sockin_accept(struct socket *so)
    187  1.4.2.1    skrll {
    188  1.4.2.1    skrll 	struct socket *nso;
    189  1.4.2.1    skrll 	struct sockaddr_in sin;
    190  1.4.2.1    skrll 	int news, error, slen;
    191  1.4.2.1    skrll 
    192  1.4.2.1    skrll 	slen = sizeof(sin);
    193  1.4.2.1    skrll 	news = rumpuser_net_accept(SO2S(so), (struct sockaddr *)&sin,
    194  1.4.2.1    skrll 	    &slen, &error);
    195  1.4.2.1    skrll 	if (news == -1)
    196  1.4.2.1    skrll 		return;
    197      1.1    pooka 
    198  1.4.2.1    skrll 	if ((nso = sonewconn(so, SS_ISCONNECTED)) == NULL)
    199  1.4.2.1    skrll 		goto errout;
    200  1.4.2.1    skrll 	if (registersock(nso, news) != 0)
    201  1.4.2.1    skrll 		goto errout;
    202  1.4.2.1    skrll 	return;
    203  1.4.2.1    skrll 
    204  1.4.2.1    skrll  errout:
    205  1.4.2.1    skrll 	rumpuser_close(news, &error);
    206  1.4.2.1    skrll 	if (nso)
    207  1.4.2.1    skrll 		soclose(nso);
    208  1.4.2.1    skrll }
    209      1.1    pooka 
    210      1.1    pooka #define POLLTIMEOUT 100	/* check for new entries every 100ms */
    211      1.1    pooka 
    212      1.1    pooka /* XXX: doesn't handle socket (kernel) locking properly? */
    213      1.1    pooka static void
    214      1.1    pooka sockinworker(void *arg)
    215      1.1    pooka {
    216      1.1    pooka 	struct pollfd *pfds = NULL, *npfds;
    217      1.1    pooka 	struct sockin_unit *su_iter;
    218  1.4.2.1    skrll 	struct socket *so;
    219      1.1    pooka 	int cursock = 0, i, rv, error;
    220      1.1    pooka 
    221      1.1    pooka 	/*
    222      1.1    pooka 	 * Loop reading requests.  Check for new sockets periodically
    223      1.1    pooka 	 * (could be smarter, but I'm lazy).
    224      1.1    pooka 	 */
    225      1.1    pooka 	for (;;) {
    226      1.1    pooka 		if (rebuild) {
    227      1.1    pooka 			npfds = NULL;
    228      1.1    pooka 			mutex_enter(&su_mtx);
    229      1.1    pooka 			if (nsock)
    230      1.1    pooka 				npfds = kmem_alloc(nsock * sizeof(*npfds),
    231      1.1    pooka 				    KM_NOSLEEP);
    232      1.1    pooka 			if (npfds || nsock == 0) {
    233      1.1    pooka 				if (pfds)
    234      1.1    pooka 					kmem_free(pfds, cursock*sizeof(*pfds));
    235      1.1    pooka 				pfds = npfds;
    236      1.1    pooka 				cursock = nsock;
    237      1.1    pooka 				rebuild = false;
    238      1.1    pooka 
    239      1.1    pooka 				i = 0;
    240      1.1    pooka 				LIST_FOREACH(su_iter, &su_ent, su_entries) {
    241      1.1    pooka 					pfds[i].fd = SO2S(su_iter->su_so);
    242      1.1    pooka 					pfds[i].events = POLLIN;
    243      1.1    pooka 					pfds[i].revents = 0;
    244      1.1    pooka 					i++;
    245      1.1    pooka 				}
    246      1.1    pooka 				KASSERT(i == nsock);
    247      1.1    pooka 			}
    248      1.1    pooka 			mutex_exit(&su_mtx);
    249      1.1    pooka 		}
    250      1.1    pooka 
    251      1.1    pooka 		/* find affected sockets & process */
    252      1.1    pooka 		rv = rumpuser_poll(pfds, cursock, POLLTIMEOUT, &error);
    253      1.1    pooka 		for (i = 0; i < cursock && rv > 0; i++) {
    254      1.1    pooka 			if (pfds[i].revents & POLLIN) {
    255      1.1    pooka 				mutex_enter(&su_mtx);
    256      1.1    pooka 				LIST_FOREACH(su_iter, &su_ent, su_entries) {
    257      1.1    pooka 					if (SO2S(su_iter->su_so)==pfds[i].fd) {
    258  1.4.2.1    skrll 						so = su_iter->su_so;
    259  1.4.2.1    skrll 						mutex_exit(&su_mtx);
    260      1.1    pooka 						mutex_enter(softnet_lock);
    261  1.4.2.1    skrll 						if(so->so_options&SO_ACCEPTCONN)
    262  1.4.2.1    skrll 							sockin_accept(so);
    263  1.4.2.1    skrll 						else
    264  1.4.2.1    skrll 							sockin_process(so);
    265      1.1    pooka 						mutex_exit(softnet_lock);
    266  1.4.2.1    skrll 						mutex_enter(&su_mtx);
    267      1.1    pooka 						break;
    268      1.1    pooka 					}
    269      1.1    pooka 				}
    270      1.1    pooka 				/* if we can't find it, just wing it */
    271      1.1    pooka 				KASSERT(rebuild || su_iter);
    272      1.1    pooka 				mutex_exit(&su_mtx);
    273      1.1    pooka 				pfds[i].revents = 0;
    274      1.1    pooka 				rv--;
    275      1.1    pooka 				i = -1;
    276      1.1    pooka 				continue;
    277      1.1    pooka 			}
    278      1.1    pooka 
    279      1.1    pooka 			/* something else?  ignore */
    280      1.1    pooka 			if (pfds[i].revents) {
    281      1.1    pooka 				pfds[i].revents = 0;
    282      1.1    pooka 				rv--;
    283      1.1    pooka 			}
    284      1.1    pooka 		}
    285      1.1    pooka 		KASSERT(rv <= 0);
    286      1.1    pooka 	}
    287      1.1    pooka 
    288      1.1    pooka }
    289      1.1    pooka #endif /* SOCKIN_NOTHREAD */
    290      1.1    pooka 
    291      1.1    pooka static void
    292      1.1    pooka sockin_init()
    293      1.1    pooka {
    294      1.1    pooka #ifndef SOCKIN_NOTHREAD
    295      1.1    pooka 	int rv;
    296      1.1    pooka 
    297      1.1    pooka 	if ((rv = kthread_create(PRI_NONE, 0, NULL, sockinworker,
    298      1.1    pooka 	    NULL, NULL, "sockwork")) != 0)
    299      1.1    pooka 		panic("sockin_init: could not create worker thread\n");
    300      1.1    pooka #endif
    301      1.1    pooka 	mutex_init(&su_mtx, MUTEX_DEFAULT, IPL_NONE);
    302      1.1    pooka }
    303      1.1    pooka 
    304      1.1    pooka static int
    305      1.1    pooka sockin_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
    306      1.1    pooka 	struct mbuf *control, struct lwp *l)
    307      1.1    pooka {
    308      1.2    pooka 	int error = 0, rv;
    309      1.1    pooka 
    310      1.1    pooka 	switch (req) {
    311      1.1    pooka 	case PRU_ATTACH:
    312      1.1    pooka 	{
    313      1.1    pooka 		int news;
    314      1.1    pooka 
    315      1.1    pooka 		sosetlock(so);
    316      1.2    pooka 		if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
    317      1.2    pooka 			error = soreserve(so, SOCKIN_SBSIZE, SOCKIN_SBSIZE);
    318      1.2    pooka 			if (error)
    319      1.2    pooka 				break;
    320      1.2    pooka 		}
    321      1.1    pooka 
    322      1.2    pooka 		news = rumpuser_net_socket(PF_INET, so->so_proto->pr_type,
    323      1.2    pooka 		    0, &error);
    324  1.4.2.1    skrll 		if (news == -1)
    325      1.1    pooka 			break;
    326      1.1    pooka 
    327  1.4.2.1    skrll 		if ((error = registersock(so, news)) != 0)
    328  1.4.2.1    skrll 			rumpuser_close(news, &error);
    329  1.4.2.1    skrll 
    330      1.1    pooka 		break;
    331      1.1    pooka 	}
    332      1.1    pooka 
    333  1.4.2.1    skrll 	case PRU_ACCEPT:
    334  1.4.2.1    skrll 		/* we do all the work in the worker thread */
    335  1.4.2.1    skrll 		break;
    336  1.4.2.1    skrll 
    337  1.4.2.1    skrll 	case PRU_BIND:
    338  1.4.2.1    skrll 		rumpuser_net_bind(SO2S(so), mtod(nam, const struct sockaddr *),
    339  1.4.2.1    skrll 		    sizeof(struct sockaddr_in), &error);
    340  1.4.2.1    skrll 		break;
    341  1.4.2.1    skrll 
    342      1.1    pooka 	case PRU_CONNECT:
    343      1.2    pooka 		/* don't bother to connect udp sockets, always sendmsg */
    344      1.2    pooka 		if (so->so_proto->pr_type == SOCK_DGRAM)
    345      1.2    pooka 			break;
    346      1.2    pooka 
    347      1.3    pooka 		rv = rumpuser_net_connect(SO2S(so),
    348      1.2    pooka 		    mtod(nam, struct sockaddr *), sizeof(struct sockaddr_in),
    349      1.2    pooka 		    &error);
    350      1.2    pooka 		if (rv == 0)
    351      1.2    pooka 		soisconnected(so);
    352      1.1    pooka 		break;
    353      1.1    pooka 
    354  1.4.2.1    skrll 	case PRU_LISTEN:
    355  1.4.2.1    skrll 		rumpuser_net_listen(SO2S(so), so->so_qlimit, &error);
    356  1.4.2.1    skrll 		break;
    357  1.4.2.1    skrll 
    358      1.1    pooka 	case PRU_SEND:
    359      1.1    pooka 	{
    360      1.1    pooka 		struct sockaddr *saddr;
    361      1.1    pooka 		struct msghdr mhdr;
    362      1.1    pooka 		struct iovec iov[16];
    363      1.1    pooka 		struct mbuf *m2;
    364      1.1    pooka 		size_t tot;
    365      1.1    pooka 		int i, s;
    366      1.1    pooka 
    367      1.1    pooka 		memset(&mhdr, 0, sizeof(mhdr));
    368      1.1    pooka 
    369      1.1    pooka 		tot = 0;
    370      1.1    pooka 		for (i = 0, m2 = m; m2; m2 = m2->m_next, i++) {
    371      1.1    pooka 			if (i > 16)
    372      1.1    pooka 				panic("lazy bum");
    373      1.1    pooka 			iov[i].iov_base = m2->m_data;
    374      1.1    pooka 			iov[i].iov_len = m2->m_len;
    375      1.1    pooka 			tot += m2->m_len;
    376      1.1    pooka 
    377      1.1    pooka 		}
    378      1.1    pooka 		mhdr.msg_iov = iov;
    379      1.1    pooka 		mhdr.msg_iovlen = i;
    380      1.3    pooka 		s = SO2S(so);
    381      1.2    pooka 
    382      1.2    pooka 		if (so->so_proto->pr_type == SOCK_DGRAM) {
    383      1.2    pooka 			saddr = mtod(nam, struct sockaddr *);
    384      1.2    pooka 			mhdr.msg_name = saddr;
    385      1.2    pooka 			mhdr.msg_namelen = saddr->sa_len;
    386      1.2    pooka 		}
    387      1.1    pooka 
    388      1.1    pooka 		rumpuser_net_sendmsg(s, &mhdr, 0, &error);
    389      1.2    pooka 
    390      1.1    pooka 		m_freem(m);
    391      1.1    pooka 		m_freem(control);
    392      1.1    pooka #ifdef SOCKIN_NOTHREAD
    393      1.1    pooka 		/* this assumes too many things to list.. buthey, testing */
    394      1.1    pooka 		sockin_process(so);
    395      1.1    pooka #endif
    396      1.1    pooka 	}
    397      1.1    pooka 		break;
    398      1.1    pooka 
    399      1.1    pooka 	case PRU_SHUTDOWN:
    400      1.1    pooka 	{
    401      1.1    pooka 		struct sockin_unit *su_iter;
    402      1.1    pooka 
    403      1.1    pooka 		mutex_enter(&su_mtx);
    404      1.1    pooka 		LIST_FOREACH(su_iter, &su_ent, su_entries) {
    405      1.1    pooka 			if (su_iter->su_so == so)
    406      1.1    pooka 				break;
    407      1.1    pooka 		}
    408      1.1    pooka 		if (!su_iter)
    409      1.1    pooka 			panic("no such socket");
    410      1.1    pooka 
    411      1.1    pooka 		LIST_REMOVE(su_iter, su_entries);
    412      1.1    pooka 		nsock--;
    413      1.1    pooka 		rebuild = true;
    414      1.1    pooka 		mutex_exit(&su_mtx);
    415      1.1    pooka 
    416      1.1    pooka 		rumpuser_close(SO2S(su_iter->su_so), &error);
    417      1.1    pooka 		kmem_free(su_iter, sizeof(*su_iter));
    418      1.1    pooka 	}
    419      1.1    pooka 		break;
    420      1.1    pooka 
    421      1.1    pooka 	default:
    422      1.1    pooka 		panic("sockin_usrreq: IMPLEMENT ME, req %d not supported", req);
    423      1.1    pooka 	}
    424      1.1    pooka 
    425      1.1    pooka 	return error;
    426      1.1    pooka }
    427  1.4.2.1    skrll 
    428  1.4.2.1    skrll static int
    429  1.4.2.1    skrll sockin_ctloutput(int op, struct socket *so, struct sockopt *sopt)
    430  1.4.2.1    skrll {
    431  1.4.2.1    skrll 
    432  1.4.2.1    skrll 	/* XXX: we should also do something here */
    433  1.4.2.1    skrll 	return 0;
    434  1.4.2.1    skrll }
    435