Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netkey safer key_{spd, }dump. comment from yamt.
details: https://anonhg.NetBSD.org/src/rev/d150627a7e42
branches: trunk
changeset: 567072:d150627a7e42
user: itojun <itojun%NetBSD.org@localhost>
date: Mon May 31 04:29:01 2004 +0000
description:
safer key_{spd,}dump. comment from yamt.
XXX is spl level ok?
diffstat:
sys/netkey/key.c | 32 ++++++++++++++++++++++++--------
sys/netkey/keysock.c | 11 ++++++-----
2 files changed, 30 insertions(+), 13 deletions(-)
diffs (119 lines):
diff -r 4a426f81e956 -r d150627a7e42 sys/netkey/key.c
--- a/sys/netkey/key.c Mon May 31 03:58:57 2004 +0000
+++ b/sys/netkey/key.c Mon May 31 04:29:01 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.120 2004/05/26 02:59:15 itojun Exp $ */
+/* $NetBSD: key.c,v 1.121 2004/05/31 04:29:01 itojun Exp $ */
/* $KAME: key.c,v 1.310 2003/09/08 02:23:44 itojun Exp $ */
/*
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.120 2004/05/26 02:59:15 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.121 2004/05/31 04:29:01 itojun Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -2307,6 +2307,8 @@
int cnt;
u_int dir;
struct mbuf *n;
+ struct keycb *kp;
+ int error = 0, needwait = 0;
/* sanity check */
if (so == NULL || m == NULL || mhp == NULL || mhp->msg == NULL)
@@ -2329,11 +2331,18 @@
n = key_setdumpsp(sp, SADB_X_SPDDUMP, cnt,
mhp->msg->sadb_msg_pid);
- if (n)
- key_sendup_mbuf(so, n,
+ if (n) {
+ error = key_sendup_mbuf(so, n,
KEY_SENDUP_ONE | KEY_SENDUP_CANWAIT);
- }
- }
+ if (error == EAGAIN)
+ needwait = 1;
+ }
+ }
+ }
+
+ kp = (struct keycb *)sotorawcb(so);
+ while (needwait && kp->kp_queue)
+ sbwait(&so->so_rcv);
m_freem(m);
return 0;
@@ -6757,7 +6766,8 @@
u_int stateidx;
u_int8_t satype;
u_int8_t state;
- int cnt;
+ int cnt, error = 0, needwait = 0;
+ struct keycb *kp;
struct mbuf *n;
/* sanity check */
@@ -6812,12 +6822,18 @@
if (!n)
return key_senderror(so, m, ENOBUFS);
- key_sendup_mbuf(so, n,
+ error = key_sendup_mbuf(so, n,
KEY_SENDUP_ONE | KEY_SENDUP_CANWAIT);
+ if (error == EAGAIN)
+ needwait = 1;
}
}
}
+ kp = (struct keycb *)sotorawcb(so);
+ while (needwait && kp->kp_queue)
+ sbwait(&so->so_rcv);
+
m_freem(m);
return 0;
}
diff -r 4a426f81e956 -r d150627a7e42 sys/netkey/keysock.c
--- a/sys/netkey/keysock.c Mon May 31 03:58:57 2004 +0000
+++ b/sys/netkey/keysock.c Mon May 31 04:29:01 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: keysock.c,v 1.30 2004/05/26 02:59:15 itojun Exp $ */
+/* $NetBSD: keysock.c,v 1.31 2004/05/31 04:29:01 itojun Exp $ */
/* $KAME: keysock.c,v 1.32 2003/08/22 05:45:08 itojun Exp $ */
/*
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.30 2004/05/26 02:59:15 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.31 2004/05/31 04:29:01 itojun Exp $");
#include "opt_inet.h"
@@ -268,8 +268,10 @@
}
if (canwait &&
- sbspace(&rp->rcb_socket->so_rcv) < m->m_pkthdr.len)
- sbwait(&rp->rcb_socket->so_rcv);
+ sbspace(&rp->rcb_socket->so_rcv) < m->m_pkthdr.len) {
+ error = EAGAIN;
+ continue;
+ }
if (!sbappendaddr(&rp->rcb_socket->so_rcv,
(struct sockaddr *)&key_src, m, NULL)) {
@@ -278,7 +280,6 @@
error = ENOBUFS;
} else
error = 0;
- sorwakeup(rp->rcb_socket);
}
return error;
}
Home |
Main Index |
Thread Index |
Old Index