keysock.c (108107) | keysock.c (109623) |
---|---|
1/* $FreeBSD: head/sys/netipsec/keysock.c 108107 2002-12-19 22:58:27Z bmilekic $ */ | 1/* $FreeBSD: head/sys/netipsec/keysock.c 109623 2003-01-21 08:56:16Z alfred $ */ |
2/* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 137 unchanged lines hidden (view full) --- 147 struct mbuf *m; 148 int promisc; 149{ 150 int error; 151 152 if (promisc) { 153 struct sadb_msg *pmsg; 154 | 2/* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ 3 4/* 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 137 unchanged lines hidden (view full) --- 147 struct mbuf *m; 148 int promisc; 149{ 150 int error; 151 152 if (promisc) { 153 struct sadb_msg *pmsg; 154 |
155 M_PREPEND(m, sizeof(struct sadb_msg), M_DONTWAIT); | 155 M_PREPEND(m, sizeof(struct sadb_msg), M_NOWAIT); |
156 if (m && m->m_len < sizeof(struct sadb_msg)) 157 m = m_pullup(m, sizeof(struct sadb_msg)); 158 if (!m) { 159 pfkeystat.in_nomem++; 160 m_freem(m); 161 return ENOBUFS; 162 } 163 m->m_pkthdr.len += sizeof(*pmsg); --- 54 unchanged lines hidden (view full) --- 218 * sbspace() computes # of actual data bytes AND mbuf region. 219 * 220 * TODO: SADB_ACQUIRE filters should be implemented. 221 */ 222 tlen = len; 223 m = mprev = NULL; 224 while (tlen > 0) { 225 if (tlen == len) { | 156 if (m && m->m_len < sizeof(struct sadb_msg)) 157 m = m_pullup(m, sizeof(struct sadb_msg)); 158 if (!m) { 159 pfkeystat.in_nomem++; 160 m_freem(m); 161 return ENOBUFS; 162 } 163 m->m_pkthdr.len += sizeof(*pmsg); --- 54 unchanged lines hidden (view full) --- 218 * sbspace() computes # of actual data bytes AND mbuf region. 219 * 220 * TODO: SADB_ACQUIRE filters should be implemented. 221 */ 222 tlen = len; 223 m = mprev = NULL; 224 while (tlen > 0) { 225 if (tlen == len) { |
226 MGETHDR(n, M_DONTWAIT, MT_DATA); | 226 MGETHDR(n, M_NOWAIT, MT_DATA); |
227 n->m_len = MHLEN; 228 } else { | 227 n->m_len = MHLEN; 228 } else { |
229 MGET(n, M_DONTWAIT, MT_DATA); | 229 MGET(n, M_NOWAIT, MT_DATA); |
230 n->m_len = MLEN; 231 } 232 if (!n) { 233 pfkeystat.in_nomem++; 234 return ENOBUFS; 235 } 236 if (tlen >= MCLBYTES) { /*XXX better threshold? */ | 230 n->m_len = MLEN; 231 } 232 if (!n) { 233 pfkeystat.in_nomem++; 234 return ENOBUFS; 235 } 236 if (tlen >= MCLBYTES) { /*XXX better threshold? */ |
237 MCLGET(n, M_DONTWAIT); | 237 MCLGET(n, M_NOWAIT); |
238 if ((n->m_flags & M_EXT) == 0) { 239 m_free(n); 240 m_freem(m); 241 pfkeystat.in_nomem++; 242 return ENOBUFS; 243 } 244 n->m_len = MCLBYTES; 245 } --- 151 unchanged lines hidden (view full) --- 397static int 398key_attach(struct socket *so, int proto, struct thread *td) 399{ 400 struct keycb *kp; 401 int s, error; 402 403 if (sotorawcb(so) != 0) 404 return EISCONN; /* XXX panic? */ | 238 if ((n->m_flags & M_EXT) == 0) { 239 m_free(n); 240 m_freem(m); 241 pfkeystat.in_nomem++; 242 return ENOBUFS; 243 } 244 n->m_len = MCLBYTES; 245 } --- 151 unchanged lines hidden (view full) --- 397static int 398key_attach(struct socket *so, int proto, struct thread *td) 399{ 400 struct keycb *kp; 401 int s, error; 402 403 if (sotorawcb(so) != 0) 404 return EISCONN; /* XXX panic? */ |
405 kp = (struct keycb *)malloc(sizeof *kp, M_PCB, M_WAITOK|M_ZERO); /* XXX */ | 405 kp = (struct keycb *)malloc(sizeof *kp, M_PCB, M_ZERO); /* XXX */ |
406 if (kp == 0) 407 return ENOBUFS; 408 409 /* 410 * The splnet() is necessary to block protocols from sending 411 * error notifications (like RTM_REDIRECT or RTM_LOSING) while 412 * this PCB is extant but incompletely initialized. 413 * Probably we should try to do more of this work beforehand and --- 190 unchanged lines hidden --- | 406 if (kp == 0) 407 return ENOBUFS; 408 409 /* 410 * The splnet() is necessary to block protocols from sending 411 * error notifications (like RTM_REDIRECT or RTM_LOSING) while 412 * this PCB is extant but incompletely initialized. 413 * Probably we should try to do more of this work beforehand and --- 190 unchanged lines hidden --- |