Improve m_cat() by being able to also merge contents from M_EXT
mbuf's by doing proper testing with M_WRITABLE(). In m_collapse() replace an incomplete manual check for M_RDONLY with the M_WRITABLE() macro that also tests for shared buffers and other cases that make a particular mbuf immutable. MFC after: 2 weeks
This commit is contained in:
parent
4faaea5505
commit
14d7c5b11c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=242256
@ -911,8 +911,8 @@ m_cat(struct mbuf *m, struct mbuf *n)
|
||||
while (m->m_next)
|
||||
m = m->m_next;
|
||||
while (n) {
|
||||
if (m->m_flags & M_EXT ||
|
||||
m->m_data + m->m_len + n->m_len >= &m->m_dat[MLEN]) {
|
||||
if (!M_WRITABLE(m) ||
|
||||
M_TRAILINGSPACE(m) < n->m_len) {
|
||||
/* just join the two chains */
|
||||
m->m_next = n;
|
||||
return;
|
||||
@ -1584,7 +1584,7 @@ m_collapse(struct mbuf *m0, int how, int maxfrags)
|
||||
n = m->m_next;
|
||||
if (n == NULL)
|
||||
break;
|
||||
if ((m->m_flags & M_RDONLY) == 0 &&
|
||||
if (M_WRITABLE(m) &&
|
||||
n->m_len < M_TRAILINGSPACE(m)) {
|
||||
bcopy(mtod(n, void *), mtod(m, char *) + m->m_len,
|
||||
n->m_len);
|
||||
|
Loading…
Reference in New Issue
Block a user