fix IP_ECN_set_ce
Subsystems (2)
RFC PATCH 1/1 fix IP_ECN_set_ce
From: Li RongQing <[email protected]>
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
--- include/net/inet_ecn.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
include/net/inet_ecn.h +4 -18
@@ -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 ; }
Signature · 1 line
1.7.10.4
Hello,
Quoted 29 lines · On Wed, 19 Dec 2012, [email protected] wrote:
From: Li RongQing <[email protected]>
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 — CE3. Remove the misunderstand comment
4. fix the checksum computation
Signed-off-by Li RongQing <[email protected]>--- include/net/inet_ecn.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)include/net/inet_ecn.h +0
-0@@ -73,27 +73,13 @@ static inline void INET_ECN_dontxmit(struct sock *sk)static inline int IP_ECN_set_ce (struct iphdr *iph) {
include/net/inet_ecn.h static inline void INET_ECN_dontxmit(struct sock *sk) · line 85
Quoted 10 lines
include/net/inet_ecn.h +0
-10-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 -*/
I think, the above comment explains how an
increment (iph->tos + 1) serves the purpose to check for ECT_1 and ECT_0, there is no such thing as addressing the next byte from header. It is just an optimized logic that avoids complex INET_ECN_is_XXX checks.
include/net/inet_ecn.h static inline void INET_ECN_dontxmit(struct sock *sk) · line 79
Quoted 5 lines
include/net/inet_ecn.h +3
-1-if (!(ecn &2 )) +u32 ecn = iph->tos &INET_ECN_MASK ; + +if (INET_ECN_is_ce (ecn) ||INET_ECN_is_not_ect (ecn))return !ecn;
May be return INET_ECN_is_ce(ecn) ?
Quoted 15 lines
include/net/inet_ecn.h +1
-7-/* -* 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 ; }Signature · 1 line
1.7.10.4
Regards
--
Julian Anastasov <[email protected]>
2012/12/19 Julian Anastasov <[email protected]>:
Quoted 43 lines
Hello,
Quoted 38 lines · On Wed, 19 Dec 2012, [email protected] wrote:
From: Li RongQing <[email protected]>
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 — CE3. Remove the misunderstand comment
4. fix the checksum computation
Signed-off-by Li RongQing <[email protected]>--- include/net/inet_ecn.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)include/net/inet_ecn.h +0
-9@@ -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
Quoted 8 lines
include/net/inet_ecn.h static inline void INET_ECN_dontxmit(struct sock *sk) · line 85
Quoted 1 line
include/net/inet_ecn.h +0
-1-*/ I think, the above comment explains how an
increment (iph->tos+ 1) serves the purpose to check forECT_1andECT_0, there is no such thing as addressing the next byte from header. It is just an optimized logic that avoids complexINET_ECN_is_XXXchecks.
Thanks for your reply.
Do you mean this comment are valuable?
Quoted 9 lines
include/net/inet_ecn.h static inline void INET_ECN_dontxmit(struct sock *sk) · line 79
Quoted 6 lines
include/net/inet_ecn.h +3
-1-if (!(ecn &2 )) +u32 ecn = iph->tos &INET_ECN_MASK ; + +if (INET_ECN_is_ce (ecn) ||INET_ECN_is_not_ect (ecn))return !ecn;May be return
INET_ECN_is_ce(ecn)?
I like to set the return value to void, since noone cares about the return value.
-Roy
Quoted 20 lines
Quoted 14 lines
include/net/inet_ecn.h +1
-8-/* -* 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 ; } --Quoted 1 line
1.7.10.4
Regards
--
Julian Anastasov <[email protected]>
Hello,
Quoted 13 lines · RongQing Li
Quoted 13 lines
Quoted 12 lines
static inline int
IP_ECN_set_ce(struct iphdr *iph){include/net/inet_ecn.h +0
-10-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 -*/
Quoted 8 lines
Quoted 6 lines
I think, the above comment explains how an
increment (iph->tos+ 1) serves the purpose to check forECT_1andECT_0, there is no such thing as addressing the next byte from header. It is just an optimized logic that avoids complexINET_ECN_is_XXXchecks.Thanks for your reply.
Do you mean this comment are valuable?
It looks better to me with the comment and the
original checks. But I can't comment the correctness of the other changes in your patch.
Quoted 11 lines
Quoted 8 lines
include/net/inet_ecn.h static inline void INET_ECN_dontxmit(struct sock *sk) · line 79
Quoted 5 lines
include/net/inet_ecn.h +3
-1-if (!(ecn &2 )) +u32 ecn = iph->tos &INET_ECN_MASK ; + +if (INET_ECN_is_ce (ecn) ||INET_ECN_is_not_ect (ecn))return !ecn;May be return
INET_ECN_is_ce(ecn)?I like to set the return value to void, since noone cares about the return value.
It is used by INET_ECN_set_ce and its users innet/sched/
Quoted 1 line
-Roy
Regards
--
Julian Anastasov <[email protected]>
2012/12/19 Julian Anastasov <[email protected]>:
Quoted 24 lines
Hello,
Quoted 19 lines · RongQing Li
Quoted 19 lines
include/net/inet_ecn.h static inline void INET_ECN_dontxmit(struct sock *sk) · line 85
Quoted 12 lines
static inline int
IP_ECN_set_ce(struct iphdr *iph){include/net/inet_ecn.h +0
-10-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 -*/ I think, the above comment explains how an
increment (iph->tos+ 1) serves the purpose to check forECT_1andECT_0, there is no such thing as addressing the next byte from header. It is just an optimized logic that avoids complexINET_ECN_is_XXXchecks.
Quoted 6 lines
Quoted 2 lines
Thanks for your reply.
Do you mean this comment are valuable?It looks better to me with the comment and the
original checks. But I can't comment the correctness of the other changes in your patch.
I do not know how they are useful, and how the original check works, since the value in comments are wrong, the correct is:
enum {
INET_ECN_NOT_ECT = 0,
INET_ECN_ECT_1 = 1,
INET_ECN_ECT_0 = 2,
INET_ECN_CE = 3,
INET_ECN_MASK = 3,
}; 00: Non ECN-Capable Transport — Non-ECT
10: ECN Capable Transport — ECT(0)
01: ECN Capable Transport — ECT(1)
11: Congestion Encountered — CE
-Roy
Quoted 22 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
include/net/inet_ecn.h +3
-1-if (!(ecn &2 )) +u32 ecn = iph->tos &INET_ECN_MASK ; + +if (INET_ECN_is_ce (ecn) ||INET_ECN_is_not_ect (ecn))return !ecn;Quoted 5 lines
Quoted 2 lines
May be return
INET_ECN_is_ce(ecn)?I like to set the return value to void, since noone cares about the return value.
It is used by
INET_ECN_set_ceand its users innet/sched/Quoted 1 line
-Roy
Regards
--
Julian Anastasov <[email protected]>
David Miller
maintainerFrom: RongQing Li <[email protected]>
Date: Wed, 19 Dec 2012 17:11:59 +0800
Quoted 44 lines
2012/12/19 Julian Anastasov <[email protected]>:
Quoted 24 lines
Hello,
Quoted 19 lines · RongQing Li
Quoted 19 lines
include/net/inet_ecn.h static inline void INET_ECN_dontxmit(struct sock *sk) · line 85
Quoted 12 lines
static inline int
IP_ECN_set_ce(struct iphdr *iph){include/net/inet_ecn.h +0
-10-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 -*/ I think, the above comment explains how an
increment (iph->tos+ 1) serves the purpose to check forECT_1andECT_0, there is no such thing as addressing the next byte from header. It is just an optimized logic that avoids complexINET_ECN_is_XXXchecks.Quoted 6 lines
Quoted 2 lines
Thanks for your reply.
Do you mean this comment are valuable?It looks better to me with the comment and the
original checks. But I can't comment the correctness of the other changes in your patch.I do not know how they are useful, and how the original check works, since the value in comments are wrong, the correct is:
enum { INET_ECN_NOT_ECT = 0, INET_ECN_ECT_1 = 1, INET_ECN_ECT_0 = 2, INET_ECN_CE = 3, INET_ECN_MASK = 3, };
Quoted 4 lines
00: Non ECN-Capable Transport ― Non-ECT
10: ECN Capable Transport ― ECT(0)
01: ECN Capable Transport ― ECT(1)
11: Congestion Encountered ― CE
You really don't understand the comment, it is saying what the incremented value corresponds to, ECN wise.
If iph->tos + 1 is 01, we had INET_ECN_NOT_ECT in iph->tos to begine with, and so on an so forth.
Because you are having so much trouble with this most fundamental aspect of this code, I have zero confidence in your being able to make reasonable changes here.
I am not applying this patch.
Quoted 12 lines · On Wed, 2012-12-19 at 14:21 +0800, [email protected] wrote:
From: Li RongQing <[email protected]>
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
Quoted 5 lines
3. Remove the misunderstand comment
4. fix the checksum computation
Signed-off-by Li RongQing <[email protected]>
This is total crap.
Its perfectly clear to me and compiler generates fast code.
If you don't understand this code, please don't touch it.