summaryrefslogtreecommitdiffstats
path: root/sys/netncp
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2001-02-14 05:13:04 +0000
committerbmilekic <bmilekic@FreeBSD.org>2001-02-14 05:13:04 +0000
commitcc2f31e1a4c8a6d2678fbbb8b9705d49fc18de63 (patch)
tree639d9a4c07772cd49b2cf77c738e8aaf5c15f850 /sys/netncp
parent1c970ba5b314cd2286a5a889bb69df2bc58ed73c (diff)
downloadFreeBSD-src-cc2f31e1a4c8a6d2678fbbb8b9705d49fc18de63.zip
FreeBSD-src-cc2f31e1a4c8a6d2678fbbb8b9705d49fc18de63.tar.gz
Implement m_getm() which will perform an "all or nothing" mbuf + cluster
allocation, as required. If m_getm() receives NULL as a first argument, then it allocates `len' (second argument) bytes worth of mbufs + clusters and returns the chain only if it was able to allocate everything. If the first argument is non-NULL, then it should be an existing mbuf chain (e.g. pre-allocated mbuf sitting on a ring, on some list, etc.) and so it will allocate `len' bytes worth of clusters and mbufs, as needed, and append them to the tail of the passed in chain, only if it was able to allocate everything requested. If allocation fails, only what was allocated by the routine will be freed, and NULL will be returned. Also, get rid of existing m_getm() in netncp code and replace calls to it to calls to this new generic code. Heavily Reviewed by: bp
Diffstat (limited to 'sys/netncp')
-rw-r--r--sys/netncp/ncp_rq.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/sys/netncp/ncp_rq.c b/sys/netncp/ncp_rq.c
index e661f5e..dacdee0 100644
--- a/sys/netncp/ncp_rq.c
+++ b/sys/netncp/ncp_rq.c
@@ -46,8 +46,6 @@
#include <netncp/ncp_ncp.h>
#include <netncp/ncp_nls.h>
-static struct mbuf* m_getm(struct mbuf *top, int len);
-
int
ncp_rq_head(struct ncp_rq *rqp, u_int32_t ptype, u_int8_t fn,struct proc *p,
struct ucred *cred)
@@ -98,29 +96,6 @@ ncp_rq_done(struct ncp_rq *rqp) {
return (0);
}
-static struct mbuf*
-m_getm(struct mbuf *top, int len) {
- int rest = len, mlen;
- struct mbuf *m=0,*mp;
-
- mp = top;
- while (rest > 0) {
-/* NCPSDEBUG("%d\n",rest);*/
- m = m_get(M_TRYWAIT, MT_DATA);
- if (rest > MINCLSIZE) {
- MCLGET(m,M_TRYWAIT);
- mlen = ( (m->m_flags & M_EXT) == 0) ? MLEN : MCLBYTES;
- } else {
- mlen = MLEN;
- }
- m->m_len = 0/*min(mlen,rest)*/;
- mp->m_next = m;
- mp = m;
- rest -= mlen;
- }
- return top;
-}
-
/*
* Routines to fill the request
*/
@@ -182,7 +157,7 @@ ncp_rq_pathstring(struct ncp_rq *rqp, int size, char *name, struct ncp_nlstables
m->m_len += cplen;
}
if (size) {
- m_getm(m, size);
+ m = m_getm(m, size, MT_DATA, M_TRYWAIT);
while (size > 0){
m = m->m_next;
cplen = min(size, M_TRAILINGSPACE(m));
@@ -215,7 +190,7 @@ ncp_rq_putanymem(struct ncp_rq *rqp, caddr_t source, int size, int type) {
m->m_len += cplen;
}
if (size) {
- m_getm(m, size);
+ m = m_getm(m, size, MT_DATA, M_TRYWAIT);
while (size > 0){
m = m->m_next;
cplen = min(size, M_TRAILINGSPACE(m));
OpenPOWER on IntegriCloud