From: roy.qing.li@gmail.com
To: netdev@vger.kernel.org
Subject: [RFC PATCH] fix IP_ECN_set_ce
Date: Wed, 19 Dec 2012 14:21:35 +0800 [thread overview]
Message-ID: <1355898095-7444-1-git-send-email-roy.qing.li@gmail.com> (raw)
From: Li RongQing <roy.qing.li@gmail.com>
1. ECN uses the two least significant (right-most) bits of the DiffServ
field in the IPv4, so it should be in iph->tos, not in (iph->tos+1)
2. When setting CE, we should check if ECN Capable Transport supports,
both 10 and 01 mean ECN Capable Transport, so only check 10 is not enough
00: Non ECN-Capable Transport — Non-ECT
10: ECN Capable Transport — ECT(0)
01: ECN Capable Transport — ECT(1)
11: Congestion Encountered — CE
3. Remove the misunderstand comment
4. fix the checksum computation
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
include/net/inet_ecn.h | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index aab7375..545a683 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -73,27 +73,13 @@ static inline void INET_ECN_dontxmit(struct sock *sk)
static inline int IP_ECN_set_ce(struct iphdr *iph)
{
- u32 check = (__force u32)iph->check;
- u32 ecn = (iph->tos + 1) & INET_ECN_MASK;
-
- /*
- * After the last operation we have (in binary):
- * INET_ECN_NOT_ECT => 01
- * INET_ECN_ECT_1 => 10
- * INET_ECN_ECT_0 => 11
- * INET_ECN_CE => 00
- */
- if (!(ecn & 2))
+ u32 ecn = iph->tos & INET_ECN_MASK;
+
+ if (INET_ECN_is_ce(ecn) || INET_ECN_is_not_ect(ecn))
return !ecn;
- /*
- * The following gives us:
- * INET_ECN_ECT_1 => check += htons(0xFFFD)
- * INET_ECN_ECT_0 => check += htons(0xFFFE)
- */
- check += (__force u16)htons(0xFFFB) + (__force u16)htons(ecn);
+ csum_replace2(&iph->check, iph->tos, iph->tos|INET_ECN_CE);
- iph->check = (__force __sum16)(check + (check>=0xFFFF));
iph->tos |= INET_ECN_CE;
return 1;
}
--
1.7.10.4
next reply other threads:[~2012-12-19 6:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 6:21 roy.qing.li [this message]
2012-12-19 8:11 ` [RFC PATCH] fix IP_ECN_set_ce Julian Anastasov
2012-12-19 8:41 ` RongQing Li
2012-12-19 8:58 ` Julian Anastasov
2012-12-19 9:11 ` RongQing Li
2012-12-19 9:31 ` David Miller
2012-12-19 16:14 ` Eric Dumazet
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=1355898095-7444-1-git-send-email-roy.qing.li@gmail.com \
--to=roy.qing.li@gmail.com \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).