On Mon, 17 Oct 2022 19:57:58 +1100 David Gibson <david(a)gibson.dropbear.id.au> wrote:We calculate IPv4 header checksums in at least two places, in dhcp() and in tap_ip_send. Add a helper to handle this calculation in both places. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- checksum.c | 6 ++++++ checksum.h | 1 + dhcp.c | 3 +-- tap.c | 3 +-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/checksum.c b/checksum.c index 72f1cfb..f25a96a 100644 --- a/checksum.c +++ b/checksum.c @@ -114,6 +114,12 @@ uint16_t csum_unaligned(const void *buf, size_t len, uint32_t init) return (uint16_t)~csum_fold(sum_16b(buf, len) + init); }/** * csum_ip4_header() - Calculate and set IPv4 header checksum * @iph: IPv4 header */ ...I just tried to run Doxygen, I think it would be nice to have eventually (especially for DOT call graphs), things don't look too bad.+void csum_ip4_header(struct iphdr *ip4hr) +{ + ip4hr->check = 0; + ip4hr->check = csum_unaligned(ip4hr, (size_t)ip4hr->ihl * 4, 0);iph, for consistency. -- Stefano