On Mon, Aug 28, 2017 at 07:11:48PM +0800, 孙建希 wrote: > all: > > I am reading tcp checksum code. > > uh->check = csum_tcpudp_magic(src, dst, len, IPPROTO_UDP, csum); > if (uh->check == 0) > uh->check = CSUM_MANGLED_0; > > #define CSUM_MANGLED_0 ((__force __sum16)0xffff) > uh->check will be 0, but will never be 0xFFFF. Why set uh->check to > CSUM_MANGLED_0? Hi, This is UDP checksum, not TCP. Just check out RFC 768. Following excerpt from the RFC document makes it clear. If the computed checksum is zero, it is transmitted as all ones (the equivalent in one's complement arithmetic). An all zero transmitted checksum value means that the transmitter generated no checksum (for debugging or for higher level protocols that don't care). > > _______________________________________________ > Kernelnewbies mailing list > Kernelnewbies@xxxxxxxxxxxxxxxxx > https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies