Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netkey recover kp_queue properly. yamt
details: https://anonhg.NetBSD.org/src/rev/f69b79e8a29b
branches: trunk
changeset: 567108:f69b79e8a29b
user: itojun <itojun%NetBSD.org@localhost>
date: Tue Jun 01 02:01:14 2004 +0000
description:
recover kp_queue properly. yamt
diffstat:
sys/netkey/keysock.c | 44 +++++++++++++++++++++++++++++++-------------
1 files changed, 31 insertions(+), 13 deletions(-)
diffs (90 lines):
diff -r 8752fd72c18d -r f69b79e8a29b sys/netkey/keysock.c
--- a/sys/netkey/keysock.c Tue Jun 01 00:49:41 2004 +0000
+++ b/sys/netkey/keysock.c Tue Jun 01 02:01:14 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: keysock.c,v 1.34 2004/05/31 11:40:40 itojun Exp $ */
+/* $NetBSD: keysock.c,v 1.35 2004/06/01 02:01:14 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.34 2004/05/31 11:40:40 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: keysock.c,v 1.35 2004/06/01 02:01:14 itojun Exp $");
#include "opt_inet.h"
@@ -240,8 +240,10 @@
kp->kp_queue = NULL;
} else
m->m_nextpkt = NULL; /* just for safety */
- } else
- m->m_nextpkt = NULL; /* just for safety */
+ } else {
+ /* NOTE: kp_queue is !NULL */
+ m->m_nextpkt = NULL;
+ }
for (; m && error == 0; m = n) {
n = m->m_nextpkt;
@@ -254,8 +256,8 @@
m = m_pullup(m, sizeof(struct sadb_msg));
if (!m) {
pfkeystat.in_nomem++;
- kp->kp_queue = n;
- return ENOBUFS;
+ error = ENOBUFS;
+ goto recovery;
}
m->m_pkthdr.len += sizeof(*pmsg);
@@ -272,9 +274,7 @@
if (canwait &&
sbspace(&rp->rcb_socket->so_rcv) < m->m_pkthdr.len) {
error = EAGAIN;
- kp->kp_queue = m;
- m->m_nextpkt = n;
- break;
+ goto recovery;
}
m->m_nextpkt = NULL;
@@ -282,14 +282,32 @@
if (!sbappendaddr(&rp->rcb_socket->so_rcv,
(struct sockaddr *)&key_src, m, NULL)) {
pfkeystat.in_nomem++;
- kp->kp_queue = m;
- m->m_nextpkt = n;
error = ENOBUFS;
- break;
+ goto recovery;
} else
error = 0;
}
- return error;
+ return (error);
+
+recovery:
+ if (kp->kp_queue) {
+ /*
+ * insert m to the head of queue, as normally mbuf on the queue
+ * is less important than others.
+ */
+ m->m_nextpkt = kp->kp_queue;
+ kp->kp_queue = m;
+ } else {
+ /* recover the queue */
+ if (!m) {
+ /* first ENOBUFS case */
+ kp->kp_queue = n;
+ } else {
+ kp->kp_queue = m;
+ m->m_nextpkt = n;
+ }
+ }
+ return (error);
}
/* so can be NULL if target != KEY_SENDUP_ONE */
Home |
Main Index |
Thread Index |
Old Index