[BACK]Return to raw_ip.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/raw_ip.c between version 1.171 and 1.171.2.4

version 1.171, 2018/02/28 11:23:24 version 1.171.2.4, 2018/05/21 04:36:16
Line 100  __KERNEL_RCSID(0, "$NetBSD$");
Line 100  __KERNEL_RCSID(0, "$NetBSD$");
   
 #ifdef IPSEC  #ifdef IPSEC
 #include <netipsec/ipsec.h>  #include <netipsec/ipsec.h>
 #include <netipsec/ipsec_var.h>  
 #endif  #endif
   
 struct inpcbtable rawcbtable;  struct inpcbtable rawcbtable;
Line 138  rip_init(void)
Line 137  rip_init(void)
   
 static void  static void
 rip_sbappendaddr(struct inpcb *last, struct ip *ip, const struct sockaddr *sa,  rip_sbappendaddr(struct inpcb *last, struct ip *ip, const struct sockaddr *sa,
     int hlen, struct mbuf *opts, struct mbuf *n)      int hlen, struct mbuf *n)
 {  {
           struct mbuf *opts = NULL;
   
         if (last->inp_flags & INP_NOHEADER)          if (last->inp_flags & INP_NOHEADER)
                 m_adj(n, hlen);                  m_adj(n, hlen);
         if (last->inp_flags & INP_CONTROLOPTS          if (last->inp_flags & INP_CONTROLOPTS ||
             || SOOPT_TIMESTAMP(last->inp_socket->so_options))              SOOPT_TIMESTAMP(last->inp_socket->so_options))
                 ip_savecontrol(last, &opts, ip, n);                  ip_savecontrol(last, &opts, ip, n);
         if (sbappendaddr(&last->inp_socket->so_rcv, sa, n, opts) == 0) {          if (sbappendaddr(&last->inp_socket->so_rcv, sa, n, opts) == 0) {
                 /* should notify about lost packet */                  soroverflow(last->inp_socket);
                 m_freem(n);                  m_freem(n);
                 if (opts)                  if (opts)
                         m_freem(opts);                          m_freem(opts);
         } else          } else {
                 sorwakeup(last->inp_socket);                  sorwakeup(last->inp_socket);
           }
 }  }
   
 /*  /*
Line 167  rip_input(struct mbuf *m, ...)
Line 169  rip_input(struct mbuf *m, ...)
         struct inpcb_hdr *inph;          struct inpcb_hdr *inph;
         struct inpcb *inp;          struct inpcb *inp;
         struct inpcb *last = NULL;          struct inpcb *last = NULL;
         struct mbuf *n, *opts = NULL;          struct mbuf *n;
         struct sockaddr_in ripsrc;          struct sockaddr_in ripsrc;
         va_list ap;          va_list ap;
   
Line 199  rip_input(struct mbuf *m, ...)
Line 201  rip_input(struct mbuf *m, ...)
                 if (!in_nullhost(inp->inp_faddr) &&                  if (!in_nullhost(inp->inp_faddr) &&
                     !in_hosteq(inp->inp_faddr, ip->ip_src))                      !in_hosteq(inp->inp_faddr, ip->ip_src))
                         continue;                          continue;
                 if (last == NULL)  
                   if (last == NULL) {
                         ;                          ;
                   }
 #if defined(IPSEC)  #if defined(IPSEC)
                 /* check AH/ESP integrity. */  
                 else if (ipsec_used && ipsec_in_reject(m, last)) {                  else if (ipsec_used && ipsec_in_reject(m, last)) {
                         /* do not inject data to pcb */                          /* do not inject data into pcb */
                 }                  }
 #endif /*IPSEC*/  #endif
                 else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {                  else if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) {
                         rip_sbappendaddr(last, ip, sintosa(&ripsrc), hlen, opts,                          rip_sbappendaddr(last, ip, sintosa(&ripsrc), hlen, n);
                             n);  
                         opts = NULL;  
                 }                  }
   
                 last = inp;                  last = inp;
         }          }
   
 #if defined(IPSEC)  #if defined(IPSEC)
         /* check AH/ESP integrity. */  
         if (ipsec_used && last != NULL && ipsec_in_reject(m, last)) {          if (ipsec_used && last != NULL && ipsec_in_reject(m, last)) {
                 m_freem(m);                  m_freem(m);
                 IP_STATDEC(IP_STAT_DELIVERED);                  IP_STATDEC(IP_STAT_DELIVERED);
                 /* do not inject data to pcb */                  /* do not inject data into pcb */
         } else          } else
 #endif /*IPSEC*/  #endif
         if (last != NULL)          if (last != NULL) {
                 rip_sbappendaddr(last, ip, sintosa(&ripsrc), hlen, opts, m);                  rip_sbappendaddr(last, ip, sintosa(&ripsrc), hlen, m);
         else if (inetsw[ip_protox[ip->ip_p]].pr_input == rip_input) {          } else if (inetsw[ip_protox[ip->ip_p]].pr_input == rip_input) {
                 uint64_t *ips;                  uint64_t *ips;
   
                 icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PROTOCOL,                  icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PROTOCOL,
Line 233  rip_input(struct mbuf *m, ...)
Line 235  rip_input(struct mbuf *m, ...)
                 ips[IP_STAT_NOPROTO]++;                  ips[IP_STAT_NOPROTO]++;
                 ips[IP_STAT_DELIVERED]--;                  ips[IP_STAT_DELIVERED]--;
                 IP_STAT_PUTREF();                  IP_STAT_PUTREF();
         } else          } else {
                 m_freem(m);                  m_freem(m);
           }
   
         return;          return;
 }  }
   
Line 351  rip_output(struct mbuf *m, struct inpcb 
Line 355  rip_output(struct mbuf *m, struct inpcb 
                         error = EMSGSIZE;                          error = EMSGSIZE;
                         goto release;                          goto release;
                 }                  }
                   if (m->m_pkthdr.len < sizeof(struct ip)) {
                           error = EINVAL;
                           goto release;
                   }
                 ip = mtod(m, struct ip *);                  ip = mtod(m, struct ip *);
   
                 /*                  /*
Line 363  rip_output(struct mbuf *m, struct inpcb 
Line 371  rip_output(struct mbuf *m, struct inpcb 
   
                         m = m_copyup(m, hlen, (max_linkhdr + 3) & ~3);                          m = m_copyup(m, hlen, (max_linkhdr + 3) & ~3);
                         if (m == NULL) {                          if (m == NULL) {
                                 error = ENOMEM; /* XXX */                                  error = ENOMEM;
                                 goto release;                                  goto release;
                         }                          }
                         ip = mtod(m, struct ip *);                          ip = mtod(m, struct ip *);
Line 376  rip_output(struct mbuf *m, struct inpcb 
Line 384  rip_output(struct mbuf *m, struct inpcb 
                 }                  }
                 HTONS(ip->ip_len);                  HTONS(ip->ip_len);
                 HTONS(ip->ip_off);                  HTONS(ip->ip_off);
   
                 if (ip->ip_id != 0 || m->m_pkthdr.len < IP_MINFRAGSIZE)                  if (ip->ip_id != 0 || m->m_pkthdr.len < IP_MINFRAGSIZE)
                         flags |= IP_NOIPNEWID;                          flags |= IP_NOIPNEWID;
                 opts = NULL;                  opts = NULL;
                 /* XXX prevent ip_output from overwriting header fields */  
                   /* Prevent ip_output from overwriting header fields. */
                 flags |= IP_RAWOUTPUT;                  flags |= IP_RAWOUTPUT;
   
                 IP_STATINC(IP_STAT_RAWOUT);                  IP_STATINC(IP_STAT_RAWOUT);
         }          }
   

Legend:
Removed from v.1.171  
changed lines
  Added in v.1.171.2.4

CVSweb <webmaster@jp.NetBSD.org>