aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet/udp_usrreq.c
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2014-09-09 04:19:36 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2014-09-09 04:19:36 +0000
commit8ad1a83b48c6fae4cc7d75650a135e3332a61206 (patch)
treee4223131515e0e5907a84a721e7a998a0e1584e2 /sys/netinet/udp_usrreq.c
parentb8bc95cd49446231025df4b1e66b254dff00805f (diff)
downloadsrc-8ad1a83b48c6fae4cc7d75650a135e3332a61206.tar.gz
src-8ad1a83b48c6fae4cc7d75650a135e3332a61206.zip
Calculate the RSS hash for outbound UDPv4 frames.
Differential Revision: https://reviews.freebsd.org/D527 Reviewed by: grehan
Notes
Notes: svn path=/head/; revision=271301
Diffstat (limited to 'sys/netinet/udp_usrreq.c')
-rw-r--r--sys/netinet/udp_usrreq.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index ecb7aec8d889..584f390e9d3b 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/udplite.h>
+#include <netinet/in_rss.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
@@ -207,6 +208,13 @@ 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,
"udp_inpcb", udp_inpcb_init, NULL, UMA_ZONE_NOFREE,
IPI_HASHFIELDS_2TUPLE);
@@ -1435,9 +1443,46 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr,
m->m_flags |= M_FLOWID;
m->m_pkthdr.flowid = flowid;
M_HASHTYPE_SET(m, flowid_type);
+#ifdef RSS
+ } else {
+ 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(faddr, laddr, fport, lport,
+ pr, &hash_val, &hash_type) == 0) {
+ m->m_pkthdr.flowid = hash_val;
+ m->m_flags |= M_FLOWID;
+ M_HASHTYPE_SET(m, hash_type);
+ }
+#endif
}
#ifdef RSS
+ /*
+ * 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;
#endif /* RSS */