[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.319.4.10 and 1.347.2.1

version 1.319.4.10, 2017/08/28 17:53:12 version 1.347.2.1, 2017/04/21 16:54:06
Line 95  __KERNEL_RCSID(0, "$NetBSD$");
Line 95  __KERNEL_RCSID(0, "$NetBSD$");
   
 #ifdef _KERNEL_OPT  #ifdef _KERNEL_OPT
 #include "opt_inet.h"  #include "opt_inet.h"
   #include "opt_compat_netbsd.h"
 #include "opt_gateway.h"  #include "opt_gateway.h"
 #include "opt_ipsec.h"  #include "opt_ipsec.h"
 #include "opt_mrouting.h"  #include "opt_mrouting.h"
Line 173  __KERNEL_RCSID(0, "$NetBSD$");
Line 174  __KERNEL_RCSID(0, "$NetBSD$");
 #define IPMTUDISCTIMEOUT (10 * 60)      /* as per RFC 1191 */  #define IPMTUDISCTIMEOUT (10 * 60)      /* as per RFC 1191 */
 #endif  #endif
   
   #ifdef COMPAT_50
   #include <compat/sys/time.h>
   #include <compat/sys/socket.h>
   #endif
   
 /*  /*
  * Note: DIRECTED_BROADCAST is handled this way so that previous   * Note: DIRECTED_BROADCAST is handled this way so that previous
  * configuration using this option will Just Work.   * configuration using this option will Just Work.
Line 336  ip_init(void)
Line 342  ip_init(void)
 #endif /* MBUFTRACE */  #endif /* MBUFTRACE */
   
         ipstat_percpu = percpu_alloc(sizeof(uint64_t) * IP_NSTATS);          ipstat_percpu = percpu_alloc(sizeof(uint64_t) * IP_NSTATS);
   
         ipforward_rt_percpu = percpu_alloc(sizeof(struct route));          ipforward_rt_percpu = percpu_alloc(sizeof(struct route));
           if (ipforward_rt_percpu == NULL)
                   panic("failed to allocate ipforward_rt_percpu");
   
         ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout);          ip_mtudisc_timeout_q = rt_timer_queue_create(ip_mtudisc_timeout);
 }  }
   
Line 752  ip_input(struct mbuf *m)
Line 762  ip_input(struct mbuf *m)
                         return;                          return;
                 }                  }
 #ifdef IPSEC  #ifdef IPSEC
                 /* Check the security policy (SP) for the packet */                  /* Perform IPsec, if any. */
                 if (ipsec_used) {                  if (ipsec_used) {
                           SOFTNET_LOCK();
                         if (ipsec4_input(m, IP_FORWARDING |                          if (ipsec4_input(m, IP_FORWARDING |
                             (ip_directedbcast ? IP_ALLOWBROADCAST : 0)) != 0) {                              (ip_directedbcast ? IP_ALLOWBROADCAST : 0)) != 0) {
                                   SOFTNET_UNLOCK();
                                 goto out;                                  goto out;
                         }                          }
                           SOFTNET_UNLOCK();
                 }                  }
 #endif  #endif
                 ip_forward(m, srcrt, ifp);                  ip_forward(m, srcrt, ifp);
Line 800  ours:
Line 813  ours:
          */           */
         if (ipsec_used &&          if (ipsec_used &&
             (inetsw[ip_protox[ip->ip_p]].pr_flags & PR_LASTHDR) != 0) {              (inetsw[ip_protox[ip->ip_p]].pr_flags & PR_LASTHDR) != 0) {
                   SOFTNET_LOCK();
                 if (ipsec4_input(m, 0) != 0) {                  if (ipsec4_input(m, 0) != 0) {
                           SOFTNET_UNLOCK();
                         goto out;                          goto out;
                 }                  }
                   SOFTNET_UNLOCK();
         }          }
 #endif  #endif
   
Line 1509  ip_savecontrol(struct inpcb *inp, struct
Line 1525  ip_savecontrol(struct inpcb *inp, struct
     struct mbuf *m)      struct mbuf *m)
 {  {
         struct socket *so = inp->inp_socket;          struct socket *so = inp->inp_socket;
           ifnet_t *ifp;
         int inpflags = inp->inp_flags;          int inpflags = inp->inp_flags;
           struct psref psref;
   
         if (SOOPT_TIMESTAMP(so->so_options))          ifp = m_get_rcvif_psref(m, &psref);
                 mp = sbsavetimestamp(so->so_options, m, mp);          if (__predict_false(ifp == NULL))
                   return; /* XXX should report error? */
   
         if (inpflags & INP_RECVDSTADDR) {          if (so->so_options & SO_TIMESTAMP
                 *mp = sbcreatecontrol(&ip->ip_dst,  #ifdef SO_OTIMESTAMP
                     sizeof(struct in_addr), IP_RECVDSTADDR, IPPROTO_IP);              || so->so_options & SO_OTIMESTAMP
   #endif
               ) {
                   struct timeval tv;
   
                   microtime(&tv);
   #ifdef SO_OTIMESTAMP
                   if (so->so_options & SO_OTIMESTAMP) {
                           struct timeval50 tv50;
                           timeval_to_timeval50(&tv, &tv50);
                           *mp = sbcreatecontrol((void *) &tv50, sizeof(tv50),
                               SCM_OTIMESTAMP, SOL_SOCKET);
                   } else
   #endif
                   *mp = sbcreatecontrol((void *) &tv, sizeof(tv),
                       SCM_TIMESTAMP, SOL_SOCKET);
                 if (*mp)                  if (*mp)
                         mp = &(*mp)->m_next;                          mp = &(*mp)->m_next;
         }          }
           if (inpflags & INP_RECVDSTADDR) {
         if (inpflags & INP_RECVTTL) {                  *mp = sbcreatecontrol((void *) &ip->ip_dst,
                 *mp = sbcreatecontrol(&ip->ip_ttl,                      sizeof(struct in_addr), IP_RECVDSTADDR, IPPROTO_IP);
                     sizeof(uint8_t), IP_RECVTTL, IPPROTO_IP);  
                 if (*mp)                  if (*mp)
                         mp = &(*mp)->m_next;                          mp = &(*mp)->m_next;
         }          }
   
         struct psref psref;  
         ifnet_t *ifp = m_get_rcvif_psref(m, &psref);  
         if (__predict_false(ifp == NULL)) {  
 #ifdef DIAGNOSTIC  
                 printf("%s: missing receive interface\n", __func__);  
 #endif  
                 return; /* XXX should report error? */  
         }  
   
         if (inpflags & INP_RECVPKTINFO) {          if (inpflags & INP_RECVPKTINFO) {
                 struct in_pktinfo ipi;                  struct in_pktinfo ipi;
                 ipi.ipi_addr = ip->ip_src;                  ipi.ipi_addr = ip->ip_src;
                 ipi.ipi_ifindex = ifp->if_index;                  ipi.ipi_ifindex = ifp->if_index;
                 *mp = sbcreatecontrol(&ipi,                  *mp = sbcreatecontrol((void *) &ipi,
                     sizeof(ipi), IP_RECVPKTINFO, IPPROTO_IP);                      sizeof(ipi), IP_RECVPKTINFO, IPPROTO_IP);
                 if (*mp)                  if (*mp)
                         mp = &(*mp)->m_next;                          mp = &(*mp)->m_next;
Line 1550  ip_savecontrol(struct inpcb *inp, struct
Line 1573  ip_savecontrol(struct inpcb *inp, struct
                 struct in_pktinfo ipi;                  struct in_pktinfo ipi;
                 ipi.ipi_addr = ip->ip_dst;                  ipi.ipi_addr = ip->ip_dst;
                 ipi.ipi_ifindex = ifp->if_index;                  ipi.ipi_ifindex = ifp->if_index;
                 *mp = sbcreatecontrol(&ipi,                  *mp = sbcreatecontrol((void *) &ipi,
                     sizeof(ipi), IP_PKTINFO, IPPROTO_IP);                      sizeof(ipi), IP_PKTINFO, IPPROTO_IP);
                 if (*mp)                  if (*mp)
                         mp = &(*mp)->m_next;                          mp = &(*mp)->m_next;
Line 1564  ip_savecontrol(struct inpcb *inp, struct
Line 1587  ip_savecontrol(struct inpcb *inp, struct
                 if (*mp)                  if (*mp)
                         mp = &(*mp)->m_next;                          mp = &(*mp)->m_next;
         }          }
           if (inpflags & INP_RECVTTL) {
                   *mp = sbcreatecontrol((void *) &ip->ip_ttl,
                       sizeof(uint8_t), IP_RECVTTL, IPPROTO_IP);
                   if (*mp)
                           mp = &(*mp)->m_next;
           }
         m_put_rcvif_psref(ifp, &psref);          m_put_rcvif_psref(ifp, &psref);
 }  }
   

Legend:
Removed from v.1.319.4.10  
changed lines
  Added in v.1.347.2.1

CVSweb <webmaster@jp.NetBSD.org>