diff options
author | bz <bz@FreeBSD.org> | 2012-05-25 09:24:45 +0000 |
---|---|---|
committer | bz <bz@FreeBSD.org> | 2012-05-25 09:24:45 +0000 |
commit | 38909f62228cac599a036be39ae2bcb8fea24a4a (patch) | |
tree | 673e8d2dfbf3fcd7ad273d12b0db9762b1b0e42d /sys/netinet/udp_usrreq.c | |
parent | fe722ad5af4b63021329220b59efca9752e6cc2c (diff) | |
download | FreeBSD-src-38909f62228cac599a036be39ae2bcb8fea24a4a.zip FreeBSD-src-38909f62228cac599a036be39ae2bcb8fea24a4a.tar.gz |
MFp4 bz_ipv6_fast:
Properly protect the inp read access when handling the control code.
In the past this was expensive but given the rlock it's not so much
anymore.
Spotted while: optimizing udp6
Discussed with: rwatson (a few months ago)
Sponsored by: The FreeBSD Foundation
Sponsored by: iXsystems
Reviewed by: gnn (as part of the whole)
MFC After: 3 days
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r-- | sys/netinet/udp_usrreq.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 2056baf..d3e7aca 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -971,12 +971,14 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, } src.sin_family = 0; + INP_RLOCK(inp); if (control != NULL) { /* * XXX: Currently, we assume all the optional information is * stored in a single mbuf. */ if (control->m_next) { + INP_RUNLOCK(inp); m_freem(control); m_freem(m); return (EINVAL); @@ -1018,6 +1020,7 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, m_freem(control); } if (error) { + INP_RUNLOCK(inp); m_freem(m); return (error); } @@ -1039,7 +1042,6 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, * XXXRW: Check that hash locking update here is correct. */ sin = (struct sockaddr_in *)addr; - INP_RLOCK(inp); if (sin != NULL && (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0)) { INP_RUNLOCK(inp); |