aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp
diff options
context:
space:
mode:
Diffstat (limited to 'net/dccp')
-rw-r--r--net/dccp/ccids/ccid3.c70
-rw-r--r--net/dccp/ccids/ccid3.h12
2 files changed, 37 insertions, 45 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index 348e6fb262c3..ea30012dd195 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -112,8 +112,7 @@ static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state)
112static inline void ccid3_hc_tx_set_state(struct sock *sk, 112static inline void ccid3_hc_tx_set_state(struct sock *sk,
113 enum ccid3_hc_tx_states state) 113 enum ccid3_hc_tx_states state)
114{ 114{
115 struct dccp_sock *dp = dccp_sk(sk); 115 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
116 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
117 enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state; 116 enum ccid3_hc_tx_states oldstate = hctx->ccid3hctx_state;
118 117
119 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", 118 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
@@ -154,8 +153,7 @@ static inline void ccid3_calc_new_delta(struct ccid3_hc_tx_sock *hctx)
154 */ 153 */
155static void ccid3_hc_tx_update_x(struct sock *sk) 154static void ccid3_hc_tx_update_x(struct sock *sk)
156{ 155{
157 struct dccp_sock *dp = dccp_sk(sk); 156 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
158 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
159 157
160 /* To avoid large error in calcX */ 158 /* To avoid large error in calcX */
161 if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) { 159 if (hctx->ccid3hctx_p >= TFRC_SMALLEST_P) {
@@ -184,9 +182,8 @@ static void ccid3_hc_tx_update_x(struct sock *sk)
184static void ccid3_hc_tx_no_feedback_timer(unsigned long data) 182static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
185{ 183{
186 struct sock *sk = (struct sock *)data; 184 struct sock *sk = (struct sock *)data;
187 struct dccp_sock *dp = dccp_sk(sk);
188 unsigned long next_tmout = 0; 185 unsigned long next_tmout = 0;
189 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 186 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
190 187
191 bh_lock_sock(sk); 188 bh_lock_sock(sk);
192 if (sock_owned_by_user(sk)) { 189 if (sock_owned_by_user(sk)) {
@@ -284,7 +281,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk,
284 struct sk_buff *skb, int len) 281 struct sk_buff *skb, int len)
285{ 282{
286 struct dccp_sock *dp = dccp_sk(sk); 283 struct dccp_sock *dp = dccp_sk(sk);
287 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 284 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
288 struct dccp_tx_hist_entry *new_packet; 285 struct dccp_tx_hist_entry *new_packet;
289 struct timeval now; 286 struct timeval now;
290 long delay; 287 long delay;
@@ -370,8 +367,8 @@ out:
370 367
371static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) 368static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
372{ 369{
373 struct dccp_sock *dp = dccp_sk(sk); 370 const struct dccp_sock *dp = dccp_sk(sk);
374 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 371 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
375 struct timeval now; 372 struct timeval now;
376 373
377 BUG_ON(hctx == NULL); 374 BUG_ON(hctx == NULL);
@@ -457,8 +454,8 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len)
457 454
458static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) 455static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
459{ 456{
460 struct dccp_sock *dp = dccp_sk(sk); 457 const struct dccp_sock *dp = dccp_sk(sk);
461 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 458 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
462 struct ccid3_options_received *opt_recv; 459 struct ccid3_options_received *opt_recv;
463 struct dccp_tx_hist_entry *packet; 460 struct dccp_tx_hist_entry *packet;
464 struct timeval now; 461 struct timeval now;
@@ -609,8 +606,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
609 606
610static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb) 607static void ccid3_hc_tx_insert_options(struct sock *sk, struct sk_buff *skb)
611{ 608{
612 const struct dccp_sock *dp = dccp_sk(sk); 609 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
613 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
614 610
615 if (hctx == NULL || !(sk->sk_state == DCCP_OPEN || 611 if (hctx == NULL || !(sk->sk_state == DCCP_OPEN ||
616 sk->sk_state == DCCP_PARTOPEN)) 612 sk->sk_state == DCCP_PARTOPEN))
@@ -624,8 +620,8 @@ static int ccid3_hc_tx_parse_options(struct sock *sk, unsigned char option,
624 unsigned char *value) 620 unsigned char *value)
625{ 621{
626 int rc = 0; 622 int rc = 0;
627 struct dccp_sock *dp = dccp_sk(sk); 623 const struct dccp_sock *dp = dccp_sk(sk);
628 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 624 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
629 struct ccid3_options_received *opt_recv; 625 struct ccid3_options_received *opt_recv;
630 626
631 if (hctx == NULL) 627 if (hctx == NULL)
@@ -688,11 +684,11 @@ static int ccid3_hc_tx_init(struct sock *sk)
688 684
689 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 685 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
690 686
691 hctx = dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), 687 dp->dccps_hc_tx_ccid_private = kmalloc(sizeof(*hctx), gfp_any());
692 gfp_any()); 688 if (dp->dccps_hc_tx_ccid_private == NULL)
693 if (hctx == NULL)
694 return -ENOMEM; 689 return -ENOMEM;
695 690
691 hctx = ccid3_hc_tx_sk(sk);
696 memset(hctx, 0, sizeof(*hctx)); 692 memset(hctx, 0, sizeof(*hctx));
697 693
698 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && 694 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
@@ -714,7 +710,7 @@ static int ccid3_hc_tx_init(struct sock *sk)
714static void ccid3_hc_tx_exit(struct sock *sk) 710static void ccid3_hc_tx_exit(struct sock *sk)
715{ 711{
716 struct dccp_sock *dp = dccp_sk(sk); 712 struct dccp_sock *dp = dccp_sk(sk);
717 struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; 713 struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
718 714
719 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 715 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
720 BUG_ON(hctx == NULL); 716 BUG_ON(hctx == NULL);
@@ -756,8 +752,7 @@ static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state)
756static inline void ccid3_hc_rx_set_state(struct sock *sk, 752static inline void ccid3_hc_rx_set_state(struct sock *sk,
757 enum ccid3_hc_rx_states state) 753 enum ccid3_hc_rx_states state)
758{ 754{
759 struct dccp_sock *dp = dccp_sk(sk); 755 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
760 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
761 enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state; 756 enum ccid3_hc_rx_states oldstate = hcrx->ccid3hcrx_state;
762 757
763 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n", 758 ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
@@ -769,8 +764,8 @@ static inline void ccid3_hc_rx_set_state(struct sock *sk,
769 764
770static void ccid3_hc_rx_send_feedback(struct sock *sk) 765static void ccid3_hc_rx_send_feedback(struct sock *sk)
771{ 766{
767 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
772 struct dccp_sock *dp = dccp_sk(sk); 768 struct dccp_sock *dp = dccp_sk(sk);
773 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
774 struct dccp_rx_hist_entry *packet; 769 struct dccp_rx_hist_entry *packet;
775 struct timeval now; 770 struct timeval now;
776 771
@@ -822,9 +817,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk)
822 817
823static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) 818static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
824{ 819{
825 const struct dccp_sock *dp = dccp_sk(sk); 820 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
826 u32 x_recv, pinv; 821 u32 x_recv, pinv;
827 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
828 822
829 if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN || 823 if (hcrx == NULL || !(sk->sk_state == DCCP_OPEN ||
830 sk->sk_state == DCCP_PARTOPEN)) 824 sk->sk_state == DCCP_PARTOPEN))
@@ -853,8 +847,7 @@ static void ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
853 847
854static u32 ccid3_hc_rx_calc_first_li(struct sock *sk) 848static u32 ccid3_hc_rx_calc_first_li(struct sock *sk)
855{ 849{
856 struct dccp_sock *dp = dccp_sk(sk); 850 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
857 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
858 struct dccp_rx_hist_entry *entry, *next, *tail = NULL; 851 struct dccp_rx_hist_entry *entry, *next, *tail = NULL;
859 u32 rtt, delta, x_recv, fval, p, tmp2; 852 u32 rtt, delta, x_recv, fval, p, tmp2;
860 struct timeval tstamp = { 0, }; 853 struct timeval tstamp = { 0, };
@@ -926,8 +919,7 @@ found:
926 919
927static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss) 920static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
928{ 921{
929 struct dccp_sock *dp = dccp_sk(sk); 922 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
930 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
931 923
932 if (seq_loss != DCCP_MAX_SEQNO + 1 && 924 if (seq_loss != DCCP_MAX_SEQNO + 1 &&
933 list_empty(&hcrx->ccid3hcrx_li_hist)) { 925 list_empty(&hcrx->ccid3hcrx_li_hist)) {
@@ -945,8 +937,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
945 937
946static void ccid3_hc_rx_detect_loss(struct sock *sk) 938static void ccid3_hc_rx_detect_loss(struct sock *sk)
947{ 939{
948 struct dccp_sock *dp = dccp_sk(sk); 940 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
949 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
950 u8 win_loss; 941 u8 win_loss;
951 const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist, 942 const u64 seq_loss = dccp_rx_hist_detect_loss(&hcrx->ccid3hcrx_hist,
952 &hcrx->ccid3hcrx_li_hist, 943 &hcrx->ccid3hcrx_li_hist,
@@ -957,8 +948,7 @@ static void ccid3_hc_rx_detect_loss(struct sock *sk)
957 948
958static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) 949static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
959{ 950{
960 struct dccp_sock *dp = dccp_sk(sk); 951 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
961 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
962 const struct dccp_options_received *opt_recv; 952 const struct dccp_options_received *opt_recv;
963 struct dccp_rx_hist_entry *packet; 953 struct dccp_rx_hist_entry *packet;
964 struct timeval now; 954 struct timeval now;
@@ -972,7 +962,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
972 BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA || 962 BUG_ON(!(hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA ||
973 hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA)); 963 hcrx->ccid3hcrx_state == TFRC_RSTATE_DATA));
974 964
975 opt_recv = &dp->dccps_options_received; 965 opt_recv = &dccp_sk(sk)->dccps_options_received;
976 966
977 switch (DCCP_SKB_CB(skb)->dccpd_type) { 967 switch (DCCP_SKB_CB(skb)->dccpd_type) {
978 case DCCP_PKT_ACK: 968 case DCCP_PKT_ACK:
@@ -1085,11 +1075,11 @@ static int ccid3_hc_rx_init(struct sock *sk)
1085 1075
1086 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 1076 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
1087 1077
1088 hcrx = dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), 1078 dp->dccps_hc_rx_ccid_private = kmalloc(sizeof(*hcrx), gfp_any());
1089 gfp_any()); 1079 if (dp->dccps_hc_rx_ccid_private == NULL)
1090 if (hcrx == NULL)
1091 return -ENOMEM; 1080 return -ENOMEM;
1092 1081
1082 hcrx = ccid3_hc_rx_sk(sk);
1093 memset(hcrx, 0, sizeof(*hcrx)); 1083 memset(hcrx, 0, sizeof(*hcrx));
1094 1084
1095 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE && 1085 if (dp->dccps_packet_size >= TFRC_MIN_PACKET_SIZE &&
@@ -1109,8 +1099,8 @@ static int ccid3_hc_rx_init(struct sock *sk)
1109 1099
1110static void ccid3_hc_rx_exit(struct sock *sk) 1100static void ccid3_hc_rx_exit(struct sock *sk)
1111{ 1101{
1102 struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1112 struct dccp_sock *dp = dccp_sk(sk); 1103 struct dccp_sock *dp = dccp_sk(sk);
1113 struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
1114 1104
1115 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); 1105 ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk);
1116 1106
@@ -1131,8 +1121,7 @@ static void ccid3_hc_rx_exit(struct sock *sk)
1131 1121
1132static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) 1122static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
1133{ 1123{
1134 const struct dccp_sock *dp = dccp_sk(sk); 1124 const struct ccid3_hc_rx_sock *hcrx = ccid3_hc_rx_sk(sk);
1135 const struct ccid3_hc_rx_sock *hcrx = dp->dccps_hc_rx_ccid_private;
1136 1125
1137 if (hcrx == NULL) 1126 if (hcrx == NULL)
1138 return; 1127 return;
@@ -1144,8 +1133,7 @@ static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
1144 1133
1145static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) 1134static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
1146{ 1135{
1147 const struct dccp_sock *dp = dccp_sk(sk); 1136 const struct ccid3_hc_tx_sock *hctx = ccid3_hc_tx_sk(sk);
1148 const struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private;
1149 1137
1150 if (hctx == NULL) 1138 if (hctx == NULL)
1151 return; 1139 return;
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h
index 58be6125b695..d16f00d784f3 100644
--- a/net/dccp/ccids/ccid3.h
+++ b/net/dccp/ccids/ccid3.h
@@ -128,10 +128,14 @@ struct ccid3_hc_rx_sock {
128 u32 ccid3hcrx_x_recv; 128 u32 ccid3hcrx_x_recv;
129}; 129};
130 130
131#define ccid3_hc_tx_field(s,field) (s->dccps_hc_tx_ccid_private == NULL ? 0 : \ 131static inline struct ccid3_hc_tx_sock *ccid3_hc_tx_sk(const struct sock *sk)
132 ((struct ccid3_hc_tx_sock *)s->dccps_hc_tx_ccid_private)->ccid3hctx_##field) 132{
133 return dccp_sk(sk)->dccps_hc_tx_ccid_private;
134}
133 135
134#define ccid3_hc_rx_field(s,field) (s->dccps_hc_rx_ccid_private == NULL ? 0 : \ 136static inline struct ccid3_hc_rx_sock *ccid3_hc_rx_sk(const struct sock *sk)
135 ((struct ccid3_hc_rx_sock *)s->dccps_hc_rx_ccid_private)->ccid3hcrx_##field) 137{
138 return dccp_sk(sk)->dccps_hc_rx_ccid_private;
139}
136 140
137#endif /* _DCCP_CCID3_H_ */ 141#endif /* _DCCP_CCID3_H_ */