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 10/10] Userspace support for reading ECN bits
Date: Sun, 9 Aug 2009 21:48:47 +0200 [thread overview]
Message-ID: <1249847327-6792-11-git-send-email-gerrit@erg.abdn.ac.uk> (raw)
In-Reply-To: <1249847327-6792-10-git-send-email-gerrit@erg.abdn.ac.uk>
This adds support to read the ECN bits of incoming DCCP packets.
RFC: This is an AF-independent alternative to IP_RECVTOS/IPV6_RECVTCLASS.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
Documentation/networking/dccp.txt | 6 ++++++
include/linux/dccp.h | 5 ++++-
net/dccp/proto.c | 15 +++++++++++++++
3 files changed, 25 insertions(+), 1 deletions(-)
--- a/Documentation/networking/dccp.txt
+++ b/Documentation/networking/dccp.txt
@@ -41,6 +41,8 @@ than 3 are not accepted. Values need to be wrapped into a cmsg(3) header:
cmsg->cmsg_level = SOL_DCCP;
cmsg->cmsg_type = DCCP_SCM_ECN_BITS;
cmsg->cmsg_len = CMSG_LEN(sizeof(uint8_t)); /* or CMSG_LEN(1) */
+The process can be reversed for recvmsg(2) when the DCCP_SOCKOPT_GET_ECN_BITS
+socket option is enabled (see below), using the same cmsg encapsulation.
Missing features
@@ -131,6 +133,10 @@ DCCP_SOCKOPT_RECV_CSCOV is for the receiver and has a different meaning: it
restrictive this setting (see [RFC 4340, sec. 9.2.1]). Partial coverage
settings are inherited to the child socket after accept().
+DCCP_SOCKOPT_GET_ECN_BITS takes a boolean int value and enables the delivery
+ of ECN bits as ancillary data to recvmsg(2). The data is received as
+ uint8_t value at SOL_DCCP level and cmsg_type of DCCP_SCM_ECN_BITS.
+
The following two options apply to CCID 3 exclusively and are getsockopt()-only.
In either case, a TFRC info struct (defined in <linux/tfrc.h>) is returned.
DCCP_SOCKOPT_CCID_RX_INFO
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -228,6 +228,7 @@ enum dccp_packet_dequeueing_policy {
#define DCCP_SOCKOPT_RX_CCID 15
#define DCCP_SOCKOPT_QPOLICY_ID 16
#define DCCP_SOCKOPT_QPOLICY_TXQLEN 17
+#define DCCP_SOCKOPT_GET_ECN_BITS 18
#define DCCP_SOCKOPT_CCID_RX_INFO 128
#define DCCP_SOCKOPT_CCID_TX_INFO 192
@@ -470,6 +471,7 @@ struct dccp_ackvec;
* @dccps_r_seq_win - remote Sequence Window (influences seq number validity)
* @dccps_l_ecn_ok - this host understands ECN bits (RFC 4340, 12.1)
* @dccps_r_ecn_ok - the remote end understands ECN bits
+ * @dccps_get_ecn_bits - this host requests ECN bits as recvmsg() ancillary data
* @dccps_pcslen - sender partial checksum coverage (via sockopt)
* @dccps_pcrlen - receiver partial checksum coverage (via sockopt)
* @dccps_send_ndp_count - local Send NDP Count feature (7.7.2)
@@ -516,7 +518,8 @@ struct dccp_sock {
__u64 dccps_l_seq_win:48;
__u64 dccps_r_seq_win:48;
bool dccps_l_ecn_ok:1,
- dccps_r_ecn_ok:1;
+ dccps_r_ecn_ok:1,
+ dccps_get_ecn_bits:1;
__u8 dccps_pcslen:4;
__u8 dccps_pcrlen:4;
__u8 dccps_send_ndp_count:1;
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -550,6 +550,9 @@ static int do_dccp_setsockopt(struct sock *sk, int level, int optname,
else
dp->dccps_tx_qlen = val;
break;
+ case DCCP_SOCKOPT_GET_ECN_BITS:
+ dp->dccps_get_ecn_bits = (val != 0);
+ break;
default:
err = -ENOPROTOOPT;
break;
@@ -663,6 +666,9 @@ static int do_dccp_getsockopt(struct sock *sk, int level, int optname,
case DCCP_SOCKOPT_QPOLICY_TXQLEN:
val = dp->dccps_tx_qlen;
break;
+ case DCCP_SOCKOPT_GET_ECN_BITS:
+ val = dp->dccps_get_ecn_bits;
+ break;
case 128 ... 191:
return ccid_hc_rx_getsockopt(dp->dccps_hc_rx_ccid, sk, optname,
len, (u32 __user *)optval, optlen);
@@ -825,6 +831,13 @@ out_discard:
EXPORT_SYMBOL_GPL(dccp_sendmsg);
+static void dccp_cmsg_recv_ecn_bits(struct msghdr *msg, struct sk_buff *skb)
+{
+ u8 val = DCCP_SKB_CB(skb)->dccpd_ecn;
+
+ put_cmsg(msg, SOL_DCCP, DCCP_SCM_ECN_BITS, sizeof(val), &val);
+}
+
int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
size_t len, int nonblock, int flags, int *addr_len)
{
@@ -919,6 +932,8 @@ verify_sock_status:
len = -EFAULT;
break;
}
+ if (dccp_sk(sk)->dccps_get_ecn_bits)
+ dccp_cmsg_recv_ecn_bits(msg, skb);
found_fin_ok:
if (!(flags & MSG_PEEK))
sk_eat_skb(sk, skb, 0);
--
1.6.0.rc2
prev parent reply other threads:[~2009-08-09 19:48 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 ` 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 ` Gerrit Renker [this message]
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-11-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