Bug 194697

Summary: incoming IP TOS bits get zeroed on mbufs that need checksumming
Product: Base System Reporter: Sebastian Kuzminsky <seb>
Component: kernAssignee: freebsd-net (Nobody) <net>
Status: Closed FIXED    
Severity: Affects Some People CC: hiren
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
save & restore IP TOS field when computing TCP checksum none

Description Sebastian Kuzminsky 2014-10-29 23:15:44 UTC
Created attachment 148780 [details]
save & restore IP TOS field when computing TCP checksum

On mbufs that don't have the CSUM_DATA_VALID flag set, tcp_input() needs to compute the TCP checksum itself.

The TCP checksum includes some but not all fields from the IP header.

tcp_input() zeroes the fields of the IP header that are not to be included in the checksum, then checksums the entire packet (IP header, TCP header, and TCP data), then restores the IP header fields it will need later.

The bug is that the IP TOS field was not restored, so the later read of it returned a zeroed byte instead of the incoming packet's actual TOS value.

The attached patch contains a suggested fix that resolves the issue for me.
Comment 1 Sebastian Kuzminsky 2014-10-29 23:16:26 UTC
This bugfix is also available as a github Pull Request:

https://github.com/freebsd/freebsd/pull/12
Comment 2 Hiren Panchasara freebsd_committer freebsd_triage 2017-01-06 00:34:03 UTC
Thanks for your submission.
https://svnweb.freebsd.org/base?view=revision&revision=306458