Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 121837
b: refs/heads/master
c: 9eca0a4
h: refs/heads/master
i:
  121835: 9b3be1e
v: v3
  • Loading branch information
Gerrit Renker authored and David S. Miller committed Nov 12, 2008
1 parent ecbc137 commit e22eddc
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d90ebcbfa7f5a8b4e20518c9f94c5c4e4cd3c2e5
refs/heads/master: 9eca0a47dee201a73967026985b5f0a79a46bd36
1 change: 1 addition & 0 deletions trunk/net/dccp/dccp.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ static inline int dccp_ack_pending(const struct sock *sk)
inet_csk_ack_scheduled(sk);
}

extern int dccp_feat_finalise_settings(struct dccp_sock *dp);
extern void dccp_feat_list_purge(struct list_head *fn_list);

extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb);
Expand Down
160 changes: 160 additions & 0 deletions trunk/net/dccp/feat.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,166 @@ int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature,

EXPORT_SYMBOL_GPL(dccp_feat_change);

/*
* Tracking features whose value depend on the choice of CCID
*
* This is designed with an extension in mind so that a list walk could be done
* before activating any features. However, the existing framework was found to
* work satisfactorily up until now, the automatic verification is left open.
* When adding new CCIDs, add a corresponding dependency table here.
*/
static const struct ccid_dependency *dccp_feat_ccid_deps(u8 ccid, bool is_local)
{
static const struct ccid_dependency ccid2_dependencies[2][2] = {
/*
* CCID2 mandates Ack Vectors (RFC 4341, 4.): as CCID is a TX
* feature and Send Ack Vector is an RX feature, `is_local'
* needs to be reversed.
*/
{ /* Dependencies of the receiver-side (remote) CCID2 */
{
.dependent_feat = DCCPF_SEND_ACK_VECTOR,
.is_local = true,
.is_mandatory = true,
.val = 1
},
{ 0, 0, 0, 0 }
},
{ /* Dependencies of the sender-side (local) CCID2 */
{
.dependent_feat = DCCPF_SEND_ACK_VECTOR,
.is_local = false,
.is_mandatory = true,
.val = 1
},
{ 0, 0, 0, 0 }
}
};
static const struct ccid_dependency ccid3_dependencies[2][5] = {
{ /*
* Dependencies of the receiver-side CCID3
*/
{ /* locally disable Ack Vectors */
.dependent_feat = DCCPF_SEND_ACK_VECTOR,
.is_local = true,
.is_mandatory = false,
.val = 0
},
{ /* see below why Send Loss Event Rate is on */
.dependent_feat = DCCPF_SEND_LEV_RATE,
.is_local = true,
.is_mandatory = true,
.val = 1
},
{ /* NDP Count is needed as per RFC 4342, 6.1.1 */
.dependent_feat = DCCPF_SEND_NDP_COUNT,
.is_local = false,
.is_mandatory = true,
.val = 1
},
{ 0, 0, 0, 0 },
},
{ /*
* CCID3 at the TX side: we request that the HC-receiver
* will not send Ack Vectors (they will be ignored, so
* Mandatory is not set); we enable Send Loss Event Rate
* (Mandatory since the implementation does not support
* the Loss Intervals option of RFC 4342, 8.6).
* The last two options are for peer's information only.
*/
{
.dependent_feat = DCCPF_SEND_ACK_VECTOR,
.is_local = false,
.is_mandatory = false,
.val = 0
},
{
.dependent_feat = DCCPF_SEND_LEV_RATE,
.is_local = false,
.is_mandatory = true,
.val = 1
},
{ /* this CCID does not support Ack Ratio */
.dependent_feat = DCCPF_ACK_RATIO,
.is_local = true,
.is_mandatory = false,
.val = 0
},
{ /* tell receiver we are sending NDP counts */
.dependent_feat = DCCPF_SEND_NDP_COUNT,
.is_local = true,
.is_mandatory = false,
.val = 1
},
{ 0, 0, 0, 0 }
}
};
switch (ccid) {
case DCCPC_CCID2:
return ccid2_dependencies[is_local];
case DCCPC_CCID3:
return ccid3_dependencies[is_local];
default:
return NULL;
}
}

/**
* dccp_feat_propagate_ccid - Resolve dependencies of features on choice of CCID
* @fn: feature-negotiation list to update
* @id: CCID number to track
* @is_local: whether TX CCID (1) or RX CCID (0) is meant
* This function needs to be called after registering all other features.
*/
static int dccp_feat_propagate_ccid(struct list_head *fn, u8 id, bool is_local)
{
const struct ccid_dependency *table = dccp_feat_ccid_deps(id, is_local);
int i, rc = (table == NULL);

for (i = 0; rc == 0 && table[i].dependent_feat != DCCPF_RESERVED; i++)
if (dccp_feat_type(table[i].dependent_feat) == FEAT_SP)
rc = __feat_register_sp(fn, table[i].dependent_feat,
table[i].is_local,
table[i].is_mandatory,
&table[i].val, 1);
else
rc = __feat_register_nn(fn, table[i].dependent_feat,
table[i].is_mandatory,
table[i].val);
return rc;
}

/**
* dccp_feat_finalise_settings - Finalise settings before starting negotiation
* @dp: client or listening socket (settings will be inherited)
* This is called after all registrations (socket initialisation, sysctls, and
* sockopt calls), and before sending the first packet containing Change options
* (ie. client-Request or server-Response), to ensure internal consistency.
*/
int dccp_feat_finalise_settings(struct dccp_sock *dp)
{
struct list_head *fn = &dp->dccps_featneg;
struct dccp_feat_entry *entry;
int i = 2, ccids[2] = { -1, -1 };

/*
* Propagating CCIDs:
* 1) not useful to propagate CCID settings if this host advertises more
* than one CCID: the choice of CCID may still change - if this is
* the client, or if this is the server and the client sends
* singleton CCID values.
* 2) since is that propagate_ccid changes the list, we defer changing
* the sorted list until after the traversal.
*/
list_for_each_entry(entry, fn, node)
if (entry->feat_num == DCCPF_CCID && entry->val.sp.len == 1)
ccids[entry->is_local] = entry->val.sp.vec[0];
while (i--)
if (ccids[i] > 0 && dccp_feat_propagate_ccid(fn, ccids[i], i))
return -1;
return 0;
}

static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr)
{
struct dccp_sock *dp = dccp_sk(sk);
Expand Down
4 changes: 4 additions & 0 deletions trunk/net/dccp/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ int dccp_connect(struct sock *sk)
struct sk_buff *skb;
struct inet_connection_sock *icsk = inet_csk(sk);

/* do not connect if feature negotiation setup fails */
if (dccp_feat_finalise_settings(dccp_sk(sk)))
return -EPROTO;

dccp_connect_init(sk);

skb = alloc_skb(sk->sk_prot->max_header, sk->sk_allocation);
Expand Down
3 changes: 3 additions & 0 deletions trunk/net/dccp/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ static inline int dccp_listen_start(struct sock *sk, int backlog)
struct dccp_sock *dp = dccp_sk(sk);

dp->dccps_role = DCCP_ROLE_LISTEN;
/* do not start to listen if feature negotiation setup fails */
if (dccp_feat_finalise_settings(dp))
return -EPROTO;
return inet_csk_listen_start(sk, backlog);
}

Expand Down

0 comments on commit e22eddc

Please sign in to comment.