Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/udp_usrreq.c
Show All 37 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_ipfw.h" | #include "opt_ipfw.h" | ||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_inet6.h" | #include "opt_inet6.h" | ||||
#include "opt_ipsec.h" | #include "opt_ipsec.h" | ||||
#include "opt_rss.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/domain.h> | #include <sys/domain.h> | ||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#include <sys/jail.h> | #include <sys/jail.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
Show All 30 Lines | |||||
#include <netinet/ip_var.h> | #include <netinet/ip_var.h> | ||||
#include <netinet/ip_options.h> | #include <netinet/ip_options.h> | ||||
#ifdef INET6 | #ifdef INET6 | ||||
#include <netinet6/ip6_var.h> | #include <netinet6/ip6_var.h> | ||||
#endif | #endif | ||||
#include <netinet/udp.h> | #include <netinet/udp.h> | ||||
#include <netinet/udp_var.h> | #include <netinet/udp_var.h> | ||||
#include <netinet/udplite.h> | #include <netinet/udplite.h> | ||||
#include <netinet/in_rss.h> | |||||
#ifdef IPSEC | #ifdef IPSEC | ||||
#include <netipsec/ipsec.h> | #include <netipsec/ipsec.h> | ||||
#include <netipsec/esp.h> | #include <netipsec/esp.h> | ||||
#endif | #endif | ||||
#include <machine/in_cksum.h> | #include <machine/in_cksum.h> | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | udplite_inpcb_init(void *mem, int size, int flags) | ||||
INP_LOCK_INIT(inp, "inp", "udpliteinp"); | INP_LOCK_INIT(inp, "inp", "udpliteinp"); | ||||
return (0); | return (0); | ||||
} | } | ||||
void | void | ||||
udp_init(void) | udp_init(void) | ||||
{ | { | ||||
/* | |||||
* For now default to 2-tuple UDP hashing - until the fragment | |||||
* reassembly code can also update the flowid. | |||||
* | |||||
* Once we can calculate the flowid that way and re-establish | |||||
* a 4-tuple, flip this to 4-tuple. | |||||
*/ | |||||
in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE, | in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE, | ||||
"udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE, | "udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE, | ||||
IPI_HASHFIELDS_2TUPLE); | IPI_HASHFIELDS_2TUPLE); | ||||
V_udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb), | V_udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb), | ||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); | NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); | ||||
uma_zone_set_max(V_udpcb_zone, maxsockets); | uma_zone_set_max(V_udpcb_zone, maxsockets); | ||||
uma_zone_set_warning(V_udpcb_zone, "kern.ipc.maxsockets limit reached"); | uma_zone_set_warning(V_udpcb_zone, "kern.ipc.maxsockets limit reached"); | ||||
EVENTHANDLER_REGISTER(maxsockets_change, udp_zone_change, NULL, | EVENTHANDLER_REGISTER(maxsockets_change, udp_zone_change, NULL, | ||||
▲ Show 20 Lines • Show All 1,172 Lines • ▼ Show 20 Lines | ui->ui_sum = in_pseudo(ui->ui_src.s_addr, faddr.s_addr, | ||||
htons((u_short)len + sizeof(struct udphdr) + pr)); | htons((u_short)len + sizeof(struct udphdr) + pr)); | ||||
m->m_pkthdr.csum_flags = CSUM_UDP; | m->m_pkthdr.csum_flags = CSUM_UDP; | ||||
m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); | m->m_pkthdr.csum_data = offsetof(struct udphdr, uh_sum); | ||||
} | } | ||||
((struct ip *)ui)->ip_len = htons(sizeof(struct udpiphdr) + len); | ((struct ip *)ui)->ip_len = htons(sizeof(struct udpiphdr) + len); | ||||
((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */ | ((struct ip *)ui)->ip_ttl = inp->inp_ip_ttl; /* XXX */ | ||||
((struct ip *)ui)->ip_tos = tos; /* XXX */ | ((struct ip *)ui)->ip_tos = tos; /* XXX */ | ||||
UDPSTAT_INC(udps_opackets); | UDPSTAT_INC(udps_opackets); | ||||
/* | |||||
* Setup flowid / RSS information for outbound socket. | |||||
* | |||||
* Once the UDP code decides to set a flowid some other way, | |||||
* this allows the flowid to be overridden by userland. | |||||
grehan: typo. | |||||
* | |||||
* Remember ip_output() overrides with the inp flowid details | |||||
* if they exist. | |||||
* | |||||
* .. and ip_output() -> flowtable_lookup() also assigns | |||||
* a flowid too. Ugh. | |||||
*/ | |||||
if (use_flowid) { | |||||
m->m_flags |= M_FLOWID; | |||||
m->m_pkthdr.flowid = flowid; | |||||
M_HASHTYPE_SET(m, flowid_type); | |||||
#ifdef RSS | |||||
{ | |||||
uint32_t hash_val, hash_type; | |||||
/* | |||||
* Calculate an appropriate RSS hash for UDP and | |||||
* UDP Lite. | |||||
* | |||||
* The called function will take care of figuring out | |||||
* whether a 2-tuple or 4-tuple hash is required based | |||||
* on the currently configured scheme. | |||||
* | |||||
* Later later on connected socket values should be | |||||
* cached in the inpcb and reused, rather than constantly | |||||
* re-calculating it. | |||||
* | |||||
* UDP Lite is a different protocol number and will | |||||
* likely end up being hashed as a 2-tuple until | |||||
* RSS / NICs grow UDP Lite protocol awareness. | |||||
*/ | |||||
if (rss_proto_software_hash_v4(laddr, faddr, lport, fport, | |||||
pr, RSS_HASH_PKT_EGRESS, | |||||
&hash_val, &hash_type) == 0) { | |||||
m->m_pkthdr.flowid = hash_val; | |||||
m->m_flags |= M_FLOWID; | |||||
M_HASHTYPE_SET(m, hash_type); | |||||
} | |||||
} | |||||
#endif | |||||
/* | |||||
* Don't override with the inp cached flowid value. | |||||
* | |||||
* Depending upon the kind of send being done, the inp | |||||
* flowid/flowtype values may actually not be appropriate | |||||
* for this particular socket send. | |||||
* | |||||
* We should either leave the flowid at zero (which is what is | |||||
* currently done) or set it to some software generated | |||||
* hash value based on the packet contents. | |||||
*/ | |||||
ipflags |= IP_NODEFAULTFLOWID; | |||||
if (unlock_udbinfo == UH_WLOCKED) | if (unlock_udbinfo == UH_WLOCKED) | ||||
INP_HASH_WUNLOCK(pcbinfo); | INP_HASH_WUNLOCK(pcbinfo); | ||||
else if (unlock_udbinfo == UH_RLOCKED) | else if (unlock_udbinfo == UH_RLOCKED) | ||||
INP_HASH_RUNLOCK(pcbinfo); | INP_HASH_RUNLOCK(pcbinfo); | ||||
UDP_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u); | UDP_PROBE(send, NULL, inp, &ui->ui_i, inp, &ui->ui_u); | ||||
error = ip_output(m, inp->inp_options, NULL, ipflags, | error = ip_output(m, inp->inp_options, NULL, ipflags, | ||||
inp->inp_moptions, inp); | inp->inp_moptions, inp); | ||||
▲ Show 20 Lines • Show All 395 Lines • Show Last 20 Lines |
typo.