aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/feat.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2006-03-21 01:50:58 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 01:50:58 -0500
commita4bf3902427a128455b8de299ff0918072b2e974 (patch)
tree5269cd4d84702a0a728b390e08242be01252d20d /net/dccp/feat.c
parente6f507196c2b50243beb09b1bfa4639f999d4d1e (diff)
[DCCP] minisock: Rename struct dccp_options to struct dccp_minisock
This will later be included in struct dccp_request_sock so that we can have per connection feature negotiation state while in the 3way handshake, when we clone the DCCP_ROLE_LISTEN socket (in dccp_create_openreq_child) we'll just copy this state from dreq_minisock to dccps_minisock. Also the feature negotiation and option parsing code will mostly touch dccps_minisock, which will simplify some stuff. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/feat.c')
-rw-r--r--net/dccp/feat.c81
1 files changed, 37 insertions, 44 deletions
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index ed0851fa3cb3..b09064c4643d 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -22,7 +22,7 @@
22int dccp_feat_change(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len, 22int dccp_feat_change(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len,
23 gfp_t gfp) 23 gfp_t gfp)
24{ 24{
25 struct dccp_sock *dp = dccp_sk(sk); 25 struct dccp_minisock *dmsk = dccp_msk(sk);
26 struct dccp_opt_pend *opt; 26 struct dccp_opt_pend *opt;
27 27
28 dccp_pr_debug("feat change type=%d feat=%d\n", type, feature); 28 dccp_pr_debug("feat change type=%d feat=%d\n", type, feature);
@@ -30,8 +30,7 @@ int dccp_feat_change(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len,
30 /* XXX sanity check feat change request */ 30 /* XXX sanity check feat change request */
31 31
32 /* check if that feature is already being negotiated */ 32 /* check if that feature is already being negotiated */
33 list_for_each_entry(opt, &dp->dccps_options.dccpo_pending, 33 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
34 dccpop_node) {
35 /* ok we found a negotiation for this option already */ 34 /* ok we found a negotiation for this option already */
36 if (opt->dccpop_feat == feature && opt->dccpop_type == type) { 35 if (opt->dccpop_feat == feature && opt->dccpop_type == type) {
37 dccp_pr_debug("Replacing old\n"); 36 dccp_pr_debug("Replacing old\n");
@@ -59,7 +58,7 @@ int dccp_feat_change(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len,
59 58
60 BUG_ON(opt->dccpop_val == NULL); 59 BUG_ON(opt->dccpop_val == NULL);
61 60
62 list_add_tail(&opt->dccpop_node, &dp->dccps_options.dccpo_pending); 61 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_pending);
63 return 0; 62 return 0;
64} 63}
65 64
@@ -68,10 +67,10 @@ EXPORT_SYMBOL_GPL(dccp_feat_change);
68static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr) 67static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr)
69{ 68{
70 struct dccp_sock *dp = dccp_sk(sk); 69 struct dccp_sock *dp = dccp_sk(sk);
70 struct dccp_minisock *dmsk = dccp_msk(sk);
71 /* figure out if we are changing our CCID or the peer's */ 71 /* figure out if we are changing our CCID or the peer's */
72 const int rx = type == DCCPO_CHANGE_R; 72 const int rx = type == DCCPO_CHANGE_R;
73 const u8 ccid_nr = rx ? dp->dccps_options.dccpo_rx_ccid : 73 const u8 ccid_nr = rx ? dmsk->dccpms_rx_ccid : dmsk->dccpms_tx_ccid;
74 dp->dccps_options.dccpo_tx_ccid;
75 struct ccid *new_ccid; 74 struct ccid *new_ccid;
76 75
77 /* Check if nothing is being changed. */ 76 /* Check if nothing is being changed. */
@@ -85,11 +84,11 @@ static int dccp_feat_update_ccid(struct sock *sk, u8 type, u8 new_ccid_nr)
85 if (rx) { 84 if (rx) {
86 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk); 85 ccid_hc_rx_delete(dp->dccps_hc_rx_ccid, sk);
87 dp->dccps_hc_rx_ccid = new_ccid; 86 dp->dccps_hc_rx_ccid = new_ccid;
88 dp->dccps_options.dccpo_rx_ccid = new_ccid_nr; 87 dmsk->dccpms_rx_ccid = new_ccid_nr;
89 } else { 88 } else {
90 ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk); 89 ccid_hc_tx_delete(dp->dccps_hc_tx_ccid, sk);
91 dp->dccps_hc_tx_ccid = new_ccid; 90 dp->dccps_hc_tx_ccid = new_ccid;
92 dp->dccps_options.dccpo_tx_ccid = new_ccid_nr; 91 dmsk->dccpms_tx_ccid = new_ccid_nr;
93 } 92 }
94 93
95 return 0; 94 return 0;
@@ -159,9 +158,9 @@ static int dccp_feat_reconcile(struct sock *sk, struct dccp_opt_pend *opt,
159 case DCCPF_CCID: 158 case DCCPF_CCID:
160 /* XXX did i get this right? =P */ 159 /* XXX did i get this right? =P */
161 if (opt->dccpop_type == DCCPO_CHANGE_L) 160 if (opt->dccpop_type == DCCPO_CHANGE_L)
162 res = &dp->dccps_options.dccpo_tx_ccid; 161 res = &dccp_msk(sk)->dccpms_tx_ccid;
163 else 162 else
164 res = &dp->dccps_options.dccpo_rx_ccid; 163 res = &dccp_msk(sk)->dccpms_rx_ccid;
165 break; 164 break;
166 165
167 default: 166 default:
@@ -226,7 +225,7 @@ static int dccp_feat_reconcile(struct sock *sk, struct dccp_opt_pend *opt,
226 225
227static int dccp_feat_sp(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len) 226static int dccp_feat_sp(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
228{ 227{
229 struct dccp_sock *dp = dccp_sk(sk); 228 struct dccp_minisock *dmsk = dccp_msk(sk);
230 struct dccp_opt_pend *opt; 229 struct dccp_opt_pend *opt;
231 int rc = 1; 230 int rc = 1;
232 u8 t; 231 u8 t;
@@ -242,8 +241,7 @@ static int dccp_feat_sp(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
242 t = DCCPO_CHANGE_L; 241 t = DCCPO_CHANGE_L;
243 242
244 /* find our preference list for this feature */ 243 /* find our preference list for this feature */
245 list_for_each_entry(opt, &dp->dccps_options.dccpo_pending, 244 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
246 dccpop_node) {
247 if (opt->dccpop_type != t || opt->dccpop_feat != feature) 245 if (opt->dccpop_type != t || opt->dccpop_feat != feature)
248 continue; 246 continue;
249 247
@@ -265,7 +263,7 @@ static int dccp_feat_sp(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
265static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len) 263static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
266{ 264{
267 struct dccp_opt_pend *opt; 265 struct dccp_opt_pend *opt;
268 struct dccp_sock *dp = dccp_sk(sk); 266 struct dccp_minisock *dmsk = dccp_msk(sk);
269 u8 *copy; 267 u8 *copy;
270 int rc; 268 int rc;
271 269
@@ -304,14 +302,14 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
304 } 302 }
305 303
306 dccp_pr_debug("Confirming NN feature %d (val=%d)\n", feature, *copy); 304 dccp_pr_debug("Confirming NN feature %d (val=%d)\n", feature, *copy);
307 list_add_tail(&opt->dccpop_node, &dp->dccps_options.dccpo_conf); 305 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf);
308 306
309 return 0; 307 return 0;
310} 308}
311 309
312static void dccp_feat_empty_confirm(struct sock *sk, u8 type, u8 feature) 310static void dccp_feat_empty_confirm(struct sock *sk, u8 type, u8 feature)
313{ 311{
314 struct dccp_sock *dp = dccp_sk(sk); 312 struct dccp_minisock *dmsk = dccp_msk(sk);
315 /* XXX check if other confirms for that are queued and recycle slot */ 313 /* XXX check if other confirms for that are queued and recycle slot */
316 struct dccp_opt_pend *opt = kzalloc(sizeof(*opt), GFP_ATOMIC); 314 struct dccp_opt_pend *opt = kzalloc(sizeof(*opt), GFP_ATOMIC);
317 315
@@ -330,20 +328,19 @@ static void dccp_feat_empty_confirm(struct sock *sk, u8 type, u8 feature)
330 328
331 /* change feature */ 329 /* change feature */
332 dccp_pr_debug("Empty confirm feature %d type %d\n", feature, type); 330 dccp_pr_debug("Empty confirm feature %d type %d\n", feature, type);
333 list_add_tail(&opt->dccpop_node, &dp->dccps_options.dccpo_conf); 331 list_add_tail(&opt->dccpop_node, &dmsk->dccpms_conf);
334} 332}
335 333
336static void dccp_feat_flush_confirm(struct sock *sk) 334static void dccp_feat_flush_confirm(struct sock *sk)
337{ 335{
338 struct dccp_sock *dp = dccp_sk(sk); 336 struct dccp_minisock *dmsk = dccp_msk(sk);
339 /* Check if there is anything to confirm in the first place */ 337 /* Check if there is anything to confirm in the first place */
340 int yes = !list_empty(&dp->dccps_options.dccpo_conf); 338 int yes = !list_empty(&dmsk->dccpms_conf);
341 339
342 if (!yes) { 340 if (!yes) {
343 struct dccp_opt_pend *opt; 341 struct dccp_opt_pend *opt;
344 342
345 list_for_each_entry(opt, &dp->dccps_options.dccpo_pending, 343 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
346 dccpop_node) {
347 if (opt->dccpop_conf) { 344 if (opt->dccpop_conf) {
348 yes = 1; 345 yes = 1;
349 break; 346 break;
@@ -407,7 +404,7 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
407{ 404{
408 u8 t; 405 u8 t;
409 struct dccp_opt_pend *opt; 406 struct dccp_opt_pend *opt;
410 struct dccp_sock *dp = dccp_sk(sk); 407 struct dccp_minisock *dmsk = dccp_msk(sk);
411 int rc = 1; 408 int rc = 1;
412 int all_confirmed = 1; 409 int all_confirmed = 1;
413 410
@@ -418,8 +415,7 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
418 /* locate our change request */ 415 /* locate our change request */
419 t = type == DCCPO_CONFIRM_L ? DCCPO_CHANGE_R : DCCPO_CHANGE_L; 416 t = type == DCCPO_CONFIRM_L ? DCCPO_CHANGE_R : DCCPO_CHANGE_L;
420 417
421 list_for_each_entry(opt, &dp->dccps_options.dccpo_pending, 418 list_for_each_entry(opt, &dmsk->dccpms_pending, dccpop_node) {
422 dccpop_node) {
423 if (!opt->dccpop_conf && opt->dccpop_type == t && 419 if (!opt->dccpop_conf && opt->dccpop_type == t &&
424 opt->dccpop_feat == feature) { 420 opt->dccpop_feat == feature) {
425 /* we found it */ 421 /* we found it */
@@ -462,10 +458,10 @@ EXPORT_SYMBOL_GPL(dccp_feat_confirm_recv);
462 458
463void dccp_feat_clean(struct sock *sk) 459void dccp_feat_clean(struct sock *sk)
464{ 460{
465 struct dccp_sock *dp = dccp_sk(sk); 461 struct dccp_minisock *dmsk = dccp_msk(sk);
466 struct dccp_opt_pend *opt, *next; 462 struct dccp_opt_pend *opt, *next;
467 463
468 list_for_each_entry_safe(opt, next, &dp->dccps_options.dccpo_pending, 464 list_for_each_entry_safe(opt, next, &dmsk->dccpms_pending,
469 dccpop_node) { 465 dccpop_node) {
470 BUG_ON(opt->dccpop_val == NULL); 466 BUG_ON(opt->dccpop_val == NULL);
471 kfree(opt->dccpop_val); 467 kfree(opt->dccpop_val);
@@ -478,16 +474,15 @@ void dccp_feat_clean(struct sock *sk)
478 474
479 kfree(opt); 475 kfree(opt);
480 } 476 }
481 INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending); 477 INIT_LIST_HEAD(&dmsk->dccpms_pending);
482 478
483 list_for_each_entry_safe(opt, next, &dp->dccps_options.dccpo_conf, 479 list_for_each_entry_safe(opt, next, &dmsk->dccpms_conf, dccpop_node) {
484 dccpop_node) {
485 BUG_ON(opt == NULL); 480 BUG_ON(opt == NULL);
486 if (opt->dccpop_val != NULL) 481 if (opt->dccpop_val != NULL)
487 kfree(opt->dccpop_val); 482 kfree(opt->dccpop_val);
488 kfree(opt); 483 kfree(opt);
489 } 484 }
490 INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf); 485 INIT_LIST_HEAD(&dmsk->dccpms_conf);
491} 486}
492 487
493EXPORT_SYMBOL_GPL(dccp_feat_clean); 488EXPORT_SYMBOL_GPL(dccp_feat_clean);
@@ -498,16 +493,15 @@ EXPORT_SYMBOL_GPL(dccp_feat_clean);
498 */ 493 */
499int dccp_feat_clone(struct sock *oldsk, struct sock *newsk) 494int dccp_feat_clone(struct sock *oldsk, struct sock *newsk)
500{ 495{
501 struct dccp_sock *olddp = dccp_sk(oldsk); 496 struct dccp_minisock *olddmsk = dccp_msk(oldsk);
502 struct dccp_sock *newdp = dccp_sk(newsk); 497 struct dccp_minisock *newdmsk = dccp_msk(newsk);
503 struct dccp_opt_pend *opt; 498 struct dccp_opt_pend *opt;
504 int rc = 0; 499 int rc = 0;
505 500
506 INIT_LIST_HEAD(&newdp->dccps_options.dccpo_pending); 501 INIT_LIST_HEAD(&newdmsk->dccpms_pending);
507 INIT_LIST_HEAD(&newdp->dccps_options.dccpo_conf); 502 INIT_LIST_HEAD(&newdmsk->dccpms_conf);
508 503
509 list_for_each_entry(opt, &olddp->dccps_options.dccpo_pending, 504 list_for_each_entry(opt, &olddmsk->dccpms_pending, dccpop_node) {
510 dccpop_node) {
511 struct dccp_opt_pend *newopt; 505 struct dccp_opt_pend *newopt;
512 /* copy the value of the option */ 506 /* copy the value of the option */
513 u8 *val = kmalloc(opt->dccpop_len, GFP_ATOMIC); 507 u8 *val = kmalloc(opt->dccpop_len, GFP_ATOMIC);
@@ -525,8 +519,7 @@ int dccp_feat_clone(struct sock *oldsk, struct sock *newsk)
525 /* insert the option */ 519 /* insert the option */
526 memcpy(newopt, opt, sizeof(*newopt)); 520 memcpy(newopt, opt, sizeof(*newopt));
527 newopt->dccpop_val = val; 521 newopt->dccpop_val = val;
528 list_add_tail(&newopt->dccpop_node, 522 list_add_tail(&newopt->dccpop_node, &newdmsk->dccpms_pending);
529 &newdp->dccps_options.dccpo_pending);
530 523
531 /* XXX what happens with backlogs and multiple connections at 524 /* XXX what happens with backlogs and multiple connections at
532 * once... 525 * once...
@@ -567,27 +560,27 @@ static int __dccp_feat_init(struct sock *sk, u8 type, u8 feat, u8 *val, u8 len)
567 560
568int dccp_feat_init(struct sock *sk) 561int dccp_feat_init(struct sock *sk)
569{ 562{
570 struct dccp_sock *dp = dccp_sk(sk); 563 struct dccp_minisock *dmsk = dccp_msk(sk);
571 int rc; 564 int rc;
572 565
573 INIT_LIST_HEAD(&dp->dccps_options.dccpo_pending); 566 INIT_LIST_HEAD(&dmsk->dccpms_pending);
574 INIT_LIST_HEAD(&dp->dccps_options.dccpo_conf); 567 INIT_LIST_HEAD(&dmsk->dccpms_conf);
575 568
576 /* CCID L */ 569 /* CCID L */
577 rc = __dccp_feat_init(sk, DCCPO_CHANGE_L, DCCPF_CCID, 570 rc = __dccp_feat_init(sk, DCCPO_CHANGE_L, DCCPF_CCID,
578 &dp->dccps_options.dccpo_tx_ccid, 1); 571 &dmsk->dccpms_tx_ccid, 1);
579 if (rc) 572 if (rc)
580 goto out; 573 goto out;
581 574
582 /* CCID R */ 575 /* CCID R */
583 rc = __dccp_feat_init(sk, DCCPO_CHANGE_R, DCCPF_CCID, 576 rc = __dccp_feat_init(sk, DCCPO_CHANGE_R, DCCPF_CCID,
584 &dp->dccps_options.dccpo_rx_ccid, 1); 577 &dmsk->dccpms_rx_ccid, 1);
585 if (rc) 578 if (rc)
586 goto out; 579 goto out;
587 580
588 /* Ack ratio */ 581 /* Ack ratio */
589 rc = __dccp_feat_init(sk, DCCPO_CHANGE_L, DCCPF_ACK_RATIO, 582 rc = __dccp_feat_init(sk, DCCPO_CHANGE_L, DCCPF_ACK_RATIO,
590 &dp->dccps_options.dccpo_ack_ratio, 1); 583 &dmsk->dccpms_ack_ratio, 1);
591out: 584out:
592 return rc; 585 return rc;
593} 586}