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

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

Diff for /src/sys/netinet/ip_input.c between version 1.256 and 1.256.2.1

version 1.256, 2007/11/26 08:40:46 version 1.256.2.1, 2007/12/26 19:57:39
Line 896  ours:
Line 896  ours:
          * but it's not worth the time; just let them time out.)           * but it's not worth the time; just let them time out.)
          */           */
         if (ip->ip_off & ~htons(IP_DF|IP_RF)) {          if (ip->ip_off & ~htons(IP_DF|IP_RF)) {
                   uint16_t off;
                   /*
                    * Prevent TCP blind data attacks by not allowing non-initial
                    * fragments to start at less than 68 bytes (minimal fragment
                    * size) and making sure the first fragment is at least 68
                    * bytes.
                    */
                   off = (ntohs(ip->ip_off) & IP_OFFMASK) << 3;
                   if ((off > 0 ? off + hlen : len) < IP_MINFRAGSIZE - 1) {
                           ipstat.ips_badfrags++;
                           goto bad;
                   }
                 /*                  /*
                  * Look for queue of fragments                   * Look for queue of fragments
                  * of this datagram.                   * of this datagram.
Line 907  ours:
Line 918  ours:
                         if (ip->ip_id == fp->ipq_id &&                          if (ip->ip_id == fp->ipq_id &&
                             in_hosteq(ip->ip_src, fp->ipq_src) &&                              in_hosteq(ip->ip_src, fp->ipq_src) &&
                             in_hosteq(ip->ip_dst, fp->ipq_dst) &&                              in_hosteq(ip->ip_dst, fp->ipq_dst) &&
                             ip->ip_p == fp->ipq_p)                              ip->ip_p == fp->ipq_p) {
                                   /*
                                    * Make sure the TOS is matches previous
                                    * fragments.
                                    */
                                   if (ip->ip_tos != fp->ipq_tos) {
                                           ipstat.ips_badfrags++;
                                           goto bad;
                                   }
                                 goto found;                                  goto found;
                           }
                 }                  }
                 fp = 0;                  fp = 0;
 found:  found:
Line 1105  ip_reass(struct ipqent *ipqe, struct ipq
Line 1124  ip_reass(struct ipqent *ipqe, struct ipq
                 fp->ipq_ttl = IPFRAGTTL;                  fp->ipq_ttl = IPFRAGTTL;
                 fp->ipq_p = ipqe->ipqe_ip->ip_p;                  fp->ipq_p = ipqe->ipqe_ip->ip_p;
                 fp->ipq_id = ipqe->ipqe_ip->ip_id;                  fp->ipq_id = ipqe->ipqe_ip->ip_id;
                   fp->ipq_tos = ipqe->ipqe_ip->ip_tos;
                 TAILQ_INIT(&fp->ipq_fragq);                  TAILQ_INIT(&fp->ipq_fragq);
                 fp->ipq_src = ipqe->ipqe_ip->ip_src;                  fp->ipq_src = ipqe->ipqe_ip->ip_src;
                 fp->ipq_dst = ipqe->ipqe_ip->ip_dst;                  fp->ipq_dst = ipqe->ipqe_ip->ip_dst;
Line 1934  ip_forward(struct mbuf *m, int srcrt)
Line 1954  ip_forward(struct mbuf *m, int srcrt)
                 type = ICMP_UNREACH;                  type = ICMP_UNREACH;
                 code = ICMP_UNREACH_NEEDFRAG;                  code = ICMP_UNREACH_NEEDFRAG;
 #if !defined(IPSEC) && !defined(FAST_IPSEC)  #if !defined(IPSEC) && !defined(FAST_IPSEC)
                 if (ipforward_rt.ro_rt != NULL)                  if ((rt = rtcache_getrt(&ipforward_rt)) != NULL)
                         destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu;                          destmtu = rt->rt_ifp->if_mtu;
 #else  #else
                 /*                  /*
                  * If the packet is routed over IPsec tunnel, tell the                   * If the packet is routed over IPsec tunnel, tell the
Line 1943  ip_forward(struct mbuf *m, int srcrt)
Line 1963  ip_forward(struct mbuf *m, int srcrt)
                  *      tunnel MTU = if MTU - sizeof(IP) - ESP/AH hdrsiz                   *      tunnel MTU = if MTU - sizeof(IP) - ESP/AH hdrsiz
                  * XXX quickhack!!!                   * XXX quickhack!!!
                  */                   */
                 if (ipforward_rt.ro_rt != NULL) {                  if ((rt = rtcache_getrt(&ipforward_rt)) != NULL) {
                         struct secpolicy *sp;                          struct secpolicy *sp;
                         int ipsecerror;                          int ipsecerror;
                         size_t ipsechdr;                          size_t ipsechdr;
Line 1954  ip_forward(struct mbuf *m, int srcrt)
Line 1974  ip_forward(struct mbuf *m, int srcrt)
                             &ipsecerror);                              &ipsecerror);
   
                         if (sp == NULL)                          if (sp == NULL)
                                 destmtu = ipforward_rt.ro_rt->rt_ifp->if_mtu;                                  destmtu = rt->rt_ifp->if_mtu;
                         else {                          else {
                                 /* count IPsec header size */                                  /* count IPsec header size */
                                 ipsechdr = ipsec4_hdrsiz(mcopy,                                  ipsechdr = ipsec4_hdrsiz(mcopy,
Line 1969  ip_forward(struct mbuf *m, int srcrt)
Line 1989  ip_forward(struct mbuf *m, int srcrt)
                                  && sp->req->sav != NULL                                   && sp->req->sav != NULL
                                  && sp->req->sav->sah != NULL) {                                   && sp->req->sav->sah != NULL) {
                                         ro = &sp->req->sav->sah->sa_route;                                          ro = &sp->req->sav->sah->sa_route;
                                         if (ro->ro_rt && ro->ro_rt->rt_ifp) {                                          if (rt && rt->rt_ifp) {
                                                 destmtu =                                                  destmtu =
                                                     ro->ro_rt->rt_rmx.rmx_mtu ?                                                      rt->rt_rmx.rmx_mtu ?
                                                     ro->ro_rt->rt_rmx.rmx_mtu :                                                      rt->rt_rmx.rmx_mtu :
                                                     ro->ro_rt->rt_ifp->if_mtu;                                                      rt->rt_ifp->if_mtu;
                                                 destmtu -= ipsechdr;                                                  destmtu -= ipsechdr;
                                         }                                          }
                                 }                                  }

Legend:
Removed from v.1.256  
changed lines
  Added in v.1.256.2.1

CVSweb <webmaster@jp.NetBSD.org>