Module Name: src Committed By: riastradh Date: Wed Apr 12 06:48:08 UTC 2023
Modified Files: src/sys/kern: uipc_mbuf.c src/sys/sys: mbuf.h Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.250 -r1.251 src/sys/kern/uipc_mbuf.c cvs rdiff -u -r1.237 -r1.238 src/sys/sys/mbuf.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.