diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-08-21 16:14:04 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-08-21 16:14:04 +0000 |
commit | 51b320a56b1066f625fa565d54a28268409b94fe (patch) | |
tree | 5fd29093f6c8d965abd338cb271807133105293f /sys/netinet/udp_usrreq.c | |
parent | a5550b6452d0153240f429c40e7522b3ffb6221c (diff) | |
download | FreeBSD-src-51b320a56b1066f625fa565d54a28268409b94fe.zip FreeBSD-src-51b320a56b1066f625fa565d54a28268409b94fe.tar.gz |
When prepending space onto outgoing UDP datagram payloads to hold the
UDP/IP header, make sure that space is also allocated for the link
layer header. If an mbuf must be allocated to hold the UDP/IP header
(very likely), then this will avoid an additional mbuf allocation at
the link layer. This trick is also used by TCP and other protocols to
avoid extra calls to the mbuf allocator in the ethernet (and related)
output routines.
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r-- | sys/netinet/udp_usrreq.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 5f1a1bb..81ab6e1 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -851,15 +851,18 @@ udp_output(inp, m, addr, control, td) goto release; } } + /* - * Calculate data length and get a mbuf - * for UDP and IP headers. + * Calculate data length and get a mbuf for UDP, IP, and possible + * link-layer headers. */ - M_PREPEND(m, sizeof(struct udpiphdr), M_DONTWAIT); - if (m == 0) { + M_PREPEND(m, sizeof(struct udpiphdr) + max_linkhdr, M_DONTWAIT); + if (m == NULL) { error = ENOBUFS; goto release; } + m->m_data += max_linkhdr; + m->m_len -= max_linkhdr; /* * Fill in mbuf with extended UDP header |