From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id D2DE1A0679 for ; Fri, 5 Apr 2019 03:30:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 807551B3EA; Fri, 5 Apr 2019 03:30:11 +0200 (CEST) Received: from magic.dirtside.com (magic.dirtside.com [199.33.225.25]) by dpdk.org (Postfix) with ESMTP id E0E191B3D8 for ; Fri, 5 Apr 2019 03:30:08 +0200 (CEST) Received: from minoc.dirtside.com ([199.33.225.53]) by magic.dirtside.com (8.14.3/) with ESMTP id x351U35d010342 for ; Thu, 4 Apr 2019 18:30:03 -0700 X-Really-To: Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by minoc.dirtside.com (Postfix) with ESMTPSA id 08880EBD78 for ; Thu, 4 Apr 2019 18:30:03 -0700 (PDT) Received: by mail-pl1-f176.google.com with SMTP id y6so2086218pll.13 for ; Thu, 04 Apr 2019 18:30:03 -0700 (PDT) X-Gm-Message-State: APjAAAWUhXAhMhvL1HiNjzFCwVwg6vOtxEDpeo0CsOaaQ3rEOzJaHKru dURxkpR4cbPV10BZs56ovA5mLk5rS2ba0acZEfI= X-Google-Smtp-Source: APXvYqwlouyD25QCYrthsmR8vYxQiOgo/rOQpkuVbtN/O8OxJ9QIcfAUnMQh7swp5HwriTi5GrDyBrAVpz8ttQdo98o= X-Received: by 2002:a17:902:ab91:: with SMTP id f17mr5309952plr.151.1554427802650; Thu, 04 Apr 2019 18:30:02 -0700 (PDT) MIME-Version: 1.0 From: William Herrin Date: Thu, 4 Apr 2019 18:29:51 -0700 X-Gmail-Original-Message-ID: Message-ID: To: users@dpdk.org X-Spam-Checker: magic.dirtside.com X-Spam-Report: * -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 HTML_MESSAGE BODY: HTML included in message * 0.0 BAYES_50 BODY: Bayesian spam probability is 40 to 60% [score: 0.4996] X-Spam-Score: -1.8 Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-users] checksums? X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Sender: "users" 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: