Netdev List
 help / color / mirror / Atom feed
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
To: dccp@vger.kernel.org
Cc: netdev@vger.kernel.org, Gerrit Renker <gerrit@erg.abdn.ac.uk>
Subject: dccp-test-tree [PATCH 5/10] net: Mask out ECN bits when setting TOS/TCLASS
Date: Sun,  9 Aug 2009 21:48:42 +0200	[thread overview]
Message-ID: <1249847327-6792-6-git-send-email-gerrit@erg.abdn.ac.uk> (raw)
In-Reply-To: <1249847327-6792-5-git-send-email-gerrit@erg.abdn.ac.uk>

This patch is needed by the AF-independent approach to provide DCCPv4/6
ECN support. Since this approach handles ECN at in the module, the patch
disables user-side manipulation of ECN bits via TOS/TCLASS.

However, it also fixes a bug occurring in SCTPv6: when passing values that
contain 0x1 in the ECN bits, the internal value of ECT(0) gets turned into
0x3 = CE, i.e. it suggests to the other side that congestion was experienced.

I am working on these issues and would greatly appreciate feedback/suggestions.
(NB - not touched datagram_send_ctl(), since it is used only by udpv6/rawv6).

An alternative for modifying ECN bits in user space is in a subsequent patch.

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
 net/ipv4/ip_sockglue.c   |    7 ++++---
 net/ipv6/ipv6_sockglue.c |    2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -27,6 +27,7 @@
 #include <net/ip.h>
 #include <net/icmp.h>
 #include <net/tcp_states.h>
+#include <net/inet_ecn.h>
 #include <linux/udp.h>
 #include <linux/igmp.h>
 #include <linux/netfilter.h>
@@ -550,9 +551,9 @@ static int do_ip_setsockopt(struct sock *sk, int level,
 			inet->cmsg_flags &= ~IP_CMSG_ORIGDSTADDR;
 		break;
 	case IP_TOS:	/* This sets both TOS and Precedence */
-		if (sk->sk_type == SOCK_STREAM) {
-			val &= ~3;
-			val |= inet->tos & 3;
+		if (sk->sk_type != SOCK_RAW) {
+			val &= ~INET_ECN_MASK;
+			val |= inet->tos & INET_ECN_MASK;
 		}
 		if (inet->tos != val) {
 			inet->tos = val;
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -318,6 +318,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
 		/* RFC 3542, 6.5: default traffic class of 0x0 */
 		if (val == -1)
 			val = 0;
+		if (sk->sk_type != SOCK_RAW)
+			val &= ~INET_ECN_MASK;
 		np->tclass = val;
 		retv = 0;
 		break;
-- 
1.6.0.rc2


  reply	other threads:[~2009-08-09 19:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <dccp_test_tree_sending_ecn_for_review>
2009-08-09 19:48 ` [PATCH 0/10]: DCCPv4/6 support for ECN/ECT(0) Gerrit Renker
2009-08-09 19:48   ` dccp-test-tree [PATCH 1/10]: Put the ECN bits into the dccp_skb_cb Gerrit Renker
2009-08-09 19:48     ` dccp-test-tree [PATCH 2/10] Add sysctl to toggle the local support for ECN Gerrit Renker
2009-08-09 19:48       ` dccp-test-tree [PATCH 3/10] Add feature-negotiation handler for ECN-Incapable feature Gerrit Renker
2009-08-09 19:48         ` dccp-test-tree [PATCH 4/10] net: Hack to enable IPv6 ECN support Gerrit Renker
2009-08-09 19:48           ` Gerrit Renker [this message]
2009-08-09 19:48             ` dccp-test-tree [PATCH 6/10] Extend the loss interval code to support ECN events Gerrit Renker
2009-08-09 19:48               ` dccp-test-tree [PATCH 7/10] Extend the packet-history code to support ECN-marked-CE events Gerrit Renker
2009-08-09 19:48                 ` dccp-test-tree [PATCH 8/10] ccid-2: Ack Vector ECN support Gerrit Renker
2009-08-09 19:48                   ` dccp-test-tree [PATCH 9/10] Userspace support for modifying the ECN bits of Data/DataAck packets Gerrit Renker
2009-08-09 19:48                     ` dccp-test-tree [PATCH 10/10] Userspace support for reading ECN bits Gerrit Renker

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=1249847327-6792-6-git-send-email-gerrit@erg.abdn.ac.uk \
    --to=gerrit@erg.abdn.ac.uk \
    --cc=dccp@vger.kernel.org \
    --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