[BACK]Return to frag6.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / netinet6

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/netinet6/frag6.c between version 1.10.4.2 and 1.11

version 1.10.4.2, 2003/02/11 15:56:40 version 1.11, 2001/02/10 04:14:26
Line 1 
Line 1 
 /*      $NetBSD$        */  /*      $NetBSD$        */
   /*      $KAME: frag6.c,v 1.28 2000/12/12 10:54:06 itojun Exp $  */
   
 /*  /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.   * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  * All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions   * modification, are permitted provided that the following conditions
  * are met:   * are met:
Line 15 
Line 16 
  * 3. Neither the name of the project nor the names of its contributors   * 3. Neither the name of the project nor the names of its contributors
  *    may be used to endorse or promote products derived from this software   *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.   *    without specific prior written permission.
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND   * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Line 66  static void frag6_insque __P((struct ip6
Line 67  static void frag6_insque __P((struct ip6
 static void frag6_remque __P((struct ip6q *));  static void frag6_remque __P((struct ip6q *));
 static void frag6_freef __P((struct ip6q *));  static void frag6_freef __P((struct ip6q *));
   
 /* XXX we eventually need splreass6, or some real semaphore */  
 int frag6_doing_reass;  int frag6_doing_reass;
 u_int frag6_nfragpackets;  u_int frag6_nfragpackets;
 struct  ip6q ip6q;      /* ip6 reassemble queue */  struct  ip6q ip6q;      /* ip6 reassemble queue */
Line 104  frag6_init()
Line 104  frag6_init()
  *      the Fragmentable Part of the original packet.   *      the Fragmentable Part of the original packet.
  *              -> next header field is same for all fragments   *              -> next header field is same for all fragments
  *   *
  * reassembly rule (p21):   * reassembly rule (p21):
  *      The Next Header field of the last header of the Unfragmentable   *      The Next Header field of the last header of the Unfragmentable
  *      Part is obtained from the Next Header field of the first   *      Part is obtained from the Next Header field of the first
  *      fragment's Fragment header.   *      fragment's Fragment header.
Line 187  frag6_input(mp, offp, proto)
Line 187  frag6_input(mp, offp, proto)
   
         /*          /*
          * check whether fragment packet's fragment length is           * check whether fragment packet's fragment length is
          * multiple of 8 octets.           * multiple of 8 octets.
          * sizeof(struct ip6_frag) == 8           * sizeof(struct ip6_frag) == 8
          * sizeof(struct ip6_hdr) = 40           * sizeof(struct ip6_hdr) = 40
          */           */
Line 206  frag6_input(mp, offp, proto)
Line 206  frag6_input(mp, offp, proto)
         /* offset now points to data portion */          /* offset now points to data portion */
         offset += sizeof(struct ip6_frag);          offset += sizeof(struct ip6_frag);
   
         frag6_doing_reass = 1;  
   
         for (q6 = ip6q.ip6q_next; q6 != &ip6q; q6 = q6->ip6q_next)          for (q6 = ip6q.ip6q_next; q6 != &ip6q; q6 = q6->ip6q_next)
                 if (ip6f->ip6f_ident == q6->ip6q_ident &&                  if (ip6f->ip6f_ident == q6->ip6q_ident &&
                     IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &q6->ip6q_src) &&                      IN6_ARE_ADDR_EQUAL(&ip6->ip6_src, &q6->ip6q_src) &&
Line 219  frag6_input(mp, offp, proto)
Line 217  frag6_input(mp, offp, proto)
                  * the first fragment to arrive, create a reassembly queue.                   * the first fragment to arrive, create a reassembly queue.
                  */                   */
                 first_frag = 1;                  first_frag = 1;
                   frag6_nfragpackets++;
   
                 /*                  /*
                  * Enforce upper bound on number of fragmented packets                   * Enforce upper bound on number of fragmented packets
                  * for which we attempt reassembly;                   * for which we attempt reassembly;
                  * If maxfrag is 0, never accept fragments.                   * If maxfrag is 0, never accept fragments.
                  * If maxfrag is -1, accept all fragments without limitation.                   * If maxfrag is -1, accept all fragments without limitation.
                  */                   */
                 if (ip6_maxfragpackets < 0)                  if (frag6_nfragpackets >= (u_int)ip6_maxfragpackets) {
                         ;                          ip6stat.ip6s_fragoverflow++;
                 else if (frag6_nfragpackets >= (u_int)ip6_maxfragpackets)                          in6_ifstat_inc(dstifp, ifs6_reass_fail);
                         goto dropfrag;                          frag6_freef(ip6q.ip6q_prev);
                 frag6_nfragpackets++;                  }
                 q6 = (struct ip6q *)malloc(sizeof(struct ip6q), M_FTABLE,                  q6 = (struct ip6q *)malloc(sizeof(struct ip6q), M_FTABLE,
                         M_DONTWAIT);                          M_DONTWAIT);
                 if (q6 == NULL)                  if (q6 == NULL)
Line 275  frag6_input(mp, offp, proto)
Line 274  frag6_input(mp, offp, proto)
                         icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,                          icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
                                     offset - sizeof(struct ip6_frag) +                                      offset - sizeof(struct ip6_frag) +
                                         offsetof(struct ip6_frag, ip6f_offlg));                                          offsetof(struct ip6_frag, ip6f_offlg));
                         frag6_doing_reass = 0;  
                         return(IPPROTO_DONE);                          return(IPPROTO_DONE);
                 }                  }
         }          }
Line 283  frag6_input(mp, offp, proto)
Line 281  frag6_input(mp, offp, proto)
                 icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,                  icmp6_error(m, ICMP6_PARAM_PROB, ICMP6_PARAMPROB_HEADER,
                             offset - sizeof(struct ip6_frag) +                              offset - sizeof(struct ip6_frag) +
                                 offsetof(struct ip6_frag, ip6f_offlg));                                  offsetof(struct ip6_frag, ip6f_offlg));
                 frag6_doing_reass = 0;  
                 return(IPPROTO_DONE);                  return(IPPROTO_DONE);
         }          }
         /*          /*
Line 396  frag6_input(mp, offp, proto)
Line 393  frag6_input(mp, offp, proto)
                 i = af6->ip6af_up->ip6af_off + af6->ip6af_up->ip6af_frglen                  i = af6->ip6af_up->ip6af_off + af6->ip6af_up->ip6af_frglen
                         - ip6af->ip6af_off;                          - ip6af->ip6af_off;
                 if (i > 0) {                  if (i > 0) {
 #if 0                           /* suppress the noisy log */  
                         log(LOG_ERR, "%d bytes of a fragment from %s "                          log(LOG_ERR, "%d bytes of a fragment from %s "
                             "overlaps the previous fragment\n",                              "overlaps the previous fragment\n",
                             i, ip6_sprintf(&q6->ip6q_src));                              i, ip6_sprintf(&q6->ip6q_src));
 #endif  
                         free(ip6af, M_FTABLE);  
                         goto dropfrag;                          goto dropfrag;
                 }                  }
         }          }
         if (af6 != (struct ip6asfrag *)q6) {          if (af6 != (struct ip6asfrag *)q6) {
                 i = (ip6af->ip6af_off + ip6af->ip6af_frglen) - af6->ip6af_off;                  i = (ip6af->ip6af_off + ip6af->ip6af_frglen) - af6->ip6af_off;
                 if (i > 0) {                  if (i > 0) {
 #if 0                           /* suppress the noisy log */  
                         log(LOG_ERR, "%d bytes of a fragment from %s "                          log(LOG_ERR, "%d bytes of a fragment from %s "
                             "overlaps the succeeding fragment",                              "overlaps the succeeding fragment",
                             i, ip6_sprintf(&q6->ip6q_src));                              i, ip6_sprintf(&q6->ip6q_src));
 #endif  
                         free(ip6af, M_FTABLE);  
                         goto dropfrag;                          goto dropfrag;
                 }                  }
         }          }
Line 534  insert:
Line 525  insert:
         in6_ifstat_inc(dstifp, ifs6_reass_fail);          in6_ifstat_inc(dstifp, ifs6_reass_fail);
         ip6stat.ip6s_fragdropped++;          ip6stat.ip6s_fragdropped++;
         m_freem(m);          m_freem(m);
         frag6_doing_reass = 0;  
         return IPPROTO_DONE;          return IPPROTO_DONE;
 }  }
   
Line 605  frag6_deq(af6)
Line 595  frag6_deq(af6)
         af6->ip6af_down->ip6af_up = af6->ip6af_up;          af6->ip6af_down->ip6af_up = af6->ip6af_up;
 }  }
   
 void  void
 frag6_insque(new, old)  frag6_insque(new, old)
         struct ip6q *new, *old;          struct ip6q *new, *old;
 {  {
Line 624  frag6_remque(p6)
Line 614  frag6_remque(p6)
 }  }
   
 /*  /*
  * IP timer processing;   * IPv6 reassembling timer processing;
  * if a timer expires on a reassembly   * if a timer expires on a reassembly
  * queue, discard it.   * queue, discard it.
  */   */
Line 654  frag6_slowtimo()
Line 644  frag6_slowtimo()
          * (due to the limit being lowered), drain off           * (due to the limit being lowered), drain off
          * enough to get down to the new limit.           * enough to get down to the new limit.
          */           */
         while (frag6_nfragpackets > (u_int)ip6_maxfragpackets &&          while (frag6_nfragpackets > (u_int)ip6_maxfragpackets) {
             ip6q.ip6q_prev) {  
                 ip6stat.ip6s_fragoverflow++;                  ip6stat.ip6s_fragoverflow++;
                 /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */                  /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
                 frag6_freef(ip6q.ip6q_prev);                  frag6_freef(ip6q.ip6q_prev);

Legend:
Removed from v.1.10.4.2  
changed lines
  Added in v.1.11

CVSweb <webmaster@jp.NetBSD.org>