Deleted Added
full compact
ipsec_mbuf.c (108989) ipsec_mbuf.c (109623)
1/* $FreeBSD: head/sys/netipsec/ipsec_mbuf.c 108989 2003-01-09 05:30:25Z sam $ */
1/* $FreeBSD: head/sys/netipsec/ipsec_mbuf.c 109623 2003-01-21 08:56:16Z alfred $ */
2
3/*
4 * IPsec-specific mbuf routines.
5 */
6
7#include "opt_param.h"
8
9#include <sys/param.h>

--- 90 unchanged lines hidden (view full) ---

100 /* XXX why can M_PKTHDR be set past the first mbuf? */
101 if (mprev == NULL && (m->m_flags & M_PKTHDR)) {
102 /*
103 * NB: if a packet header is present we must
104 * allocate the mbuf separately from any cluster
105 * because M_MOVE_PKTHDR will smash the data
106 * pointer and drop the M_EXT marker.
107 */
2
3/*
4 * IPsec-specific mbuf routines.
5 */
6
7#include "opt_param.h"
8
9#include <sys/param.h>

--- 90 unchanged lines hidden (view full) ---

100 /* XXX why can M_PKTHDR be set past the first mbuf? */
101 if (mprev == NULL && (m->m_flags & M_PKTHDR)) {
102 /*
103 * NB: if a packet header is present we must
104 * allocate the mbuf separately from any cluster
105 * because M_MOVE_PKTHDR will smash the data
106 * pointer and drop the M_EXT marker.
107 */
108 MGETHDR(n, M_DONTWAIT, m->m_type);
108 MGETHDR(n, M_NOWAIT, m->m_type);
109 if (n == NULL) {
110 m_freem(m0);
111 return (NULL);
112 }
113 M_MOVE_PKTHDR(n, m);
109 if (n == NULL) {
110 m_freem(m0);
111 return (NULL);
112 }
113 M_MOVE_PKTHDR(n, m);
114 MCLGET(n, M_DONTWAIT);
114 MCLGET(n, M_NOWAIT);
115 if ((n->m_flags & M_EXT) == 0) {
116 m_free(n);
117 m_freem(m0);
118 return (NULL);
119 }
120 } else {
115 if ((n->m_flags & M_EXT) == 0) {
116 m_free(n);
117 m_freem(m0);
118 return (NULL);
119 }
120 } else {
121 n = m_getcl(M_DONTWAIT, m->m_type, m->m_flags);
121 n = m_getcl(M_NOWAIT, m->m_type, m->m_flags);
122 if (n == NULL) {
123 m_freem(m0);
124 return (NULL);
125 }
126 }
127 /*
128 * ... and copy the data. We deal with jumbo mbufs
129 * (i.e. m_len > MCLBYTES) by splitting them into

--- 15 unchanged lines hidden (view full) ---

145 mlast = n;
146 newipsecstat.ips_clcopied++;
147
148 len -= cc;
149 if (len <= 0)
150 break;
151 off += cc;
152
122 if (n == NULL) {
123 m_freem(m0);
124 return (NULL);
125 }
126 }
127 /*
128 * ... and copy the data. We deal with jumbo mbufs
129 * (i.e. m_len > MCLBYTES) by splitting them into

--- 15 unchanged lines hidden (view full) ---

145 mlast = n;
146 newipsecstat.ips_clcopied++;
147
148 len -= cc;
149 if (len <= 0)
150 break;
151 off += cc;
152
153 n = m_getcl(M_DONTWAIT, m->m_type, m->m_flags);
153 n = m_getcl(M_NOWAIT, m->m_type, m->m_flags);
154 if (n == NULL) {
155 m_freem(mfirst);
156 m_freem(m0);
157 return (NULL);
158 }
159 }
160 n->m_next = m->m_next;
161 if (mprev == NULL)

--- 43 unchanged lines hidden (view full) ---

205 KASSERT(remain < MLEN,
206 ("m_makespace: remainder too big: %u", remain));
207 /*
208 * Not enough space in m, split the contents
209 * of m, inserting new mbufs as required.
210 *
211 * NB: this ignores mbuf types.
212 */
154 if (n == NULL) {
155 m_freem(mfirst);
156 m_freem(m0);
157 return (NULL);
158 }
159 }
160 n->m_next = m->m_next;
161 if (mprev == NULL)

--- 43 unchanged lines hidden (view full) ---

205 KASSERT(remain < MLEN,
206 ("m_makespace: remainder too big: %u", remain));
207 /*
208 * Not enough space in m, split the contents
209 * of m, inserting new mbufs as required.
210 *
211 * NB: this ignores mbuf types.
212 */
213 MGET(n, M_DONTWAIT, MT_DATA);
213 MGET(n, M_NOWAIT, MT_DATA);
214 if (n == NULL)
215 return (NULL);
216 n->m_next = m->m_next; /* splice new mbuf */
217 m->m_next = n;
218 newipsecstat.ips_mbinserted++;
219 if (hlen <= M_TRAILINGSPACE(m) + remain) {
220 /*
221 * New header fits in the old mbuf if we copy

--- 11 unchanged lines hidden (view full) ---

233 * Make space in the new mbuf and check the
234 * remainder'd data fits too. If not then we
235 * must allocate an additional mbuf (yech).
236 */
237 n->m_len = 0;
238 if (remain + hlen > M_TRAILINGSPACE(n)) {
239 struct mbuf *n2;
240
214 if (n == NULL)
215 return (NULL);
216 n->m_next = m->m_next; /* splice new mbuf */
217 m->m_next = n;
218 newipsecstat.ips_mbinserted++;
219 if (hlen <= M_TRAILINGSPACE(m) + remain) {
220 /*
221 * New header fits in the old mbuf if we copy

--- 11 unchanged lines hidden (view full) ---

233 * Make space in the new mbuf and check the
234 * remainder'd data fits too. If not then we
235 * must allocate an additional mbuf (yech).
236 */
237 n->m_len = 0;
238 if (remain + hlen > M_TRAILINGSPACE(n)) {
239 struct mbuf *n2;
240
241 MGET(n2, M_DONTWAIT, MT_DATA);
241 MGET(n2, M_NOWAIT, MT_DATA);
242 /* NB: new mbuf is on chain, let caller free */
243 if (n2 == NULL)
244 return (NULL);
245 n2->m_len = 0;
246 memcpy(mtod(n2, caddr_t),
247 mtod(m, caddr_t) + skip, remain);
248 n2->m_len = remain;
249 /* splice in second mbuf */

--- 73 unchanged lines hidden (view full) ---

323 return NULL;
324 }
325
326 m0 = m1->m_next;
327 }
328
329 if (pad > M_TRAILINGSPACE(m0)) {
330 /* Add an mbuf to the chain. */
242 /* NB: new mbuf is on chain, let caller free */
243 if (n2 == NULL)
244 return (NULL);
245 n2->m_len = 0;
246 memcpy(mtod(n2, caddr_t),
247 mtod(m, caddr_t) + skip, remain);
248 n2->m_len = remain;
249 /* splice in second mbuf */

--- 73 unchanged lines hidden (view full) ---

323 return NULL;
324 }
325
326 m0 = m1->m_next;
327 }
328
329 if (pad > M_TRAILINGSPACE(m0)) {
330 /* Add an mbuf to the chain. */
331 MGET(m1, M_DONTWAIT, MT_DATA);
331 MGET(m1, M_NOWAIT, MT_DATA);
332 if (m1 == 0) {
333 m_freem(m0);
334 DPRINTF(("m_pad: unable to get extra mbuf\n"));
335 return NULL;
336 }
337
338 m0->m_next = m1;
339 m0 = m1;

--- 113 unchanged lines hidden ---
332 if (m1 == 0) {
333 m_freem(m0);
334 DPRINTF(("m_pad: unable to get extra mbuf\n"));
335 return NULL;
336 }
337
338 m0->m_next = m1;
339 m0 = m1;

--- 113 unchanged lines hidden ---