Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/netinet Pull up revision 1.23 (requested by darrenr):



details:   https://anonhg.NetBSD.org/src/rev/1dc9893913c4
branches:  netbsd-1-5
changeset: 491239:1dc9893913c4
user:      he <he%NetBSD.org@localhost>
date:      Sat Apr 14 20:56:22 2001 +0000

description:
Pull up revision 1.23 (requested by darrenr):
  Fix bug related to fragment cache handling.

diffstat:

 sys/netinet/ip_frag.c |  33 +++++++++++++++++++++++++++------
 1 files changed, 27 insertions(+), 6 deletions(-)

diffs (86 lines):

diff -r 55600d030659 -r 1dc9893913c4 sys/netinet/ip_frag.c
--- a/sys/netinet/ip_frag.c     Fri Apr 06 11:34:01 2001 +0000
+++ b/sys/netinet/ip_frag.c     Sat Apr 14 20:56:22 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_frag.c,v 1.21 2000/06/12 10:29:36 veego Exp $       */
+/*     $NetBSD: ip_frag.c,v 1.21.2.1 2001/04/14 20:56:22 he Exp $      */
 
 /*
  * Copyright (C) 1993-2000 by Darren Reed.
@@ -9,7 +9,7 @@
  */
 #if !defined(lint)
 #if defined(__NetBSD__)
-static const char rcsid[] = "$NetBSD: ip_frag.c,v 1.21 2000/06/12 10:29:36 veego Exp $";
+static const char rcsid[] = "$NetBSD: ip_frag.c,v 1.21.2.1 2001/04/14 20:56:22 he Exp $";
 #else
 static const char sccsid[] = "@(#)ip_frag.c    1.11 3/24/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: ip_frag.c,v 2.10.2.4 2000/06/06 15:49:15 darrenr Exp";
@@ -147,12 +147,15 @@
 u_int pass;
 ipfr_t *table[];
 {
-       ipfr_t  **fp, *fra, frag;
-       u_int   idx;
+       ipfr_t **fp, *fra, frag;
+       u_int idx, off;
 
        if (ipfr_inuse >= IPFT_SIZE)
                return NULL;
 
+       if (!(fin->fin_fi.fi_fl & FI_FRAG))
+               return NULL;
+
        frag.ipfr_p = ip->ip_p;
        idx = ip->ip_p;
        frag.ipfr_id = ip->ip_id;
@@ -205,7 +208,10 @@
        /*
         * Compute the offset of the expected start of the next packet.
         */
-       fra->ipfr_off = (ip->ip_off & IP_OFFMASK) + (fin->fin_dlen >> 3);
+       off = ip->ip_off & IP_OFFMASK;
+       if (!off)
+               fra->ipfr_seen0 = 1;
+       fra->ipfr_off = off + (fin->fin_dlen >> 3);
        ATOMIC_INCL(ipfr_stats.ifs_new);
        ATOMIC_INC32(ipfr_inuse);
        return fra;
@@ -261,6 +267,9 @@
        ipfr_t  *f, frag;
        u_int   idx;
 
+       if (!(fin->fin_fi.fi_fl & FI_FRAG))
+               return NULL;
+
        /*
         * For fragments, we record protocol, packet id, TOS and both IP#'s
         * (these should all be the same for all fragments of a packet).
@@ -287,6 +296,19 @@
                          IPFR_CMPSZ)) {
                        u_short atoff, off;
 
+                       /*
+                        * XXX - We really need to be guarding against the
+                        * retransmission of (src,dst,id,offset-range) here
+                        * because a fragmented packet is never resent with
+                        * the same IP ID#.
+                        */
+                       off = ip->ip_off & IP_OFFMASK;
+                       if (f->ipfr_seen0) {
+                               if (!off || (fin->fin_fi.fi_fl & FI_SHORT))
+                                       continue;
+                       } else if (!off)
+                               f->ipfr_seen0 = 1;
+
                        if (f != table[idx]) {
                                /*
                                 * move fragment info. to the top of the list
@@ -299,7 +321,6 @@
                                f->ipfr_prev = NULL;
                                table[idx] = f;
                        }
-                       off = ip->ip_off & IP_OFFMASK;
                        atoff = off + (fin->fin_dlen >> 3);
                        /*
                         * If we've follwed the fragments, and this is the



Home | Main Index | Thread Index | Old Index