[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.186 and 1.188

version 1.186, 2012/03/22 20:34:39 version 1.188, 2013/06/04 22:47:37
Line 96  __KERNEL_RCSID(0, "$NetBSD$");
Line 96  __KERNEL_RCSID(0, "$NetBSD$");
 #include <netinet/udp.h>  #include <netinet/udp.h>
 #include <netinet/udp_var.h>  #include <netinet/udp_var.h>
 #include <netinet/udp_private.h>  #include <netinet/udp_private.h>
 #include <netinet/rfc6056.h>  
   
 #ifdef INET6  #ifdef INET6
 #include <netinet/ip6.h>  #include <netinet/ip6.h>
Line 149  struct inpcbtable udbtable;
Line 148  struct inpcbtable udbtable;
 percpu_t *udpstat_percpu;  percpu_t *udpstat_percpu;
   
 #ifdef INET  #ifdef INET
 #ifdef IPSEC_NAT_T  
 static int udp4_espinudp (struct mbuf **, int, struct sockaddr *,  static int udp4_espinudp (struct mbuf **, int, struct sockaddr *,
         struct socket *);          struct socket *);
 #endif  
 static void udp4_sendup (struct mbuf *, int, struct sockaddr *,  static void udp4_sendup (struct mbuf *, int, struct sockaddr *,
         struct socket *);          struct socket *);
 static int udp4_realinput (struct sockaddr_in *, struct sockaddr_in *,  static int udp4_realinput (struct sockaddr_in *, struct sockaddr_in *,
Line 405  udp_input(struct mbuf *m, ...)
Line 402  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 805  udp4_realinput(struct sockaddr_in *src, 
Line 810  udp4_realinput(struct sockaddr_in *src, 
                                 return rcvcnt;                                  return rcvcnt;
                 }                  }
   
 #ifdef IPSEC_NAT_T  
                 /* 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 831  udp4_realinput(struct sockaddr_in *src, 
Line 835  udp4_realinput(struct sockaddr_in *src, 
                                 break;                                  break;
                         }                          }
                 }                  }
 #endif  
   
                 /*                  /*
                  * Check the minimum TTL for socket.                   * Check the minimum TTL for socket.
Line 1059  udp_ctloutput(int op, struct socket *so,
Line 1062  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 1073  udp_ctloutput(int op, struct socket *so,
Line 1075  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;
                         }                          }
                         break;                          break;
   
                 case UDP_RFC6056ALGO:  
                         error = sockopt_getint(sopt, &optval);  
                         if (error)  
                                 break;  
   
                         error = rfc6056_algo_index_select(  
                             (struct inpcb_hdr *)inp, optval);  
                         break;  
   
                 default:                  default:
                         error = ENOPROTOOPT;                          error = ENOPROTOOPT;
                         break;                          break;
Line 1377  sysctl_net_inet_udp_stats(SYSCTLFN_ARGS)
Line 1369  sysctl_net_inet_udp_stats(SYSCTLFN_ARGS)
 static void  static void
 sysctl_net_inet_udp_setup(struct sysctllog **clog)  sysctl_net_inet_udp_setup(struct sysctllog **clog)
 {  {
         const struct sysctlnode *rfc6056_node;  
   
         sysctl_createv(clog, 0, NULL, NULL,          sysctl_createv(clog, 0, NULL, NULL,
                        CTLFLAG_PERMANENT,                         CTLFLAG_PERMANENT,
                        CTLTYPE_NODE, "net", NULL,                         CTLTYPE_NODE, "net", NULL,
Line 1438  sysctl_net_inet_udp_setup(struct sysctll
Line 1428  sysctl_net_inet_udp_setup(struct sysctll
                        sysctl_net_inet_udp_stats, 0, NULL, 0,                         sysctl_net_inet_udp_stats, 0, NULL, 0,
                        CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_STATS,                         CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_STATS,
                        CTL_EOL);                         CTL_EOL);
         /* RFC6056 subtree */  
         sysctl_createv(clog, 0, NULL, &rfc6056_node,  
                        CTLFLAG_PERMANENT,  
                        CTLTYPE_NODE, "rfc6056",  
                        SYSCTL_DESCR("RFC 6056"),  
                        NULL, 0, NULL, 0,  
                        CTL_NET, PF_INET, IPPROTO_UDP, CTL_CREATE, CTL_EOL);  
         sysctl_createv(clog, 0, &rfc6056_node, NULL,  
                        CTLFLAG_PERMANENT,  
                        CTLTYPE_STRING, "available",  
                        SYSCTL_DESCR("RFC 6056 available algorithms"),  
                        sysctl_rfc6056_available, 0, NULL, RFC6056_MAXLEN,  
                        CTL_CREATE, CTL_EOL);  
         sysctl_createv(clog, 0, &rfc6056_node, NULL,  
                        CTLFLAG_PERMANENT|CTLFLAG_READWRITE,  
                        CTLTYPE_STRING, "selected",  
                        SYSCTL_DESCR("RFC 6056 selected algorithm"),  
                        sysctl_rfc6056_selected, 0, NULL, RFC6056_MAXLEN,  
                        CTL_CREATE, CTL_EOL);  
 }  }
 #endif  #endif
   
Line 1468  udp_statinc(u_int stat)
Line 1439  udp_statinc(u_int stat)
         UDP_STATINC(stat);          UDP_STATINC(stat);
 }  }
   
 #if (defined INET && defined IPSEC_NAT_T)  #if defined(INET)
 /*  /*
  * Returns:   * Returns:
  * 1 if the packet was processed   * 1 if the packet was processed
Line 1486  udp4_espinudp(struct mbuf **mp, int off,
Line 1457  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 1514  udp4_espinudp(struct mbuf **mp, int off,
Line 1484  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 1573  udp4_espinudp(struct mbuf **mp, int off,
Line 1545  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 1591  udp4_espinudp(struct mbuf **mp, int off,
Line 1556  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 FAST_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.186  
changed lines
  Added in v.1.188

CVSweb <webmaster@jp.NetBSD.org>