DCCP protocol discussions
 help / color / mirror / Atom feed
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
To: dccp@vger.kernel.org
Subject: [PATCH 10/14]: Initialisation framework for feature negotiation
Date: Wed, 03 Oct 2007 14:02:49 +0000	[thread overview]
Message-ID: <200710031502.49899@strip-the-willow> (raw)

[DCCP]: Initialisation framework for feature negotiation

This initialises feature negotiation from two tables, which are initialised
from sysctls. Furthermore, specifics of the implementation (e.g. currently
short seqnos and ECN are not supported) are advertised for robustness.

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
 include/linux/dccp.h |   19 -------------
 net/dccp/feat.c      |   71 +++++++++++++++++++++++++++++++++++++++++++--------
 net/dccp/feat.h      |    2 -
 3 files changed, 61 insertions(+), 31 deletions(-)

--- a/net/dccp/feat.h
+++ b/net/dccp/feat.h
@@ -101,12 +101,12 @@ static inline void dccp_feat_debug(const
 #define dccp_feat_debug(type, feat, val)
 #endif /* CONFIG_IP_DCCP_DEBUG */
 
+extern int  dccp_feat_init(struct sock *sk);
 extern int  dccp_feat_register_change(struct sock *sk, u8 feat,
 				      u8 is_local, u8 *val, u8 len);
 extern int  dccp_feat_parse_options(struct sock *, struct dccp_request_sock *,
 				    u8 mand, u8 opt, u8 feat, u8 *val, u8 len);
 extern int  dccp_feat_clone_list(struct list_head const *, struct list_head *);
-extern int  dccp_feat_init(struct sock *sk);
 
 /*
  * Determining lengths of variable-length options.
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -1016,24 +1016,73 @@ int dccp_feat_parse_options(struct sock 
 	return 0;	/* ignore FN options in all other states */
 }
 
+/**
+ * dccp_feat_init  -  Seed feature negotiation with host-specific defaults
+ * This initialises global defaults, depending on the value of the sysctls.
+ * These can later be overridden by registering changes via setsockopt calls.
+ * The last link in the chain is finalise_settings, to make sure that between
+ * here and the start of actual feature negotiation no inconsistencies enter.
+ */
 int dccp_feat_init(struct sock *sk)
 {
-	struct dccp_sock *dp = dccp_sk(sk);
-	struct dccp_minisock *dmsk = dccp_msk(sk);
-	int rc;
+	struct list_head *fn = &dccp_sk(sk)->dccps_featneg;
+	u8 on = 1, off = 0;
+	int rc = 0, i;
+	/*
+	 * All features not appearing in these tables use either defaults or
+	 * are later adjusted in dccp_feat_finalise_settings().
+	 */
+	struct {
+		u8	feat_num;
+		u64	val;
+	} nn [] = {
+		{ DCCPF_SEQUENCE_WINDOW, sysctl_dccp_feat_sequence_window },
+		/* ACK Ratio may be overridden due to choice of CCID */
+		{ DCCPF_ACK_RATIO,	 sysctl_dccp_feat_ack_ratio }
+	};
+	struct {
+		u8	feat_num;
+		bool	is_local;
+		bool	mandatory;
+		u8	*val;
+		u8	len;
+	} sp[] = {
+		{ DCCPF_CCID,		true,	false }, /* local  / TX CCID */
+		{ DCCPF_CCID,		false,	false }, /* remote / RX CCID */
+		/* Advertise that short seqnos are not supported (7.6.1) */
+		{ DCCPF_SHORT_SEQNOS,	true,	true, &off, sizeof(off) },
+		/*
+		 * RFC 4340 12.1: "If a DCCP is not ECN capable, it MUST send
+		 * Mandatory `Change L(ECN Incapable, 1)' options [...]".
+		 */
+		{ DCCPF_ECN_INCAPABLE,	true,	true, &on, sizeof(on) },
+	};
 
-	INIT_LIST_HEAD(&dmsk->dccpms_pending);	/* XXX no longer used */
-	INIT_LIST_HEAD(&dmsk->dccpms_conf);	/* XXX no longer used */
+	/*
+	 * We advertise the available list of CCIDs and reorder according to
+	 * preferences, since negotiating conflicting singleton values inevitably
+	 * leads to failure (can still be overridden via sockopts).
+	 */
+	if (ccid_get_default_ccids(&sp[0].val, &sp[0].len) ||
+	    ccid_get_default_ccids(&sp[1].val, &sp[1].len))
+		return -ENOBUFS;
+
+	if (!dccp_feat_prefer(sysctl_dccp_feat_tx_ccid, sp[0].val, sp[0].len) ||
+	    !dccp_feat_prefer(sysctl_dccp_feat_rx_ccid, sp[1].val, sp[1].len))
+		rc = -ENOPROTOOPT;
+
+	for (i = 0; rc = 0 && i < ARRAY_SIZE(nn); i++)
+		rc = dccp_feat_register_nn(fn, nn[i].feat_num, 0, nn[i].val);
+
+	for (i = 0; rc = 0 && i < ARRAY_SIZE(sp); i++)
+		rc = dccp_feat_register_sp(fn, sp[i].feat_num, sp[i].is_local,
+					sp[i].mandatory, sp[i].val, sp[i].len);
 
-	/* Ack ratio */
-	rc = dccp_feat_register_nn(&dp->dccps_featneg, DCCPF_ACK_RATIO, 0,
-				   dmsk->dccpms_ack_ratio);
-out:
+	kfree(sp[0].val);
+	kfree(sp[1].val);
 	return rc;
 }
 
-EXPORT_SYMBOL_GPL(dccp_feat_init);
-
 int dccp_feat_activate_values(struct sock *sk, struct list_head *fn_list)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -383,30 +383,11 @@ static inline unsigned int dccp_hdr_len(
   * @dccpms_sequence_window - Sequence Window Feature (section 7.5.2)
   * @dccpms_send_ndp_count - Send NDP Count Feature (7.7.2)
   * @dccpms_ack_ratio - Ack Ratio Feature (section 11.3)
-  * @dccpms_pending - List of features being negotiated
-  * @dccpms_conf -
   */
 struct dccp_minisock {
 	__u64			dccpms_sequence_window;
 	__u8			dccpms_send_ndp_count;
 	__u8			dccpms_ack_ratio;
-	struct list_head	dccpms_pending;
-	struct list_head	dccpms_conf;
-};
-
-struct dccp_opt_conf {
-	__u8			*dccpoc_val;
-	__u8			dccpoc_len;
-};
-
-struct dccp_opt_pend {
-	struct list_head	dccpop_node;
-	__u8			dccpop_type;
-	__u8			dccpop_feat;
-	__u8		        *dccpop_val;
-	__u8			dccpop_len;
-	int			dccpop_conf;
-	struct dccp_opt_conf    *dccpop_sc;
 };
 
 extern void dccp_minisock_init(struct dccp_minisock *dmsk);

             reply	other threads:[~2007-10-03 14:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-03 14:02 Gerrit Renker [this message]
2007-10-03 21:06 ` [PATCH 10/14]: Initialisation framework for feature negotiation Ian McDonald

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=200710031502.49899@strip-the-willow \
    --to=gerrit@erg.abdn.ac.uk \
    --cc=dccp@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