version 1.103.2.4, 2004/09/21 13:37:15 |
version 1.115, 2004/03/10 18:50:45 |
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); |
|
|
|
|
#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; |
|
|
|
|
#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; |
} |
} |
|
|
|
|
#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 511 udp4_sendup(struct mbuf *m, int off /* o |
|
Line 521 udp4_sendup(struct mbuf *m, int off /* o |
|
m_freem(n); |
m_freem(n); |
if (opts) |
if (opts) |
m_freem(opts); |
m_freem(opts); |
so->so_rcv.sb_overflowed++; |
|
udpstat.udps_fullsock++; |
udpstat.udps_fullsock++; |
} else |
} else |
sorwakeup(so); |
sorwakeup(so); |
Line 521 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 557 udp6_sendup(struct mbuf *m, int off /* o |
|
Line 569 udp6_sendup(struct mbuf *m, int off /* o |
|
m_freem(n); |
m_freem(n); |
if (opts) |
if (opts) |
m_freem(opts); |
m_freem(opts); |
so->so_rcv.sb_overflowed++; |
|
udp6stat.udp6s_fullsock++; |
udp6stat.udp6s_fullsock++; |
} else |
} else |
sorwakeup(so); |
sorwakeup(so); |
Line 567 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; |
|
|
|
|
#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; |
|
|
* 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 826 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 905 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)); |
|
|
SYSCTL_SETUP(sysctl_net_inet_udp_setup, "sysctl net.inet.udp subtree setup") |
SYSCTL_SETUP(sysctl_net_inet_udp_setup, "sysctl net.inet.udp subtree setup") |
{ |
{ |
|
|
sysctl_createv(clog, 0, NULL, NULL, |
sysctl_createv(SYSCTL_PERMANENT, |
CTLFLAG_PERMANENT, |
|
CTLTYPE_NODE, "net", NULL, |
CTLTYPE_NODE, "net", NULL, |
NULL, 0, NULL, 0, |
NULL, 0, NULL, 0, |
CTL_NET, CTL_EOL); |
CTL_NET, CTL_EOL); |
sysctl_createv(clog, 0, NULL, NULL, |
sysctl_createv(SYSCTL_PERMANENT, |
CTLFLAG_PERMANENT, |
|
CTLTYPE_NODE, "inet", NULL, |
CTLTYPE_NODE, "inet", NULL, |
NULL, 0, NULL, 0, |
NULL, 0, NULL, 0, |
CTL_NET, PF_INET, CTL_EOL); |
CTL_NET, PF_INET, CTL_EOL); |
sysctl_createv(clog, 0, NULL, NULL, |
sysctl_createv(SYSCTL_PERMANENT, |
CTLFLAG_PERMANENT, |
CTLTYPE_NODE, "udp", NULL, |
CTLTYPE_NODE, "udp", |
|
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(SYSCTL_PERMANENT|SYSCTL_READWRITE, |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
CTLTYPE_INT, "checksum", NULL, |
CTLTYPE_INT, "checksum", |
|
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(SYSCTL_PERMANENT|SYSCTL_READWRITE, |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
CTLTYPE_INT, "sendspace", NULL, |
CTLTYPE_INT, "sendspace", |
|
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(SYSCTL_PERMANENT|SYSCTL_READWRITE, |
CTLFLAG_PERMANENT|CTLFLAG_READWRITE, |
CTLTYPE_INT, "recvspace", NULL, |
CTLTYPE_INT, "recvspace", |
|
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); |