From 6745eb64766a734e107bb754d8eecbb11b04708a Mon Sep 17 00:00:00 2001 From: rin Date: Tue, 28 Aug 2018 07:28:01 +0000 Subject: [PATCH] No need to update mlen also in the case of (mlen & 16) != 0. --- sys/netinet/cpu_in_cksum.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sys/netinet/cpu_in_cksum.c b/sys/netinet/cpu_in_cksum.c index 2e9f0e2ac2d2..91aa694d87cf 100644 --- a/sys/netinet/cpu_in_cksum.c +++ b/sys/netinet/cpu_in_cksum.c @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_in_cksum.c,v 1.1 2008/01/25 21:12:14 joerg Exp $ */ +/* $NetBSD: cpu_in_cksum.c,v 1.2 2018/08/28 07:28:01 rin Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger . * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.c,v 1.1 2008/01/25 21:12:14 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.c,v 1.2 2018/08/28 07:28:01 rin Exp $"); #include #include @@ -162,6 +162,10 @@ cpu_in_cksum(struct mbuf *m, int len, int off, uint32_t initial_sum) partial = 0; } } + /* + * mlen is not updated below as the remaining tests + * are using bit masks, which are not affected. + */ if (mlen & 16) { partial += *(uint16_t *)data; partial += *(uint16_t *)(data + 2); @@ -172,12 +176,7 @@ cpu_in_cksum(struct mbuf *m, int len, int off, uint32_t initial_sum) partial += *(uint16_t *)(data + 12); partial += *(uint16_t *)(data + 14); data += 16; - mlen -= 16; } - /* - * mlen is not updated below as the remaining tests - * are using bit masks, which are not affected. - */ if (mlen & 8) { partial += *(uint16_t *)data; partial += *(uint16_t *)(data + 2);