51#include <sys/domain.h>
52#include <sys/eventhandler.h>
54#include <sys/kernel.h>
56#include <sys/malloc.h>
60#include <sys/protosw.h>
62#include <sys/signalvar.h>
63#include <sys/socket.h>
64#include <sys/socketvar.h>
66#include <sys/sysctl.h>
67#include <sys/syslog.h>
73#include <net/if_var.h>
75#include <net/route/nhop.h>
76#include <net/rss_config.h>
93#include <netinet6/ip6_var.h>
100#include <netipsec/ipsec_support.h>
102#include <machine/in_cksum.h>
104#include <security/mac/mac_framework.h>
120 &VNET_NAME(udp_cksum), 0,
"compute udp checksum");
123SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_VNET | CTLFLAG_RW,
124 &VNET_NAME(udp_log_in_vain), 0,
"Log all incoming UDP packets");
127SYSCTL_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_VNET | CTLFLAG_RW,
128 &VNET_NAME(udp_blackhole), 0,
129 "Do not send port unreachables for refused connects");
131SYSCTL_BOOL(_net_inet_udp, OID_AUTO, blackhole_local, CTLFLAG_VNET |
132 CTLFLAG_RW, &VNET_NAME(udp_blackhole_local),
false,
133 "Enforce net.inet.udp.blackhole for locally originated packets");
141 sizeof(
struct sockaddr_in6)
148 &
udp_recvspace, 0,
"Maximum space for incoming UDP datagrams");
153#define V_udpcb_zone VNET(udpcb_zone)
156#define UDBHASHSIZE 128
162 udpstat,
"UDP statistics (struct udpstat, netinet/udp_var.h)");
168static void udp_detach(
struct socket *so);
169static int udp_output(
struct inpcb *,
struct mbuf *,
struct sockaddr *,
170 struct mbuf *,
struct thread *,
int);
190 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
192 uma_zone_set_warning(
V_udpcb_zone,
"kern.ipc.maxsockets limit reached");
211 counter_u64_add(VNET(
udpstat)[statnum], 1);
235udp_destroy(
void *unused __unused)
241VNET_SYSUNINIT(udp, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, udp_destroy, NULL);
244udplite_destroy(
void *unused __unused)
249VNET_SYSUNINIT(udplite, SI_SUB_PROTO_DOMAIN, SI_ORDER_FOURTH, udplite_destroy,
271udp_append(
struct inpcb *inp,
struct ip *
ip,
struct mbuf *n,
int off,
274 struct sockaddr *append_sa;
276 struct mbuf *tmpopts, *opts = NULL;
278 struct sockaddr_in6 udp_in6;
291 (*up->
u_tun_func)(n, off, inp, (
struct sockaddr *)&udp_in[0],
297 off +=
sizeof(
struct udphdr);
299#if defined(IPSEC) || defined(IPSEC_SUPPORT)
301 if (IPSEC_ENABLED(ipv4) &&
302 IPSEC_CHECK_POLICY(ipv4, n, inp) != 0) {
307 if (IPSEC_ENABLED(ipv4) &&
308 UDPENCAP_INPUT(n, off, AF_INET) != 0)
313 if (mac_inpcb_check_deliver(inp, n) != 0) {
319 inp->
inp_socket->so_options & (SO_TIMESTAMP | SO_BINTIME)) {
322 (void)ip6_savecontrol_v4(inp, n, &opts, NULL);
328 tmpopts = sbcreatecontrol((caddr_t)&udp_in[1],
332 tmpopts->m_next = opts;
340 bzero(&udp_in6,
sizeof(udp_in6));
341 udp_in6.sin6_len =
sizeof(udp_in6);
342 udp_in6.sin6_family = AF_INET6;
343 in6_sin_2_v4mapsin6(&udp_in[0], &udp_in6);
344 append_sa = (
struct sockaddr *)&udp_in6;
347 append_sa = (
struct sockaddr *)&udp_in[0];
351 SOCKBUF_LOCK(&so->so_rcv);
352 if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) {
353 soroverflow_locked(so);
359 sorwakeup_locked(so);
364udp_multi_match(
const struct inpcb *inp,
void *v)
379 inp->inp_faddr.s_addr !=
ip->ip_src.s_addr)
381 if (inp->inp_fport != 0 &&
389udp_multi_input(
struct mbuf *m,
int proto,
struct sockaddr_in *udp_in)
391 struct ip *
ip = mtod(m,
struct ip *);
401 MPASS(
ip->
ip_hl ==
sizeof(
struct ip) >> 2);
403 while ((inp =
inp_next(&inpi)) != NULL) {
415 struct ip_moptions *imo;
424 group.sin_family = AF_INET;
428 (
struct sockaddr *)&group,
429 (
struct sockaddr *)&udp_in[0]);
439 if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != NULL) {
440 if (proto == IPPROTO_UDPLITE)
444 if (udp_append(inp,
ip, n,
sizeof(
struct ip), udp_in)) {
459 (SO_REUSEPORT|SO_REUSEPORT_LB|SO_REUSEADDR)) == 0) {
479 return (IPPROTO_DONE);
483udp_input(
struct mbuf **mp,
int *offp,
int proto)
493 struct m_tag *fwd_tag;
494 int cscov_partial, iphlen;
498 ifp = m->m_pkthdr.rcvif;
507 if (iphlen >
sizeof (
struct ip)) {
509 iphlen =
sizeof(
struct ip);
515 if (m->m_len < iphlen +
sizeof(
struct udphdr)) {
516 if ((m = m_pullup(m, iphlen +
sizeof(
struct udphdr))) == NULL) {
518 return (IPPROTO_DONE);
521 ip = mtod(m,
struct ip *);
522 uh = (
struct udphdr *)((caddr_t)
ip + iphlen);
523 cscov_partial = (proto == IPPROTO_UDPLITE) ? 1 : 0;
549 len = ntohs((u_short)uh->
uh_ulen);
551 if (proto == IPPROTO_UDPLITE && (len == 0 || len ==
ip_len)) {
572 if ((m->m_pkthdr.csum_flags & CSUM_DATA_VALID) &&
574 if (m->m_pkthdr.csum_flags & CSUM_PSEUDO_HDR)
575 uh_sum = m->m_pkthdr.csum_data;
579 m->m_pkthdr.csum_data + proto));
582 char b[offsetof(
struct ipovly, ih_src)];
585 bcopy(ipov, b,
sizeof(b));
586 bzero(ipov,
sizeof(ipov->
ih_x1));
589 uh_sum = in_cksum(m, len +
sizeof (
struct ip));
590 bcopy(b, ipov,
sizeof(b));
595 return (IPPROTO_DONE);
604 return (IPPROTO_DONE);
610 return (udp_multi_input(m, proto, udp_in));
619 if ((m->m_flags & M_IP_NEXTHOP) &&
620 (fwd_tag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL)) != NULL) {
644 m_tag_delete(m, fwd_tag);
645 m->m_flags &= ~M_IP_NEXTHOP;
652 char src[INET_ADDRSTRLEN];
653 char dst[INET_ADDRSTRLEN];
656 "Connection attempt to UDP %s:%d from %s:%d\n",
660 if (proto == IPPROTO_UDPLITE)
665 if (m->m_flags & (M_BCAST | M_MCAST)) {
675 return (IPPROTO_DONE);
683 if (proto == IPPROTO_UDPLITE)
689 return (IPPROTO_DONE);
698 return (IPPROTO_DONE);
702 if (proto == IPPROTO_UDPLITE)
706 if (udp_append(inp,
ip, m, iphlen, udp_in) == 0)
708 return (IPPROTO_DONE);
712 return (IPPROTO_DONE);
725 if ((errno == EHOSTUNREACH || errno == ENETUNREACH ||
726 errno == EHOSTDOWN) && inp->
inp_route.ro_nh) {
728 inp->
inp_route.ro_nh = (
struct nhop_object *)NULL;
739udp_common_ctlinput(
int cmd,
struct sockaddr *sa,
void *vip,
748 if (sa->sa_family != AF_INET || faddr.s_addr ==
INADDR_ANY)
751 if (PRC_IS_REDIRECT(cmd)) {
763 if (cmd == PRC_HOSTDEAD)
765 else if ((
unsigned)cmd >= PRC_NCMDS ||
inetctlerrmap[cmd] == 0)
791 (*func)(cmd, sa, vip, ctx);
802 return (udp_common_ctlinput(cmd, sa, vip, &
V_udbinfo));
822 if (req->newptr != 0)
825 if (req->oldptr == 0) {
829 n += imax(n / 8, 10);
830 req->oldidx = 2 * (
sizeof xig) + n *
sizeof(
struct xinpcb);
834 if ((error = sysctl_wire_old_buffer(req, 0)) != 0)
837 bzero(&xig,
sizeof(xig));
838 xig.xig_len =
sizeof xig;
841 xig.xig_sogen = so_gencnt;
842 error = SYSCTL_OUT(req, &xig,
sizeof xig);
846 while ((inp =
inp_next(&inpi)) != NULL) {
852 error = SYSCTL_OUT(req, &xi,
sizeof xi);
868 xig.xig_sogen = so_gencnt;
870 error = SYSCTL_OUT(req, &xig,
sizeof xig);
877 CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
879 "List of active UDP sockets");
883udp_getcred(SYSCTL_HANDLER_ARGS)
887 struct epoch_tracker et;
891 error = priv_check(req->td, PRIV_NETINET_GETCRED);
894 error = SYSCTL_IN(req, addrs,
sizeof(addrs));
899 addrs[0].sin_addr, addrs[0].sin_port,
914 error = SYSCTL_OUT(req, &xuc,
sizeof(
struct xucred));
919 CTLTYPE_OPAQUE | CTLFLAG_RW | CTLFLAG_PRISON | CTLFLAG_MPSAFE,
920 0, 0, udp_getcred,
"S,xucred",
921 "Get the xucred of a UDP connection");
929 int isudplite, error, optval;
932 isudplite = (so->so_proto->pr_protocol == IPPROTO_UDPLITE) ? 1 : 0;
934 KASSERT(inp != NULL, (
"%s: inp == NULL", __func__));
936 if (sopt->sopt_level != so->so_proto->pr_protocol) {
940 error = ip6_ctloutput(so, sopt);
943#if defined(INET) && defined(INET6)
955 switch (sopt->sopt_dir) {
957 switch (sopt->sopt_name) {
958#if defined(IPSEC) || defined(IPSEC_SUPPORT)
961 if (!IPSEC_ENABLED(ipv4)) {
963 return (ENOPROTOOPT);
965 error = UDPENCAP_PCBCTL(inp, sopt);
977 error = sooptcopyin(sopt, &optval,
sizeof(optval),
982 KASSERT(inp != NULL, (
"%s: inp == NULL", __func__));
985 KASSERT(up != NULL, (
"%s: up == NULL", __func__));
986 if ((optval != 0 && optval < 8) || (optval > 65535)) {
1004 switch (sopt->sopt_name) {
1005#if defined(IPSEC) || defined(IPSEC_SUPPORT)
1008 if (!IPSEC_ENABLED(ipv4)) {
1010 return (ENOPROTOOPT);
1012 error = UDPENCAP_PCBCTL(inp, sopt);
1020 error = ENOPROTOOPT;
1024 KASSERT(up != NULL, (
"%s: up == NULL", __func__));
1030 error = sooptcopyout(sopt, &optval,
sizeof(optval));
1034 error = ENOPROTOOPT;
1046udp_v4mapped_pktinfo(
struct cmsghdr *cm,
struct sockaddr_in * src,
1047 struct inpcb *inp,
int flags)
1050 struct in6_pktinfo *pktinfo;
1053 if ((flags & PRUS_IPV6) == 0)
1056 if (cm->cmsg_level != IPPROTO_IPV6)
1059 if (cm->cmsg_type != IPV6_2292PKTINFO &&
1060 cm->cmsg_type != IPV6_PKTINFO)
1064 CMSG_LEN(
sizeof(
struct in6_pktinfo)))
1067 pktinfo = (
struct in6_pktinfo *)CMSG_DATA(cm);
1068 if (!IN6_IS_ADDR_V4MAPPED(&pktinfo->ipi6_addr) &&
1069 !IN6_IS_ADDR_UNSPECIFIED(&pktinfo->ipi6_addr))
1073 if (pktinfo->ipi6_ifindex) {
1074 struct epoch_tracker et;
1076 NET_EPOCH_ENTER(et);
1077 ifp = ifnet_byindex(pktinfo->ipi6_ifindex);
1083 if (ifp != NULL && !IN6_IS_ADDR_UNSPECIFIED(&pktinfo->ipi6_addr)) {
1084 ia.s_addr = pktinfo->ipi6_addr.s6_addr32[3];
1086 return (EADDRNOTAVAIL);
1089 bzero(src,
sizeof(*src));
1100udp_output(
struct inpcb *inp,
struct mbuf *m,
struct sockaddr *addr,
1101 struct mbuf *control,
struct thread *td,
int flags)
1104 int len = m->m_pkthdr.len;
1109 struct epoch_tracker et;
1110 int cscov_partial = 0;
1113 u_short fport, lport;
1118 uint8_t flowtype = M_HASHTYPE_NONE;
1140 (inp->inp_laddr.s_addr ==
INADDR_ANY && inp->inp_lport == 0))
1144 NET_EPOCH_ENTER(et);
1146 if (control != NULL) {
1151 if (control->m_next) {
1156 for (; control->m_len > 0;
1157 control->m_data += CMSG_ALIGN(cm->cmsg_len),
1158 control->m_len -= CMSG_ALIGN(cm->cmsg_len)) {
1159 cm = mtod(control,
struct cmsghdr *);
1160 if (control->m_len <
sizeof(*cm) || cm->cmsg_len == 0
1161 || cm->cmsg_len > control->m_len) {
1166 error = udp_v4mapped_pktinfo(cm, &src, inp, flags);
1173 switch (cm->cmsg_type) {
1174 case IP_SENDSRCADDR:
1176 CMSG_LEN(
sizeof(
struct in_addr))) {
1180 bzero(&src,
sizeof(src));
1185 *(
struct in_addr *)CMSG_DATA(cm);
1189 if (cm->cmsg_len != CMSG_LEN(
sizeof(u_char))) {
1193 tos = *(u_char *)CMSG_DATA(cm);
1197 if (cm->cmsg_len != CMSG_LEN(
sizeof(
uint32_t))) {
1201 flowid = *(
uint32_t *) CMSG_DATA(cm);
1205 if (cm->cmsg_len != CMSG_LEN(
sizeof(
uint32_t))) {
1209 flowtype = *(
uint32_t *) CMSG_DATA(cm);
1213 case IP_RSSBUCKETID:
1214 if (cm->cmsg_len != CMSG_LEN(
sizeof(
uint32_t))) {
1222 error = ENOPROTOOPT;
1242 laddr = inp->inp_laddr;
1243 lport = inp->inp_lport;
1253 &laddr.s_addr, &lport, td->td_ucred);
1294 inp->inp_lport == 0 ||
1299 &lport, &faddr.s_addr, &fport, NULL,
1312 inp->inp_lport == 0) {
1318 if (prison_flag(td->td_ucred, PR_IP4))
1319 inp->inp_laddr = laddr;
1320 inp->inp_lport = lport;
1337 faddr = inp->inp_faddr;
1338 fport = inp->inp_fport;
1350 M_PREPEND(m,
sizeof(
struct udpiphdr) + max_linkhdr, M_NOWAIT);
1355 m->m_data += max_linkhdr;
1356 m->m_len -= max_linkhdr;
1357 m->m_pkthdr.len -= max_linkhdr;
1364 bzero(ui->ui_x1,
sizeof(ui->ui_x1));
1369 ui->ui_sport = lport;
1370 ui->ui_dport = fport;
1371 ui->ui_ulen = htons((u_short)len +
sizeof(
struct udphdr));
1372 if (pr == IPPROTO_UDPLITE) {
1378 plen = (u_short)len +
sizeof(
struct udphdr);
1381 ui->ui_len = htons(plen);
1382 ui->ui_ulen = htons(cscov);
1387 cscov_partial = (cscov == 0) ? 0 : 1;
1400 if (inp->
inp_socket->so_options & SO_DONTROUTE)
1402 if (inp->
inp_socket->so_options & SO_BROADCAST)
1408 mac_inpcb_create_mbuf(inp, m);
1415 if (pr == IPPROTO_UDPLITE) {
1418 if (cscov_partial) {
1419 if ((ui->ui_sum = in_cksum(m,
sizeof(
struct ip) + cscov)) == 0)
1420 ui->ui_sum = 0xffff;
1422 if ((ui->ui_sum = in_cksum(m,
sizeof(
struct udpiphdr) + len)) == 0)
1423 ui->ui_sum = 0xffff;
1428 ui->ui_sum =
in_pseudo(ui->ui_src.s_addr, faddr.s_addr,
1429 htons((u_short)len +
sizeof(
struct udphdr) + pr));
1430 m->m_pkthdr.csum_flags = CSUM_UDP;
1431 m->m_pkthdr.csum_data = offsetof(
struct udphdr, uh_sum);
1433 ((
struct ip *)ui)->ip_len = htons(
sizeof(
struct udpiphdr) + len);
1435 ((
struct ip *)ui)->ip_tos = tos;
1444 if (flowtype != M_HASHTYPE_NONE) {
1445 m->m_pkthdr.flowid = flowid;
1446 M_HASHTYPE_SET(m, flowtype);
1448#if defined(ROUTE_MPATH) || defined(RSS)
1449 else if (CALC_FLOWID_OUTBOUND_SENDTO) {
1452 hash_val = fib4_calc_packet_hash(laddr, faddr,
1453 lport, fport, pr, &hash_type);
1454 m->m_pkthdr.flowid = hash_val;
1455 M_HASHTYPE_SET(m, hash_type);
1472 if (pr == IPPROTO_UDPLITE)
1491udp_abort(
struct socket *so)
1498 KASSERT(inp != NULL, (
"udp_abort: inp == NULL"));
1505 soisdisconnected(so);
1511udp_attach(
struct socket *so,
int proto,
struct thread *td)
1520 KASSERT(inp == NULL, (
"udp_attach: inp != NULL"));
1531 inp->
inp_flowid = atomic_fetchadd_int(&udp_flowid, 1);
1552 KASSERT(so->so_type == SOCK_DGRAM,
1553 (
"udp_set_kernel_tunneling: !dgram"));
1555 KASSERT(inp != NULL, (
"udp_set_kernel_tunneling: inp == NULL"));
1558 if ((f != NULL || i != NULL) && ((up->
u_tun_func != NULL) ||
1572udp_bind(
struct socket *so,
struct sockaddr *nam,
struct thread *td)
1581 KASSERT(inp != NULL, (
"udp_bind: inp == NULL"));
1584 if (nam->sa_family != AF_INET) {
1588 if (nam->sa_family != AF_UNSPEC ||
1591 return (EAFNOSUPPORT);
1592 nam->sa_family = AF_INET;
1606udp_close(
struct socket *so)
1613 KASSERT(inp != NULL, (
"udp_close: inp == NULL"));
1620 soisdisconnected(so);
1626udp_connect(
struct socket *so,
struct sockaddr *nam,
struct thread *td)
1628 struct epoch_tracker et;
1636 KASSERT(inp != NULL, (
"udp_connect: inp == NULL"));
1640 return (EAFNOSUPPORT);
1641 if (sin->
sin_len !=
sizeof(*sin))
1654 NET_EPOCH_ENTER(et);
1666udp_detach(
struct socket *so)
1672 KASSERT(inp != NULL, (
"udp_detach: inp == NULL"));
1674 (
"udp_detach: not disconnected"));
1677 KASSERT(up != NULL, (
"%s: up == NULL", __func__));
1685udp_disconnect(
struct socket *so)
1692 KASSERT(inp != NULL, (
"udp_disconnect: inp == NULL"));
1703 so->so_state &= ~SS_ISCONNECTED;
1710udp_send(
struct socket *so,
int flags,
struct mbuf *m,
struct sockaddr *addr,
1711 struct mbuf *control,
struct thread *td)
1717 KASSERT(inp != NULL, (
"udp_send: inp == NULL"));
1721 if (addr->sa_family != AF_INET)
1722 error = EAFNOSUPPORT;
1723 else if (addr->sa_len !=
sizeof(
struct sockaddr_in))
1725 if (__predict_false(error != 0)) {
1731 return (udp_output(inp, m, addr, control, td, flags));
1741 KASSERT(inp != NULL, (
"udp_shutdown: inp == NULL"));
1750 .pru_abort = udp_abort,
1751 .pru_attach = udp_attach,
1752 .pru_bind = udp_bind,
1753 .pru_connect = udp_connect,
1755 .pru_detach = udp_detach,
1756 .pru_disconnect = udp_disconnect,
1758 .pru_send = udp_send,
1759 .pru_soreceive = soreceive_dgram,
1760 .pru_sosend = sosend_dgram,
1764 .pru_close = udp_close,
#define BANDLIM_ICMP_UNREACH
VNET_PCPUSTAT_SYSUNINIT(igmpstat)
bool in_localip(struct in_addr in)
int in_ifhasaddr(struct ifnet *ifp, struct in_addr in)
int in_broadcast(struct in_addr in, struct ifnet *ifp)
int in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, struct thread *td)
char * inet_ntoa_r(struct in_addr ina, char *buf)
u_short in_pseudo(u_int32_t a, u_int32_t b, u_int32_t c)
int prison_remote_ip4(struct ucred *cred, struct in_addr *ia)
#define UDP_PROBE(probe, arg0, arg1, arg2, arg3, arg4)
#define UDPLITE_PROBE(probe, arg0, arg1, arg2, arg3, arg4)
int imo_multi_filter(const struct ip_moptions *imo, const struct ifnet *ifp, const struct sockaddr *group, const struct sockaddr *src)
struct inpcb * inp_next(struct inpcb_iterator *ii)
bool in_pcbrele_rlocked(struct inpcb *inp)
int in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo)
void in_pcbinfo_destroy(struct inpcbinfo *pcbinfo)
void in_pcbtoxinpcb(const struct inpcb *inp, struct xinpcb *xi)
void in_pcbsosetlabel(struct socket *so)
void in_pcbref(struct inpcb *inp)
int in_pcbinshash(struct inpcb *inp)
void in_pcbdetach(struct inpcb *inp)
void in_pcbinfo_init(struct inpcbinfo *pcbinfo, struct inpcbstorage *pcbstor, u_int hash_nelements, u_int porthash_nelements)
void in_pcbfree(struct inpcb *inp)
#define INP_LOCK_ASSERT(inp)
#define INP_HASH_WUNLOCK(ipi)
void in_pcbdisconnect(struct inpcb *)
struct inpcb * in_pcblookup(struct inpcbinfo *, struct in_addr, u_int, struct in_addr, u_int, int, struct ifnet *)
#define INP_ALL_ITERATOR(_ipi, _lock)
int in_getsockaddr(struct socket *so, struct sockaddr **nam)
int in_pcbconnect_setup(struct inpcb *, struct sockaddr *, in_addr_t *, u_short *, in_addr_t *, u_short *, struct inpcb **, struct ucred *)
int in_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *)
#define INP_WLOCK_ASSERT(inp)
int in_pcbbind_setup(struct inpcb *, struct sockaddr *, in_addr_t *, u_short *, struct ucred *)
int in_getpeeraddr(struct socket *so, struct sockaddr **nam)
int in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *, bool)
#define INP_HASH_WLOCK(ipi)
struct inpcb * in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int, struct in_addr, u_int, int, struct ifnet *, struct mbuf *)
#define INP_CHECK_SOCKAF(so, af)
#define INP_RLOCK_ASSERT(inp)
void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, int, struct inpcb *(*)(struct inpcb *, int))
#define INP_ITERATOR(_ipi, _lock, _match, _ctx)
int cr_canseeinpcb(struct ucred *cred, struct inpcb *inp)
VNET_SYSUNINIT(divert, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, div_destroy, NULL)
void icmp_error(struct mbuf *, int, int, uint32_t, int)
#define ICMP_UNREACH_PORT
void ip_stripoptions(struct mbuf *m)
int ip_ctloutput(struct socket *so, struct sockopt *sopt)
int ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags, struct ip_moptions *imo, struct inpcb *inp)
#define IP_NODEFAULTFLOWID
#define IP_ALLOWBROADCAST
struct socket * inp_socket
struct mbuf * inp_options
struct ip_moptions * inp_moptions
struct in_addr ip_src ip_dst
udp_tun_func_t u_tun_func
udp_tun_icmp_t u_icmp_func
VNET_PCPUSTAT_SYSINIT(udpstat)
VNET_DEFINE(int, udp_cksum)
VNET_DEFINE_STATIC(uma_zone_t, udpcb_zone)
void udp_discardcb(struct udpcb *up)
SYSCTL_VNET_PCPUSTAT(_net_inet_udp, UDPCTL_STATS, stats, struct udpstat, udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)")
INPCBSTORAGE_DEFINE(udpcbstor, "udpinp", "udp_inpcb", "udp", "udphash")
struct inpcb * udp_notify(struct inpcb *inp, int errno)
int udp_shutdown(struct socket *so)
int udp_newudpcb(struct inpcb *inp)
static int udp_pcblist(SYSCTL_HANDLER_ARGS)
VNET_SYSINIT(udp_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, udp_init, NULL)
SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, udp_pcblist, "S,xinpcb", "List of active UDP sockets")
static void udp_init(void *arg __unused)
VNET_PCPUSTAT_DEFINE(struct udpstat, udpstat)
void kmod_udpstat_inc(int statnum)
SYSCTL_BOOL(_net_inet_udp, OID_AUTO, blackhole_local, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(udp_blackhole_local), false, "Enforce net.inet.udp.blackhole for locally originated packets")
SYSCTL_INT(_net_inet_udp, UDPCTL_CHECKSUM, checksum, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(udp_cksum), 0, "compute udp checksum")
SYSCTL_ULONG(_net_inet_udp, UDPCTL_MAXDGRAM, maxdgram, CTLFLAG_RW, &udp_sendspace, 0, "Maximum outgoing UDP datagram size")
int udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f, udp_tun_icmp_t i, void *ctx)
int udp_ctloutput(struct socket *so, struct sockopt *sopt)
static __inline struct inpcbinfo * udp_get_inpcbinfo(int protocol)
#define V_udp_blackhole_local
struct pr_usrreqs udp_usrreqs
void udplite_ctlinput(int, struct sockaddr *, void *)
void(* udp_tun_func_t)(struct mbuf *, int, struct inpcb *, const struct sockaddr *, void *)
void udp_ctlinput(int, struct sockaddr *, void *)
int udp_input(struct mbuf **, int *, int)
void(* udp_tun_icmp_t)(int, struct sockaddr *, void *, void *)
#define V_udp_log_in_vain
#define UDPSTAT_INC(name)
#define UDPLITE_SEND_CSCOV
#define UDPLITE_RECV_CSCOV