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 1/10]: Put the ECN bits into the dccp_skb_cb
Date: Sun, 9 Aug 2009 21:48:38 +0200 [thread overview]
Message-ID: <1249847327-6792-2-git-send-email-gerrit@erg.abdn.ac.uk> (raw)
In-Reply-To: <1249847327-6792-1-git-send-email-gerrit@erg.abdn.ac.uk>
This adds the two bits from the IPv4 TOS or IPv6 Traffic Class field into the
dccp_skb_cb.
To make the required room, dccp_opt_len is curtailed to 10 bits, since the
DCCP option length can not exceed 1020 < 2^10-1.
Further changes:
----------------
* added code to copy the TOS/traffic class field contents,
* supplied a utility function that checks for CE,
* deleted duplicate inclusion of headers.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
net/dccp/dccp.h | 10 +++++++++-
net/dccp/ipv4.c | 5 ++---
net/dccp/ipv6.c | 15 ++++++++-------
3 files changed, 19 insertions(+), 11 deletions(-)
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -14,6 +14,7 @@
#include <linux/dccp.h>
#include <linux/ktime.h>
+#include <net/inet_ecn.h>
#include <net/snmp.h>
#include <net/sock.h>
#include <net/tcp.h>
@@ -355,6 +356,7 @@ static inline int dccp_bad_service_code(const struct sock *sk,
* dccp_skb_cb - DCCP per-packet control information
* @dccpd_type: one of %dccp_pkt_type (or unknown)
* @dccpd_ccval: CCVal field (5.1), see e.g. RFC 4342, 8.1
+ * @dccpd_ecn: ECN bits read from the IPv4 TOS / IPv6 Traffic Class field
* @dccpd_reset_code: one of %dccp_reset_codes
* @dccpd_reset_data: Data1..3 fields (depend on @dccpd_reset_code)
* @dccpd_opt_len: total length of all options (5.8) in the packet
@@ -371,15 +373,21 @@ struct dccp_skb_cb {
} header;
__u8 dccpd_type:4;
__u8 dccpd_ccval:4;
+ __u8 dccpd_ecn:2;
__u8 dccpd_reset_code,
dccpd_reset_data[3];
- __u16 dccpd_opt_len;
+ __u16 dccpd_opt_len:10;
__u64 dccpd_seq;
__u64 dccpd_ack_seq;
};
#define DCCP_SKB_CB(__skb) ((struct dccp_skb_cb *)&((__skb)->cb[0]))
+static inline bool dccp_skb_is_ecn_ce(const struct sk_buff *skb)
+{
+ return (DCCP_SKB_CB(skb)->dccpd_ecn & INET_ECN_MASK) == INET_ECN_CE;
+}
+
/* RFC 4340, sec. 7.7 */
static inline int dccp_non_data_packet(const struct sk_buff *skb)
{
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -10,16 +10,13 @@
* 2 of the License, or (at your option) any later version.
*/
-#include <linux/dccp.h>
#include <linux/icmp.h>
#include <linux/module.h>
-#include <linux/skbuff.h>
#include <linux/random.h>
#include <net/icmp.h>
#include <net/inet_common.h>
#include <net/inet_hashtables.h>
-#include <net/inet_sock.h>
#include <net/protocol.h>
#include <net/sock.h>
#include <net/timewait_sock.h>
@@ -783,6 +780,8 @@ static int dccp_v4_rcv(struct sk_buff *skb)
goto discard_it;
iph = ip_hdr(skb);
+ DCCP_SKB_CB(skb)->dccpd_ecn = iph->tos & INET_ECN_MASK;
+
/* Step 1: If header checksum is incorrect, drop packet and return */
if (dccp_v4_csum_finish(skb, iph->saddr, iph->daddr)) {
DCCP_WARN("dropped packet with invalid checksum\n");
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -19,7 +19,6 @@
#include <net/addrconf.h>
#include <net/inet_common.h>
#include <net/inet_hashtables.h>
-#include <net/inet_sock.h>
#include <net/inet6_connection_sock.h>
#include <net/inet6_hashtables.h>
#include <net/ip6_route.h>
@@ -783,6 +782,7 @@ discard:
static int dccp_v6_rcv(struct sk_buff *skb)
{
+ struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
const struct dccp_hdr *dh;
struct sock *sk;
int min_cov;
@@ -792,6 +792,8 @@ static int dccp_v6_rcv(struct sk_buff *skb)
if (dccp_invalid_packet(skb))
goto discard_it;
+ dcb->dccpd_ecn = ipv6_get_dsfield(ipv6_hdr(skb)) & INET_ECN_MASK;
+
/* Step 1: If header checksum is incorrect, drop packet and return. */
if (dccp_v6_csum_finish(skb, &ipv6_hdr(skb)->saddr,
&ipv6_hdr(skb)->daddr)) {
@@ -801,13 +803,13 @@ static int dccp_v6_rcv(struct sk_buff *skb)
dh = dccp_hdr(skb);
- DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(dh);
- DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
+ dcb->dccpd_seq = dccp_hdr_seq(dh);
+ dcb->dccpd_type = dh->dccph_type;
if (dccp_packet_without_ack(skb))
- DCCP_SKB_CB(skb)->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;
+ dcb->dccpd_ack_seq = DCCP_PKT_WITHOUT_ACK_SEQ;
else
- DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
+ dcb->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
/* Step 2:
* Look up flow ID in table and get corresponding socket */
@@ -863,8 +865,7 @@ no_dccp_socket:
* Drop packet and return
*/
if (dh->dccph_type != DCCP_PKT_RESET) {
- DCCP_SKB_CB(skb)->dccpd_reset_code =
- DCCP_RESET_CODE_NO_CONNECTION;
+ dcb->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION;
dccp_v6_ctl_send_reset(sk, skb);
}
--
1.6.0.rc2
next prev parent reply other threads:[~2009-08-09 19:52 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 ` Gerrit Renker [this message]
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 ` dccp-test-tree [PATCH 5/10] net: Mask out ECN bits when setting TOS/TCLASS Gerrit Renker
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-2-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