2 * Copyright (c) 2003, 2004 Jeffrey M. Hsu. All rights reserved.
3 * Copyright (c) 2003, 2004 The DragonFly Project. All rights reserved.
5 * This code is derived from software contributed to The DragonFly Project
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of The DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific, prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/msgport.h>
38 #include <sys/protosw.h>
39 #include <sys/socket.h>
40 #include <sys/socketvar.h>
41 #include <sys/socketops.h>
42 #include <sys/thread.h>
43 #include <sys/msgport2.h>
44 #include <sys/spinlock2.h>
45 #include <sys/sysctl.h>
49 #include <net/netmsg2.h>
50 #include <net/netisr2.h>
51 #include <sys/socketvar2.h>
53 #include <net/netisr.h>
54 #include <net/netmsg.h>
56 static int async_rcvd_drop_race = 0;
57 SYSCTL_INT(_kern_ipc, OID_AUTO, async_rcvd_drop_race, CTLFLAG_RW,
58 &async_rcvd_drop_race, 0, "# of asynchronized pru_rcvd msg drop races");
61 * Abort a socket and free it, asynchronously. Called from
62 * soabort_async() only. soabort_async() got a ref on the
63 * socket which we must free on reply.
66 so_pru_abort_async(struct socket *so)
68 struct netmsg_pru_abort *msg;
70 msg = kmalloc(sizeof(*msg), M_LWKTMSG, M_WAITOK | M_ZERO);
71 netmsg_init(&msg->base, so, &netisr_afree_free_so_rport,
72 0, so->so_proto->pr_usrreqs->pru_abort);
73 lwkt_sendmsg(so->so_port, &msg->base.lmsg);
77 * Abort a socket and free it. Called from soabort_direct() only.
78 * Caller must make sure that the current CPU is inpcb's owner CPU.
79 * soabort_direct() got a ref on the socket which we must free.
82 so_pru_abort_direct(struct socket *so)
84 struct netmsg_pru_abort msg;
85 netisr_fn_t func = so->so_proto->pr_usrreqs->pru_abort;
87 netmsg_init(&msg.base, so, &netisr_adone_rport, 0, func);
88 msg.base.lmsg.ms_flags &= ~(MSGF_REPLY | MSGF_DONE);
89 msg.base.lmsg.ms_flags |= MSGF_SYNC;
91 KKASSERT(msg.base.lmsg.ms_flags & MSGF_DONE);
92 sofree(msg.base.nm_so);
96 so_pru_accept(struct socket *so, struct sockaddr **nam)
98 struct netmsg_pru_accept msg;
100 netmsg_init(&msg.base, so, &curthread->td_msgport,
101 0, so->so_proto->pr_usrreqs->pru_accept);
104 return lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
108 so_pru_attach(struct socket *so, int proto, struct pru_attach_info *ai)
110 struct netmsg_pru_attach msg;
113 netmsg_init(&msg.base, so, &curthread->td_msgport,
114 0, so->so_proto->pr_usrreqs->pru_attach);
115 msg.nm_proto = proto;
117 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
122 so_pru_attach_direct(struct socket *so, int proto, struct pru_attach_info *ai)
124 struct netmsg_pru_attach msg;
125 netisr_fn_t func = so->so_proto->pr_usrreqs->pru_attach;
127 netmsg_init(&msg.base, so, &netisr_adone_rport, 0, func);
128 msg.base.lmsg.ms_flags &= ~(MSGF_REPLY | MSGF_DONE);
129 msg.base.lmsg.ms_flags |= MSGF_SYNC;
130 msg.nm_proto = proto;
132 func((netmsg_t)&msg);
133 KKASSERT(msg.base.lmsg.ms_flags & MSGF_DONE);
134 return(msg.base.lmsg.ms_error);
138 so_pru_attach_fast(struct socket *so, int proto, struct pru_attach_info *ai)
140 struct netmsg_pru_attach *msg;
143 error = so->so_proto->pr_usrreqs->pru_preattach(so, proto, ai);
147 msg = kmalloc(sizeof(*msg), M_LWKTMSG, M_WAITOK | M_NULLOK);
150 * Fail to allocate message; fallback to
151 * synchronized pru_attach.
153 return so_pru_attach(so, proto, NULL /* postattach */);
156 netmsg_init(&msg->base, so, &netisr_afree_rport, 0,
157 so->so_proto->pr_usrreqs->pru_attach);
158 msg->nm_proto = proto;
159 msg->nm_ai = NULL; /* postattach */
160 if (so->so_port == netisr_curport())
161 lwkt_sendmsg_oncpu(so->so_port, &msg->base.lmsg);
163 lwkt_sendmsg(so->so_port, &msg->base.lmsg);
169 * NOTE: If the target port changes the bind operation will deal with it.
172 so_pru_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
174 struct netmsg_pru_bind msg;
177 netmsg_init(&msg.base, so, &curthread->td_msgport,
178 0, so->so_proto->pr_usrreqs->pru_bind);
180 msg.nm_td = td; /* used only for prison_ip() */
182 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
187 so_pru_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
189 struct netmsg_pru_connect msg;
192 netmsg_init(&msg.base, so, &curthread->td_msgport,
193 0, so->so_proto->pr_usrreqs->pru_connect);
199 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
204 so_pru_connect_async(struct socket *so, struct sockaddr *nam, struct thread *td)
206 struct netmsg_pru_connect *msg;
209 KASSERT(so->so_proto->pr_usrreqs->pru_preconnect != NULL,
210 ("async pru_connect is not supported"));
212 /* NOTE: sockaddr immediately follows netmsg */
213 msg = kmalloc(sizeof(*msg) + nam->sa_len, M_LWKTMSG,
214 M_WAITOK | M_NULLOK);
217 * Fail to allocate message; fallback to
218 * synchronized pru_connect.
220 return so_pru_connect(so, nam, td);
223 error = so->so_proto->pr_usrreqs->pru_preconnect(so, nam, td);
225 kfree(msg, M_LWKTMSG);
230 if (td != NULL && (so->so_proto->pr_flags & PR_ACONN_HOLDTD)) {
232 flags |= PRUC_HELDTD;
235 netmsg_init(&msg->base, so, &netisr_afree_rport, 0,
236 so->so_proto->pr_usrreqs->pru_connect);
237 msg->nm_nam = (struct sockaddr *)(msg + 1);
238 memcpy(msg->nm_nam, nam, nam->sa_len);
241 msg->nm_sndflags = 0;
242 msg->nm_flags = flags;
243 if (so->so_port == netisr_curport())
244 lwkt_sendmsg_oncpu(so->so_port, &msg->base.lmsg);
246 lwkt_sendmsg(so->so_port, &msg->base.lmsg);
251 so_pru_connect2(struct socket *so1, struct socket *so2)
253 struct netmsg_pru_connect2 msg;
256 netmsg_init(&msg.base, so1, &curthread->td_msgport,
257 0, so1->so_proto->pr_usrreqs->pru_connect2);
260 error = lwkt_domsg(so1->so_port, &msg.base.lmsg, 0);
265 * WARNING! Synchronous call from user context. Control function may do
269 so_pru_control_direct(struct socket *so, u_long cmd, caddr_t data,
272 struct netmsg_pru_control msg;
273 netisr_fn_t func = so->so_proto->pr_usrreqs->pru_control;
275 netmsg_init(&msg.base, so, &netisr_adone_rport, 0, func);
276 msg.base.lmsg.ms_flags &= ~(MSGF_REPLY | MSGF_DONE);
277 msg.base.lmsg.ms_flags |= MSGF_SYNC;
281 msg.nm_td = curthread;
282 func((netmsg_t)&msg);
283 KKASSERT(msg.base.lmsg.ms_flags & MSGF_DONE);
284 return(msg.base.lmsg.ms_error);
288 so_pru_detach(struct socket *so)
290 struct netmsg_pru_detach msg;
293 netmsg_init(&msg.base, so, &curthread->td_msgport,
294 0, so->so_proto->pr_usrreqs->pru_detach);
295 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
300 so_pru_detach_direct(struct socket *so)
302 struct netmsg_pru_detach msg;
303 netisr_fn_t func = so->so_proto->pr_usrreqs->pru_detach;
305 netmsg_init(&msg.base, so, &netisr_adone_rport, 0, func);
306 msg.base.lmsg.ms_flags &= ~(MSGF_REPLY | MSGF_DONE);
307 msg.base.lmsg.ms_flags |= MSGF_SYNC;
308 func((netmsg_t)&msg);
309 KKASSERT(msg.base.lmsg.ms_flags & MSGF_DONE);
310 return(msg.base.lmsg.ms_error);
314 so_pru_disconnect(struct socket *so)
316 struct netmsg_pru_disconnect msg;
319 netmsg_init(&msg.base, so, &curthread->td_msgport,
320 0, so->so_proto->pr_usrreqs->pru_disconnect);
321 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
326 so_pru_disconnect_direct(struct socket *so)
328 struct netmsg_pru_disconnect msg;
329 netisr_fn_t func = so->so_proto->pr_usrreqs->pru_disconnect;
331 netmsg_init(&msg.base, so, &netisr_adone_rport, 0, func);
332 msg.base.lmsg.ms_flags &= ~(MSGF_REPLY | MSGF_DONE);
333 msg.base.lmsg.ms_flags |= MSGF_SYNC;
334 func((netmsg_t)&msg);
335 KKASSERT(msg.base.lmsg.ms_flags & MSGF_DONE);
339 so_pru_listen(struct socket *so, struct thread *td)
341 struct netmsg_pru_listen msg;
344 netmsg_init(&msg.base, so, &curthread->td_msgport,
345 0, so->so_proto->pr_usrreqs->pru_listen);
346 msg.nm_td = td; /* used only for prison_ip() XXX JH */
348 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
353 so_pru_peeraddr(struct socket *so, struct sockaddr **nam)
355 struct netmsg_pru_peeraddr msg;
358 netmsg_init(&msg.base, so, &curthread->td_msgport,
359 0, so->so_proto->pr_usrreqs->pru_peeraddr);
361 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
366 so_pru_rcvd(struct socket *so, int flags)
368 struct netmsg_pru_rcvd msg;
371 netmsg_init(&msg.base, so, &curthread->td_msgport,
372 0, so->so_proto->pr_usrreqs->pru_rcvd);
373 msg.nm_flags = flags;
374 msg.nm_pru_flags = 0;
375 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
380 so_pru_rcvd_async(struct socket *so)
382 lwkt_msg_t lmsg = &so->so_rcvd_msg.base.lmsg;
384 KASSERT(so->so_proto->pr_flags & PR_ASYNC_RCVD,
385 ("async pru_rcvd is not supported"));
388 * WARNING! Spinlock is a bit dodgy, use hacked up sendmsg
389 * to avoid deadlocking.
391 spin_lock(&so->so_rcvd_spin);
392 if ((so->so_rcvd_msg.nm_pru_flags & PRUR_DEAD) == 0) {
393 if (lmsg->ms_flags & MSGF_DONE) {
394 lwkt_sendmsg_prepare(so->so_port, lmsg);
395 spin_unlock(&so->so_rcvd_spin);
396 if (so->so_port == netisr_curport())
397 lwkt_sendmsg_start_oncpu(so->so_port, lmsg);
399 lwkt_sendmsg_start(so->so_port, lmsg);
401 spin_unlock(&so->so_rcvd_spin);
404 spin_unlock(&so->so_rcvd_spin);
409 so_pru_rcvoob(struct socket *so, struct mbuf *m, int flags)
411 struct netmsg_pru_rcvoob msg;
414 netmsg_init(&msg.base, so, &curthread->td_msgport,
415 0, so->so_proto->pr_usrreqs->pru_rcvoob);
417 msg.nm_flags = flags;
418 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
423 * NOTE: If the target port changes the implied connect will deal with it.
426 so_pru_send(struct socket *so, int flags, struct mbuf *m,
427 struct sockaddr *addr, struct mbuf *control, struct thread *td)
429 struct netmsg_pru_send msg;
432 netmsg_init(&msg.base, so, &curthread->td_msgport,
433 0, so->so_proto->pr_usrreqs->pru_send);
434 msg.nm_flags = flags;
437 msg.nm_control = control;
439 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
444 so_pru_sync(struct socket *so)
446 struct netmsg_base msg;
448 netmsg_init(&msg, so, &curthread->td_msgport, 0,
449 netmsg_sync_handler);
450 lwkt_domsg(so->so_port, &msg.lmsg, 0);
454 so_pru_send_async(struct socket *so, int flags, struct mbuf *m,
455 struct sockaddr *addr0, struct mbuf *control, struct thread *td)
457 struct netmsg_pru_send *msg;
458 struct sockaddr *addr = NULL;
460 KASSERT(so->so_proto->pr_flags & PR_ASYNC_SEND,
461 ("async pru_send is not supported"));
464 addr = kmalloc(addr0->sa_len, M_SONAME, M_WAITOK | M_NULLOK);
467 * Fail to allocate address; fallback to
468 * synchronized pru_send.
470 so_pru_send(so, flags, m, addr0, control, td);
473 memcpy(addr, addr0, addr0->sa_len);
474 flags |= PRUS_FREEADDR;
476 flags |= PRUS_NOREPLY;
478 if (td != NULL && (so->so_proto->pr_flags & PR_ASEND_HOLDTD)) {
480 flags |= PRUS_HELDTD;
483 msg = &m->m_hdr.mh_sndmsg;
484 netmsg_init(&msg->base, so, &netisr_apanic_rport,
485 0, so->so_proto->pr_usrreqs->pru_send);
486 msg->nm_flags = flags;
489 msg->nm_control = control;
491 if (so->so_port == netisr_curport())
492 lwkt_sendmsg_oncpu(so->so_port, &msg->base.lmsg);
494 lwkt_sendmsg(so->so_port, &msg->base.lmsg);
498 so_pru_sense(struct socket *so, struct stat *sb)
500 struct netmsg_pru_sense msg;
503 netmsg_init(&msg.base, so, &curthread->td_msgport,
504 0, so->so_proto->pr_usrreqs->pru_sense);
506 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
511 so_pru_shutdown(struct socket *so)
513 struct netmsg_pru_shutdown msg;
516 netmsg_init(&msg.base, so, &curthread->td_msgport,
517 0, so->so_proto->pr_usrreqs->pru_shutdown);
518 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
523 so_pru_sockaddr(struct socket *so, struct sockaddr **nam)
525 struct netmsg_pru_sockaddr msg;
528 netmsg_init(&msg.base, so, &curthread->td_msgport,
529 0, so->so_proto->pr_usrreqs->pru_sockaddr);
531 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
536 so_pr_ctloutput(struct socket *so, struct sockopt *sopt)
538 struct netmsg_pr_ctloutput msg;
541 KKASSERT(!sopt->sopt_val || kva_p(sopt->sopt_val));
543 if (sopt->sopt_dir == SOPT_SET && so->so_proto->pr_ctloutmsg != NULL) {
544 struct netmsg_pr_ctloutput *amsg;
546 /* Fast path: asynchronous pr_ctloutput */
547 amsg = so->so_proto->pr_ctloutmsg(sopt);
549 netmsg_init(&amsg->base, so, &netisr_afree_rport, 0,
550 so->so_proto->pr_ctloutput);
551 /* nm_flags and nm_sopt are setup by pr_ctloutmsg */
552 if (so->so_port == netisr_curport()) {
553 lwkt_sendmsg_oncpu(so->so_port,
556 lwkt_sendmsg(so->so_port, &amsg->base.lmsg);
563 netmsg_init(&msg.base, so, &curthread->td_msgport,
564 0, so->so_proto->pr_ctloutput);
567 error = lwkt_domsg(so->so_port, &msg.base.lmsg, 0);
572 so_pr_ctlport(struct protosw *pr, int cmd, struct sockaddr *arg,
573 void *extra, int *cpuid)
575 if (pr->pr_ctlport == NULL)
577 KKASSERT(pr->pr_ctlinput != NULL);
579 return pr->pr_ctlport(cmd, arg, extra, cpuid);
583 * Protocol control input, typically via icmp.
585 * If the protocol pr_ctlport is not NULL we call it to figure out the
586 * protocol port. If NULL is returned we can just return, otherwise
587 * we issue a netmsg to call pr_ctlinput in the proper thread.
589 * This must be done synchronously as arg and/or extra may point to
593 so_pr_ctlinput(struct protosw *pr, int cmd, struct sockaddr *arg, void *extra)
595 struct netmsg_pr_ctlinput msg;
599 port = so_pr_ctlport(pr, cmd, arg, extra, &cpuid);
602 netmsg_init(&msg.base, NULL, &curthread->td_msgport,
607 msg.nm_extra = extra;
608 lwkt_domsg(port, &msg.base.lmsg, 0);
612 so_pr_ctlinput_direct(struct protosw *pr, int cmd, struct sockaddr *arg,
615 struct netmsg_pr_ctlinput msg;
620 port = so_pr_ctlport(pr, cmd, arg, extra, &cpuid);
623 if (cpuid != netisr_ncpus && cpuid != mycpuid)
626 func = pr->pr_ctlinput;
627 netmsg_init(&msg.base, NULL, &netisr_adone_rport, 0, func);
628 msg.base.lmsg.ms_flags &= ~(MSGF_REPLY | MSGF_DONE);
629 msg.base.lmsg.ms_flags |= MSGF_SYNC;
633 msg.nm_extra = extra;
634 func((netmsg_t)&msg);
635 KKASSERT(msg.base.lmsg.ms_flags & MSGF_DONE);
639 * If we convert all the protosw pr_ functions for all the protocols
640 * to take a message directly, this layer can go away. For the moment
641 * our dispatcher ignores the return value, but since we are handling
642 * the replymsg ourselves we return EASYNC by convention.
646 * Handle a predicate event request. This function is only called once
647 * when the predicate message queueing request is received.
650 netmsg_so_notify(netmsg_t msg)
652 struct socket *so = msg->base.nm_so;
653 struct signalsockbuf *ssb;
655 ssb = (msg->notify.nm_etype & NM_REVENT) ? &so->so_rcv : &so->so_snd;
658 * Reply immediately if the event has occured, otherwise queue the
661 * NOTE: Socket can change if this is an accept predicate so cache
664 lwkt_getpooltoken(so);
665 atomic_set_int(&ssb->ssb_flags, SSB_MEVENT);
666 if (msg->notify.nm_predicate(&msg->notify)) {
667 if (TAILQ_EMPTY(&ssb->ssb_mlist))
668 atomic_clear_int(&ssb->ssb_flags, SSB_MEVENT);
669 lwkt_relpooltoken(so);
670 lwkt_replymsg(&msg->base.lmsg,
671 msg->base.lmsg.ms_error);
673 TAILQ_INSERT_TAIL(&ssb->ssb_mlist, &msg->notify, nm_list);
676 * If predict ever blocks, 'tok' will be released, so
677 * SSB_MEVENT set beforehand could have been cleared
678 * when we reach here. In case that happens, we set
679 * SSB_MEVENT again, after the notify has been queued.
681 atomic_set_int(&ssb->ssb_flags, SSB_MEVENT);
682 lwkt_relpooltoken(so);
687 * Called by doio when trying to abort a netmsg_so_notify message.
688 * Unlike the other functions this one is dispatched directly by
689 * the LWKT subsystem, so it takes a lwkt_msg_t as an argument.
691 * The original message, lmsg, is under the control of the caller and
692 * will not be destroyed until we return so we can safely reference it
693 * in our synchronous abort request.
695 * This part of the abort request occurs on the originating cpu which
696 * means we may race the message flags and the original message may
697 * not even have been processed by the target cpu yet.
700 netmsg_so_notify_doabort(lwkt_msg_t lmsg)
702 struct netmsg_so_notify_abort msg;
704 if ((lmsg->ms_flags & (MSGF_DONE | MSGF_REPLY)) == 0) {
705 const struct netmsg_base *nmsg =
706 (const struct netmsg_base *)lmsg;
708 netmsg_init(&msg.base, nmsg->nm_so, &curthread->td_msgport,
709 0, netmsg_so_notify_abort);
710 msg.nm_notifymsg = (void *)lmsg;
711 lwkt_domsg(lmsg->ms_target_port, &msg.base.lmsg, 0);
716 * Predicate requests can be aborted. This function is only called once
717 * and will interlock against processing/reply races (since such races
718 * occur on the same thread that controls the port where the abort is
721 * This part of the abort request occurs on the target cpu. The message
722 * flags must be tested again in case the test that we did on the
723 * originating cpu raced. Since messages are handled in sequence, the
724 * original message will have already been handled by the loop and either
725 * replied to or queued.
727 * We really only need to interlock with MSGF_REPLY (a bit that is set on
728 * our cpu when we reply). Note that MSGF_DONE is not set until the
729 * reply reaches the originating cpu. Test both bits anyway.
732 netmsg_so_notify_abort(netmsg_t msg)
734 struct netmsg_so_notify_abort *abrtmsg = &msg->notify_abort;
735 struct netmsg_so_notify *nmsg = abrtmsg->nm_notifymsg;
736 struct signalsockbuf *ssb;
739 * The original notify message is not destroyed until after the
740 * abort request is returned, so we can check its state.
742 lwkt_getpooltoken(nmsg->base.nm_so);
743 if ((nmsg->base.lmsg.ms_flags & (MSGF_DONE | MSGF_REPLY)) == 0) {
744 ssb = (nmsg->nm_etype & NM_REVENT) ?
745 &nmsg->base.nm_so->so_rcv :
746 &nmsg->base.nm_so->so_snd;
747 TAILQ_REMOVE(&ssb->ssb_mlist, nmsg, nm_list);
748 lwkt_relpooltoken(nmsg->base.nm_so);
749 lwkt_replymsg(&nmsg->base.lmsg, EINTR);
751 lwkt_relpooltoken(nmsg->base.nm_so);
755 * Reply to the abort message
757 lwkt_replymsg(&abrtmsg->base.lmsg, 0);
761 so_async_rcvd_reply(struct socket *so)
764 * Spinlock safe, reply runs to degenerate lwkt_null_replyport()
766 spin_lock(&so->so_rcvd_spin);
767 lwkt_replymsg(&so->so_rcvd_msg.base.lmsg, 0);
768 spin_unlock(&so->so_rcvd_spin);
772 so_async_rcvd_drop(struct socket *so)
774 lwkt_msg_t lmsg = &so->so_rcvd_msg.base.lmsg;
777 * Spinlock safe, drop runs to degenerate lwkt_spin_dropmsg()
779 spin_lock(&so->so_rcvd_spin);
780 so->so_rcvd_msg.nm_pru_flags |= PRUR_DEAD;
783 if ((lmsg->ms_flags & MSGF_DONE) == 0) {
784 ++async_rcvd_drop_race;
785 ssleep(so, &so->so_rcvd_spin, 0, "soadrop", 1);
788 spin_unlock(&so->so_rcvd_spin);