[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.103.2.2 and 1.116

version 1.103.2.2, 2004/08/03 10:54:46 version 1.116, 2004/03/24 15:34:54
Line 117  __KERNEL_RCSID(0, "$NetBSD$");
Line 117  __KERNEL_RCSID(0, "$NetBSD$");
   
 #ifdef FAST_IPSEC  #ifdef FAST_IPSEC
 #include <netipsec/ipsec.h>  #include <netipsec/ipsec.h>
 #include <netipsec/ipsec_var.h>                 /* XXX ipsecstat namespace */  
 #ifdef INET6  #ifdef INET6
 #include <netipsec/ipsec6.h>  #include <netipsec/ipsec6.h>
 #endif  #endif
Line 146  struct inpcbtable udbtable;
Line 145  struct inpcbtable udbtable;
 struct  udpstat udpstat;  struct  udpstat udpstat;
   
 #ifdef INET  #ifdef INET
 static void udp4_sendup (struct mbuf *, int, struct sockaddr *,  static void udp4_sendup __P((struct mbuf *, int, struct sockaddr *,
         struct socket *);          struct socket *));
 static int udp4_realinput (struct sockaddr_in *, struct sockaddr_in *,  static int udp4_realinput __P((struct sockaddr_in *, struct sockaddr_in *,
         struct mbuf *, int);          struct mbuf *, int));
 #endif  #endif
 #ifdef INET6  #ifdef INET6
 static void udp6_sendup (struct mbuf *, int, struct sockaddr *,  static void udp6_sendup __P((struct mbuf *, int, struct sockaddr *,
         struct socket *);          struct socket *));
 static int udp6_realinput (int, struct sockaddr_in6 *,  static int udp6_realinput __P((int, struct sockaddr_in6 *,
         struct sockaddr_in6 *, struct mbuf *, int);          struct sockaddr_in6 *, struct mbuf *, int));
 #endif  #endif
 #ifdef INET  #ifdef INET
 static  void udp_notify (struct inpcb *, int);  static  void udp_notify __P((struct inpcb *, int));
 #endif  #endif
   
 #ifndef UDBHASHSIZE  #ifndef UDBHASHSIZE
Line 186  struct evcnt udp_swcsum = EVCNT_INITIALI
Line 185  struct evcnt udp_swcsum = EVCNT_INITIALI
   
 #define UDP_CSUM_COUNTER_INCR(ev)       (ev)->ev_count++  #define UDP_CSUM_COUNTER_INCR(ev)       (ev)->ev_count++
   
 EVCNT_ATTACH_STATIC(udp_hwcsum_bad);  
 EVCNT_ATTACH_STATIC(udp_hwcsum_ok);  
 EVCNT_ATTACH_STATIC(udp_hwcsum_data);  
 EVCNT_ATTACH_STATIC(udp_swcsum);  
   
 #else  #else
   
 #define UDP_CSUM_COUNTER_INCR(ev)       /* nothing */  #define UDP_CSUM_COUNTER_INCR(ev)       /* nothing */
Line 198  EVCNT_ATTACH_STATIC(udp_swcsum);
Line 192  EVCNT_ATTACH_STATIC(udp_swcsum);
 #endif /* UDP_CSUM_COUNTERS */  #endif /* UDP_CSUM_COUNTERS */
   
 void  void
 udp_init(void)  udp_init()
 {  {
   
         in_pcbinit(&udbtable, udbhashsize, udbhashsize);          in_pcbinit(&udbtable, udbhashsize, udbhashsize);
   
   #ifdef UDP_CSUM_COUNTERS
           evcnt_attach_static(&udp_hwcsum_bad);
           evcnt_attach_static(&udp_hwcsum_ok);
           evcnt_attach_static(&udp_hwcsum_data);
           evcnt_attach_static(&udp_swcsum);
   #endif /* UDP_CSUM_COUNTERS */
   
         MOWNER_ATTACH(&udp_tx_mowner);          MOWNER_ATTACH(&udp_tx_mowner);
         MOWNER_ATTACH(&udp_rx_mowner);          MOWNER_ATTACH(&udp_rx_mowner);
         MOWNER_ATTACH(&udp_mowner);          MOWNER_ATTACH(&udp_mowner);
Line 210  udp_init(void)
Line 211  udp_init(void)
   
 #ifdef INET  #ifdef INET
 void  void
   #if __STDC__
 udp_input(struct mbuf *m, ...)  udp_input(struct mbuf *m, ...)
   #else
   udp_input(m, va_alist)
           struct mbuf *m;
           va_dcl
   #endif
 {  {
         va_list ap;          va_list ap;
         struct sockaddr_in src, dst;          struct sockaddr_in src, dst;
Line 365  badcsum:
Line 372  badcsum:
   
 #ifdef INET6  #ifdef INET6
 int  int
 udp6_input(struct mbuf **mp, int *offp, int proto)  udp6_input(mp, offp, proto)
           struct mbuf **mp;
           int *offp, proto;
 {  {
         struct mbuf *m = *mp;          struct mbuf *m = *mp;
         int off = *offp;          int off = *offp;
Line 421  udp6_input(struct mbuf **mp, int *offp, 
Line 430  udp6_input(struct mbuf **mp, int *offp, 
         /*          /*
          * Checksum extended UDP header and data.           * Checksum extended UDP header and data.
          */           */
         if (uh->uh_sum == 0) {          if (uh->uh_sum == 0)
                 udp6stat.udp6s_nosum++;                  udp6stat.udp6s_nosum++;
                 goto bad;          else if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) {
         }  
         if (in6_cksum(m, IPPROTO_UDP, off, ulen) != 0) {  
                 udp6stat.udp6s_badsum++;                  udp6stat.udp6s_badsum++;
                 goto bad;                  goto bad;
         }          }
Line 466  bad:
Line 473  bad:
   
 #ifdef INET  #ifdef INET
 static void  static void
 udp4_sendup(struct mbuf *m, int off /* offset of data portion */,  udp4_sendup(m, off, src, so)
         struct sockaddr *src, struct socket *so)          struct mbuf *m;
           int off;        /* offset of data portion */
           struct sockaddr *src;
           struct socket *so;
 {  {
         struct mbuf *opts = NULL;          struct mbuf *opts = NULL;
         struct mbuf *n;          struct mbuf *n;
Line 520  udp4_sendup(struct mbuf *m, int off /* o
Line 530  udp4_sendup(struct mbuf *m, int off /* o
   
 #ifdef INET6  #ifdef INET6
 static void  static void
 udp6_sendup(struct mbuf *m, int off /* offset of data portion */,  udp6_sendup(m, off, src, so)
         struct sockaddr *src, struct socket *so)          struct mbuf *m;
           int off;        /* offset of data portion */
           struct sockaddr *src;
           struct socket *so;
 {  {
         struct mbuf *opts = NULL;          struct mbuf *opts = NULL;
         struct mbuf *n;          struct mbuf *n;
Line 565  udp6_sendup(struct mbuf *m, int off /* o
Line 578  udp6_sendup(struct mbuf *m, int off /* o
   
 #ifdef INET  #ifdef INET
 static int  static int
 udp4_realinput(struct sockaddr_in *src, struct sockaddr_in *dst,  udp4_realinput(src, dst, m, off)
         struct mbuf *m, int off /* offset of udphdr */)          struct sockaddr_in *src;
           struct sockaddr_in *dst;
           struct mbuf *m;
           int off;        /* offset of udphdr */
 {  {
         u_int16_t *sport, *dport;          u_int16_t *sport, *dport;
         int rcvcnt;          int rcvcnt;
Line 666  bad:
Line 682  bad:
   
 #ifdef INET6  #ifdef INET6
 static int  static int
 udp6_realinput(int af, struct sockaddr_in6 *src, struct sockaddr_in6 *dst,  udp6_realinput(af, src, dst, m, off)
         struct mbuf *m, int off)          int af;         /* af on packet */
           struct sockaddr_in6 *src;
           struct sockaddr_in6 *dst;
           struct mbuf *m;
           int off;        /* offset of udphdr */
 {  {
         u_int16_t sport, dport;          u_int16_t sport, dport;
         int rcvcnt;          int rcvcnt;
Line 784  bad:
Line 804  bad:
  * just wake up so that he can collect error status.   * just wake up so that he can collect error status.
  */   */
 static void  static void
 udp_notify(struct inpcb *inp, int errno)  udp_notify(inp, errno)
           struct inpcb *inp;
           int errno;
 {  {
   
         inp->inp_socket->so_error = errno;          inp->inp_socket->so_error = errno;
         sorwakeup(inp->inp_socket);          sorwakeup(inp->inp_socket);
         sowwakeup(inp->inp_socket);          sowwakeup(inp->inp_socket);
 }  }
   
 void *  void *
 udp_ctlinput(int cmd, struct sockaddr *sa, void *v)  udp_ctlinput(cmd, sa, v)
           int cmd;
           struct sockaddr *sa;
           void *v;
 {  {
         struct ip *ip = v;          struct ip *ip = v;
         struct udphdr *uh;          struct udphdr *uh;
         void (*notify)(struct inpcb *, int) = udp_notify;          void (*notify) __P((struct inpcb *, int)) = udp_notify;
         int errno;          int errno;
   
         if (sa->sa_family != AF_INET          if (sa->sa_family != AF_INET
Line 824  udp_ctlinput(int cmd, struct sockaddr *s
Line 850  udp_ctlinput(int cmd, struct sockaddr *s
 }  }
   
 int  int
   #if __STDC__
 udp_output(struct mbuf *m, ...)  udp_output(struct mbuf *m, ...)
   #else
   udp_output(m, va_alist)
           struct mbuf *m;
           va_dcl
   #endif
 {  {
         struct inpcb *inp;          struct inpcb *inp;
         struct udpiphdr *ui;          struct udpiphdr *ui;
Line 903  int udp_recvspace = 40 * (1024 + sizeof(
Line 935  int udp_recvspace = 40 * (1024 + sizeof(
   
 /*ARGSUSED*/  /*ARGSUSED*/
 int  int
 udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,  udp_usrreq(so, req, m, nam, control, p)
         struct mbuf *control, struct lwp *l)          struct socket *so;
           int req;
           struct mbuf *m, *nam, *control;
           struct proc *p;
 {  {
         struct inpcb *inp;          struct inpcb *inp;
         struct proc *p;  
         int s;          int s;
         int error = 0;          int error = 0;
   
         p = l ? l->l_proc : NULL;  
         if (req == PRU_CONTROL)          if (req == PRU_CONTROL)
                 return (in_control(so, (long)m, (caddr_t)nam,                  return (in_control(so, (long)m, (caddr_t)nam,
                     (struct ifnet *)control, p));                      (struct ifnet *)control, p));
Line 1091  SYSCTL_SETUP(sysctl_net_inet_udp_setup, 
Line 1124  SYSCTL_SETUP(sysctl_net_inet_udp_setup, 
                        CTL_NET, PF_INET, CTL_EOL);                         CTL_NET, PF_INET, CTL_EOL);
         sysctl_createv(clog, 0, NULL, NULL,          sysctl_createv(clog, 0, NULL, NULL,
                        CTLFLAG_PERMANENT,                         CTLFLAG_PERMANENT,
                        CTLTYPE_NODE, "udp",                         CTLTYPE_NODE, "udp", NULL,
                        SYSCTL_DESCR("UDPv4 related settings"),  
                        NULL, 0, NULL, 0,                         NULL, 0, NULL, 0,
                        CTL_NET, PF_INET, IPPROTO_UDP, CTL_EOL);                         CTL_NET, PF_INET, IPPROTO_UDP, CTL_EOL);
   
         sysctl_createv(clog, 0, NULL, NULL,          sysctl_createv(clog, 0, NULL, NULL,
                        CTLFLAG_PERMANENT|CTLFLAG_READWRITE,                         CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                        CTLTYPE_INT, "checksum",                         CTLTYPE_INT, "checksum", NULL,
                        SYSCTL_DESCR("Compute UDP checksums"),  
                        NULL, 0, &udpcksum, 0,                         NULL, 0, &udpcksum, 0,
                        CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_CHECKSUM,                         CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_CHECKSUM,
                        CTL_EOL);                         CTL_EOL);
         sysctl_createv(clog, 0, NULL, NULL,          sysctl_createv(clog, 0, NULL, NULL,
                        CTLFLAG_PERMANENT|CTLFLAG_READWRITE,                         CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                        CTLTYPE_INT, "sendspace",                         CTLTYPE_INT, "sendspace", NULL,
                        SYSCTL_DESCR("Default UDP send buffer size"),  
                        NULL, 0, &udp_sendspace, 0,                         NULL, 0, &udp_sendspace, 0,
                        CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_SENDSPACE,                         CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_SENDSPACE,
                        CTL_EOL);                         CTL_EOL);
         sysctl_createv(clog, 0, NULL, NULL,          sysctl_createv(clog, 0, NULL, NULL,
                        CTLFLAG_PERMANENT|CTLFLAG_READWRITE,                         CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
                        CTLTYPE_INT, "recvspace",                         CTLTYPE_INT, "recvspace", NULL,
                        SYSCTL_DESCR("Default UDP receive buffer size"),  
                        NULL, 0, &udp_recvspace, 0,                         NULL, 0, &udp_recvspace, 0,
                        CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_RECVSPACE,                         CTL_NET, PF_INET, IPPROTO_UDP, UDPCTL_RECVSPACE,
                        CTL_EOL);                         CTL_EOL);

Legend:
Removed from v.1.103.2.2  
changed lines
  Added in v.1.116

CVSweb <webmaster@jp.NetBSD.org>