net: Correct TOS priority mapping for DSCP EF
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): =1410783785.7106.154.camel@edumazet-glaptop2.roam.corp.google.com
PATCH 1/1 net: Correct TOS priority mapping for DSCP EF
The DSCP value for Expedited Forwarding (EF) got mapped to internal priority TC_PRIO_INTERACTIVE_BULK, which ends up in medium/best-effort priority band(1) of pfifo_fast
This patch change TOS mapping, causing the DSCP EF to get mapped to TC_PRIO_INTERACTIVE, which end up in high priority band(0) of pfifo_fast.
While performing this policy change, document the TOS to priority lookup table ip_tos2prio[16]. Thus, making it easier to understand this table for reviewers.
The DSCP AFxx mappings are also suboptimal, but we choose not to change those mapping, only document the mapping in the code.
---
net/ipv4/route.c | 43 +++++++++++++++++++++++++++---------------- 1 files changed, 27 insertions(+), 16 deletions(-)
net/ipv4/route.c +27 -16
@@ -168,23 +168,34 @@ static struct dst_ops ipv4_dst_ops = {#define ECN_OR_COST (class) TC_PRIO_##class +/* lookup: tos bitmasked 0x1E and shifted right (tos>>1) in rt_tos2priority() */ const __u8 ip_tos2prio[16 ] = { -TC_PRIO_BESTEFFORT , -ECN_OR_COST (BESTEFFORT ), -TC_PRIO_BESTEFFORT , -ECN_OR_COST (BESTEFFORT ), -TC_PRIO_BULK , -ECN_OR_COST (BULK ), -TC_PRIO_BULK , -ECN_OR_COST (BULK ), -TC_PRIO_INTERACTIVE , -ECN_OR_COST (INTERACTIVE ), -TC_PRIO_INTERACTIVE , -ECN_OR_COST (INTERACTIVE ), -TC_PRIO_INTERACTIVE_BULK , -ECN_OR_COST (INTERACTIVE_BULK ), -TC_PRIO_INTERACTIVE_BULK , -ECN_OR_COST (INTERACTIVE_BULK ) +/* Desc format: two least-significant bits should have been +* for ECN (see "-" split). The hex values represent the TOS +* byte in IP-header (masked with 0x1E) +*/ +TC_PRIO_BESTEFFORT ,/* [0] 000-00 = 0x00 default */ +ECN_OR_COST (BESTEFFORT ),/* [1] 000-10 = 0x02 TOS-"mincost" */ +TC_PRIO_BESTEFFORT ,/* [2] 001-00 = 0x04 TOS-"reliability" */ +ECN_OR_COST (BESTEFFORT ),/* [3] 001-10 = 0x06 */ +TC_PRIO_BULK ,/* [4] 010-00 = 0x08 TOS-"throughput" +* (incidentally maps) DSCP(AF11+21+31+41) +*/ +ECN_OR_COST (BULK ),/* [5] 010-10 = 0x0A */ +TC_PRIO_BULK ,/* [6] 011-00 = 0x0C */ +ECN_OR_COST (BULK ),/* [7] 011-10 = 0x0E */ +TC_PRIO_INTERACTIVE ,/* [8] 100-00 = 0x10 TOS-"lowdelay" +* (incidentally maps) DSCP(AF12+22+32+42) +*/ +ECN_OR_COST (INTERACTIVE ),/* [9] 100-10 = 0x12 */ +TC_PRIO_INTERACTIVE ,/*[10] 101-00 = 0x14 */ +ECN_OR_COST (INTERACTIVE ),/*[11] 101-10 = 0x16 */ +TC_PRIO_INTERACTIVE_BULK ,/*[12] 110-00 = 0x18 +* (incidentally maps) DSCP(AF13+23+33+43) +*/ +ECN_OR_COST (INTERACTIVE_BULK ),/*[13] 110-10 = 0x1A */ +TC_PRIO_INTERACTIVE ,/*[14] 111-00 = 0x1C maps DSCP(EF) */ +ECN_OR_COST (INTERACTIVE_BULK )/*[15] 111-10 = 0x1E */ };EXPORT_SYMBOL (ip_tos2prio);
David Miller
maintainerFrom: Jesper Dangaard Brouer <[email protected]>
Date: Mon, 15 Sep 2014 16:50:47 +0200
Quoted 8 lines
The DSCP value for Expedited Forwarding (EF) got mapped to internal priority
TC_PRIO_INTERACTIVE_BULK, which ends up in medium/best-effort priority band(1) ofpfifo_fastThis patch change TOS mapping, causing the DSCP EF to get mapped to
TC_PRIO_INTERACTIVE, which end up in high priority band(0) ofpfifo_fast.
Quoted 8 lines
While performing this policy change, document the TOS to priority lookup table ip_tos2prio[16]. Thus, making it easier to understand this table for reviewers.
The DSCP AFxx mappings are also suboptimal, but we choose not to change those mapping, only document the mapping in the code.
Signed-off-by Jesper Dangaard Brouer <[email protected]>
I don't think you can make these mappings given that we don't take the code-service bits of the TOS into account when we use this table at all.
The DSCP values are composed in the top 6 bits, but we are only considering the low 3 bits of that field (along with the high bit of "CU", which is part of the ECN value and thus "don't care")
We should only match EF when the top two DSCP bits are "10".
This table and it's relationship to DSCP is confusing (but your comments in this patch helped a lot, thanks). Also it isn't clear why we don't interpret the full DSCP field.
ECN_OR_COST() does nothing but serve as an annotation meaning that this value has an ECN bit set.
So why don't we shift down by two bits, to get rid of the entire "CU" field, and consider all 6 bits of the DSCP value in the ip_tos2prio[] table?