diff options
Diffstat (limited to 'net/dccp/ccids/ccid2.c')
-rw-r--r-- | net/dccp/ccids/ccid2.c | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c index 3328d23c4be7..b40c4569a820 100644 --- a/net/dccp/ccids/ccid2.c +++ b/net/dccp/ccids/ccid2.c | |||
@@ -52,16 +52,6 @@ static int ccid2_debug; | |||
52 | 52 | ||
53 | static const int ccid2_seq_len = 128; | 53 | static const int ccid2_seq_len = 128; |
54 | 54 | ||
55 | static inline struct ccid2_hc_tx_sock *ccid2_hc_tx_sk(const struct sock *sk) | ||
56 | { | ||
57 | return dccp_sk(sk)->dccps_hc_tx_ccid_private; | ||
58 | } | ||
59 | |||
60 | static inline struct ccid2_hc_rx_sock *ccid2_hc_rx_sk(const struct sock *sk) | ||
61 | { | ||
62 | return dccp_sk(sk)->dccps_hc_rx_ccid_private; | ||
63 | } | ||
64 | |||
65 | #ifdef CCID2_DEBUG | 55 | #ifdef CCID2_DEBUG |
66 | static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) | 56 | static void ccid2_hc_tx_check_sanity(const struct ccid2_hc_tx_sock *hctx) |
67 | { | 57 | { |
@@ -707,19 +697,12 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
707 | ccid2_hc_tx_check_sanity(hctx); | 697 | ccid2_hc_tx_check_sanity(hctx); |
708 | } | 698 | } |
709 | 699 | ||
710 | static int ccid2_hc_tx_init(struct sock *sk) | 700 | static int ccid2_hc_tx_init(struct ccid *ccid, struct sock *sk) |
711 | { | 701 | { |
712 | struct dccp_sock *dp = dccp_sk(sk); | 702 | struct ccid2_hc_tx_sock *hctx = ccid_priv(ccid); |
713 | struct ccid2_hc_tx_sock *hctx; | ||
714 | int seqcount = ccid2_seq_len; | 703 | int seqcount = ccid2_seq_len; |
715 | int i; | 704 | int i; |
716 | 705 | ||
717 | dp->dccps_hc_tx_ccid_private = kzalloc(sizeof(*hctx), gfp_any()); | ||
718 | if (dp->dccps_hc_tx_ccid_private == NULL) | ||
719 | return -ENOMEM; | ||
720 | |||
721 | hctx = ccid2_hc_tx_sk(sk); | ||
722 | |||
723 | /* XXX init variables with proper values */ | 706 | /* XXX init variables with proper values */ |
724 | hctx->ccid2hctx_cwnd = 1; | 707 | hctx->ccid2hctx_cwnd = 1; |
725 | hctx->ccid2hctx_ssthresh = 10; | 708 | hctx->ccid2hctx_ssthresh = 10; |
@@ -728,11 +711,9 @@ static int ccid2_hc_tx_init(struct sock *sk) | |||
728 | /* XXX init ~ to window size... */ | 711 | /* XXX init ~ to window size... */ |
729 | hctx->ccid2hctx_seqbuf = kmalloc(sizeof(*hctx->ccid2hctx_seqbuf) * | 712 | hctx->ccid2hctx_seqbuf = kmalloc(sizeof(*hctx->ccid2hctx_seqbuf) * |
730 | seqcount, gfp_any()); | 713 | seqcount, gfp_any()); |
731 | if (hctx->ccid2hctx_seqbuf == NULL) { | 714 | if (hctx->ccid2hctx_seqbuf == NULL) |
732 | kfree(dp->dccps_hc_tx_ccid_private); | ||
733 | dp->dccps_hc_tx_ccid_private = NULL; | ||
734 | return -ENOMEM; | 715 | return -ENOMEM; |
735 | } | 716 | |
736 | for (i = 0; i < (seqcount - 1); i++) { | 717 | for (i = 0; i < (seqcount - 1); i++) { |
737 | hctx->ccid2hctx_seqbuf[i].ccid2s_next = | 718 | hctx->ccid2hctx_seqbuf[i].ccid2s_next = |
738 | &hctx->ccid2hctx_seqbuf[i + 1]; | 719 | &hctx->ccid2hctx_seqbuf[i + 1]; |
@@ -763,15 +744,11 @@ static int ccid2_hc_tx_init(struct sock *sk) | |||
763 | 744 | ||
764 | static void ccid2_hc_tx_exit(struct sock *sk) | 745 | static void ccid2_hc_tx_exit(struct sock *sk) |
765 | { | 746 | { |
766 | struct dccp_sock *dp = dccp_sk(sk); | ||
767 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); | 747 | struct ccid2_hc_tx_sock *hctx = ccid2_hc_tx_sk(sk); |
768 | 748 | ||
769 | ccid2_hc_tx_kill_rto_timer(sk); | 749 | ccid2_hc_tx_kill_rto_timer(sk); |
770 | |||
771 | kfree(hctx->ccid2hctx_seqbuf); | 750 | kfree(hctx->ccid2hctx_seqbuf); |
772 | 751 | hctx->ccid2hctx_seqbuf = NULL; | |
773 | kfree(dp->dccps_hc_tx_ccid_private); | ||
774 | dp->dccps_hc_tx_ccid_private = NULL; | ||
775 | } | 752 | } |
776 | 753 | ||
777 | static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | 754 | static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) |
@@ -791,33 +768,17 @@ static void ccid2_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
791 | } | 768 | } |
792 | } | 769 | } |
793 | 770 | ||
794 | static int ccid2_hc_rx_init(struct sock *sk) | 771 | static struct ccid_operations ccid2 = { |
795 | { | ||
796 | struct dccp_sock *dp = dccp_sk(sk); | ||
797 | dp->dccps_hc_rx_ccid_private = kzalloc(sizeof(struct ccid2_hc_rx_sock), | ||
798 | gfp_any()); | ||
799 | return dp->dccps_hc_rx_ccid_private == NULL ? -ENOMEM : 0; | ||
800 | } | ||
801 | |||
802 | static void ccid2_hc_rx_exit(struct sock *sk) | ||
803 | { | ||
804 | struct dccp_sock *dp = dccp_sk(sk); | ||
805 | |||
806 | kfree(dp->dccps_hc_rx_ccid_private); | ||
807 | dp->dccps_hc_rx_ccid_private = NULL; | ||
808 | } | ||
809 | |||
810 | static struct ccid ccid2 = { | ||
811 | .ccid_id = 2, | 772 | .ccid_id = 2, |
812 | .ccid_name = "ccid2", | 773 | .ccid_name = "ccid2", |
813 | .ccid_owner = THIS_MODULE, | 774 | .ccid_owner = THIS_MODULE, |
775 | .ccid_hc_tx_obj_size = sizeof(struct ccid2_hc_tx_sock), | ||
814 | .ccid_hc_tx_init = ccid2_hc_tx_init, | 776 | .ccid_hc_tx_init = ccid2_hc_tx_init, |
815 | .ccid_hc_tx_exit = ccid2_hc_tx_exit, | 777 | .ccid_hc_tx_exit = ccid2_hc_tx_exit, |
816 | .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet, | 778 | .ccid_hc_tx_send_packet = ccid2_hc_tx_send_packet, |
817 | .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent, | 779 | .ccid_hc_tx_packet_sent = ccid2_hc_tx_packet_sent, |
818 | .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv, | 780 | .ccid_hc_tx_packet_recv = ccid2_hc_tx_packet_recv, |
819 | .ccid_hc_rx_init = ccid2_hc_rx_init, | 781 | .ccid_hc_rx_obj_size = sizeof(struct ccid2_hc_rx_sock), |
820 | .ccid_hc_rx_exit = ccid2_hc_rx_exit, | ||
821 | .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv, | 782 | .ccid_hc_rx_packet_recv = ccid2_hc_rx_packet_recv, |
822 | }; | 783 | }; |
823 | 784 | ||