This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2.10-357-ga0902db 1/1] Add DSCP/ECN to netinet/ip.h
- From: Philip Prindeville <philipp at redfish-solutions dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Sun, 25 Oct 2009 11:46:04 -0600
- Subject: [PATCH 2.10-357-ga0902db 1/1] Add DSCP/ECN to netinet/ip.h
Most of the Internet has deprecated TOS and Precedence markings, in favor of
DSCP... yet DSCP definitions aren't in /usr/include to allow sockets-based
programs to facilitate such markings (and in doing so, improve the overall
performance of the Internet by more correctly utilizing available resources).
DSCP is obviously useful. ECN is included here for completeness (since ip_tos
is an u_int8_t, all bits should be described). Some diagnostic programs such
as tcpdump can use these definitions.
Currently, no UNIX/POSIX OS out there implements these definitions. Most
programs get around this by having their own definitions locally (e.g. Asterisk).
This patch entails just defining the bit-field values of DSCP and ECN as per
the relevant RFC's, which I'll quote here for completeness. Note that the RFC's
don't define a formal API, just the requisite values and their suggested usage.
The definitions from RFC-791 are already present:
/*
* Definitions for IP type of service (ip_tos)
*/
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
#define IPTOS_LOWDELAY 0x10
#define IPTOS_THROUGHPUT 0x08
#define IPTOS_RELIABILITY 0x04
#define IPTOS_LOWCOST 0x02
#define IPTOS_MINCOST IPTOS_LOWCOST
/*
* Definitions for IP precedence (also in ip_tos) (hopefully unused)
*/
#define IPTOS_PREC_MASK 0xe0
#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
#define IPTOS_PREC_NETCONTROL 0xe0
#define IPTOS_PREC_INTERNETCONTROL 0xc0
#define IPTOS_PREC_CRITIC_ECP 0xa0
#define IPTOS_PREC_FLASHOVERRIDE 0x80
#define IPTOS_PREC_FLASH 0x60
#define IPTOS_PREC_IMMEDIATE 0x40
#define IPTOS_PREC_PRIORITY 0x20
#define IPTOS_PREC_ROUTINE 0x00
but the referenced RFC's (3168, 2597, and 2598) all specify that they
supersede RFC-791 in the relevant definitions.
Quoting those sections here:
[RFC-2597]
6. Recommended Codepoints
Recommended codepoints for the four general use AF classes are given
below. These codepoints do not overlap with any other general use PHB
groups.
The RECOMMENDED values of the AF codepoints are as follows: AF11 = '
001010', AF12 = '001100', AF13 = '001110', AF21 = '010010', AF22 = '
010100', AF23 = '010110', AF31 = '011010', AF32 = '011100', AF33 = '
011110', AF41 = '100010', AF42 = '100100', and AF43 = '100110'. The
table below summarizes the recommended AF codepoint values.
Class 1 Class 2 Class 3 Class 4
+----------+----------+----------+----------+
Low Drop Prec | 001010 | 010010 | 011010 | 100010 |
Medium Drop Prec | 001100 | 010100 | 011100 | 100100 |
High Drop Prec | 001110 | 010110 | 011110 | 100110 |
+----------+----------+----------+----------+
[RFC-2598]
2.3 Recommended codepoint for this PHB
Codepoint 101110 is recommended for the EF PHB.
[RFC-3168]
5. Explicit Congestion Notification in IP
This document specifies that the Internet provide a congestion
indication for incipient congestion (as in RED and earlier work
[RJ90]) where the notification can sometimes be through marking
packets rather than dropping them. This uses an ECN field in the IP
header with two bits, making four ECN codepoints, '00' to '11'. The
ECN-Capable Transport (ECT) codepoints '10' and '01' are set by the
data sender to indicate that the end-points of the transport protocol
are ECN-capable; we call them ECT(0) and ECT(1) respectively. The
phrase "the ECT codepoint" in this documents refers to either of the
two ECT codepoints. Routers treat the ECT(0) and ECT(1) codepoints
as equivalent. Senders are free to use either the ECT(0) or the
ECT(1) codepoint to indicate ECT, on a packet-by-packet basis.
The use of both the two codepoints for ECT, ECT(0) and ECT(1), is
motivated primarily by the desire to allow mechanisms for the data
sender to verify that network elements are not erasing the CE
codepoint, and that data receivers are properly reporting to the
sender the receipt of packets with the CE codepoint set, as required
by the transport protocol. Guidelines for the senders and receivers
to differentiate between the ECT(0) and ECT(1) codepoints will be
addressed in separate documents, for each transport protocol. In
particular, this document does not address mechanisms for TCP end-
nodes to differentiate between the ECT(0) and ECT(1) codepoints.
Protocols and senders that only require a single ECT codepoint SHOULD
use ECT(0).
The not-ECT codepoint '00' indicates a packet that is not using ECN.
The CE codepoint '11' is set by a router to indicate congestion to
the end nodes. Routers that have a packet arriving at a full queue
drop the packet, just as they do in the absence of ECN.
+-----+-----+
| ECN FIELD |
+-----+-----+
ECT CE [Obsolete] RFC 2481 names for the ECN bits.
0 0 Not-ECT
0 1 ECT(1)
1 0 ECT(0)
1 1 CE
Figure 1: The ECN Field in IP.
So this patch pretty much just 'lifts' the bitfield definitions from these
RFC's and incorporates them into the header in the same way that was previously
done for RFC-791 and TOS/Precedence.
========
2009-10-14 Philip Prindeville <philipp@redfish-solutions.com>
* sysdeps/include/generic/netinet/ip.h: Add DSCP definitions
for ip_tos (per RFC's 2597 and 2598). Add ECN definitions (per
RFC 3168).
Fixes: http://sourceware.org/bugzilla/show_bug.cgi?id=10789
---
diff --git a/sysdeps/generic/netinet/ip.h b/sysdeps/generic/netinet/ip.h
index fc91440..1977fce 100644
--- a/sysdeps/generic/netinet/ip.h
+++ b/sysdeps/generic/netinet/ip.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,93,95,96,97,98,99,2000,2009 Free Software
+ Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -153,7 +154,43 @@ struct ip_timestamp
#define IP_MAXPACKET 65535 /* maximum packet size */
/*
- * Definitions for IP type of service (ip_tos)
+ * Definitions for Explicit Congestion Notification (ECN)
+ *
+ * Taken from RFC-3168, Section 5.
+ */
+
+#define IPTOS_ECN_MASK 0x03
+#define IPTOS_ECN(x) ((x) & IPTOS_ECN_MASK)
+#define IPTOS_ECN_NOT_ECT 0x00
+#define IPTOS_ECN_ECT1 0x01
+#define IPTOS_ECN_ECT0 0x02
+#define IPTOS_ECN_CE 0x03
+
+/*
+ * Definitions for IP differentiated services code points (DSCP)
+ *
+ * Taken from RFC-2597, Section 6 and RFC-2598, Section 2.3.
+ */
+
+#define IPTOS_DSCP_MASK 0xfc
+#define IPTOS_DSCP(x) ((x) & IPTOS_DSCP_MASK)
+#define IPTOS_DSCP_AF11 0x28
+#define IPTOS_DSCP_AF12 0x30
+#define IPTOS_DSCP_AF13 0x38
+#define IPTOS_DSCP_AF21 0x48
+#define IPTOS_DSCP_AF22 0x50
+#define IPTOS_DSCP_AF23 0x58
+#define IPTOS_DSCP_AF31 0x68
+#define IPTOS_DSCP_AF32 0x70
+#define IPTOS_DSCP_AF33 0x78
+#define IPTOS_DSCP_AF41 0x88
+#define IPTOS_DSCP_AF42 0x90
+#define IPTOS_DSCP_AF43 0x98
+#define IPTOS_DSCP_EF 0xb8
+
+/*
+ * Definitions for IP type of service (ip_tos) [deprecated; use DSCP
+ * definitions above instead.]
*/
#define IPTOS_TOS_MASK 0x1E
#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
@@ -164,7 +201,7 @@ struct ip_timestamp
#define IPTOS_MINCOST IPTOS_LOWCOST
/*
- * Definitions for IP precedence (also in ip_tos) (hopefully unused)
+ * Definitions for IP precedence (also in ip_tos) [also deprecated.]
*/
#define IPTOS_PREC_MASK 0xe0
#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>