aboutsummaryrefslogtreecommitdiff
path: root/sys/netinet6/in6_rss.c
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2020-10-18 17:15:47 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2020-10-18 17:15:47 +0000
commit0c325f53f16731f608919a4489f96fbbe28d2344 (patch)
tree47edfa6af78113b91e7dad7f002817c6e110b01f /sys/netinet6/in6_rss.c
parent186bcdaac7c70e59eb04412ad402a6fb57b97d11 (diff)
downloadsrc-0c325f53f16731f608919a4489f96fbbe28d2344.tar.gz
src-0c325f53f16731f608919a4489f96fbbe28d2344.zip
Implement flowid calculation for outbound connections to balance
connections over multiple paths. Multipath routing relies on mbuf flowid data for both transit and outbound traffic. Current code fills mbuf flowid from inp_flowid for connection-oriented sockets. However, inp_flowid is currently not calculated for outbound connections. This change creates simple hashing functions and starts calculating hashes for TCP,UDP/UDP-Lite and raw IP if multipath routes are present in the system. Reviewed by: glebius (previous version),ae Differential Revision: https://reviews.freebsd.org/D26523
Notes
Notes: svn path=/head/; revision=366813
Diffstat (limited to 'sys/netinet6/in6_rss.c')
-rw-r--r--sys/netinet6/in6_rss.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/sys/netinet6/in6_rss.c b/sys/netinet6/in6_rss.c
index 72dd0a8831af..2b86d961515b 100644
--- a/sys/netinet6/in6_rss.c
+++ b/sys/netinet6/in6_rss.c
@@ -153,6 +153,50 @@ rss_proto_software_hash_v6(const struct in6_addr *s, const struct in6_addr *d,
}
/*
+ * Calculate an appropriate ipv6 2-tuple or 4-tuple given the given
+ * IPv6 source/destination address, UDP or TCP source/destination ports
+ * and the protocol type.
+ *
+ * The protocol code may wish to do a software hash of the given
+ * tuple. This depends upon the currently configured RSS hash types.
+ *
+ * It assumes the packet source/destination address
+ * are in "outgoin" packet order (ie, destination is "far" address.)
+ */
+uint32_t
+xps_proto_software_hash_v6(const struct in6_addr *s, const struct in6_addr *d,
+ u_short sp, u_short dp, int proto, uint32_t *hashtype)
+{
+
+ uint32_t hash;
+
+ /*
+ * Next, choose the hash type depending upon the protocol
+ * identifier.
+ */
+ if ((proto == IPPROTO_TCP) &&
+ (rss_gethashconfig() & RSS_HASHTYPE_RSS_TCP_IPV6)) {
+ hash = rss_hash_ip6_4tuple(d, dp, s, sp);
+ *hashtype = M_HASHTYPE_RSS_TCP_IPV6;
+ return (hash);
+ } else if ((proto == IPPROTO_UDP) &&
+ (rss_gethashconfig() & RSS_HASHTYPE_RSS_UDP_IPV6)) {
+ hash = rss_hash_ip6_4tuple(d, dp, s, sp);
+ *hashtype = M_HASHTYPE_RSS_UDP_IPV6;
+ return (hash);
+ } else if (rss_gethashconfig() & RSS_HASHTYPE_RSS_IPV6) {
+ /* RSS doesn't hash on other protocols like SCTP; so 2-tuple */
+ hash = rss_hash_ip6_2tuple(d, s);
+ *hashtype = M_HASHTYPE_RSS_IPV6;
+ return (hash);
+ }
+
+ *hashtype = M_HASHTYPE_NONE;
+ return (0);
+}
+
+
+/*
* Do a software calculation of the RSS for the given mbuf.
*
* This is typically used by the input path to recalculate the RSS after