version 1.217, 2014/08/09 05:33:01 |
version 1.217.4.9, 2017/08/28 17:53:12 |
|
|
#include <sys/cdefs.h> |
#include <sys/cdefs.h> |
__KERNEL_RCSID(0, "$NetBSD$"); |
__KERNEL_RCSID(0, "$NetBSD$"); |
|
|
|
#ifdef _KERNEL_OPT |
#include "opt_inet.h" |
#include "opt_inet.h" |
#include "opt_compat_netbsd.h" |
|
#include "opt_ipsec.h" |
#include "opt_ipsec.h" |
#include "opt_inet_csum.h" |
#include "opt_inet_csum.h" |
#include "opt_ipkdb.h" |
#include "opt_ipkdb.h" |
#include "opt_mbuftrace.h" |
#include "opt_mbuftrace.h" |
|
#include "opt_net_mpsafe.h" |
|
#endif |
|
|
#include <sys/param.h> |
#include <sys/param.h> |
#include <sys/mbuf.h> |
#include <sys/mbuf.h> |
Line 87 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 89 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#include <sys/sysctl.h> |
#include <sys/sysctl.h> |
|
|
#include <net/if.h> |
#include <net/if.h> |
#include <net/route.h> |
|
|
|
#include <netinet/in.h> |
#include <netinet/in.h> |
#include <netinet/in_systm.h> |
#include <netinet/in_systm.h> |
Line 125 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 126 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#endif |
#endif |
#endif /* IPSEC */ |
#endif /* IPSEC */ |
|
|
#ifdef COMPAT_50 |
|
#include <compat/sys/socket.h> |
|
#endif |
|
|
|
#ifdef IPKDB |
#ifdef IPKDB |
#include <ipkdb/ipkdb.h> |
#include <ipkdb/ipkdb.h> |
#endif |
#endif |
Line 275 udp4_input_checksum(struct mbuf *m, cons |
|
Line 272 udp4_input_checksum(struct mbuf *m, cons |
|
return 0; |
return 0; |
|
|
switch (m->m_pkthdr.csum_flags & |
switch (m->m_pkthdr.csum_flags & |
((m->m_pkthdr.rcvif->if_csum_flags_rx & M_CSUM_UDPv4) | |
((m_get_rcvif_NOMPSAFE(m)->if_csum_flags_rx & M_CSUM_UDPv4) | |
M_CSUM_TCP_UDP_BAD | M_CSUM_DATA)) { |
M_CSUM_TCP_UDP_BAD | M_CSUM_DATA)) { |
case M_CSUM_UDPv4|M_CSUM_TCP_UDP_BAD: |
case M_CSUM_UDPv4|M_CSUM_TCP_UDP_BAD: |
UDP_CSUM_COUNTER_INCR(&udp_hwcsum_bad); |
UDP_CSUM_COUNTER_INCR(&udp_hwcsum_bad); |
Line 308 udp4_input_checksum(struct mbuf *m, cons |
|
Line 305 udp4_input_checksum(struct mbuf *m, cons |
|
* Need to compute it ourselves. Maybe skip checksum |
* Need to compute it ourselves. Maybe skip checksum |
* on loopback interfaces. |
* on loopback interfaces. |
*/ |
*/ |
if (__predict_true(!(m->m_pkthdr.rcvif->if_flags & |
if (__predict_true(!(m_get_rcvif_NOMPSAFE(m)->if_flags & |
IFF_LOOPBACK) || |
IFF_LOOPBACK) || |
udp_do_loopback_cksum)) { |
udp_do_loopback_cksum)) { |
UDP_CSUM_COUNTER_INCR(&udp_swcsum); |
UDP_CSUM_COUNTER_INCR(&udp_swcsum); |
Line 354 udp_input(struct mbuf *m, ...) |
|
Line 351 udp_input(struct mbuf *m, ...) |
|
UDP_STATINC(UDP_STAT_HDROPS); |
UDP_STATINC(UDP_STAT_HDROPS); |
return; |
return; |
} |
} |
|
/* |
|
* Enforce alignment requirements that are violated in |
|
* some cases, see kern/50766 for details. |
|
*/ |
|
if (UDP_HDR_ALIGNED_P(uh) == 0) { |
|
m = m_copyup(m, iphlen + sizeof(struct udphdr), 0); |
|
if (m == NULL) { |
|
UDP_STATINC(UDP_STAT_HDROPS); |
|
return; |
|
} |
|
ip = mtod(m, struct ip *); |
|
uh = (struct udphdr *)(mtod(m, char *) + iphlen); |
|
} |
KASSERT(UDP_HDR_ALIGNED_P(uh)); |
KASSERT(UDP_HDR_ALIGNED_P(uh)); |
|
|
/* destination port of 0 is illegal, based on RFC768. */ |
/* destination port of 0 is illegal, based on RFC768. */ |
Line 403 udp_input(struct mbuf *m, ...) |
|
Line 413 udp_input(struct mbuf *m, ...) |
|
memset(&src6, 0, sizeof(src6)); |
memset(&src6, 0, sizeof(src6)); |
src6.sin6_family = AF_INET6; |
src6.sin6_family = AF_INET6; |
src6.sin6_len = sizeof(struct sockaddr_in6); |
src6.sin6_len = sizeof(struct sockaddr_in6); |
src6.sin6_addr.s6_addr[10] = src6.sin6_addr.s6_addr[11] = 0xff; |
in6_in_2_v4mapin6(&ip->ip_src, &src6.sin6_addr); |
memcpy(&src6.sin6_addr.s6_addr[12], &ip->ip_src, |
|
sizeof(ip->ip_src)); |
|
src6.sin6_port = uh->uh_sport; |
src6.sin6_port = uh->uh_sport; |
memset(&dst6, 0, sizeof(dst6)); |
memset(&dst6, 0, sizeof(dst6)); |
dst6.sin6_family = AF_INET6; |
dst6.sin6_family = AF_INET6; |
dst6.sin6_len = sizeof(struct sockaddr_in6); |
dst6.sin6_len = sizeof(struct sockaddr_in6); |
dst6.sin6_addr.s6_addr[10] = dst6.sin6_addr.s6_addr[11] = 0xff; |
in6_in_2_v4mapin6(&ip->ip_dst, &dst6.sin6_addr); |
memcpy(&dst6.sin6_addr.s6_addr[12], &ip->ip_dst, |
|
sizeof(ip->ip_dst)); |
|
dst6.sin6_port = uh->uh_dport; |
dst6.sin6_port = uh->uh_dport; |
|
|
n += udp6_realinput(AF_INET, &src6, &dst6, m, iphlen); |
n += udp6_realinput(AF_INET, &src6, &dst6, m, iphlen); |
Line 457 udp4_sendup(struct mbuf *m, int off /* o |
|
Line 463 udp4_sendup(struct mbuf *m, int off /* o |
|
{ |
{ |
struct mbuf *opts = NULL; |
struct mbuf *opts = NULL; |
struct mbuf *n; |
struct mbuf *n; |
struct inpcb *inp = NULL; |
struct inpcb *inp; |
|
|
if (!so) |
KASSERT(so != NULL); |
return; |
KASSERT(so->so_proto->pr_domain->dom_family == AF_INET); |
switch (so->so_proto->pr_domain->dom_family) { |
inp = sotoinpcb(so); |
case AF_INET: |
KASSERT(inp != NULL); |
inp = sotoinpcb(so); |
|
break; |
|
#ifdef INET6 |
|
case AF_INET6: |
|
break; |
|
#endif |
|
default: |
|
return; |
|
} |
|
|
|
#if defined(IPSEC) |
#if defined(IPSEC) |
/* check AH/ESP integrity. */ |
/* check AH/ESP integrity. */ |
if (ipsec_used && so != NULL && ipsec4_in_reject_so(m, so)) { |
if (ipsec_used && ipsec4_in_reject(m, inp)) { |
IPSEC_STATINC(IPSEC_STAT_IN_POLVIO); |
IPSEC_STATINC(IPSEC_STAT_IN_POLVIO); |
if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) |
if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) |
icmp_error(n, ICMP_UNREACH, ICMP_UNREACH_ADMIN_PROHIBIT, |
icmp_error(n, ICMP_UNREACH, ICMP_UNREACH_ADMIN_PROHIBIT, |
Line 485 udp4_sendup(struct mbuf *m, int off /* o |
|
Line 482 udp4_sendup(struct mbuf *m, int off /* o |
|
#endif /*IPSEC*/ |
#endif /*IPSEC*/ |
|
|
if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) { |
if ((n = m_copypacket(m, M_DONTWAIT)) != NULL) { |
if (inp && (inp->inp_flags & INP_CONTROLOPTS |
if (inp->inp_flags & INP_CONTROLOPTS |
#ifdef SO_OTIMESTAMP |
|| SOOPT_TIMESTAMP(so->so_options)) { |
|| so->so_options & SO_OTIMESTAMP |
|
#endif |
|
|| so->so_options & SO_TIMESTAMP)) { |
|
struct ip *ip = mtod(n, struct ip *); |
struct ip *ip = mtod(n, struct ip *); |
ip_savecontrol(inp, &opts, ip, n); |
ip_savecontrol(inp, &opts, ip, n); |
} |
} |
Line 532 udp4_realinput(struct sockaddr_in *src, |
|
Line 526 udp4_realinput(struct sockaddr_in *src, |
|
dport = &dst->sin_port; |
dport = &dst->sin_port; |
|
|
if (IN_MULTICAST(dst4->s_addr) || |
if (IN_MULTICAST(dst4->s_addr) || |
in_broadcast(*dst4, m->m_pkthdr.rcvif)) { |
in_broadcast(*dst4, m_get_rcvif_NOMPSAFE(m))) { |
/* |
/* |
* Deliver a multicast or broadcast datagram to *all* sockets |
* Deliver a multicast or broadcast datagram to *all* sockets |
* for which the local and remote addresses and ports match |
* for which the local and remote addresses and ports match |
Line 620 udp4_realinput(struct sockaddr_in *src, |
|
Line 614 udp4_realinput(struct sockaddr_in *src, |
|
|
|
case 0: /* plain UDP */ |
case 0: /* plain UDP */ |
default: /* Unexpected */ |
default: /* Unexpected */ |
/* |
/* |
* Normal UDP processing will take place |
* Normal UDP processing will take place |
* m may have changed. |
* m may have changed. |
*/ |
*/ |
m = *mp; |
m = *mp; |
Line 754 udp_ctloutput(int op, struct socket *so, |
|
Line 748 udp_ctloutput(int op, struct socket *so, |
|
break; |
break; |
} |
} |
break; |
break; |
|
|
default: |
default: |
error = ENOPROTOOPT; |
error = ENOPROTOOPT; |
break; |
break; |
|
|
return error; |
return error; |
} |
} |
|
|
|
|
int |
int |
udp_output(struct mbuf *m, ...) |
udp_output(struct mbuf *m, struct inpcb *inp, struct mbuf *control, |
|
struct lwp *l) |
{ |
{ |
struct inpcb *inp; |
|
struct udpiphdr *ui; |
struct udpiphdr *ui; |
struct route *ro; |
struct route *ro; |
|
struct ip_pktopts pktopts; |
|
kauth_cred_t cred; |
int len = m->m_pkthdr.len; |
int len = m->m_pkthdr.len; |
int error = 0; |
int error, flags = 0; |
va_list ap; |
|
|
|
MCLAIM(m, &udp_tx_mowner); |
MCLAIM(m, &udp_tx_mowner); |
va_start(ap, m); |
|
inp = va_arg(ap, struct inpcb *); |
|
va_end(ap); |
|
|
|
/* |
/* |
* Calculate data length and get a mbuf |
* Calculate data length and get a mbuf |
Line 806 udp_output(struct mbuf *m, ...) |
|
Line 797 udp_output(struct mbuf *m, ...) |
|
goto release; |
goto release; |
} |
} |
|
|
|
if (l == NULL) |
|
cred = NULL; |
|
else |
|
cred = l->l_cred; |
|
|
|
/* Setup IP outgoing packet options */ |
|
memset(&pktopts, 0, sizeof(pktopts)); |
|
error = ip_setpktopts(control, &pktopts, &flags, inp, cred, |
|
IPPROTO_UDP); |
|
if (error != 0) |
|
goto release; |
|
|
|
if (control != NULL) { |
|
m_freem(control); |
|
control = NULL; |
|
} |
|
|
/* |
/* |
* Fill in mbuf with extended UDP header |
* Fill in mbuf with extended UDP header |
* and addresses and length put into network format. |
* and addresses and length put into network format. |
*/ |
*/ |
ui = mtod(m, struct udpiphdr *); |
ui = mtod(m, struct udpiphdr *); |
ui->ui_pr = IPPROTO_UDP; |
ui->ui_pr = IPPROTO_UDP; |
ui->ui_src = inp->inp_laddr; |
ui->ui_src = pktopts.ippo_laddr.sin_addr; |
ui->ui_dst = inp->inp_faddr; |
ui->ui_dst = inp->inp_faddr; |
ui->ui_sport = inp->inp_lport; |
ui->ui_sport = inp->inp_lport; |
ui->ui_dport = inp->inp_fport; |
ui->ui_dport = inp->inp_fport; |
Line 840 udp_output(struct mbuf *m, ...) |
|
Line 848 udp_output(struct mbuf *m, ...) |
|
((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */ |
((struct ip *)ui)->ip_tos = inp->inp_ip.ip_tos; /* XXX */ |
UDP_STATINC(UDP_STAT_OPACKETS); |
UDP_STATINC(UDP_STAT_OPACKETS); |
|
|
return (ip_output(m, inp->inp_options, ro, |
flags |= inp->inp_socket->so_options & (SO_DONTROUTE|SO_BROADCAST); |
inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST), |
return ip_output(m, inp->inp_options, ro, flags, pktopts.ippo_imo, inp); |
inp->inp_moptions, inp->inp_socket)); |
|
|
|
release: |
release: |
|
if (control != NULL) |
|
m_freem(control); |
m_freem(m); |
m_freem(m); |
return (error); |
return error; |
} |
} |
|
|
static int |
static int |
Line 895 udp_detach(struct socket *so) |
|
Line 904 udp_detach(struct socket *so) |
|
} |
} |
|
|
static int |
static int |
udp_accept(struct socket *so, struct mbuf *nam) |
udp_accept(struct socket *so, struct sockaddr *nam) |
{ |
{ |
KASSERT(solocked(so)); |
KASSERT(solocked(so)); |
|
|
Line 905 udp_accept(struct socket *so, struct mbu |
|
Line 914 udp_accept(struct socket *so, struct mbu |
|
} |
} |
|
|
static int |
static int |
udp_bind(struct socket *so, struct mbuf *nam, struct lwp *l) |
udp_bind(struct socket *so, struct sockaddr *nam, struct lwp *l) |
{ |
{ |
struct inpcb *inp = sotoinpcb(so); |
struct inpcb *inp = sotoinpcb(so); |
|
struct sockaddr_in *sin = (struct sockaddr_in *)nam; |
int error = 0; |
int error = 0; |
int s; |
int s; |
|
|
Line 916 udp_bind(struct socket *so, struct mbuf |
|
Line 926 udp_bind(struct socket *so, struct mbuf |
|
KASSERT(nam != NULL); |
KASSERT(nam != NULL); |
|
|
s = splsoftnet(); |
s = splsoftnet(); |
error = in_pcbbind(inp, nam, l); |
error = in_pcbbind(inp, sin, l); |
splx(s); |
splx(s); |
|
|
return error; |
return error; |
Line 931 udp_listen(struct socket *so, struct lwp |
|
Line 941 udp_listen(struct socket *so, struct lwp |
|
} |
} |
|
|
static int |
static int |
udp_connect(struct socket *so, struct mbuf *nam, struct lwp *l) |
udp_connect(struct socket *so, struct sockaddr *nam, struct lwp *l) |
{ |
{ |
struct inpcb *inp = sotoinpcb(so); |
struct inpcb *inp = sotoinpcb(so); |
int error = 0; |
int error = 0; |
Line 942 udp_connect(struct socket *so, struct mb |
|
Line 952 udp_connect(struct socket *so, struct mb |
|
KASSERT(nam != NULL); |
KASSERT(nam != NULL); |
|
|
s = splsoftnet(); |
s = splsoftnet(); |
error = in_pcbconnect(inp, nam, l); |
error = in_pcbconnect(inp, (struct sockaddr_in *)nam, l); |
if (! error) |
if (! error) |
soisconnected(so); |
soisconnected(so); |
splx(s); |
splx(s); |
Line 1017 udp_stat(struct socket *so, struct stat |
|
Line 1027 udp_stat(struct socket *so, struct stat |
|
} |
} |
|
|
static int |
static int |
udp_peeraddr(struct socket *so, struct mbuf *nam) |
udp_peeraddr(struct socket *so, struct sockaddr *nam) |
{ |
{ |
int s; |
int s; |
|
|
Line 1026 udp_peeraddr(struct socket *so, struct m |
|
Line 1036 udp_peeraddr(struct socket *so, struct m |
|
KASSERT(nam != NULL); |
KASSERT(nam != NULL); |
|
|
s = splsoftnet(); |
s = splsoftnet(); |
in_setpeeraddr(sotoinpcb(so), nam); |
in_setpeeraddr(sotoinpcb(so), (struct sockaddr_in *)nam); |
splx(s); |
splx(s); |
|
|
return 0; |
return 0; |
} |
} |
|
|
static int |
static int |
udp_sockaddr(struct socket *so, struct mbuf *nam) |
udp_sockaddr(struct socket *so, struct sockaddr *nam) |
{ |
{ |
int s; |
int s; |
|
|
Line 1042 udp_sockaddr(struct socket *so, struct m |
|
Line 1052 udp_sockaddr(struct socket *so, struct m |
|
KASSERT(nam != NULL); |
KASSERT(nam != NULL); |
|
|
s = splsoftnet(); |
s = splsoftnet(); |
in_setsockaddr(sotoinpcb(so), nam); |
in_setsockaddr(sotoinpcb(so), (struct sockaddr_in *)nam); |
splx(s); |
splx(s); |
|
|
return 0; |
return 0; |
Line 1065 udp_recvoob(struct socket *so, struct mb |
|
Line 1075 udp_recvoob(struct socket *so, struct mb |
|
} |
} |
|
|
static int |
static int |
udp_send(struct socket *so, struct mbuf *m, struct mbuf *nam, |
udp_send(struct socket *so, struct mbuf *m, struct sockaddr *nam, |
struct mbuf *control, struct lwp *l) |
struct mbuf *control, struct lwp *l) |
{ |
{ |
struct inpcb *inp = sotoinpcb(so); |
struct inpcb *inp = sotoinpcb(so); |
Line 1077 udp_send(struct socket *so, struct mbuf |
|
Line 1087 udp_send(struct socket *so, struct mbuf |
|
KASSERT(inp != NULL); |
KASSERT(inp != NULL); |
KASSERT(m != NULL); |
KASSERT(m != NULL); |
|
|
if (control && control->m_len) { |
|
m_freem(control); |
|
m_freem(m); |
|
return EINVAL; |
|
} |
|
|
|
memset(&laddr, 0, sizeof laddr); |
memset(&laddr, 0, sizeof laddr); |
|
|
s = splsoftnet(); |
s = splsoftnet(); |
Line 1092 udp_send(struct socket *so, struct mbuf |
|
Line 1096 udp_send(struct socket *so, struct mbuf |
|
error = EISCONN; |
error = EISCONN; |
goto die; |
goto die; |
} |
} |
error = in_pcbconnect(inp, nam, l); |
error = in_pcbconnect(inp, (struct sockaddr_in *)nam, l); |
if (error) |
if (error) |
goto die; |
goto die; |
} else { |
} else { |
Line 1101 udp_send(struct socket *so, struct mbuf |
|
Line 1105 udp_send(struct socket *so, struct mbuf |
|
goto die; |
goto die; |
} |
} |
} |
} |
error = udp_output(m, inp); |
error = udp_output(m, inp, control, l); |
m = NULL; |
m = NULL; |
|
control = NULL; |
if (nam) { |
if (nam) { |
in_pcbdisconnect(inp); |
in_pcbdisconnect(inp); |
inp->inp_laddr = laddr; /* XXX */ |
inp->inp_laddr = laddr; /* XXX */ |
in_pcbstate(inp, INP_BOUND); /* XXX */ |
in_pcbstate(inp, INP_BOUND); /* XXX */ |
} |
} |
die: |
die: |
if (m) |
if (m != NULL) |
m_freem(m); |
m_freem(m); |
|
if (control != NULL) |
|
m_freem(control); |
|
|
splx(s); |
splx(s); |
return error; |
return error; |
Line 1135 udp_purgeif(struct socket *so, struct if |
|
Line 1142 udp_purgeif(struct socket *so, struct if |
|
s = splsoftnet(); |
s = splsoftnet(); |
mutex_enter(softnet_lock); |
mutex_enter(softnet_lock); |
in_pcbpurgeif0(&udbtable, ifp); |
in_pcbpurgeif0(&udbtable, ifp); |
|
#ifdef NET_MPSAFE |
|
mutex_exit(softnet_lock); |
|
#endif |
in_purgeif(ifp); |
in_purgeif(ifp); |
|
#ifdef NET_MPSAFE |
|
mutex_enter(softnet_lock); |
|
#endif |
in_pcbpurgeif(&udbtable, ifp); |
in_pcbpurgeif(&udbtable, ifp); |
mutex_exit(softnet_lock); |
mutex_exit(softnet_lock); |
splx(s); |
splx(s); |
Line 1144 udp_purgeif(struct socket *so, struct if |
|
Line 1157 udp_purgeif(struct socket *so, struct if |
|
} |
} |
|
|
static int |
static int |
udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, |
|
struct mbuf *control, struct lwp *l) |
|
{ |
|
KASSERT(req != PRU_ATTACH); |
|
KASSERT(req != PRU_DETACH); |
|
KASSERT(req != PRU_ACCEPT); |
|
KASSERT(req != PRU_BIND); |
|
KASSERT(req != PRU_LISTEN); |
|
KASSERT(req != PRU_CONNECT); |
|
KASSERT(req != PRU_CONNECT2); |
|
KASSERT(req != PRU_DISCONNECT); |
|
KASSERT(req != PRU_SHUTDOWN); |
|
KASSERT(req != PRU_ABORT); |
|
KASSERT(req != PRU_CONTROL); |
|
KASSERT(req != PRU_SENSE); |
|
KASSERT(req != PRU_PEERADDR); |
|
KASSERT(req != PRU_SOCKADDR); |
|
KASSERT(req != PRU_RCVD); |
|
KASSERT(req != PRU_RCVOOB); |
|
KASSERT(req != PRU_SEND); |
|
KASSERT(req != PRU_SENDOOB); |
|
KASSERT(req != PRU_PURGEIF); |
|
|
|
KASSERT(solocked(so)); |
|
|
|
if (sotoinpcb(so) == NULL) |
|
return EINVAL; |
|
|
|
panic("udp_usrreq"); |
|
|
|
return 0; |
|
} |
|
|
|
static int |
|
sysctl_net_inet_udp_stats(SYSCTLFN_ARGS) |
sysctl_net_inet_udp_stats(SYSCTLFN_ARGS) |
{ |
{ |
|
|
Line 1331 udp4_espinudp(struct mbuf **mp, int off, |
|
Line 1310 udp4_espinudp(struct mbuf **mp, int off, |
|
} |
} |
|
|
/* |
/* |
* Get the UDP ports. They are handled in network |
* Get the UDP ports. They are handled in network |
* order everywhere in IPSEC_NAT_T code. |
* order everywhere in IPSEC_NAT_T code. |
*/ |
*/ |
udphdr = (struct udphdr *)((char *)data - skip); |
udphdr = (struct udphdr *)((char *)data - skip); |
Line 1363 udp4_espinudp(struct mbuf **mp, int off, |
|
Line 1342 udp4_espinudp(struct mbuf **mp, int off, |
|
|
|
/* |
/* |
* We have modified the packet - it is now ESP, so we should not |
* We have modified the packet - it is now ESP, so we should not |
* return to UDP processing ... |
* return to UDP processing ... |
* |
* |
* 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 |
* same NAT |
* same NAT |
*/ |
*/ |
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) { |
Line 1380 udp4_espinudp(struct mbuf **mp, int off, |
|
Line 1359 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 IPSEC |
|
if (ipsec_used) |
if (ipsec_used) |
ipsec4_common_input(m, iphdrlen, IPPROTO_ESP); |
ipsec4_common_input(m, iphdrlen, IPPROTO_ESP); |
/* XXX: else */ |
/* XXX: else */ |
#else |
|
esp4_input(m, iphdrlen); |
|
#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 ... */ |
*mp = NULL; /* avoid free by caller ... */ |
Line 1414 PR_WRAP_USRREQS(udp) |
|
Line 1389 PR_WRAP_USRREQS(udp) |
|
#define udp_send udp_send_wrapper |
#define udp_send udp_send_wrapper |
#define udp_sendoob udp_sendoob_wrapper |
#define udp_sendoob udp_sendoob_wrapper |
#define udp_purgeif udp_purgeif_wrapper |
#define udp_purgeif udp_purgeif_wrapper |
#define udp_usrreq udp_usrreq_wrapper |
|
|
|
const struct pr_usrreqs udp_usrreqs = { |
const struct pr_usrreqs udp_usrreqs = { |
.pr_attach = udp_attach, |
.pr_attach = udp_attach, |
Line 1436 const struct pr_usrreqs udp_usrreqs = { |
|
Line 1410 const struct pr_usrreqs udp_usrreqs = { |
|
.pr_send = udp_send, |
.pr_send = udp_send, |
.pr_sendoob = udp_sendoob, |
.pr_sendoob = udp_sendoob, |
.pr_purgeif = udp_purgeif, |
.pr_purgeif = udp_purgeif, |
.pr_generic = udp_usrreq, |
|
}; |
}; |