Bill Fischofer(Bill-Fischofer-Linaro) replied on github web page: platform/linux-generic/include/odp_chksum_internal.h line 35 @@ -0,0 +1,59 @@ +/* Copyright (c) 2013, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP checksum - implementation internal + */ + +#ifndef ODP_CHKSUM_INTERNAL_H_ +#define ODP_CHKSUM_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Simple implementation of ones complement sum. + * Based on RFC1071 and its errata. + */ +static uint32_t _odp_chksum_ones_comp16_32(const void *p, uint32_t len, + odp_bool_t odd_offset) + +{ + uint32_t sum = 0; + const uint16_t *data = p; + + if (odd_offset) { + uint16_t left_over = 0; + + *(uint8_t *)&left_over = *(const uint8_t *)data; + sum = left_over; + data++;
Comment: This erroneously increments `data` by 2 when you want to increment it by 1 here so that it points to `p + 1`, not `p + 2`. Correct is `data = (const uint16_t *)((uintptr_t)p + 1);` > Bill Fischofer(Bill-Fischofer-Linaro) wrote: > The `odd_offset` parameter is unnecessary here. What matters is whether `p` > starts on an even or odd byte boundary since that determines whether you can > fetch `data` as `uint16_t` quantities without making unaligned storage > references. Each call to `_odp_chksum_ones_comp16_32()` is independent in > this regard, so it must always be determined anew for each call. >> Bill Fischofer(Bill-Fischofer-Linaro) wrote: >> `if (len > 1 && (uintptr_t)p % 2) ...` >>> Bill Fischofer(Bill-Fischofer-Linaro) wrote: >>> Drop use of `odd_offset` as noted earlier. >>>> Bill Fischofer(Bill-Fischofer-Linaro) wrote: >>>> Checkpatch flag: >>>> ``` >>>> WARNING: line over 80 characters >>>> #102: FILE: platform/linux-generic/odp_packet.c:2204: >>>> + ip_proto = parse_ipv4(prs, &parseptr, &offset, frame_len, >>>> chksums); >>>> total: 0 errors, 1 warnings, 0 checks, 163 lines checked >>>> ``` >>>>> Bill Fischofer(Bill-Fischofer-Linaro) wrote: >>>>> 2018 https://github.com/Linaro/odp/pull/389#discussion_r161935049 updated_at 2018-01-17 01:41:46