diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2006-03-21 01:51:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:51:53 -0500 |
commit | 8ca0d17bd716c0aa3f496714e0e304fc6b982ae3 (patch) | |
tree | a1e3881117aa4b687bacace28c794e7cc3522827 | |
parent | a4bf3902427a128455b8de299ff0918072b2e974 (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>
-rw-r--r-- | net/dccp/feat.c | 30 | ||||
-rw-r--r-- | net/dccp/feat.h | 7 | ||||
-rw-r--r-- | net/dccp/proto.c | 11 |
3 files changed, 24 insertions, 24 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 | ||
22 | int dccp_feat_change(struct sock *sk, u8 type, u8 feature, u8 *val, u8 len, | 22 | int 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 | ||
310 | static void dccp_feat_empty_confirm(struct sock *sk, u8 type, u8 feature) | 309 | static 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 | ||
457 | EXPORT_SYMBOL_GPL(dccp_feat_confirm_recv); | 456 | EXPORT_SYMBOL_GPL(dccp_feat_confirm_recv); |
458 | 457 | ||
459 | void dccp_feat_clean(struct sock *sk) | 458 | void 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 | ||
539 | out_clean: | 537 | out_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 | ||
545 | EXPORT_SYMBOL_GPL(dccp_feat_clone); | 543 | EXPORT_SYMBOL_GPL(dccp_feat_clone); |
546 | 544 | ||
547 | static int __dccp_feat_init(struct sock *sk, u8 type, u8 feat, u8 *val, u8 len) | 545 | static 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 | ||
561 | int dccp_feat_init(struct sock *sk) | 560 | int 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); |
584 | out: | 582 | out: |
585 | return rc; | 583 | return rc; |
diff --git a/net/dccp/feat.h b/net/dccp/feat.h index 67da06265f14..6048373c7186 100644 --- a/net/dccp/feat.h +++ b/net/dccp/feat.h | |||
@@ -14,15 +14,16 @@ | |||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | 15 | ||
16 | struct sock; | 16 | struct sock; |
17 | struct dccp_minisock; | ||
17 | 18 | ||
18 | extern int dccp_feat_change(struct sock *sk, u8 type, u8 feature, | 19 | extern int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, |
19 | u8 *val, u8 len, gfp_t gfp); | 20 | u8 *val, u8 len, gfp_t gfp); |
20 | extern int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, | 21 | extern int dccp_feat_change_recv(struct sock *sk, u8 type, u8 feature, |
21 | u8 *val, u8 len); | 22 | u8 *val, u8 len); |
22 | extern int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature, | 23 | extern int dccp_feat_confirm_recv(struct sock *sk, u8 type, u8 feature, |
23 | u8 *val, u8 len); | 24 | u8 *val, u8 len); |
24 | extern void dccp_feat_clean(struct sock *sk); | 25 | extern void dccp_feat_clean(struct dccp_minisock *dmsk); |
25 | extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk); | 26 | extern int dccp_feat_clone(struct sock *oldsk, struct sock *newsk); |
26 | extern int dccp_feat_init(struct sock *sk); | 27 | extern int dccp_feat_init(struct dccp_minisock *dmsk); |
27 | 28 | ||
28 | #endif /* _DCCP_FEAT_H */ | 29 | #endif /* _DCCP_FEAT_H */ |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index ede969074967..d4b293e16283 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -180,7 +180,7 @@ int dccp_init_sock(struct sock *sk, const __u8 ctl_sock_initialized) | |||
180 | * setsockopt(CCIDs-I-want/accept). -acme | 180 | * setsockopt(CCIDs-I-want/accept). -acme |
181 | */ | 181 | */ |
182 | if (likely(ctl_sock_initialized)) { | 182 | if (likely(ctl_sock_initialized)) { |
183 | int rc = dccp_feat_init(sk); | 183 | int rc = dccp_feat_init(dmsk); |
184 | 184 | ||
185 | if (rc) | 185 | if (rc) |
186 | return rc; | 186 | return rc; |
@@ -229,6 +229,7 @@ EXPORT_SYMBOL_GPL(dccp_init_sock); | |||
229 | int dccp_destroy_sock(struct sock *sk) | 229 | int dccp_destroy_sock(struct sock *sk) |
230 | { | 230 | { |
231 | struct dccp_sock *dp = dccp_sk(sk); | 231 | struct dccp_sock *dp = dccp_sk(sk); |
232 | struct dccp_minisock *dmsk = dccp_msk(sk); | ||
232 | 233 | ||
233 | /* | 234 | /* |
234 | * DCCP doesn't use sk_write_queue, just sk_send_head | 235 | * DCCP doesn't use sk_write_queue, just sk_send_head |
@@ -246,7 +247,7 @@ int dccp_destroy_sock(struct sock *sk) | |||
246 | kfree(dp->dccps_service_list); | 247 | kfree(dp->dccps_service_list); |
247 | dp->dccps_service_list = NULL; | 248 | dp->dccps_service_list = NULL; |
248 | 249 | ||
249 | if (dccp_msk(sk)->dccpms_send_ack_vector) { | 250 | if (dmsk->dccpms_send_ack_vector) { |
250 | dccp_ackvec_free(dp->dccps_hc_rx_ackvec); | 251 | dccp_ackvec_free(dp->dccps_hc_rx_ackvec); |
251 | dp->dccps_hc_rx_ackvec = NULL; | 252 | dp->dccps_hc_rx_ackvec = NULL; |
252 | } | 253 | } |
@@ -255,7 +256,7 @@ int dccp_destroy_sock(struct sock *sk) | |||
255 | dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; | 256 | dp->dccps_hc_rx_ccid = dp->dccps_hc_tx_ccid = NULL; |
256 | 257 | ||
257 | /* clean up feature negotiation state */ | 258 | /* clean up feature negotiation state */ |
258 | dccp_feat_clean(sk); | 259 | dccp_feat_clean(dmsk); |
259 | 260 | ||
260 | return 0; | 261 | return 0; |
261 | } | 262 | } |
@@ -441,8 +442,8 @@ static int dccp_setsockopt_change(struct sock *sk, int type, | |||
441 | goto out_free_val; | 442 | goto out_free_val; |
442 | } | 443 | } |
443 | 444 | ||
444 | rc = dccp_feat_change(sk, type, opt.dccpsf_feat, val, opt.dccpsf_len, | 445 | rc = dccp_feat_change(dccp_msk(sk), type, opt.dccpsf_feat, |
445 | GFP_KERNEL); | 446 | val, opt.dccpsf_len, GFP_KERNEL); |
446 | if (rc) | 447 | if (rc) |
447 | goto out_free_val; | 448 | goto out_free_val; |
448 | 449 | ||