aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids/ccid3.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@mandriva.com>2006-03-20 22:21:44 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-20 22:21:44 -0500
commit91f0ebf7b6d5cb2b6e818d48587566144821babe (patch)
tree505c66f36bd72014d7eacb7a04ea011bae2e9a3a /net/dccp/ccids/ccid3.c
parentf38c39d6ce8226519455a6dfe91c2ad84f363f6f (diff)
[DCCP] CCID: Improve CCID infrastructure
1. No need for ->ccid_init nor ->ccid_exit, this is what module_{init,exit} does and anynways neither ccid2 nor ccid3 were using it. 2. Rename struct ccid to struct ccid_operations and introduce struct ccid with a pointer to ccid_operations and rigth after it the rx or tx private state. 3. Remove the pointer to the state of the half connections from struct dccp_sock, now its derived thru ccid_priv() from the ccid pointer. Now we also can implement the setsockopt for changing the CCID easily as no ccid init routines can affect struct dccp_sock in any way that prevents other CCIDs from working if a CCID switch operation is asked by apps. Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/ccids/ccid3.c')
-rw-r--r--net/dccp/ccids/ccid3.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index f9e16db09bef..0587f52e4af1 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -647,17 +647,10 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
647 return rc; 647 return rc;
648} 648}
649 649
650static int ccid3_hc_tx_init(struct sock *sk) 650static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
651{ 651{
652 struct dccp_sock *dp = dccp_sk(sk); 652 struct dccp_sock *dp = dccp_sk(sk);
653 struct ccid3_hc_tx_sock *hctx; 653 struct ccid3_hc_tx_sock *hctx = ccid_priv(ccid);
654
655 dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any());
656 if (dp->dccps_hc_tx_ccid_private == NULL)
657 return -ENOMEM;
658
659 hctx = ccid3_hc_tx_sk(sk);
660 memset(hctx, 0, sizeof(*hctx));
661 654
662 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && 655 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
663 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE) 656 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE)
@@ -680,7 +673,6 @@ static int ccid3_hc_tx_init(struct sock *sk)
680 673
681static void ccid3_hc_tx_exit(struct sock *sk) 674static void ccid3_hc_tx_exit(struct sock *sk)
682{ 675{
683 struct dccp_sock *dp = dccp_sk(sk);
684 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk); 676 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
685 677
686 BUG_ON(hctx == NULL); 678 BUG_ON(hctx == NULL);
@@ -690,9 +682,6 @@ static void ccid3_hc_tx_exit(struct sock *sk)
690 682
691 /* Empty packet history */ 683 /* Empty packet history */
692 dccp_tx_hist_purge(ccid3_tx_hist, &hctx->ccid3hctx_hist); 684 dccp_tx_hist_purge(ccid3_tx_hist, &hctx->ccid3hctx_hist);
693
694 kfree(dp->dccps_hc_tx_ccid_private);
695 dp->dccps_hc_tx_ccid_private = NULL;
696} 685}
697 686
698/* 687/*
@@ -1039,20 +1028,13 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1039 } 1028 }
1040} 1029}
1041 1030
1042static int ccid3_hc_rx_init(struct sock *sk) 1031static int ccid3_hc_rx_init(struct ccid *ccid, struct sock *sk)
1043{ 1032{
1044 struct dccp_sock *dp = dccp_sk(sk); 1033 struct dccp_sock *dp = dccp_sk(sk);
1045 struct ccid3_hc_rx_sock *hcrx; 1034 struct ccid3_hc_rx_sock *hcrx = ccid_priv(ccid);
1046 1035
1047 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 1036 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
1048 1037
1049 dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any());
1050 if (dp->dccps_hc_rx_ccid_private == NULL)
1051 return -ENOMEM;
1052
1053 hcrx = ccid3_hc_rx_sk(sk);
1054 memset(hcrx, 0, sizeof(*hcrx));
1055
1056 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && 1038 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
1057 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE) 1039 dp->dccps_packet_size <= TFRC_MAX_PACKET_SIZE)
1058 hcrx->ccid3hcrx_s = dp->dccps_packet_size; 1040 hcrx->ccid3hcrx_s = dp->dccps_packet_size;
@@ -1071,7 +1053,6 @@ static int ccid3_hc_rx_init(struct sock *sk)
1071static void ccid3_hc_rx_exit(struct sock *sk) 1053static void ccid3_hc_rx_exit(struct sock *sk)
1072{ 1054{
1073 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk); 1055 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1074 struct dccp_sock *dp = dccp_sk(sk);
1075 1056
1076 BUG_ON(hcrx == NULL); 1057 BUG_ON(hcrx == NULL);
1077 1058
@@ -1082,9 +1063,6 @@ static void ccid3_hc_rx_exit(struct sock *sk)
1082 1063
1083 /* Empty loss interval history */ 1064 /* Empty loss interval history */
1084 dccp_li_hist_purge(ccid3_li_hist, &hcrx->ccid3hcrx_li_hist); 1065 dccp_li_hist_purge(ccid3_li_hist, &hcrx->ccid3hcrx_li_hist);
1085
1086 kfree(dp->dccps_hc_rx_ccid_private);
1087 dp->dccps_hc_rx_ccid_private = NULL;
1088} 1066}
1089 1067
1090static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) 1068static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
@@ -1170,10 +1148,11 @@ static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
1170 return 0; 1148 return 0;
1171} 1149}
1172 1150
1173static struct ccid ccid3 = { 1151static struct ccid_operations ccid3 = {
1174 .ccid_id = 3, 1152 .ccid_id = 3,
1175 .ccid_name = "ccid3", 1153 .ccid_name = "ccid3",
1176 .ccid_owner = THIS_MODULE, 1154 .ccid_owner = THIS_MODULE,
1155 .ccid_hc_tx_obj_size = sizeof(struct ccid3_hc_tx_sock),
1177 .ccid_hc_tx_init = ccid3_hc_tx_init, 1156 .ccid_hc_tx_init = ccid3_hc_tx_init,
1178 .ccid_hc_tx_exit = ccid3_hc_tx_exit, 1157 .ccid_hc_tx_exit = ccid3_hc_tx_exit,
1179 .ccid_hc_tx_send_packet = ccid3_hc_tx_send_packet, 1158 .ccid_hc_tx_send_packet = ccid3_hc_tx_send_packet,
@@ -1181,6 +1160,7 @@ static struct ccid ccid3 = {
1181 .ccid_hc_tx_packet_recv = ccid3_hc_tx_packet_recv, 1160 .ccid_hc_tx_packet_recv = ccid3_hc_tx_packet_recv,
1182 .ccid_hc_tx_insert_options = ccid3_hc_tx_insert_options, 1161 .ccid_hc_tx_insert_options = ccid3_hc_tx_insert_options,
1183 .ccid_hc_tx_parse_options = ccid3_hc_tx_parse_options, 1162 .ccid_hc_tx_parse_options = ccid3_hc_tx_parse_options,
1163 .ccid_hc_rx_obj_size = sizeof(struct ccid3_hc_rx_sock),
1184 .ccid_hc_rx_init = ccid3_hc_rx_init, 1164 .ccid_hc_rx_init = ccid3_hc_rx_init,
1185 .ccid_hc_rx_exit = ccid3_hc_rx_exit, 1165 .ccid_hc_rx_exit = ccid3_hc_rx_exit,
1186 .ccid_hc_rx_insert_options = ccid3_hc_rx_insert_options, 1166 .ccid_hc_rx_insert_options = ccid3_hc_rx_insert_options,