opengnsys_ipxe/src/net
Michael Brown 8baefad659 [tcpip] Avoid generating positive zero for transmitted UDP checksums
TCP/IP checksum fields are one's complement values and therefore have
two possible representations of zero: positive zero (0x0000) and
negative zero (0xffff).

In RFC768, UDP over IPv4 exploits this redundancy to repurpose the
positive representation of zero (0x0000) to mean "no checksum
calculated"; checksums are optional for UDP over IPv4.

In RFC2460, checksums are made mandatory for UDP over IPv4.  The
wording of the RFC is such that the UDP header is mandated to use only
the negative representation of zero (0xffff), rather than simply
requiring the checksum to be correct but allowing for either
representation of zero to be used.

In RFC1071, an example algorithm is given for calculating the TCP/IP
checksum.  This algorithm happens to produce only the positive
representation of zero (0x0000); this is an artifact of the way that
unsigned arithmetic is used to calculate a signed one's complement
sum (and its final negation).

A common misconception has developed (exemplified in RFC1624) that
this artifact is part of the specification.  Many people have assumed
that the checksum field should never contain the negative
representation of zero (0xffff).

A sensible receiver will calculate the checksum over the whole packet
and verify that the result is zero (in whichever representation of
zero happens to be generated by the receiver's algorithm).  Such a
receiver will not care which representation of zero happens to be used
in the checksum field.

However, there are receivers in existence which will verify the
received checksum the hard way: by calculating the checksum over the
remainder of the packet and comparing the result against the checksum
field.  If the representation of zero used by the receiver's algorithm
does not match the representation of zero used by the transmitter (and
so placed in the checksum field), and if the receiver does not
explicitly allow for both representations to compare as equal, then
the receiver may reject packets with a valid checksum.

For UDP, the combined RFCs effectively mandate that we should generate
only the negative representation of zero in the checksum field.

For IP, TCP and ICMP, the RFCs do not mandate which representation of
zero should be used, but the misconceptions which have grown up around
RFC1071 and RFC1624 suggest that it would be least surprising to
generate only the positive representation of zero in the checksum
field.

Fix by ensuring that all of our checksum algorithms generate only the
positive representation of zero, and explicitly inverting this in the
case of transmitted UDP packets.

Reported-by: Wissam Shoukair <wissams@mellanox.com>
Tested-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2015-09-10 14:46:54 +01:00
..
80211 [netdevice] Allow network devices to disclaim IRQ support at runtime 2015-07-28 15:14:40 +01:00
infiniband [ipoib] Fix a race when chain-loading undionly.kpxe in IPoIB 2015-08-17 14:42:36 +01:00
oncrpc [nfs] Rewrite NFS URI handling 2014-05-18 21:53:39 +01:00
tcp [settings] Re-add "uristring" setting type 2015-08-25 13:31:46 +01:00
udp [dhcp] Do not skip ProxyDHCPREQUEST if next-server is empty 2015-08-26 16:08:58 +01:00
aoe.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 16:35:29 +00:00
arp.c [ipoib] Attempt to generate ARPs as needed to repopulate REMAC cache 2015-06-29 14:50:16 +01:00
dhcpopts.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:50:42 +00:00
dhcppkt.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
eapol.c [legal] Update FSF mailing address in GPL licence texts 2012-07-20 19:55:45 +01:00
eth_slow.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 16:35:29 +00:00
ethernet.c [ethernet] Add minimal support for receiving LLC frames 2015-06-25 15:28:42 +01:00
fakedhcp.c [pxe] Populate ciaddr in fake PXE Boot Server ACK packet 2015-09-01 21:24:02 +01:00
fc.c [build] Fix the REQUIRE_SYMBOL mechanism 2015-03-05 00:59:38 +00:00
fcels.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
fcns.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
fcoe.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
fcp.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
fragment.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
icmp.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
icmpv4.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
icmpv6.c [ipv6] Disambiguate received ICMPv6 errors 2015-05-11 12:45:14 +01:00
infiniband.c [ipoib] Fix a race when chain-loading undionly.kpxe in IPoIB 2015-08-17 14:42:36 +01:00
iobpad.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
ipv4.c [tcpip] Avoid generating positive zero for transmitted UDP checksums 2015-09-10 14:46:54 +01:00
ipv6.c [tcpip] Avoid generating positive zero for transmitted UDP checksums 2015-09-10 14:46:54 +01:00
ndp.c [ipv6] Do not set sin6_scope_id on source address 2014-05-23 14:11:17 +01:00
neighbour.c [neighbour] Return success when deferring a packet 2015-05-20 15:29:36 +01:00
netdev_settings.c [netdevice] Add missing bus types to netdev_fetch_bustype() 2015-03-18 16:42:39 +00:00
netdevice.c [netdevice] Avoid using zero as a network device index 2015-07-28 13:48:29 +01:00
nullnet.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
pccrc.c [peerdist] Include trimmed range within content information block 2015-07-28 15:22:26 +01:00
pccrd.c [peerdist] Add support for constructing and decoding discovery messages 2015-07-28 16:09:14 +01:00
peerblk.c [peerdist] Add individual block download mechanism 2015-08-17 13:24:39 +01:00
peerdisc.c [peerdist] Add segment discovery mechanism 2015-08-17 13:24:39 +01:00
peerdist.c [peerdist] Add support for PeerDist (aka BranchCache) HTTP content encoding 2015-08-17 13:24:40 +01:00
peermux.c [peerdist] Add block download multiplexer 2015-08-17 13:24:39 +01:00
ping.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
rarp.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
retry.c [retry] Colourise debug output 2015-03-05 11:25:54 +00:00
rndis.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
socket.c [legal] Relicense files under GPL2_OR_LATER_OR_UBDL 2015-03-02 14:17:31 +00:00
stp.c [stp] Fix interpretaton of hello time 2015-06-25 17:32:24 +01:00
tcp.c [tcp] Ensure FIN is actually sent if connection is closed while idle 2015-07-22 21:16:40 +01:00
tcpip.c [tcpip] Allow supported address families to be detected at runtime 2015-09-01 21:04:45 +01:00
tls.c [crypto] Support SHA-{224,384,512} in X.509 certificates 2015-08-02 16:54:24 +01:00
udp.c [tcpip] Avoid generating positive zero for transmitted UDP checksums 2015-09-10 14:46:54 +01:00
validator.c [xferbuf] Generalise to handle umalloc()-based buffers 2015-07-22 21:17:47 +01:00
vlan.c [netdevice] Allow network devices to disclaim IRQ support at runtime 2015-07-28 15:14:40 +01:00