diff options
author | John Thacker <johnthacker@gmail.com> | 2023-11-09 11:51:43 -0500 |
---|---|---|
committer | John Thacker <johnthacker@gmail.com> | 2023-11-11 10:12:49 -0500 |
commit | 84141d45c2ed3e67ec78bccad92e2ab9aa490c96 (patch) | |
tree | d00474ca056574c55c945d0f04326c315e4f9338 /epan/in_cksum.h | |
parent | cb211724472af936a1c67291e18147a7ccf60050 (diff) |
TCP, UDP: Calculate partial (pseudo header) checksums for offload
Linux and Windows, at least, when performing Local Checksum Offload
during Generic Segmentation Offload and at other times, place the one's
complement sum of the pseudo header in the checksum field, which
provides the necessary correction when a device (or its driver,
if not supported in hardware) computes the one's complement checksum
of each inner layer buffer in the skbuff. (This is why GSO requires
equal length buffers - so that the pseudo header contribution to
the checksum is the same.)
When performing our Internet checksum calculation, we can output
the partial sum of all but the last vector, which is an intermediate
result we calculate in the process anyway. The last vector is
generally the payload, and the previous vectors are for the pseudo
header. We can then compare this partial sum to the value in the
UDP or TCP header if the overall computed checksum isn't 0.
If it matches appropriately, we can have a more informative and
less scary message.
Update the tests a bit because this causes checksums to no longer
fail and be reported malformed in the http2 reassembly example.
Fix #18864. Related to #19109
Diffstat (limited to 'epan/in_cksum.h')
-rw-r--r-- | epan/in_cksum.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/epan/in_cksum.h b/epan/in_cksum.h index 671546f6df..d0f6fdd68d 100644 --- a/epan/in_cksum.h +++ b/epan/in_cksum.h @@ -33,6 +33,8 @@ WS_DLL_PUBLIC guint16 ip_checksum(const guint8 *ptr, int len); WS_DLL_PUBLIC guint16 ip_checksum_tvb(tvbuff_t *tvb, int offset, int len); +WS_DLL_PUBLIC int in_cksum_ret_partial(const vec_t *vec, int veclen, uint16_t *partial); + WS_DLL_PUBLIC int in_cksum(const vec_t *vec, int veclen); guint16 in_cksum_shouldbe(guint16 sum, guint16 computed_sum); |