Now
MAIN commitmail json YAML
mbuf(9): New m_get_n, m_gethdr_n.
m_get_n(how, type, alignbytes, nbytes) returns an mbuf with no packet
header having space for nbytes, with an internal buffer pointer
aligned by alignbytes (typically ETHER_ALIGN or similar, if not
zero).
m_gethdr_n(how, type, alignbytes, nbytes) does the same but for an
mbuf with a packet header.
These return NULL on failure, which can happen either:
(a) because how is M_DONTWAIT and allocating memory would sleep, or
(b) because alignbytes + nbytes > MCLBYTES.
On exit, m_len is set to nbytes, as is m_pkthdr.len for m_gethdr_n.
These should be used to systematically replace all calls to m_get,
m_gethdr, MGET, MGETHDR, and m_getcl. Most calls to m_clget and
MCLGET will probably evaporate as a consequence.
Proposed on tech-net last year:
https://mail-index.netbsd.org/tech-net/2022/07/16/msg008285.html
m_get_n(how, type, alignbytes, nbytes) returns an mbuf with no packet
header having space for nbytes, with an internal buffer pointer
aligned by alignbytes (typically ETHER_ALIGN or similar, if not
zero).
m_gethdr_n(how, type, alignbytes, nbytes) does the same but for an
mbuf with a packet header.
These return NULL on failure, which can happen either:
(a) because how is M_DONTWAIT and allocating memory would sleep, or
(b) because alignbytes + nbytes > MCLBYTES.
On exit, m_len is set to nbytes, as is m_pkthdr.len for m_gethdr_n.
These should be used to systematically replace all calls to m_get,
m_gethdr, MGET, MGETHDR, and m_getcl. Most calls to m_clget and
MCLGET will probably evaporate as a consequence.
Proposed on tech-net last year:
https://mail-index.netbsd.org/tech-net/2022/07/16/msg008285.html