If mbuf is not writable get a writable copy before invoking

m_pullup(9).

Tested by:	Garrett Cooper < yanefbsd <at> gmail dot com >
This commit is contained in:
Pyun YongHyeon 2008-09-30 04:52:30 +00:00
parent 925da971b8
commit ad415775a1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=183486

View file

@ -2559,7 +2559,16 @@ msk_encap(struct msk_if_softc *sc_if, struct mbuf **m_head)
struct ip *ip;
struct tcphdr *tcp;
/* TODO check for M_WRITABLE(m) */
if (M_WRITABLE(m) == 0) {
/* Get a writable copy. */
m = m_dup(*m_head, M_DONTWAIT);
m_freem(*m_head);
if (m == NULL) {
*m_head = NULL;
return (ENOBUFS);
}
*m_head = m;
}
offset = sizeof(struct ether_header);
m = m_pullup(m, offset);