From: Ulrich.Weigand@de.ibm.com
To: alan@lxorguk.ukuu.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: IP checksum broken in 2.2 .18 ip_decrease_ttl
Date: Wed, 16 May 2001 21:49:03 +0200 [thread overview]
Message-ID: <C1256A4E.006CDEF5.00@d12mta11.de.ibm.com> (raw)
Hi Alan,
the fast IP checksum update in ip_decrease_ttl appears
to be broken (at least on big endian machines) since 2.2.18.
Even on little endian machines IMO the overflow is incorrect
in two cases:
0xfeff goes to 0x0000 instead of 0xffff
0xffff goes to 0x0000 instead of 0x0100
On big endian machines, the overflow from the high byte
is never carried over correctly:
0xfeff goes to 0x0000 instead of 0xffff
0xff00 goes to 0x0000 instead of 0x0001
0xff01 goes to 0x0001 instead of 0x0002
...
0xffff goes to 0x00ff instead of 0x0100
The following patch reverts the ip_decrease_ttl routine
to the pre-2.2.18 level, which might be less efficient,
but should at least be correct ...
diff -urN linux-2.2.19/include/net/ip.h linux-2.2.19-s390/include/net/ip.h
--- linux-2.2.19/include/net/ip.h Sun Mar 25 18:37:40 2001
+++ linux-2.2.19-s390/include/net/ip.h Wed May 16 14:51:03 2001
@@ -171,8 +171,10 @@
int ip_decrease_ttl(struct iphdr *iph)
{
u16 check = iph->check;
- check += __constant_htons(0x0100);
- iph->check = check + ((check>=0xFFFF) ? 1 : 0);
+ check = ntohs(check) + 0x0100;
+ if ((check & 0xFF00) == 0)
+ check++; /* carry overflow */
+ iph->check = htons(check);
return --iph->ttl;
}
Mit freundlichen Gruessen / Best Regards
Ulrich Weigand
--
Dr. Ulrich Weigand
Linux for S/390 Design & Development
IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
Phone: +49-7031/16-3727 --- Email: Ulrich.Weigand@de.ibm.com
next reply other threads:[~2001-05-16 19:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-16 19:49 Ulrich.Weigand [this message]
2001-05-16 20:48 ` David S. Miller
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=C1256A4E.006CDEF5.00@d12mta11.de.ibm.com \
--to=ulrich.weigand@de.ibm.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®