[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.88.4.2 and 1.94.4.3

version 1.88.4.2, 2006/09/09 02:58:47 version 1.94.4.3, 2007/05/17 13:41:50
Line 141  rip_input(struct mbuf *m, ...)
Line 141  rip_input(struct mbuf *m, ...)
 {  {
         int proto;          int proto;
         struct ip *ip = mtod(m, struct ip *);          struct ip *ip = mtod(m, struct ip *);
           struct inpcb_hdr *inph;
         struct inpcb *inp;          struct inpcb *inp;
         struct inpcb *last = 0;          struct inpcb *last = NULL;
         struct mbuf *opts = 0;          struct mbuf *n, *opts = NULL;
         struct sockaddr_in ripsrc;          struct sockaddr_in ripsrc;
         va_list ap;          va_list ap;
   
Line 152  rip_input(struct mbuf *m, ...)
Line 153  rip_input(struct mbuf *m, ...)
         proto = va_arg(ap, int);          proto = va_arg(ap, int);
         va_end(ap);          va_end(ap);
   
         ripsrc.sin_family = AF_INET;          sockaddr_in_init(&ripsrc, &ip->ip_src, 0);
         ripsrc.sin_len = sizeof(struct sockaddr_in);  
         ripsrc.sin_addr = ip->ip_src;  
         ripsrc.sin_port = 0;  
         bzero((caddr_t)ripsrc.sin_zero, sizeof(ripsrc.sin_zero));  
   
         /*          /*
          * XXX Compatibility: programs using raw IP expect ip_len           * XXX Compatibility: programs using raw IP expect ip_len
Line 166  rip_input(struct mbuf *m, ...)
Line 163  rip_input(struct mbuf *m, ...)
         ip->ip_len = ntohs(ip->ip_len) - (ip->ip_hl << 2);          ip->ip_len = ntohs(ip->ip_len) - (ip->ip_hl << 2);
         NTOHS(ip->ip_off);          NTOHS(ip->ip_off);
   
         CIRCLEQ_FOREACH(inp, &rawcbtable.inpt_queue, inp_queue) {          CIRCLEQ_FOREACH(inph, &rawcbtable.inpt_queue, inph_queue) {
                   inp = (struct inpcb *)inph;
                 if (inp->inp_af != AF_INET)                  if (inp->inp_af != AF_INET)
                         continue;                          continue;
                 if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != proto)                  if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != proto)
Line 177  rip_input(struct mbuf *m, ...)
Line 175  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) {                  if (last == NULL)
                         struct mbuf *n;                          ;
   
 #if defined(IPSEC) || defined(FAST_IPSEC)  #if defined(IPSEC) || defined(FAST_IPSEC)
                         /* check AH/ESP integrity. */                  /* check AH/ESP integrity. */
                         if (ipsec4_in_reject_so(m, last->inp_socket)) {                  else if (ipsec4_in_reject_so(m, last->inp_socket)) {
                                 ipsecstat.in_polvio++;                          ipsecstat.in_polvio++;
                                 /* do not inject data to pcb */                          /* do not inject data to pcb */
                         } else                  }
 #endif /*IPSEC*/  #endif /*IPSEC*/
                         if ((n = m_copy(m, 0, (int)M_COPYALL)) != NULL) {                  else if ((n = m_copy(m, 0, M_COPYALL)) != NULL) {
                                 if (last->inp_flags & INP_CONTROLOPTS ||                          if (last->inp_flags & INP_CONTROLOPTS ||
                                     last->inp_socket->so_options & SO_TIMESTAMP)                              last->inp_socket->so_options & SO_TIMESTAMP)
                                         ip_savecontrol(last, &opts, ip, n);                                  ip_savecontrol(last, &opts, ip, n);
                                 if (sbappendaddr(&last->inp_socket->so_rcv,                          if (sbappendaddr(&last->inp_socket->so_rcv,
                                     sintosa(&ripsrc), n, opts) == 0) {                              sintosa(&ripsrc), n, opts) == 0) {
                                         /* should notify about lost packet */                                  /* should notify about lost packet */
                                         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);
                                 opts = NULL;                          opts = NULL;
                         }  
                 }                  }
                 last = inp;                  last = inp;
         }          }
 #if defined(IPSEC) || defined(FAST_IPSEC)  #if defined(IPSEC) || defined(FAST_IPSEC)
         /* check AH/ESP integrity. */          /* check AH/ESP integrity. */
         if (last && ipsec4_in_reject_so(m, last->inp_socket)) {          if (last != NULL && ipsec4_in_reject_so(m, last->inp_socket)) {
                 m_freem(m);                  m_freem(m);
                 ipsecstat.in_polvio++;                  ipsecstat.in_polvio++;
                 ipstat.ips_delivered--;                  ipstat.ips_delivered--;
                 /* do not inject data to pcb */                  /* do not inject data to pcb */
         } else          } else
 #endif /*IPSEC*/  #endif /*IPSEC*/
         if (last) {          if (last != NULL) {
                 if (last->inp_flags & INP_CONTROLOPTS ||                  if (last->inp_flags & INP_CONTROLOPTS ||
                     last->inp_socket->so_options & SO_TIMESTAMP)                      last->inp_socket->so_options & SO_TIMESTAMP)
                         ip_savecontrol(last, &opts, ip, m);                          ip_savecontrol(last, &opts, ip, m);
Line 224  rip_input(struct mbuf *m, ...)
Line 220  rip_input(struct mbuf *m, ...)
                                 m_freem(opts);                                  m_freem(opts);
                 } else                  } else
                         sorwakeup(last->inp_socket);                          sorwakeup(last->inp_socket);
         } else {          } else if (inetsw[ip_protox[ip->ip_p]].pr_input == rip_input) {
                 if (inetsw[ip_protox[ip->ip_p]].pr_input == rip_input) {                  icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PROTOCOL,
                         icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_PROTOCOL,                      0, 0);
                             0, 0);                  ipstat.ips_noproto++;
                         ipstat.ips_noproto++;                  ipstat.ips_delivered--;
                         ipstat.ips_delivered--;          } else
                 } else                  m_freem(m);
                         m_freem(m);  
         }  
         return;          return;
 }  }
   
Line 264  rip_pcbnotify(struct inpcbtable *table,
Line 258  rip_pcbnotify(struct inpcbtable *table,
 }  }
   
 void *  void *
 rip_ctlinput(int cmd, struct sockaddr *sa, void *v)  rip_ctlinput(int cmd, const struct sockaddr *sa, void *v)
 {  {
         struct ip *ip = v;          struct ip *ip = v;
         void (*notify)(struct inpcb *, int) = in_rtchange;          void (*notify)(struct inpcb *, int) = in_rtchange;
Line 283  rip_ctlinput(int cmd, struct sockaddr *s
Line 277  rip_ctlinput(int cmd, struct sockaddr *s
         else if (errno == 0)          else if (errno == 0)
                 return NULL;                  return NULL;
         if (ip) {          if (ip) {
                 rip_pcbnotify(&rawcbtable, satosin(sa)->sin_addr,                  rip_pcbnotify(&rawcbtable, satocsin(sa)->sin_addr,
                     ip->ip_src, ip->ip_p, errno, notify);                      ip->ip_src, ip->ip_p, errno, notify);
   
                 /* XXX mapped address case */                  /* XXX mapped address case */
         } else          } else
                 in_pcbnotifyall(&rawcbtable, satosin(sa)->sin_addr, errno,                  in_pcbnotifyall(&rawcbtable, satocsin(sa)->sin_addr, errno,
                     notify);                      notify);
         return NULL;          return NULL;
 }  }
Line 511  rip_usrreq(struct socket *so, int req,
Line 505  rip_usrreq(struct socket *so, int req,
 #endif  #endif
   
         if (req == PRU_CONTROL)          if (req == PRU_CONTROL)
                 return (in_control(so, (long)m, (caddr_t)nam,                  return (in_control(so, (long)m, (void *)nam,
                     (struct ifnet *)control, l));                      (struct ifnet *)control, l));
   
           s = splsoftnet();
   
         if (req == PRU_PURGEIF) {          if (req == PRU_PURGEIF) {
                 in_pcbpurgeif0(&rawcbtable, (struct ifnet *)control);                  in_pcbpurgeif0(&rawcbtable, (struct ifnet *)control);
                 in_purgeif((struct ifnet *)control);                  in_purgeif((struct ifnet *)control);
                 in_pcbpurgeif(&rawcbtable, (struct ifnet *)control);                  in_pcbpurgeif(&rawcbtable, (struct ifnet *)control);
                   splx(s);
                 return (0);                  return (0);
         }          }
   
         s = splsoftnet();  
         inp = sotoinpcb(so);          inp = sotoinpcb(so);
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
         if (req != PRU_SEND && req != PRU_SENDOOB && control)          if (req != PRU_SEND && req != PRU_SENDOOB && control)
Line 539  rip_usrreq(struct socket *so, int req,
Line 535  rip_usrreq(struct socket *so, int req,
                         error = EISCONN;                          error = EISCONN;
                         break;                          break;
                 }                  }
                 if (l == 0 || (error = kauth_authorize_generic(l->l_cred,  
                     KAUTH_GENERIC_ISSUSER, &l->l_acflag))) {                  if (l == NULL) {
                         error = EACCES;                          error = EACCES;
                         break;                          break;
                 }                  }
   
                   /* XXX: raw socket permissions are checked in socreate() */
   
                 if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {                  if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
                         error = soreserve(so, rip_sendspace, rip_recvspace);                          error = soreserve(so, rip_sendspace, rip_recvspace);
                         if (error)                          if (error)

Legend:
Removed from v.1.88.4.2  
changed lines
  Added in v.1.94.4.3

CVSweb <webmaster@jp.NetBSD.org>