tcp/udp checksum on loopback interface
Subsystems (2)
Hello everybody
I am interested in the reliability of TCP and UDP using the loopback interface.
I found that there is no checksum verification on the body of packets transmitted through the loopback interface : http://kerneltrap.org/mailarchive/linux-netdev/2007/10/2/327241
I ran a simple test using iperf and wireshark and I indeed found the validation of the checksum is disabled at packets reception.
At the reception, I guess the piece of code responsible for this behaviour is (line 1196 of net/ipv4/udp.c, in udp_recvmsg() for UDP) :
if (skb_csum_unnecessary(skb))
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),msg->msg_iov, len);
Is this the responsible piece of code? If yes, where does the CHECKSUM_UNNECESSARY flag is set?
However, I am not sure whether the checksum is computed on the whole packet at emission.
In __ip_append_data (net/ipv4/ip_output.c), I found the flag csummode is at the beginning at CHECKSUM_NONE.
Then, it is augmented using the dev->features flag of the network device (e.g. the loopback interface).
As the loopback interface has the NETIF_F_NO_CSUM flag, csummode stays at CHECKSUM_NONE and the checksum is not computed on the body of the message. Can you confirm the checksum is computed only on the header of the packet when sending it through the loopback interface?
Finally, why this behaviour? Is it because you assume message can not get corrupted while staying on the same machine?
Thank you in advance
Pierre Louis Aublin
Quoted 9 lines · Pierre Louis Aublin
Hello everybody
I am interested in the reliability of TCP and UDP using the loopback interface.
I found that there is no checksum verification on the body of packets transmitted through the loopback interface :Finally, why this behaviour? Is it because you assume message can not get corrupted while staying on the same machine?
That's correct. We can save cpu time by not doing the checksum because we assume that our own hardware won't introduce errors (or if it does and we care about them we'll be monitoring the hardware for ECC errors anyways).
Chris
Signature · 5 lines
Chris Friesen Software Developer GENBAND [email protected] www.genband.com