aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/feat.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2006-03-21 01:51:53 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 01:51:53 -0500
commit8ca0d17bd716c0aa3f496714e0e304fc6b982ae3 (patch)
treea1e3881117aa4b687bacace28c794e7cc3522827 /net/dccp/feat.c
parenta4bf3902427a128455b8de299ff0918072b2e974 (diff)
[DCCP] feat: Pass dccp_minisock ptr where only the minisock is used
This is in preparation for having a dccp_minisock embedded into dccp_request_sock so that feature negotiation can be done prior to creating the full blown dccp_sock. 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.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index b09064c4643d..e3dd30d36c8a 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -19,10 +19,9 @@
19 19
20#define DCCP_FEAT_SP_NOAGREE (-123) 20#define DCCP_FEAT_SP_NOAGREE (-123)
21 21
22int dccp_feat_change(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len, 22int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature,
23 gfp_t gfp) 23 u8 *val, u8 len, gfp_t gfp)
24{ 24{
25 struct dccp_minisock *dmsk = dccp_msk(sk);
26 struct dccp_opt_pend *opt; 25 struct dccp_opt_pend *opt;
27 26
28 dccp_pr_debug("feat change type=%d feat=%d\n", type, feature); 27 dccp_pr_debug("feat change type=%d feat=%d\n", type, feature);
@@ -307,9 +306,9 @@ static int dccp_feat_nn(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
307 return 0; 306 return 0;
308} 307}
309 308
310static void dccp_feat_empty_confirm(struct sock *sk, u8 type, u8 feature) 309static void dccp_feat_empty_confirm(struct dccp_minisock *dmsk,
310 u8 type, u8 feature)
311{ 311{
312 struct dccp_minisock *dmsk = dccp_msk(sk);
313 /* XXX check if other confirms for that are queued and recycle slot */ 312 /* XXX check if other confirms for that are queued and recycle slot */
314 struct dccp_opt_pend *opt = kzalloc(sizeof(*opt), GFP_ATOMIC); 313 struct dccp_opt_pend *opt = kzalloc(sizeof(*opt), GFP_ATOMIC);
315 314
@@ -388,7 +387,7 @@ int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len)
388 * mandatory 387 * mandatory
389 */ 388 */
390 if (rc != DCCP_FEAT_SP_NOAGREE) 389 if (rc != DCCP_FEAT_SP_NOAGREE)
391 dccp_feat_empty_confirm(sk, type, feature); 390 dccp_feat_empty_confirm(dccp_msk(sk), type, feature);
392 } 391 }
393 392
394 /* generate the confirm [if required] */ 393 /* generate the confirm [if required] */
@@ -456,9 +455,8 @@ int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature,
456 455
457EXPORT_SYMBOL_GPL(dccp_feat_confirm_recv); 456EXPORT_SYMBOL_GPL(dccp_feat_confirm_recv);
458 457
459void dccp_feat_clean(struct sock *sk) 458void dccp_feat_clean(struct dccp_minisock *dmsk)
460{ 459{
461 struct dccp_minisock *dmsk = dccp_msk(sk);
462 struct dccp_opt_pend *opt, *next; 460 struct dccp_opt_pend *opt, *next;
463 461
464 list_for_each_entry_safe(opt, next, &dmsk->dccpms_pending, 462 list_for_each_entry_safe(opt, next, &dmsk->dccpms_pending,
@@ -537,49 +535,49 @@ out:
537 return rc; 535 return rc;
538 536
539out_clean: 537out_clean:
540 dccp_feat_clean(newsk); 538 dccp_feat_clean(newdmsk);
541 rc = -ENOMEM; 539 rc = -ENOMEM;
542 goto out; 540 goto out;
543} 541}
544 542
545EXPORT_SYMBOL_GPL(dccp_feat_clone); 543EXPORT_SYMBOL_GPL(dccp_feat_clone);
546 544
547static int __dccp_feat_init(struct sock *sk, u8 type, u8 feat, u8 *val, u8 len) 545static int __dccp_feat_init(struct dccp_minisock *dmsk, u8 type, u8 feat,
546 u8 *val, u8 len)
548{ 547{
549 int rc = -ENOMEM; 548 int rc = -ENOMEM;
550 u8 *copy = kmalloc(len, GFP_KERNEL); 549 u8 *copy = kmalloc(len, GFP_KERNEL);
551 550
552 if (copy != NULL) { 551 if (copy != NULL) {
553 memcpy(copy, val, len); 552 memcpy(copy, val, len);
554 rc = dccp_feat_change(sk, type, feat, copy, len, GFP_KERNEL); 553 rc = dccp_feat_change(dmsk, type, feat, copy, len, GFP_KERNEL);
555 if (rc) 554 if (rc)
556 kfree(copy); 555 kfree(copy);
557 } 556 }
558 return rc; 557 return rc;
559} 558}
560 559
561int dccp_feat_init(struct sock *sk) 560int dccp_feat_init(struct dccp_minisock *dmsk)
562{ 561{
563 struct dccp_minisock *dmsk = dccp_msk(sk);
564 int rc; 562 int rc;
565 563
566 INIT_LIST_HEAD(&dmsk->dccpms_pending); 564 INIT_LIST_HEAD(&dmsk->dccpms_pending);
567 INIT_LIST_HEAD(&dmsk->dccpms_conf); 565 INIT_LIST_HEAD(&dmsk->dccpms_conf);
568 566
569 /* CCID L */ 567 /* CCID L */
570 rc = __dccp_feat_init(sk, DCCPO_CHANGE_L, DCCPF_CCID, 568 rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_L, DCCPF_CCID,
571 &dmsk->dccpms_tx_ccid, 1); 569 &dmsk->dccpms_tx_ccid, 1);
572 if (rc) 570 if (rc)
573 goto out; 571 goto out;
574 572
575 /* CCID R */ 573 /* CCID R */
576 rc = __dccp_feat_init(sk, DCCPO_CHANGE_R, DCCPF_CCID, 574 rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_R, DCCPF_CCID,
577 &dmsk->dccpms_rx_ccid, 1); 575 &dmsk->dccpms_rx_ccid, 1);
578 if (rc) 576 if (rc)
579 goto out; 577 goto out;
580 578
581 /* Ack ratio */ 579 /* Ack ratio */
582 rc = __dccp_feat_init(sk, DCCPO_CHANGE_L, DCCPF_ACK_RATIO, 580 rc = __dccp_feat_init(dmsk, DCCPO_CHANGE_L, DCCPF_ACK_RATIO,
583 &dmsk->dccpms_ack_ratio, 1); 581 &dmsk->dccpms_ack_ratio, 1);
584out: 582out:
585 return rc; 583 return rc;