mirror of
https://github.com/opnsense/src.git
synced 2026-02-04 03:00:53 -06:00
mb_unmapped_to_ext(): return error code on error
(cherry picked from commit cf322978d73a3ed4958cb64cc4f1b47ceb53a03e)
This commit is contained in:
parent
316a0990f0
commit
33a19b8045
@ -936,8 +936,8 @@ mb_unmapped_free_mext(struct mbuf *m)
|
||||
mb_free_extpg(old_m);
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
_mb_unmapped_to_ext(struct mbuf *m)
|
||||
static int
|
||||
_mb_unmapped_to_ext(struct mbuf *m, struct mbuf **mres)
|
||||
{
|
||||
struct mbuf *m_new, *top, *prev, *mref;
|
||||
struct sf_buf *sf;
|
||||
@ -947,9 +947,15 @@ _mb_unmapped_to_ext(struct mbuf *m)
|
||||
u_int ref_inc = 0;
|
||||
|
||||
M_ASSERTEXTPG(m);
|
||||
|
||||
if (m->m_epg_tls != NULL) {
|
||||
/* can't convert TLS mbuf */
|
||||
m_freem(m);
|
||||
*mres = NULL;
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
len = m->m_len;
|
||||
KASSERT(m->m_epg_tls == NULL, ("%s: can't convert TLS mbuf %p",
|
||||
__func__, m));
|
||||
|
||||
/* See if this is the mbuf that holds the embedded refcount. */
|
||||
if (m->m_ext.ext_flags & EXT_FLAG_EMBREF) {
|
||||
@ -1047,7 +1053,8 @@ _mb_unmapped_to_ext(struct mbuf *m)
|
||||
atomic_add_int(refcnt, ref_inc);
|
||||
}
|
||||
m_free(m);
|
||||
return (top);
|
||||
*mres = top;
|
||||
return (0);
|
||||
|
||||
fail:
|
||||
if (ref_inc != 0) {
|
||||
@ -1064,13 +1071,15 @@ fail:
|
||||
}
|
||||
m_free(m);
|
||||
m_freem(top);
|
||||
return (NULL);
|
||||
*mres = NULL;
|
||||
return (ENOMEM);
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
mb_unmapped_to_ext(struct mbuf *top)
|
||||
int
|
||||
mb_unmapped_to_ext(struct mbuf *top, struct mbuf **mres)
|
||||
{
|
||||
struct mbuf *m, *next, *prev = NULL;
|
||||
struct mbuf *m, *m1, *next, *prev = NULL;
|
||||
int error;
|
||||
|
||||
prev = NULL;
|
||||
for (m = top; m != NULL; m = next) {
|
||||
@ -1086,12 +1095,15 @@ mb_unmapped_to_ext(struct mbuf *top)
|
||||
*/
|
||||
prev->m_next = NULL;
|
||||
}
|
||||
m = _mb_unmapped_to_ext(m);
|
||||
if (m == NULL) {
|
||||
m_freem(top);
|
||||
error = _mb_unmapped_to_ext(m, &m1);
|
||||
if (error != 0) {
|
||||
if (top != m)
|
||||
m_free(top);
|
||||
m_freem(next);
|
||||
return (NULL);
|
||||
*mres = NULL;
|
||||
return (error);
|
||||
}
|
||||
m = m1;
|
||||
if (prev == NULL) {
|
||||
top = m;
|
||||
} else {
|
||||
@ -1110,7 +1122,8 @@ mb_unmapped_to_ext(struct mbuf *top)
|
||||
prev = m;
|
||||
}
|
||||
}
|
||||
return (top);
|
||||
*mres = top;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -814,7 +814,7 @@ struct mbuf *mb_alloc_ext_plus_pages(int, int);
|
||||
struct mbuf *mb_mapped_to_unmapped(struct mbuf *, int, int, int,
|
||||
struct mbuf **);
|
||||
int mb_unmapped_compress(struct mbuf *m);
|
||||
struct mbuf *mb_unmapped_to_ext(struct mbuf *m);
|
||||
int mb_unmapped_to_ext(struct mbuf *m, struct mbuf **mres);
|
||||
void mb_free_notready(struct mbuf *m, int count);
|
||||
void m_adj(struct mbuf *, int);
|
||||
void m_adj_decap(struct mbuf *, int);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user