[BACK]Return to udp_usrreq.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/udp_usrreq.c between version 1.183.2.2 and 1.191

version 1.183.2.2, 2012/10/30 17:22:47 version 1.191, 2013/11/23 14:20:21
Line 118  __KERNEL_RCSID(0, "$NetBSD$");
Line 118  __KERNEL_RCSID(0, "$NetBSD$");
 #include <net/if_faith.h>  #include <net/if_faith.h>
 #endif  #endif
   
 #ifdef FAST_IPSEC  #ifdef IPSEC
 #include <netipsec/ipsec.h>  #include <netipsec/ipsec.h>
 #include <netipsec/ipsec_var.h>  #include <netipsec/ipsec_var.h>
 #include <netipsec/ipsec_private.h>  #include <netipsec/ipsec_private.h>
Line 126  __KERNEL_RCSID(0, "$NetBSD$");
Line 126  __KERNEL_RCSID(0, "$NetBSD$");
 #ifdef INET6  #ifdef INET6
 #include <netipsec/ipsec6.h>  #include <netipsec/ipsec6.h>
 #endif  #endif
 #endif  /* FAST_IPSEC */  #endif  /* IPSEC */
   
 #ifdef COMPAT_50  #ifdef COMPAT_50
 #include <compat/sys/socket.h>  #include <compat/sys/socket.h>
Line 148  struct inpcbtable udbtable;
Line 148  struct inpcbtable udbtable;
 percpu_t *udpstat_percpu;  percpu_t *udpstat_percpu;
   
 #ifdef INET  #ifdef INET
 #ifdef IPSEC_NAT_T  #ifdef IPSEC
 static int udp4_espinudp (struct mbuf **, int, struct sockaddr *,  static int udp4_espinudp (struct mbuf **, int, struct sockaddr *,
         struct socket *);          struct socket *);
 #endif  #endif
Line 404  udp_input(struct mbuf *m, ...)
Line 404  udp_input(struct mbuf *m, ...)
                 UDP_STATINC(UDP_STAT_HDROPS);                  UDP_STATINC(UDP_STAT_HDROPS);
                 return;                  return;
         }          }
           if (m == NULL) {
                   /*
                    * packet has been processed by ESP stuff -
                    * e.g. dropped NAT-T-keep-alive-packet ...
                    */
                   return;
           }
           ip = mtod(m, struct ip *);
 #ifdef INET6  #ifdef INET6
         if (IN_MULTICAST(ip->ip_dst.s_addr) || n == 0) {          if (IN_MULTICAST(ip->ip_dst.s_addr) || n == 0) {
                 struct sockaddr_in6 src6, dst6;                  struct sockaddr_in6 src6, dst6;
Line 626  udp4_sendup(struct mbuf *m, int off /* o
Line 634  udp4_sendup(struct mbuf *m, int off /* o
                 return;                  return;
         }          }
   
 #if defined(FAST_IPSEC)  #if defined(IPSEC)
         /* check AH/ESP integrity. */          /* check AH/ESP integrity. */
         if (so != NULL && ipsec4_in_reject_so(m, so)) {          if (so != NULL && ipsec4_in_reject_so(m, so)) {
                 IPSEC_STATINC(IPSEC_STAT_IN_POLVIO);                  IPSEC_STATINC(IPSEC_STAT_IN_POLVIO);
Line 676  udp6_sendup(struct mbuf *m, int off /* o
Line 684  udp6_sendup(struct mbuf *m, int off /* o
                 return;                  return;
         in6p = sotoin6pcb(so);          in6p = sotoin6pcb(so);
   
 #if defined(FAST_IPSEC)  #if defined(IPSEC)
         /* check AH/ESP integrity. */          /* check AH/ESP integrity. */
         if (so != NULL && ipsec6_in_reject_so(m, so)) {          if (so != NULL && ipsec6_in_reject_so(m, so)) {
                 IPSEC6_STATINC(IPSEC_STAT_IN_POLVIO);                  IPSEC6_STATINC(IPSEC_STAT_IN_POLVIO);
Line 758  udp4_realinput(struct sockaddr_in *src, 
Line 766  udp4_realinput(struct sockaddr_in *src, 
                 /*                  /*
                  * Locate pcb(s) for datagram.                   * Locate pcb(s) for datagram.
                  */                   */
                 CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {                  TAILQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
                         inp = (struct inpcb *)inph;                          inp = (struct inpcb *)inph;
                         if (inp->inp_af != AF_INET)                          if (inp->inp_af != AF_INET)
                                 continue;                                  continue;
Line 804  udp4_realinput(struct sockaddr_in *src, 
Line 812  udp4_realinput(struct sockaddr_in *src, 
                                 return rcvcnt;                                  return rcvcnt;
                 }                  }
   
 #ifdef IPSEC_NAT_T  #ifdef IPSEC
                 /* Handle ESP over UDP */                  /* Handle ESP over UDP */
                 if (inp->inp_flags & INP_ESPINUDP_ALL) {                  if (inp->inp_flags & INP_ESPINUDP_ALL) {
                         struct sockaddr *sa = (struct sockaddr *)src;                          struct sockaddr *sa = (struct sockaddr *)src;
Line 903  udp6_realinput(int af, struct sockaddr_i
Line 911  udp6_realinput(int af, struct sockaddr_i
                 /*                  /*
                  * Locate pcb(s) for datagram.                   * Locate pcb(s) for datagram.
                  */                   */
                 CIRCLEQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {                  TAILQ_FOREACH(inph, &udbtable.inpt_queue, inph_queue) {
                         in6p = (struct in6pcb *)inph;                          in6p = (struct in6pcb *)inph;
                         if (in6p->in6p_af != AF_INET6)                          if (in6p->in6p_af != AF_INET6)
                                 continue;                                  continue;
Line 1058  udp_ctloutput(int op, struct socket *so,
Line 1066  udp_ctloutput(int op, struct socket *so,
                                 break;                                  break;
   
                         switch(optval) {                          switch(optval) {
 #ifdef IPSEC_NAT_T  
                         case 0:                          case 0:
                                 inp->inp_flags &= ~INP_ESPINUDP_ALL;                                  inp->inp_flags &= ~INP_ESPINUDP_ALL;
                                 break;                                  break;
Line 1072  udp_ctloutput(int op, struct socket *so,
Line 1079  udp_ctloutput(int op, struct socket *so,
                                 inp->inp_flags &= ~INP_ESPINUDP_ALL;                                  inp->inp_flags &= ~INP_ESPINUDP_ALL;
                                 inp->inp_flags |= INP_ESPINUDP_NON_IKE;                                  inp->inp_flags |= INP_ESPINUDP_NON_IKE;
                                 break;                                  break;
 #endif  
                         default:                          default:
                                 error = EINVAL;                                  error = EINVAL;
                                 break;                                  break;
Line 1437  udp_statinc(u_int stat)
Line 1443  udp_statinc(u_int stat)
         UDP_STATINC(stat);          UDP_STATINC(stat);
 }  }
   
 #if (defined INET && defined IPSEC_NAT_T)  #if defined(INET) && defined(IPSEC)
 /*  /*
  * Returns:   * Returns:
  * 1 if the packet was processed   * 1 if the packet was processed
Line 1455  udp4_espinudp(struct mbuf **mp, int off,
Line 1461  udp4_espinudp(struct mbuf **mp, int off,
         size_t minlen;          size_t minlen;
         size_t iphdrlen;          size_t iphdrlen;
         struct ip *ip;          struct ip *ip;
         struct mbuf *n;  
         struct m_tag *tag;          struct m_tag *tag;
         struct udphdr *udphdr;          struct udphdr *udphdr;
         u_int16_t sport, dport;          u_int16_t sport, dport;
Line 1483  udp4_espinudp(struct mbuf **mp, int off,
Line 1488  udp4_espinudp(struct mbuf **mp, int off,
   
         /* Ignore keepalive packets */          /* Ignore keepalive packets */
         if ((len == 1) && (*(unsigned char *)data == 0xff)) {          if ((len == 1) && (*(unsigned char *)data == 0xff)) {
                   m_free(m);
                   *mp = NULL; /* avoid any further processiong by caller ... */
                 return 1;                  return 1;
         }          }
   
Line 1542  udp4_espinudp(struct mbuf **mp, int off,
Line 1549  udp4_espinudp(struct mbuf **mp, int off,
         ip->ip_p = IPPROTO_ESP;          ip->ip_p = IPPROTO_ESP;
   
         /*          /*
          * Copy the mbuf to avoid multiple free, as both           * We have modified the packet - it is now ESP, so we should not
          * esp4_input (which we call) and udp_input (which           * return to UDP processing ...
          * called us) free the mbuf.           *
          */  
         if ((n = m_dup(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {  
                 printf("udp4_espinudp: m_dup failed\n");  
                 return 0;  
         }  
   
         /*  
          * Add a PACKET_TAG_IPSEC_NAT_T_PORT tag to remember           * Add a PACKET_TAG_IPSEC_NAT_T_PORT tag to remember
          * the source UDP port. This is required if we want           * the source UDP port. This is required if we want
          * to select the right SPD for multiple hosts behind           * to select the right SPD for multiple hosts behind
Line 1560  udp4_espinudp(struct mbuf **mp, int off,
Line 1560  udp4_espinudp(struct mbuf **mp, int off,
         if ((tag = m_tag_get(PACKET_TAG_IPSEC_NAT_T_PORTS,          if ((tag = m_tag_get(PACKET_TAG_IPSEC_NAT_T_PORTS,
             sizeof(sport) + sizeof(dport), M_DONTWAIT)) == NULL) {              sizeof(sport) + sizeof(dport), M_DONTWAIT)) == NULL) {
                 printf("udp4_espinudp: m_tag_get failed\n");                  printf("udp4_espinudp: m_tag_get failed\n");
                 m_freem(n);                  m_freem(m);
                 return 0;                  return -1;
         }          }
         ((u_int16_t *)(tag + 1))[0] = sport;          ((u_int16_t *)(tag + 1))[0] = sport;
         ((u_int16_t *)(tag + 1))[1] = dport;          ((u_int16_t *)(tag + 1))[1] = dport;
         m_tag_prepend(n, tag);          m_tag_prepend(m, tag);
   
 #ifdef FAST_IPSEC  #ifdef IPSEC
         ipsec4_common_input(n, iphdrlen, IPPROTO_ESP);          ipsec4_common_input(m, iphdrlen, IPPROTO_ESP);
 #else  #else
         esp4_input(n, iphdrlen);          esp4_input(m, iphdrlen);
 #endif  #endif
   
         /* We handled it, it shouldn't be handled by UDP */          /* We handled it, it shouldn't be handled by UDP */
           *mp = NULL; /* avoid free by caller ... */
         return 1;          return 1;
 }  }
 #endif  #endif

Legend:
Removed from v.1.183.2.2  
changed lines
  Added in v.1.191

CVSweb <webmaster@jp.NetBSD.org>