Browse files

when the number of the packets queued in a NDP cache exceed the limit,

discard the oldest packet, as specified in RFC2461 7.2.2.
  • Loading branch information...
1 parent b0e3bef commit ba1cf723097a7bff8a1617368b076270b4c3a3a6 suz committed Apr 4, 2005
Showing with 22 additions and 11 deletions.
  1. +7 −2 CHANGELOG
  2. +15 −9 kame/sys/netinet6/nd6.c
View
9 CHANGELOG
@@ -1,10 +1,15 @@
CHANGELOG for KAME kit
-$KAME: CHANGELOG,v 1.2741 2005/04/01 07:31:00 suz Exp $
+$KAME: CHANGELOG,v 1.2742 2005/04/04 09:14:57 suz Exp $
<200504>
+2005-04-04 SUZUKI, Shinsuke <suz@kame.net>
+ * kame/sys/netinet6/nd6.c: when the number of the packets queued in
+ a NDP cache exceed the limit, discard the oldest packet,
+ as specified in RFC2461 7.2.2.
+
2005-04-01 SUZUKI, Shinsuke <suz@kame.net>
* kame/sys/netinet/icmp6.h, kame/sys/netinet6/icmp6.c, nd6.c: limits
- the number of fragmented packets stored in a NDP cache.
+ the number of unresolved packets stored in a NDP cache.
(To prevent a DoS attack using 2005-01-21's change)
2005-04-01 SUZUKI, Shinsuke <suz@kame.net>
View
24 kame/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $KAME: nd6.c,v 1.374 2005/04/01 09:25:02 suz Exp $ */
+/* $KAME: nd6.c,v 1.375 2005/04/04 09:14:58 suz Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -2546,22 +2546,28 @@ nd6_output(ifp, origifp, m0, dst, rt0)
* There is a neighbor cache entry, but no ethernet address
* response yet. Append this latest packet to the end of the
* packet queue in the mbuf, unless the number of the packet
- * does not exceed nd6_maxqueuelen.
+ * does not exceed nd6_maxqueuelen. When it exceeds nd6_maxqueuelen,
+ * the oldest packet in the queue will be removed.
*/
if (ln->ln_state == ND6_LLINFO_NOSTATE)
ln->ln_state = ND6_LLINFO_INCOMPLETE;
if (ln->ln_hold) {
- struct mbuf *m_hold, *m_hold_last;
+ struct mbuf *m_hold;
int i;
- m_hold = m_hold_last = ln->ln_hold;
- for (i = 0; i < nd6_maxqueuelen; i++) {
- if (m_hold == NULL) {
- m_hold_last->m_nextpkt = m;
+ i = 0;
+ for (m_hold = ln->ln_hold; m_hold; m_hold = m_hold->m_nextpkt) {
+ i++;
+ if (m_hold->m_nextpkt == NULL) {
+ m_hold->m_nextpkt = m;
break;
}
- m_hold_last = m_hold;
- m_hold = m_hold->m_nextpkt;
+ }
+ while (i >= nd6_maxqueuelen) {
+ m_hold = ln->ln_hold;
+ ln->ln_hold = ln->ln_hold->m_nextpkt;
+ m_free(m_hold);
+ i--;
}
} else {
ln->ln_hold = m;

0 comments on commit ba1cf72

Please sign in to comment.