aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorStephen Hurd <shurd@FreeBSD.org>2018-11-14 15:23:39 +0000
committerStephen Hurd <shurd@FreeBSD.org>2018-11-14 15:23:39 +0000
commit8d4ceb9cc49dded04f320ed36c92350355755077 (patch)
treeb36b488eb69aae8dbfc28c89ffc0717bef88f7d2 /sys
parent4d261ce278f6fc4bf8e2571d4c101cbf944c9155 (diff)
downloadsrc-8d4ceb9cc49dded04f320ed36c92350355755077.tar.gz
src-8d4ceb9cc49dded04f320ed36c92350355755077.zip
Prevent POLA violation with TSO/CSUM offload
Ensure that any time CSUM_IP_TSO or CSUM_IP6_TSO is set that the corresponding CSUM_IP6?_TCP / CSUM_IP flags are also set. Rather than requireing drivers to bake-in an understanding that TSO implies checksum offloads, make it explicit. This change requires us to move the IFLIB_NEED_ZERO_CSUM implementation to ensure it's zeroed for TSO. Reported by: Jacob Keller <jacob.e.keller@intel.com> MFC after: 1 week Sponsored by: Limelight Networks Differential Revision: https://reviews.freebsd.org/D17801
Notes
Notes: svn path=/head/; revision=340435
Diffstat (limited to 'sys')
-rw-r--r--sys/net/iflib.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index e13d2a9d9d27..1925a6d0f7c5 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -2973,9 +2973,6 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, struct mbuf **mp)
pi->ipi_ipproto = ip->ip_p;
pi->ipi_flags |= IPI_TX_IPV4;
- if ((sctx->isc_flags & IFLIB_NEED_ZERO_CSUM) && (pi->ipi_csum_flags & CSUM_IP))
- ip->ip_sum = 0;
-
/* TCP checksum offload may require TCP header length */
if (IS_TX_OFFLOAD4(pi)) {
if (__predict_true(pi->ipi_ipproto == IPPROTO_TCP)) {
@@ -2992,6 +2989,10 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, struct mbuf **mp)
if (IS_TSO4(pi)) {
if (__predict_false(ip->ip_p != IPPROTO_TCP))
return (ENXIO);
+ /*
+ * TSO always requires hardware checksum offload.
+ */
+ pi->ipi_csum_flags |= (CSUM_IP_TCP | CSUM_IP);
th->th_sum = in_pseudo(ip->ip_src.s_addr,
ip->ip_dst.s_addr, htons(IPPROTO_TCP));
pi->ipi_tso_segsz = m->m_pkthdr.tso_segsz;
@@ -3001,6 +3002,9 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, struct mbuf **mp)
}
}
}
+ if ((sctx->isc_flags & IFLIB_NEED_ZERO_CSUM) && (pi->ipi_csum_flags & CSUM_IP))
+ ip->ip_sum = 0;
+
break;
}
#endif
@@ -3038,9 +3042,7 @@ iflib_parse_header(iflib_txq_t txq, if_pkt_info_t pi, struct mbuf **mp)
if (__predict_false(ip6->ip6_nxt != IPPROTO_TCP))
return (ENXIO);
/*
- * The corresponding flag is set by the stack in the IPv4
- * TSO case, but not in IPv6 (at least in FreeBSD 10.2).
- * So, set it here because the rest of the flow requires it.
+ * TSO always requires hardware checksum offload.
*/
pi->ipi_csum_flags |= CSUM_IP6_TCP;
th->th_sum = in6_cksum_pseudo(ip6, 0, IPPROTO_TCP, 0);