[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.98 and 1.107

version 1.98, 2000/02/12 17:45:44 version 1.107, 2000/03/10 22:39:03
Line 194  int ipprintfs = 0;
Line 194  int ipprintfs = 0;
 struct rttimer_queue *ip_mtudisc_timeout_q = NULL;  struct rttimer_queue *ip_mtudisc_timeout_q = NULL;
   
 extern  struct domain inetdomain;  extern  struct domain inetdomain;
 extern  struct protosw inetsw[];  
 u_char  ip_protox[IPPROTO_MAX];  
 int     ipqmaxlen = IFQ_MAXLEN;  int     ipqmaxlen = IFQ_MAXLEN;
 struct  in_ifaddrhead in_ifaddr;  struct  in_ifaddrhead in_ifaddr;
 struct  in_ifaddrhashhead *in_ifaddrhashtbl;  struct  in_ifaddrhashhead *in_ifaddrhashtbl;
Line 348  ip_input(struct mbuf *m)
Line 346  ip_input(struct mbuf *m)
         register struct ifaddr *ifa;          register struct ifaddr *ifa;
         struct ipqent *ipqe;          struct ipqent *ipqe;
         int hlen = 0, mff, len;          int hlen = 0, mff, len;
           int downmatch;
 #ifdef PFIL_HOOKS  #ifdef PFIL_HOOKS
         struct packet_filter_hook *pfh;          struct packet_filter_hook *pfh;
         struct mbuf *m0;          struct mbuf *m0;
Line 399  ip_input(struct mbuf *m)
Line 398  ip_input(struct mbuf *m)
         }          }
   
         /*          /*
          * RFC1112: packets with a multicast source address are           * RFC1122: packets with a multicast source address are
          * not allowed.           * not allowed.
          */           */
         if (IN_MULTICAST(ip->ip_src.s_addr)) {          if (IN_MULTICAST(ip->ip_src.s_addr)) {
Line 465  ip_input(struct mbuf *m)
Line 464  ip_input(struct mbuf *m)
          * in the list may have previously cleared it.           * in the list may have previously cleared it.
          */           */
         m0 = m;          m0 = m;
         for (pfh = pfil_hook_get(PFIL_IN); pfh; pfh = pfh->pfil_link.tqe_next)          pfh = pfil_hook_get(PFIL_IN, &inetsw[ip_protox[IPPROTO_IP]].pr_pfh);
           for (; pfh; pfh = pfh->pfil_link.tqe_next)
                 if (pfh->pfil_func) {                  if (pfh->pfil_func) {
                         rv = pfh->pfil_func(ip, hlen, m->m_pkthdr.rcvif, 0, &m0);                          rv = pfh->pfil_func(ip, hlen,
                                               m->m_pkthdr.rcvif, 0, &m0);
                         if (rv)                          if (rv)
                                 return;                                  return;
                         m = m0;                          m = m0;
Line 489  ip_input(struct mbuf *m)
Line 490  ip_input(struct mbuf *m)
   
         /*          /*
          * Check our list of addresses, to see if the packet is for us.           * Check our list of addresses, to see if the packet is for us.
            *
            * Traditional 4.4BSD did not consult IFF_UP at all.
            * The behavior here is to treat addresses on !IFF_UP interface
            * as not mine.
          */           */
           downmatch = 0;
         for (ia = IN_IFADDR_HASH(ip->ip_dst.s_addr).lh_first;          for (ia = IN_IFADDR_HASH(ip->ip_dst.s_addr).lh_first;
              ia != NULL;               ia != NULL;
              ia = ia->ia_hash.le_next) {               ia = ia->ia_hash.le_next) {
                 if (in_hosteq(ia->ia_addr.sin_addr, ip->ip_dst)) {                  if (in_hosteq(ia->ia_addr.sin_addr, ip->ip_dst)) {
                         if ((ia->ia_ifp->if_flags & IFF_UP) != 0)                          if ((ia->ia_ifp->if_flags & IFF_UP) != 0)
                                 break;                                  break;
                         else {                          else
                                 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST,                                  downmatch++;
                                     0, m->m_pkthdr.rcvif);  
                                 return;  
                         }  
                 }                  }
         }          }
         if (ia != NULL)          if (ia != NULL)
Line 591  ip_input(struct mbuf *m)
Line 594  ip_input(struct mbuf *m)
         if (ipforwarding == 0) {          if (ipforwarding == 0) {
                 ipstat.ips_cantforward++;                  ipstat.ips_cantforward++;
                 m_freem(m);                  m_freem(m);
         } else          } else {
                   /*
                    * If ip_dst matched any of my address on !IFF_UP interface,
                    * and there's no IFF_UP interface that matches ip_dst,
                    * send icmp unreach.  Forwarding it will result in in-kernel
                    * forwarding loop till TTL goes to 0.
                    */
                   if (downmatch) {
                           icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
                           ipstat.ips_cantforward++;
                           return;
                   }
                 ip_forward(m, 0);                  ip_forward(m, 0);
           }
         return;          return;
   
 ours:  ours:
Line 828  insert:
Line 843  insert:
          * Make header visible.           * Make header visible.
          */           */
         ip->ip_len = next;          ip->ip_len = next;
         ip->ip_ttl = 0; /* xxx */  
         ip->ip_sum = 0;  
         ip->ip_src = fp->ipq_src;          ip->ip_src = fp->ipq_src;
         ip->ip_dst = fp->ipq_dst;          ip->ip_dst = fp->ipq_dst;
         LIST_REMOVE(fp, ipq_q);          LIST_REMOVE(fp, ipq_q);
Line 934  ip_dooptions(m)
Line 947  ip_dooptions(m)
         struct mbuf *m;          struct mbuf *m;
 {  {
         register struct ip *ip = mtod(m, struct ip *);          register struct ip *ip = mtod(m, struct ip *);
         register u_char *cp;          register u_char *cp, *cp0;
         register struct ip_timestamp *ipt;          register struct ip_timestamp *ipt;
         register struct in_ifaddr *ia;          register struct in_ifaddr *ia;
         int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0;          int opt, optlen, cnt, off, code, type = ICMP_PARAMPROB, forward = 0;
         struct in_addr *sin, dst;          struct in_addr dst;
         n_time ntime;          n_time ntime;
   
         dst = ip->ip_dst;          dst = ip->ip_dst;
Line 1067  ip_dooptions(m)
Line 1080  ip_dooptions(m)
                                         goto bad;                                          goto bad;
                                 break;                                  break;
                         }                          }
                         sin = (struct in_addr *)(cp + ipt->ipt_ptr - 1);                          cp0 = (cp + ipt->ipt_ptr - 1);
                         switch (ipt->ipt_flg) {                          switch (ipt->ipt_flg) {
   
                         case IPOPT_TS_TSONLY:                          case IPOPT_TS_TSONLY:
Line 1082  ip_dooptions(m)
Line 1095  ip_dooptions(m)
                                     m->m_pkthdr.rcvif));                                      m->m_pkthdr.rcvif));
                                 if (ia == 0)                                  if (ia == 0)
                                         continue;                                          continue;
                                 bcopy((caddr_t)&ia->ia_addr.sin_addr,                                  bcopy(&ia->ia_addr.sin_addr,
                                     (caddr_t)sin, sizeof(struct in_addr));                                      cp0, sizeof(struct in_addr));
                                 ipt->ipt_ptr += sizeof(struct in_addr);                                  ipt->ipt_ptr += sizeof(struct in_addr);
                                 break;                                  break;
   
Line 1091  ip_dooptions(m)
Line 1104  ip_dooptions(m)
                                 if (ipt->ipt_ptr - 1 + sizeof(n_time) +                                  if (ipt->ipt_ptr - 1 + sizeof(n_time) +
                                     sizeof(struct in_addr) > ipt->ipt_len)                                      sizeof(struct in_addr) > ipt->ipt_len)
                                         goto bad;                                          goto bad;
                                 bcopy((caddr_t)sin, (caddr_t)&ipaddr.sin_addr,                                  bcopy(cp0, &ipaddr.sin_addr,
                                     sizeof(struct in_addr));                                      sizeof(struct in_addr));
                                 if (ifatoia(ifa_ifwithaddr(sintosa(&ipaddr)))                                  if (ifatoia(ifa_ifwithaddr(sintosa(&ipaddr)))
                                     == NULL)                                      == NULL)
Line 1103  ip_dooptions(m)
Line 1116  ip_dooptions(m)
                                 goto bad;                                  goto bad;
                         }                          }
                         ntime = iptime();                          ntime = iptime();
                         bcopy((caddr_t)&ntime, (caddr_t)cp + ipt->ipt_ptr - 1,                          cp0 = (u_char *) &ntime; /* XXX grumble, GCC... */
                           bcopy(cp0, (caddr_t)cp + ipt->ipt_ptr - 1,
                             sizeof(n_time));                              sizeof(n_time));
                         ipt->ipt_ptr += sizeof(n_time);                          ipt->ipt_ptr += sizeof(n_time);
                 }                  }
Line 1388  ip_forward(m, srcrt)
Line 1402  ip_forward(m, srcrt)
         }          }
   
 #ifdef IPSEC  #ifdef IPSEC
         m->m_pkthdr.rcvif = NULL;          /* Don't lookup socket in forwading case */
 #endif /*IPSEC*/          ipsec_setsocket(m, NULL);
   #endif
         error = ip_output(m, (struct mbuf *)0, &ipforward_rt,          error = ip_output(m, (struct mbuf *)0, &ipforward_rt,
             (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), 0);              (IP_FORWARDING | (ip_directedbcast ? IP_ALLOWBROADCAST : 0)), 0);
         if (error)          if (error)

Legend:
Removed from v.1.98  
changed lines
  Added in v.1.107

CVSweb <webmaster@jp.NetBSD.org>