Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

dccp: Per-socket initialisation of feature negotiation

This provides feature-negotiation initialisation for both DCCP sockets
and DCCP request_sockets, to support feature negotiation during
connection setup.

It also resolves a FIXME regarding the congestion control
initialisation.

Thanks to Wei Yongjun for help with the IPv6 side of this patch.

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information...
commit ac75773c2742d82cbcb078708df406e9017224b7 1 parent 61e6473
Gerrit Renker grrtrr authored davem330 committed
4 include/linux/dccp.h
@@ -412,6 +412,7 @@ extern void dccp_minisock_init(struct dccp_minisock *dmsk);
412 412 * @dreq_iss: initial sequence number sent on the Response (RFC 4340, 7.1)
413 413 * @dreq_isr: initial sequence number received on the Request
414 414 * @dreq_service: service code present on the Request (there is just one)
  415 + * @dreq_featneg: feature negotiation options for this connection
415 416 * The following two fields are analogous to the ones in dccp_sock:
416 417 * @dreq_timestamp_echo: last received timestamp to echo (13.1)
417 418 * @dreq_timestamp_echo: the time of receiving the last @dreq_timestamp_echo
@@ -421,6 +422,7 @@ struct dccp_request_sock {
421 422 __u64 dreq_iss;
422 423 __u64 dreq_isr;
423 424 __be32 dreq_service;
  425 + struct list_head dreq_featneg;
424 426 __u32 dreq_timestamp_echo;
425 427 __u32 dreq_timestamp_time;
426 428 };
@@ -498,6 +500,7 @@ struct dccp_ackvec;
498 500 * @dccps_mss_cache - current value of MSS (path MTU minus header sizes)
499 501 * @dccps_rate_last - timestamp for rate-limiting DCCP-Sync (RFC 4340, 7.5.4)
500 502 * @dccps_minisock - associated minisock (accessed via dccp_msk)
  503 + * @dccps_featneg - tracks feature-negotiation state (mostly during handshake)
501 504 * @dccps_hc_rx_ackvec - rx half connection ack vector
502 505 * @dccps_hc_rx_ccid - CCID used for the receiver (or receiving half-connection)
503 506 * @dccps_hc_tx_ccid - CCID used for the sender (or sending half-connection)
@@ -535,6 +538,7 @@ struct dccp_sock {
535 538 __u64 dccps_ndp_count:48;
536 539 unsigned long dccps_rate_last;
537 540 struct dccp_minisock dccps_minisock;
  541 + struct list_head dccps_featneg;
538 542 struct dccp_ackvec *dccps_hc_rx_ackvec;
539 543 struct ccid *dccps_hc_rx_ccid;
540 544 struct ccid *dccps_hc_tx_ccid;
3  net/dccp/dccp.h
@@ -252,7 +252,8 @@ extern const char *dccp_state_name(const int state);
252 252 extern void dccp_set_state(struct sock *sk, const int state);
253 253 extern void dccp_done(struct sock *sk);
254 254
255   -extern void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb);
  255 +extern int dccp_reqsk_init(struct request_sock *rq, struct dccp_sock const *dp,
  256 + struct sk_buff const *skb);
256 257
257 258 extern int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
258 259
55 net/dccp/feat.c
@@ -90,6 +90,20 @@ static u8 dccp_feat_type(u8 feat_num)
90 90 return dccp_feat_table[idx].reconciliation;
91 91 }
92 92
  93 +/* copy constructor, fval must not already contain allocated memory */
  94 +static int dccp_feat_clone_sp_val(dccp_feat_val *fval, u8 const *val, u8 len)
  95 +{
  96 + fval->sp.len = len;
  97 + if (fval->sp.len > 0) {
  98 + fval->sp.vec = kmemdup(val, len, gfp_any());
  99 + if (fval->sp.vec == NULL) {
  100 + fval->sp.len = 0;
  101 + return -ENOBUFS;
  102 + }
  103 + }
  104 + return 0;
  105 +}
  106 +
93 107 static void dccp_feat_val_destructor(u8 feat_num, dccp_feat_val *val)
94 108 {
95 109 if (unlikely(val == NULL))
@@ -99,6 +113,28 @@ static void dccp_feat_val_destructor(u8 feat_num, dccp_feat_val *val)
99 113 memset(val, 0, sizeof(*val));
100 114 }
101 115
  116 +static struct dccp_feat_entry *
  117 + dccp_feat_clone_entry(struct dccp_feat_entry const *original)
  118 +{
  119 + struct dccp_feat_entry *new;
  120 + u8 type = dccp_feat_type(original->feat_num);
  121 +
  122 + if (type == FEAT_UNKNOWN)
  123 + return NULL;
  124 +
  125 + new = kmemdup(original, sizeof(struct dccp_feat_entry), gfp_any());
  126 + if (new == NULL)
  127 + return NULL;
  128 +
  129 + if (type == FEAT_SP && dccp_feat_clone_sp_val(&new->val,
  130 + original->val.sp.vec,
  131 + original->val.sp.len)) {
  132 + kfree(new);
  133 + return NULL;
  134 + }
  135 + return new;
  136 +}
  137 +
102 138 static void dccp_feat_entry_destructor(struct dccp_feat_entry *entry)
103 139 {
104 140 if (entry != NULL) {
@@ -133,6 +169,25 @@ void dccp_feat_list_purge(struct list_head *fn_list)
133 169 }
134 170 EXPORT_SYMBOL_GPL(dccp_feat_list_purge);
135 171
  172 +/* generate @to as full clone of @from - @to must not contain any nodes */
  173 +int dccp_feat_clone_list(struct list_head const *from, struct list_head *to)
  174 +{
  175 + struct dccp_feat_entry *entry, *new;
  176 +
  177 + INIT_LIST_HEAD(to);
  178 + list_for_each_entry(entry, from, node) {
  179 + new = dccp_feat_clone_entry(entry);
  180 + if (new == NULL)
  181 + goto cloning_failed;
  182 + list_add_tail(&new->node, to);
  183 + }
  184 + return 0;
  185 +
  186 +cloning_failed:
  187 + dccp_feat_list_purge(to);
  188 + return -ENOMEM;
  189 +}
  190 +
136 191 int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature,
137 192 u8 *val, u8 len, gfp_t gfp)
138 193 {
1  net/dccp/feat.h
@@ -96,6 +96,7 @@ extern int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
96 96 u8 *val, u8 len);
97 97 extern void dccp_feat_clean(struct dccp_minisock *dmsk);
98 98 extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk);
  99 +extern int dccp_feat_clone_list(struct list_head const *, struct list_head *);
99 100 extern int dccp_feat_init(struct dccp_minisock *dmsk);
100 101
101 102 #endif /* _DCCP_FEAT_H */
2  net/dccp/input.c
@@ -590,8 +590,6 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
590 590 if (inet_csk(sk)->icsk_af_ops->conn_request(sk,
591 591 skb) < 0)
592 592 return 1;
593   -
594   - /* FIXME: do congestion control initialization */
595 593 goto discard;
596 594 }
597 595 if (dh->dccph_type == DCCP_PKT_RESET)
3  net/dccp/ipv4.c
@@ -595,7 +595,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
595 595 if (req == NULL)
596 596 goto drop;
597 597
598   - dccp_reqsk_init(req, skb);
  598 + if (dccp_reqsk_init(req, dccp_sk(sk), skb))
  599 + goto drop_and_free;
599 600
600 601 dreq = dccp_rsk(req);
601 602 if (dccp_parse_options(sk, dreq, skb))
3  net/dccp/ipv6.c
@@ -426,7 +426,8 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
426 426 if (req == NULL)
427 427 goto drop;
428 428
429   - dccp_reqsk_init(req, skb);
  429 + if (dccp_reqsk_init(req, dccp_sk(sk), skb))
  430 + goto drop_and_free;
430 431
431 432 dreq = dccp_rsk(req);
432 433 if (dccp_parse_options(sk, dreq, skb))
7 net/dccp/minisocks.c
@@ -125,6 +125,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
125 125 newdp->dccps_timestamp_time = dreq->dreq_timestamp_time;
126 126 newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
127 127
  128 + INIT_LIST_HEAD(&newdp->dccps_featneg);
128 129 if (dccp_feat_clone(sk, newsk))
129 130 goto out_free;
130 131
@@ -304,7 +305,8 @@ void dccp_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
304 305
305 306 EXPORT_SYMBOL_GPL(dccp_reqsk_send_ack);
306 307
307   -void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb)
  308 +int dccp_reqsk_init(struct request_sock *req,
  309 + struct dccp_sock const *dp, struct sk_buff const *skb)
308 310 {
309 311 struct dccp_request_sock *dreq = dccp_rsk(req);
310 312
@@ -313,6 +315,9 @@ void dccp_reqsk_init(struct request_sock *req, struct sk_buff *skb)
313 315 inet_rsk(req)->acked = 0;
314 316 req->rcv_wnd = sysctl_dccp_feat_sequence_window;
315 317 dreq->dreq_timestamp_echo = 0;
  318 +
  319 + /* inherit feature negotiation options from listening socket */
  320 + return dccp_feat_clone_list(&dp->dccps_featneg, &dreq->dreq_featneg);
316 321 }
317 322
318 323 EXPORT_SYMBOL_GPL(dccp_reqsk_init);
1  net/dccp/proto.c
@@ -193,6 +193,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized)
193 193
194 194 dccp_init_xmit_timers(sk);
195 195
  196 + INIT_LIST_HEAD(&dp->dccps_featneg);
196 197 /*
197 198 * FIXME: We're hardcoding the CCID, and doing this at this point makes
198 199 * the listening (master) sock get CCID control blocks, which is not

0 comments on commit ac75773

Please sign in to comment.
Something went wrong with that request. Please try again.