]> git.baikalelectronics.ru Git - kernel.git/commit
net: qualcomm: rmnet: IPv4 header has zero checksum
authorAlex Elder <elder@linaro.org>
Fri, 11 Jun 2021 19:05:26 +0000 (14:05 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Jun 2021 20:37:49 +0000 (13:37 -0700)
commit94ec9b494d8626e0addb8b6aa520ae2e6abc649c
treed2e79c74692ee4c30413d334c2db4717c9f4e1f7
parent9f690243b66772ffa0cfdd7ae9f832c24e974e82
net: qualcomm: rmnet: IPv4 header has zero checksum

In rmnet_map_ipv4_dl_csum_trailer(), an illegal checksum subtraction
is done, subtracting hdr_csum (in host byte order) from csum_value (in
network byte order).  Despite being illegal, it generally works,
because it turns out the value subtracted is (or should be) always 0,
which has the same representation in either byte order.

Doing illegal operations is not good form though, so fix this by
verifying the IP header checksum early in that function.  If its
checksum is non-zero, the packet will be bad, so just return an
error.  This will cause the packet to passed to the IP layer where
it can be dropped.

Thereafter, there is no need subtract the IP header checksum from
the checksum value in the trailer because we know it is zero.
Add a comment explaining this.

This type of packet error is different from other types, so add a
new statistics counter to track this condition.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h
drivers/net/ethernet/qualcomm/rmnet/rmnet_map_data.c
drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c