diff options
author | Ying Xue <ying.xue@windriver.com> | 2014-11-25 22:41:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-26 12:30:17 -0500 |
commit | f03273f1e2fc8a59c3831200dd1532cf29e37e35 (patch) | |
tree | 053d35cee17bf08943c35f9c0a24c19b3aeb39b1 /net/tipc/link.c | |
parent | bc6fecd4098df2d21b056486e5b418c84be95032 (diff) |
tipc: use generic SKB list APIs to manage link receive queue
Use standard SKB list APIs associated with struct sk_buff_head to
manage link's receive queue to simplify its relevant code cemplexity.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r-- | net/tipc/link.c | 85 |
1 files changed, 36 insertions, 49 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index d9c2310e417d..0e04508cdba4 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -966,29 +966,17 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *skb, | |||
966 | } | 966 | } |
967 | } | 967 | } |
968 | 968 | ||
969 | /** | 969 | static void link_retrieve_defq(struct tipc_link *link, |
970 | * link_insert_deferred_queue - insert deferred messages back into receive chain | 970 | struct sk_buff_head *list) |
971 | */ | ||
972 | static struct sk_buff *link_insert_deferred_queue(struct tipc_link *l_ptr, | ||
973 | struct sk_buff *buf) | ||
974 | { | 971 | { |
975 | struct sk_buff_head head; | ||
976 | struct sk_buff *skb = NULL; | ||
977 | u32 seq_no; | 972 | u32 seq_no; |
978 | 973 | ||
979 | if (skb_queue_empty(&l_ptr->deferred_queue)) | 974 | if (skb_queue_empty(&link->deferred_queue)) |
980 | return buf; | 975 | return; |
981 | 976 | ||
982 | seq_no = buf_seqno(skb_peek(&l_ptr->deferred_queue)); | 977 | seq_no = buf_seqno(skb_peek(&link->deferred_queue)); |
983 | if (seq_no == mod(l_ptr->next_in_no)) { | 978 | if (seq_no == mod(link->next_in_no)) |
984 | __skb_queue_head_init(&head); | 979 | skb_queue_splice_tail_init(&link->deferred_queue, list); |
985 | skb_queue_splice_tail_init(&l_ptr->deferred_queue, &head); | ||
986 | skb = head.next; | ||
987 | skb->prev = NULL; | ||
988 | head.prev->next = buf; | ||
989 | head.prev->prev = NULL; | ||
990 | } | ||
991 | return skb; | ||
992 | } | 980 | } |
993 | 981 | ||
994 | /** | 982 | /** |
@@ -1048,43 +1036,43 @@ static int link_recv_buf_validate(struct sk_buff *buf) | |||
1048 | 1036 | ||
1049 | /** | 1037 | /** |
1050 | * tipc_rcv - process TIPC packets/messages arriving from off-node | 1038 | * tipc_rcv - process TIPC packets/messages arriving from off-node |
1051 | * @head: pointer to message buffer chain | 1039 | * @skb: TIPC packet |
1052 | * @b_ptr: pointer to bearer message arrived on | 1040 | * @b_ptr: pointer to bearer message arrived on |
1053 | * | 1041 | * |
1054 | * Invoked with no locks held. Bearer pointer must point to a valid bearer | 1042 | * Invoked with no locks held. Bearer pointer must point to a valid bearer |
1055 | * structure (i.e. cannot be NULL), but bearer can be inactive. | 1043 | * structure (i.e. cannot be NULL), but bearer can be inactive. |
1056 | */ | 1044 | */ |
1057 | void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | 1045 | void tipc_rcv(struct sk_buff *skb, struct tipc_bearer *b_ptr) |
1058 | { | 1046 | { |
1059 | while (head) { | 1047 | struct sk_buff_head head; |
1060 | struct tipc_node *n_ptr; | 1048 | struct tipc_node *n_ptr; |
1061 | struct tipc_link *l_ptr; | 1049 | struct tipc_link *l_ptr; |
1062 | struct sk_buff *buf = head; | 1050 | struct sk_buff *skb1, *tmp; |
1063 | struct sk_buff *skb1, *tmp; | 1051 | struct tipc_msg *msg; |
1064 | struct tipc_msg *msg; | 1052 | u32 seq_no; |
1065 | u32 seq_no; | 1053 | u32 ackd; |
1066 | u32 ackd; | 1054 | u32 released; |
1067 | u32 released; | ||
1068 | 1055 | ||
1069 | head = head->next; | 1056 | __skb_queue_head_init(&head); |
1070 | buf->next = NULL; | 1057 | __skb_queue_tail(&head, skb); |
1071 | 1058 | ||
1059 | while ((skb = __skb_dequeue(&head))) { | ||
1072 | /* Ensure message is well-formed */ | 1060 | /* Ensure message is well-formed */ |
1073 | if (unlikely(!link_recv_buf_validate(buf))) | 1061 | if (unlikely(!link_recv_buf_validate(skb))) |
1074 | goto discard; | 1062 | goto discard; |
1075 | 1063 | ||
1076 | /* Ensure message data is a single contiguous unit */ | 1064 | /* Ensure message data is a single contiguous unit */ |
1077 | if (unlikely(skb_linearize(buf))) | 1065 | if (unlikely(skb_linearize(skb))) |
1078 | goto discard; | 1066 | goto discard; |
1079 | 1067 | ||
1080 | /* Handle arrival of a non-unicast link message */ | 1068 | /* Handle arrival of a non-unicast link message */ |
1081 | msg = buf_msg(buf); | 1069 | msg = buf_msg(skb); |
1082 | 1070 | ||
1083 | if (unlikely(msg_non_seq(msg))) { | 1071 | if (unlikely(msg_non_seq(msg))) { |
1084 | if (msg_user(msg) == LINK_CONFIG) | 1072 | if (msg_user(msg) == LINK_CONFIG) |
1085 | tipc_disc_rcv(buf, b_ptr); | 1073 | tipc_disc_rcv(skb, b_ptr); |
1086 | else | 1074 | else |
1087 | tipc_bclink_rcv(buf); | 1075 | tipc_bclink_rcv(skb); |
1088 | continue; | 1076 | continue; |
1089 | } | 1077 | } |
1090 | 1078 | ||
@@ -1145,8 +1133,8 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
1145 | /* Process the incoming packet */ | 1133 | /* Process the incoming packet */ |
1146 | if (unlikely(!link_working_working(l_ptr))) { | 1134 | if (unlikely(!link_working_working(l_ptr))) { |
1147 | if (msg_user(msg) == LINK_PROTOCOL) { | 1135 | if (msg_user(msg) == LINK_PROTOCOL) { |
1148 | tipc_link_proto_rcv(l_ptr, buf); | 1136 | tipc_link_proto_rcv(l_ptr, skb); |
1149 | head = link_insert_deferred_queue(l_ptr, head); | 1137 | link_retrieve_defq(l_ptr, &head); |
1150 | tipc_node_unlock(n_ptr); | 1138 | tipc_node_unlock(n_ptr); |
1151 | continue; | 1139 | continue; |
1152 | } | 1140 | } |
@@ -1156,8 +1144,7 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
1156 | 1144 | ||
1157 | if (link_working_working(l_ptr)) { | 1145 | if (link_working_working(l_ptr)) { |
1158 | /* Re-insert buffer in front of queue */ | 1146 | /* Re-insert buffer in front of queue */ |
1159 | buf->next = head; | 1147 | __skb_queue_head(&head, skb); |
1160 | head = buf; | ||
1161 | tipc_node_unlock(n_ptr); | 1148 | tipc_node_unlock(n_ptr); |
1162 | continue; | 1149 | continue; |
1163 | } | 1150 | } |
@@ -1166,33 +1153,33 @@ void tipc_rcv(struct sk_buff *head, struct tipc_bearer *b_ptr) | |||
1166 | 1153 | ||
1167 | /* Link is now in state WORKING_WORKING */ | 1154 | /* Link is now in state WORKING_WORKING */ |
1168 | if (unlikely(seq_no != mod(l_ptr->next_in_no))) { | 1155 | if (unlikely(seq_no != mod(l_ptr->next_in_no))) { |
1169 | link_handle_out_of_seq_msg(l_ptr, buf); | 1156 | link_handle_out_of_seq_msg(l_ptr, skb); |
1170 | head = link_insert_deferred_queue(l_ptr, head); | 1157 | link_retrieve_defq(l_ptr, &head); |
1171 | tipc_node_unlock(n_ptr); | 1158 | tipc_node_unlock(n_ptr); |
1172 | continue; | 1159 | continue; |
1173 | } | 1160 | } |
1174 | l_ptr->next_in_no++; | 1161 | l_ptr->next_in_no++; |
1175 | if (unlikely(!skb_queue_empty(&l_ptr->deferred_queue))) | 1162 | if (unlikely(!skb_queue_empty(&l_ptr->deferred_queue))) |
1176 | head = link_insert_deferred_queue(l_ptr, head); | 1163 | link_retrieve_defq(l_ptr, &head); |
1177 | 1164 | ||
1178 | if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) { | 1165 | if (unlikely(++l_ptr->unacked_window >= TIPC_MIN_LINK_WIN)) { |
1179 | l_ptr->stats.sent_acks++; | 1166 | l_ptr->stats.sent_acks++; |
1180 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); | 1167 | tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); |
1181 | } | 1168 | } |
1182 | 1169 | ||
1183 | if (tipc_link_prepare_input(l_ptr, &buf)) { | 1170 | if (tipc_link_prepare_input(l_ptr, &skb)) { |
1184 | tipc_node_unlock(n_ptr); | 1171 | tipc_node_unlock(n_ptr); |
1185 | continue; | 1172 | continue; |
1186 | } | 1173 | } |
1187 | tipc_node_unlock(n_ptr); | 1174 | tipc_node_unlock(n_ptr); |
1188 | msg = buf_msg(buf); | 1175 | |
1189 | if (tipc_link_input(l_ptr, buf) != 0) | 1176 | if (tipc_link_input(l_ptr, skb) != 0) |
1190 | goto discard; | 1177 | goto discard; |
1191 | continue; | 1178 | continue; |
1192 | unlock_discard: | 1179 | unlock_discard: |
1193 | tipc_node_unlock(n_ptr); | 1180 | tipc_node_unlock(n_ptr); |
1194 | discard: | 1181 | discard: |
1195 | kfree_skb(buf); | 1182 | kfree_skb(skb); |
1196 | } | 1183 | } |
1197 | } | 1184 | } |
1198 | 1185 | ||