From: Sascha Hauer <s.hauer@pengutronix.de>
To: Baruch Siach <baruch@tkos.co.il>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] net: fix checksum verification
Date: Mon, 12 Aug 2013 07:59:03 +0200 [thread overview]
Message-ID: <20130812055903.GG26614@pengutronix.de> (raw)
In-Reply-To: <2def65c701e7acd877f515ba07862495ad26e3df.1376195499.git.baruch@tkos.co.il>
On Sun, Aug 11, 2013 at 07:35:45AM +0300, Baruch Siach wrote:
> Checksum calculation on data including its own checksum (as is the case with
> IP headers) should give 0xffff before bit flipping. Current code works well
> for the correct checksum case, but fails to identify errors.
>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Applied, thanks
Sascha
> ---
> Untested.
>
> v2: net_checksum() doesn't flip bits. Fix accordingly.
>
> net/net.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/net.c b/net/net.c
> index 0bd9084..058a4d3 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -41,7 +41,7 @@ static unsigned int net_ip_id;
>
> int net_checksum_ok(unsigned char *ptr, int len)
> {
> - return net_checksum(ptr, len) + 1;
> + return net_checksum(ptr, len) == 0xffff;
> }
>
> uint16_t net_checksum(unsigned char *ptr, int len)
> --
> 1.8.4.rc1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2013-08-12 5:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-11 4:35 Baruch Siach
2013-08-12 5:59 ` Sascha Hauer [this message]
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=20130812055903.GG26614@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=baruch@tkos.co.il \
/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