void
so_pru_send_async(struct socket *so, int flags, struct mbuf *m,
- struct sockaddr *addr, struct mbuf *control, struct thread *td)
+ struct sockaddr *addr0, struct mbuf *control, struct thread *td)
{
struct netmsg_pru_send *msg;
+ struct sockaddr *addr = NULL;
KASSERT(so->so_proto->pr_flags & PR_ASYNC_SEND,
("async pru_send is not supported\n"));
+ flags |= PRUS_NOREPLY;
+ if (addr0 != NULL) {
+ addr = kmalloc(addr0->sa_len, M_SONAME, M_WAITOK);
+ memcpy(addr, addr0, addr0->sa_len);
+ flags |= PRUS_FREEADDR;
+ }
+
msg = &m->m_hdr.mh_sndmsg;
netmsg_init(&msg->base, so, &netisr_apanic_rport,
0, so->so_proto->pr_usrreqs->pru_send);
- msg->nm_flags = flags | PRUS_NOREPLY;
+ msg->nm_flags = flags;
msg->nm_m = m;
msg->nm_addr = addr;
msg->nm_control = control;
if (flags & MSG_DONTROUTE)
pru_flags |= PRUS_DONTROUTE;
- /*
- * XXX
- * 'addr' could be free by the caller, so if it is ever supplied
- * we can't do asynchronized pru_send
- */
- if (addr == NULL && udp_sosnd_async && (flags & MSG_SYNC) == 0) {
+ if (udp_sosnd_async && (flags & MSG_SYNC) == 0) {
so_pru_send_async(so, pru_flags, top, addr, NULL, td);
error = 0;
} else {
#define PRUS_NAMALLOC 0x8
#define PRUS_NOREPLY 0x10
#define PRUS_DONTROUTE 0x20
+#define PRUS_FREEADDR 0x40
struct netmsg_pru_sense {
struct netmsg_base base;
struct socket *so = msg->send.base.nm_so;
int flags = msg->send.nm_flags;
struct mbuf *m = msg->send.nm_m;
- struct mbuf *control __debugvar = msg->send.nm_control;
int error = 0;
struct inpcb *inp;
struct tcpcb *tp;
TCPDEBUG0;
- KKASSERT(control == NULL);
+ KKASSERT(msg->send.nm_control == NULL);
+ KKASSERT(msg->send.nm_addr == NULL);
+ KKASSERT((flags & PRUS_FREEADDR) == 0);
inp = so->so_pcb;
{
struct socket *so = msg->send.base.nm_so;
struct mbuf *m = msg->send.nm_m;
+ struct sockaddr *addr = msg->send.nm_addr;
int pru_flags = msg->send.nm_flags;
struct inpcb *inp;
int error;
inp = so->so_pcb;
if (inp) {
- struct sockaddr *addr = msg->send.nm_addr;
struct thread *td = msg->send.nm_td;
int flags = 0;
error = EINVAL;
}
+ if (pru_flags & PRUS_FREEADDR)
+ kfree(addr, M_SONAME);
+
if ((pru_flags & PRUS_NOREPLY) == 0)
lwkt_replymsg(&msg->send.base.lmsg, error);
}