diff options
author | rwatson <rwatson@FreeBSD.org> | 2015-01-06 12:59:37 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2015-01-06 12:59:37 +0000 |
commit | 60909669f00c3675bab15d82d9d63aaff61dfafa (patch) | |
tree | 8da641e0473d723ab1cc2e5a5772cb1eed6e4d6f /sys/netipsec | |
parent | ff9d81bf5b98e98550d75c454cbd7b6d5002e628 (diff) | |
download | FreeBSD-src-60909669f00c3675bab15d82d9d63aaff61dfafa.zip FreeBSD-src-60909669f00c3675bab15d82d9d63aaff61dfafa.tar.gz |
In order to reduce use of M_EXT outside of the mbuf allocator and
socket-buffer implementations, introduce a return value for MCLGET()
(and m_cljget() that underlies it) to allow the caller to avoid testing
M_EXT itself. Update all callers to use the return value.
With this change, very few network device drivers remain aware of
M_EXT; the primary exceptions lie in mbuf-chain pretty printers for
debugging, and in a few cases, custom mbuf and cluster allocation
implementations.
NB: This is a difficult-to-test change as it touches many drivers for
which I don't have physical devices. Instead we've gone for intensive
review, but further post-commit review would definitely be appreciated
to spot errors where changes could not easily be made mechanically,
but were largely mechanical in nature.
Differential Revision: https://reviews.freebsd.org/D1440
Reviewed by: adrian, bz, gnn
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'sys/netipsec')
-rw-r--r-- | sys/netipsec/key.c | 15 | ||||
-rw-r--r-- | sys/netipsec/keysock.c | 3 |
2 files changed, 6 insertions, 12 deletions
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index b9bcd59..a4e8a25 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -2153,8 +2153,7 @@ key_spddelete2(struct socket *so, struct mbuf *m, MGETHDR(n, M_NOWAIT, MT_DATA); if (n && len > MHLEN) { - MCLGET(n, M_NOWAIT); - if ((n->m_flags & M_EXT) == 0) { + if (!(MCLGET(n, M_NOWAIT))) { m_freem(n); n = NULL; } @@ -3496,8 +3495,7 @@ key_setsadbmsg(u_int8_t type, u_int16_t tlen, u_int8_t satype, u_int32_t seq, return NULL; MGETHDR(m, M_NOWAIT, MT_DATA); if (m && len > MHLEN) { - MCLGET(m, M_NOWAIT); - if ((m->m_flags & M_EXT) == 0) { + if (!(MCLGET(m, M_NOWAIT))) { m_freem(m); m = NULL; } @@ -4694,8 +4692,7 @@ key_getspi(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) MGETHDR(n, M_NOWAIT, MT_DATA); if (len > MHLEN) { - MCLGET(n, M_NOWAIT); - if ((n->m_flags & M_EXT) == 0) { + if (!(MCLGET(n, M_NOWAIT))) { m_freem(n); n = NULL; } @@ -6628,8 +6625,7 @@ key_register(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) MGETHDR(n, M_NOWAIT, MT_DATA); if (len > MHLEN) { - MCLGET(n, M_NOWAIT); - if ((n->m_flags & M_EXT) == 0) { + if (!(MCLGET(n, M_NOWAIT))) { m_freem(n); n = NULL; } @@ -7187,8 +7183,7 @@ key_parse(struct mbuf *m, struct socket *so) MGETHDR(n, M_NOWAIT, MT_DATA); if (n && m->m_pkthdr.len > MHLEN) { - MCLGET(n, M_NOWAIT); - if ((n->m_flags & M_EXT) == 0) { + if (!(MCLGET(n, M_NOWAIT))) { m_free(n); n = NULL; } diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index 6deea35..605d79c 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -223,8 +223,7 @@ key_sendup(struct socket *so, struct sadb_msg *msg, u_int len, int target) n->m_len = MLEN; } if (tlen >= MCLBYTES) { /*XXX better threshold? */ - MCLGET(n, M_NOWAIT); - if ((n->m_flags & M_EXT) == 0) { + if (!(MCLGET(n, M_NOWAIT))) { m_free(n); m_freem(m); PFKEYSTAT_INC(in_nomem); |