version 1.188, 2013/06/04 22:47:37 |
version 1.195, 2014/05/18 14:46:16 |
Line 73 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 73 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/malloc.h> |
#include <sys/malloc.h> |
#include <sys/mbuf.h> |
#include <sys/mbuf.h> |
|
#include <sys/once.h> |
#include <sys/protosw.h> |
#include <sys/protosw.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
#include <sys/socketvar.h> |
#include <sys/socketvar.h> |
Line 118 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 119 __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 127 __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 149 struct inpcbtable udbtable; |
|
percpu_t *udpstat_percpu; |
percpu_t *udpstat_percpu; |
|
|
#ifdef INET |
#ifdef INET |
|
#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 |
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 223 EVCNT_ATTACH_STATIC(udp6_swcsum); |
|
Line 226 EVCNT_ATTACH_STATIC(udp6_swcsum); |
|
|
|
static void sysctl_net_inet_udp_setup(struct sysctllog **); |
static void sysctl_net_inet_udp_setup(struct sysctllog **); |
|
|
void |
static int |
udp_init(void) |
do_udpinit(void) |
{ |
{ |
|
|
sysctl_net_inet_udp_setup(NULL); |
|
|
|
in_pcbinit(&udbtable, udbhashsize, udbhashsize); |
in_pcbinit(&udbtable, udbhashsize, udbhashsize); |
|
udpstat_percpu = percpu_alloc(sizeof(uint64_t) * UDP_NSTATS); |
|
|
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 |
return 0; |
udpstat_percpu = percpu_alloc(sizeof(uint64_t) * UDP_NSTATS); |
} |
#endif |
|
#ifdef INET6 |
void |
udp6stat_percpu = percpu_alloc(sizeof(uint64_t) * UDP6_NSTATS); |
udp_init_common(void) |
#endif |
{ |
|
static ONCE_DECL(doudpinit); |
|
|
|
RUN_ONCE(&doudpinit, do_udpinit); |
|
} |
|
|
|
void |
|
udp_init(void) |
|
{ |
|
|
|
sysctl_net_inet_udp_setup(NULL); |
|
|
|
udp_init_common(); |
} |
} |
|
|
/* |
/* |
Line 632 udp4_sendup(struct mbuf *m, int off /* o |
|
Line 646 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 682 udp6_sendup(struct mbuf *m, int off /* o |
|
Line 696 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 764 udp4_realinput(struct sockaddr_in *src, |
|
Line 778 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 810 udp4_realinput(struct sockaddr_in *src, |
|
Line 824 udp4_realinput(struct sockaddr_in *src, |
|
return rcvcnt; |
return rcvcnt; |
} |
} |
|
|
|
#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 835 udp4_realinput(struct sockaddr_in *src, |
|
Line 850 udp4_realinput(struct sockaddr_in *src, |
|
break; |
break; |
} |
} |
} |
} |
|
#endif |
|
|
/* |
/* |
* Check the minimum TTL for socket. |
* Check the minimum TTL for socket. |
Line 907 udp6_realinput(int af, struct sockaddr_i |
|
Line 923 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 1179 int udp_sendspace = 9216; /* really max |
|
Line 1195 int udp_sendspace = 9216; /* really max |
|
int udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in)); |
int udp_recvspace = 40 * (1024 + sizeof(struct sockaddr_in)); |
/* 40 1K datagrams */ |
/* 40 1K datagrams */ |
|
|
/*ARGSUSED*/ |
static int |
int |
|
udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, |
udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, |
struct mbuf *control, struct lwp *l) |
struct mbuf *control, struct lwp *l) |
{ |
{ |
struct inpcb *inp; |
struct inpcb *inp; |
int s; |
int s; |
Line 1369 sysctl_net_inet_udp_stats(SYSCTLFN_ARGS) |
|
Line 1384 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) |
{ |
{ |
sysctl_createv(clog, 0, NULL, NULL, |
|
CTLFLAG_PERMANENT, |
|
CTLTYPE_NODE, "net", NULL, |
|
NULL, 0, NULL, 0, |
|
CTL_NET, CTL_EOL); |
|
sysctl_createv(clog, 0, NULL, NULL, |
sysctl_createv(clog, 0, NULL, NULL, |
CTLFLAG_PERMANENT, |
CTLFLAG_PERMANENT, |
CTLTYPE_NODE, "inet", NULL, |
CTLTYPE_NODE, "inet", NULL, |
Line 1439 udp_statinc(u_int stat) |
|
Line 1450 udp_statinc(u_int stat) |
|
UDP_STATINC(stat); |
UDP_STATINC(stat); |
} |
} |
|
|
#if defined(INET) |
#if defined(INET) && defined(IPSEC) |
/* |
/* |
* Returns: |
* Returns: |
* 1 if the packet was processed |
* 1 if the packet was processed |
Line 1563 udp4_espinudp(struct mbuf **mp, int off, |
|
Line 1574 udp4_espinudp(struct mbuf **mp, int off, |
|
((u_int16_t *)(tag + 1))[1] = dport; |
((u_int16_t *)(tag + 1))[1] = dport; |
m_tag_prepend(m, tag); |
m_tag_prepend(m, tag); |
|
|
#ifdef FAST_IPSEC |
#ifdef IPSEC |
ipsec4_common_input(m, iphdrlen, IPPROTO_ESP); |
ipsec4_common_input(m, iphdrlen, IPPROTO_ESP); |
#else |
#else |
esp4_input(m, iphdrlen); |
esp4_input(m, iphdrlen); |
Line 1574 udp4_espinudp(struct mbuf **mp, int off, |
|
Line 1585 udp4_espinudp(struct mbuf **mp, int off, |
|
return 1; |
return 1; |
} |
} |
#endif |
#endif |
|
|
|
PR_WRAP_USRREQ(udp_usrreq) |
|
|
|
#define udp_usrreq udp_usrreq_wrapper |
|
|
|
const struct pr_usrreqs udp_usrreqs = { |
|
.pr_generic = udp_usrreq, |
|
}; |