From: William Herrin <bill@herrin.us>
To: users@dpdk.org
Subject: [dpdk-users] checksums?
Date: Thu, 4 Apr 2019 18:29:51 -0700 [thread overview]
Message-ID: <CAP-guGXWHNKvJ7F9WMP8b3-U9Qmu5Dk2wKRLu0Y9+DYvQFr3VQ@mail.gmail.com> (raw)
Hi folks,
I've recently done a deep dive in to IP checksums and I've run in to
something I don't understand. Any insight would be helpful.
rte_ipv4_cksum() is implemented as:
return (cksum == 0xffff) ? cksum : (uint16_t)~cksum;
Which means: if the sum is zero, return -0 (0xffff) never +0 (0x0000).
Welcome to the wonderful world of 1's complement arithmetic.
RFC 1624, on the other hand, says:
"In one's complement, there are two representations of zero: the all zero
and the all one bit values, often referred to as +0 and -0. One's
complement addition of non-zero inputs can produce -0 as a result, but
never +0. Since there is guaranteed to be at least one non-zero field in
the IP header, and the checksum field in the protocol header is the
complement of the sum, the checksum field can never contain ~(+0), which is
-0 (0xFFFF). It can, however, contain ~(-0), which is +0 (0x0000)."
Which I understand to mean that +0 (0x0000) is a legal value in an IPv4
checksum field, but -0 (0xffff) is not.
Is this a bug? Is there a more authoritative source for which zero is
correct in an IPv4 header? Please help me find the error in my
understanding.
Thanks,
Bill Herrin
--
William Herrin ................ herrin@dirtside.com bill@herrin.us
Dirtside Systems ......... Web: <http://www.dirtside.com/>
next reply other threads:[~2019-04-05 1:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-05 1:29 William Herrin [this message]
2019-04-05 9:31 ` N. Benes
2019-04-05 20:52 ` William Herrin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAP-guGXWHNKvJ7F9WMP8b3-U9Qmu5Dk2wKRLu0Y9+DYvQFr3VQ@mail.gmail.com \
--to=bill@herrin.us \
--cc=users@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).