aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/sctp/associola.c34
-rw-r--r--net/sctp/bind_addr.c15
-rw-r--r--net/sctp/outqueue.c49
-rw-r--r--net/sctp/proc.c9
-rw-r--r--net/sctp/sm_make_chunk.c10
-rw-r--r--net/sctp/sm_sideeffect.c20
-rw-r--r--net/sctp/sm_statefuns.c10
-rw-r--r--net/sctp/socket.c56
8 files changed, 69 insertions, 134 deletions
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 422c98aa9d5c..b4cd2b71953f 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -718,12 +718,11 @@ struct sctp_transport *sctp_assoc_lookup_paddr(
718 const union sctp_addr *address) 718 const union sctp_addr *address)
719{ 719{
720 struct sctp_transport *t; 720 struct sctp_transport *t;
721 struct list_head *pos;
722 721
723 /* Cycle through all transports searching for a peer address. */ 722 /* Cycle through all transports searching for a peer address. */
724 723
725 list_for_each(pos, &asoc->peer.transport_addr_list) { 724 list_for_each_entry(t, &asoc->peer.transport_addr_list,
726 t = list_entry(pos, struct sctp_transport, transports); 725 transports) {
727 if (sctp_cmp_addr_exact(address, &t->ipaddr)) 726 if (sctp_cmp_addr_exact(address, &t->ipaddr))
728 return t; 727 return t;
729 } 728 }
@@ -762,7 +761,6 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
762 struct sctp_transport *second; 761 struct sctp_transport *second;
763 struct sctp_ulpevent *event; 762 struct sctp_ulpevent *event;
764 struct sockaddr_storage addr; 763 struct sockaddr_storage addr;
765 struct list_head *pos;
766 int spc_state = 0; 764 int spc_state = 0;
767 765
768 /* Record the transition on the transport. */ 766 /* Record the transition on the transport. */
@@ -814,8 +812,8 @@ void sctp_assoc_control_transport(struct sctp_association *asoc,
814 */ 812 */
815 first = NULL; second = NULL; 813 first = NULL; second = NULL;
816 814
817 list_for_each(pos, &asoc->peer.transport_addr_list) { 815 list_for_each_entry(t, &asoc->peer.transport_addr_list,
818 t = list_entry(pos, struct sctp_transport, transports); 816 transports) {
819 817
820 if ((t->state == SCTP_INACTIVE) || 818 if ((t->state == SCTP_INACTIVE) ||
821 (t->state == SCTP_UNCONFIRMED)) 819 (t->state == SCTP_UNCONFIRMED))
@@ -932,7 +930,6 @@ struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *asoc,
932{ 930{
933 struct sctp_transport *active; 931 struct sctp_transport *active;
934 struct sctp_transport *match; 932 struct sctp_transport *match;
935 struct list_head *entry, *pos;
936 struct sctp_transport *transport; 933 struct sctp_transport *transport;
937 struct sctp_chunk *chunk; 934 struct sctp_chunk *chunk;
938 __be32 key = htonl(tsn); 935 __be32 key = htonl(tsn);
@@ -956,8 +953,8 @@ struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *asoc,
956 953
957 active = asoc->peer.active_path; 954 active = asoc->peer.active_path;
958 955
959 list_for_each(entry, &active->transmitted) { 956 list_for_each_entry(chunk, &active->transmitted,
960 chunk = list_entry(entry, struct sctp_chunk, transmitted_list); 957 transmitted_list) {
961 958
962 if (key == chunk->subh.data_hdr->tsn) { 959 if (key == chunk->subh.data_hdr->tsn) {
963 match = active; 960 match = active;
@@ -966,14 +963,13 @@ struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *asoc,
966 } 963 }
967 964
968 /* If not found, go search all the other transports. */ 965 /* If not found, go search all the other transports. */
969 list_for_each(pos, &asoc->peer.transport_addr_list) { 966 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
970 transport = list_entry(pos, struct sctp_transport, transports); 967 transports) {
971 968
972 if (transport == active) 969 if (transport == active)
973 break; 970 break;
974 list_for_each(entry, &transport->transmitted) { 971 list_for_each_entry(chunk, &transport->transmitted,
975 chunk = list_entry(entry, struct sctp_chunk, 972 transmitted_list) {
976 transmitted_list);
977 if (key == chunk->subh.data_hdr->tsn) { 973 if (key == chunk->subh.data_hdr->tsn) {
978 match = transport; 974 match = transport;
979 goto out; 975 goto out;
@@ -1154,9 +1150,8 @@ void sctp_assoc_update(struct sctp_association *asoc,
1154 1150
1155 } else { 1151 } else {
1156 /* Add any peer addresses from the new association. */ 1152 /* Add any peer addresses from the new association. */
1157 list_for_each(pos, &new->peer.transport_addr_list) { 1153 list_for_each_entry(trans, &new->peer.transport_addr_list,
1158 trans = list_entry(pos, struct sctp_transport, 1154 transports) {
1159 transports);
1160 if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr)) 1155 if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))
1161 sctp_assoc_add_peer(asoc, &trans->ipaddr, 1156 sctp_assoc_add_peer(asoc, &trans->ipaddr,
1162 GFP_ATOMIC, trans->state); 1157 GFP_ATOMIC, trans->state);
@@ -1306,15 +1301,14 @@ struct sctp_transport *sctp_assoc_choose_shutdown_transport(
1306void sctp_assoc_sync_pmtu(struct sctp_association *asoc) 1301void sctp_assoc_sync_pmtu(struct sctp_association *asoc)
1307{ 1302{
1308 struct sctp_transport *t; 1303 struct sctp_transport *t;
1309 struct list_head *pos;
1310 __u32 pmtu = 0; 1304 __u32 pmtu = 0;
1311 1305
1312 if (!asoc) 1306 if (!asoc)
1313 return; 1307 return;
1314 1308
1315 /* Get the lowest pmtu of all the transports. */ 1309 /* Get the lowest pmtu of all the transports. */
1316 list_for_each(pos, &asoc->peer.transport_addr_list) { 1310 list_for_each_entry(t, &asoc->peer.transport_addr_list,
1317 t = list_entry(pos, struct sctp_transport, transports); 1311 transports) {
1318 if (t->pmtu_pending && t->dst) { 1312 if (t->pmtu_pending && t->dst) {
1319 sctp_transport_update_pmtu(t, dst_mtu(t->dst)); 1313 sctp_transport_update_pmtu(t, dst_mtu(t->dst));
1320 t->pmtu_pending = 0; 1314 t->pmtu_pending = 0;
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index ceefda025e2d..80e6df06967a 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -67,15 +67,13 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
67 int flags) 67 int flags)
68{ 68{
69 struct sctp_sockaddr_entry *addr; 69 struct sctp_sockaddr_entry *addr;
70 struct list_head *pos;
71 int error = 0; 70 int error = 0;
72 71
73 /* All addresses share the same port. */ 72 /* All addresses share the same port. */
74 dest->port = src->port; 73 dest->port = src->port;
75 74
76 /* Extract the addresses which are relevant for this scope. */ 75 /* Extract the addresses which are relevant for this scope. */
77 list_for_each(pos, &src->address_list) { 76 list_for_each_entry(addr, &src->address_list, list) {
78 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
79 error = sctp_copy_one_addr(dest, &addr->a, scope, 77 error = sctp_copy_one_addr(dest, &addr->a, scope,
80 gfp, flags); 78 gfp, flags);
81 if (error < 0) 79 if (error < 0)
@@ -87,9 +85,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
87 * the assumption that we must be sitting behind a NAT. 85 * the assumption that we must be sitting behind a NAT.
88 */ 86 */
89 if (list_empty(&dest->address_list) && (SCTP_SCOPE_GLOBAL == scope)) { 87 if (list_empty(&dest->address_list) && (SCTP_SCOPE_GLOBAL == scope)) {
90 list_for_each(pos, &src->address_list) { 88 list_for_each_entry(addr, &src->address_list, list) {
91 addr = list_entry(pos, struct sctp_sockaddr_entry,
92 list);
93 error = sctp_copy_one_addr(dest, &addr->a, 89 error = sctp_copy_one_addr(dest, &addr->a,
94 SCTP_SCOPE_LINK, gfp, 90 SCTP_SCOPE_LINK, gfp,
95 flags); 91 flags);
@@ -115,14 +111,12 @@ int sctp_bind_addr_dup(struct sctp_bind_addr *dest,
115 gfp_t gfp) 111 gfp_t gfp)
116{ 112{
117 struct sctp_sockaddr_entry *addr; 113 struct sctp_sockaddr_entry *addr;
118 struct list_head *pos;
119 int error = 0; 114 int error = 0;
120 115
121 /* All addresses share the same port. */ 116 /* All addresses share the same port. */
122 dest->port = src->port; 117 dest->port = src->port;
123 118
124 list_for_each(pos, &src->address_list) { 119 list_for_each_entry(addr, &src->address_list, list) {
125 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
126 error = sctp_add_bind_addr(dest, &addr->a, 1, gfp); 120 error = sctp_add_bind_addr(dest, &addr->a, 1, gfp);
127 if (error < 0) 121 if (error < 0)
128 break; 122 break;
@@ -273,8 +267,7 @@ union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp,
273 267
274 addrparms = retval; 268 addrparms = retval;
275 269
276 list_for_each(pos, &bp->address_list) { 270 list_for_each_entry(addr, &bp->address_list, list) {
277 addr = list_entry(pos, struct sctp_sockaddr_entry, list);
278 af = sctp_get_af_specific(addr->a.v4.sin_family); 271 af = sctp_get_af_specific(addr->a.v4.sin_family);
279 len = af->to_addr_param(&addr->a, &rawaddr); 272 len = af->to_addr_param(&addr->a, &rawaddr);
280 memcpy(addrparms.v, &rawaddr, len); 273 memcpy(addrparms.v, &rawaddr, len);
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 392012f5ab83..213c2e2926a9 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -221,12 +221,12 @@ void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
221void sctp_outq_teardown(struct sctp_outq *q) 221void sctp_outq_teardown(struct sctp_outq *q)
222{ 222{
223 struct sctp_transport *transport; 223 struct sctp_transport *transport;
224 struct list_head *lchunk, *pos, *temp; 224 struct list_head *lchunk, *temp;
225 struct sctp_chunk *chunk, *tmp; 225 struct sctp_chunk *chunk, *tmp;
226 226
227 /* Throw away unacknowledged chunks. */ 227 /* Throw away unacknowledged chunks. */
228 list_for_each(pos, &q->asoc->peer.transport_addr_list) { 228 list_for_each_entry(transport, &q->asoc->peer.transport_addr_list,
229 transport = list_entry(pos, struct sctp_transport, transports); 229 transports) {
230 while ((lchunk = sctp_list_dequeue(&transport->transmitted)) != NULL) { 230 while ((lchunk = sctp_list_dequeue(&transport->transmitted)) != NULL) {
231 chunk = list_entry(lchunk, struct sctp_chunk, 231 chunk = list_entry(lchunk, struct sctp_chunk,
232 transmitted_list); 232 transmitted_list);
@@ -538,7 +538,7 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
538 int rtx_timeout, int *start_timer) 538 int rtx_timeout, int *start_timer)
539{ 539{
540 struct list_head *lqueue; 540 struct list_head *lqueue;
541 struct list_head *lchunk, *lchunk1; 541 struct list_head *lchunk;
542 struct sctp_transport *transport = pkt->transport; 542 struct sctp_transport *transport = pkt->transport;
543 sctp_xmit_t status; 543 sctp_xmit_t status;
544 struct sctp_chunk *chunk, *chunk1; 544 struct sctp_chunk *chunk, *chunk1;
@@ -649,9 +649,7 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
649 * to be marked as ineligible for a subsequent fast retransmit. 649 * to be marked as ineligible for a subsequent fast retransmit.
650 */ 650 */
651 if (rtx_timeout && !lchunk) { 651 if (rtx_timeout && !lchunk) {
652 list_for_each(lchunk1, lqueue) { 652 list_for_each_entry(chunk1, lqueue, transmitted_list) {
653 chunk1 = list_entry(lchunk1, struct sctp_chunk,
654 transmitted_list);
655 if (chunk1->fast_retransmit > 0) 653 if (chunk1->fast_retransmit > 0)
656 chunk1->fast_retransmit = -1; 654 chunk1->fast_retransmit = -1;
657 } 655 }
@@ -1037,7 +1035,6 @@ static void sctp_sack_update_unack_data(struct sctp_association *assoc,
1037static __u32 sctp_highest_new_tsn(struct sctp_sackhdr *sack, 1035static __u32 sctp_highest_new_tsn(struct sctp_sackhdr *sack,
1038 struct sctp_association *asoc) 1036 struct sctp_association *asoc)
1039{ 1037{
1040 struct list_head *ltransport, *lchunk;
1041 struct sctp_transport *transport; 1038 struct sctp_transport *transport;
1042 struct sctp_chunk *chunk; 1039 struct sctp_chunk *chunk;
1043 __u32 highest_new_tsn, tsn; 1040 __u32 highest_new_tsn, tsn;
@@ -1045,12 +1042,9 @@ static __u32 sctp_highest_new_tsn(struct sctp_sackhdr *sack,
1045 1042
1046 highest_new_tsn = ntohl(sack->cum_tsn_ack); 1043 highest_new_tsn = ntohl(sack->cum_tsn_ack);
1047 1044
1048 list_for_each(ltransport, transport_list) { 1045 list_for_each_entry(transport, transport_list, transports) {
1049 transport = list_entry(ltransport, struct sctp_transport, 1046 list_for_each_entry(chunk, &transport->transmitted,
1050 transports); 1047 transmitted_list) {
1051 list_for_each(lchunk, &transport->transmitted) {
1052 chunk = list_entry(lchunk, struct sctp_chunk,
1053 transmitted_list);
1054 tsn = ntohl(chunk->subh.data_hdr->tsn); 1048 tsn = ntohl(chunk->subh.data_hdr->tsn);
1055 1049
1056 if (!chunk->tsn_gap_acked && 1050 if (!chunk->tsn_gap_acked &&
@@ -1073,7 +1067,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
1073 struct sctp_association *asoc = q->asoc; 1067 struct sctp_association *asoc = q->asoc;
1074 struct sctp_transport *transport; 1068 struct sctp_transport *transport;
1075 struct sctp_chunk *tchunk = NULL; 1069 struct sctp_chunk *tchunk = NULL;
1076 struct list_head *lchunk, *transport_list, *pos, *temp; 1070 struct list_head *lchunk, *transport_list, *temp;
1077 sctp_sack_variable_t *frags = sack->variable; 1071 sctp_sack_variable_t *frags = sack->variable;
1078 __u32 sack_ctsn, ctsn, tsn; 1072 __u32 sack_ctsn, ctsn, tsn;
1079 __u32 highest_tsn, highest_new_tsn; 1073 __u32 highest_tsn, highest_new_tsn;
@@ -1099,9 +1093,8 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
1099 */ 1093 */
1100 if (TSN_lte(primary->cacc.next_tsn_at_change, sack_ctsn)) { 1094 if (TSN_lte(primary->cacc.next_tsn_at_change, sack_ctsn)) {
1101 primary->cacc.changeover_active = 0; 1095 primary->cacc.changeover_active = 0;
1102 list_for_each(pos, transport_list) { 1096 list_for_each_entry(transport, transport_list,
1103 transport = list_entry(pos, struct sctp_transport, 1097 transports) {
1104 transports);
1105 transport->cacc.cycling_changeover = 0; 1098 transport->cacc.cycling_changeover = 0;
1106 } 1099 }
1107 } 1100 }
@@ -1116,9 +1109,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
1116 */ 1109 */
1117 if (sack->num_gap_ack_blocks && 1110 if (sack->num_gap_ack_blocks &&
1118 primary->cacc.changeover_active) { 1111 primary->cacc.changeover_active) {
1119 list_for_each(pos, transport_list) { 1112 list_for_each_entry(transport, transport_list, transports) {
1120 transport = list_entry(pos, struct sctp_transport,
1121 transports);
1122 transport->cacc.cacc_saw_newack = 0; 1113 transport->cacc.cacc_saw_newack = 0;
1123 } 1114 }
1124 } 1115 }
@@ -1147,9 +1138,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
1147 * 1138 *
1148 * This is a MASSIVE candidate for optimization. 1139 * This is a MASSIVE candidate for optimization.
1149 */ 1140 */
1150 list_for_each(pos, transport_list) { 1141 list_for_each_entry(transport, transport_list, transports) {
1151 transport = list_entry(pos, struct sctp_transport,
1152 transports);
1153 sctp_check_transmitted(q, &transport->transmitted, 1142 sctp_check_transmitted(q, &transport->transmitted,
1154 transport, sack, highest_new_tsn); 1143 transport, sack, highest_new_tsn);
1155 /* 1144 /*
@@ -1161,9 +1150,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
1161 count_of_newacks ++; 1150 count_of_newacks ++;
1162 } 1151 }
1163 1152
1164 list_for_each(pos, transport_list) { 1153 list_for_each_entry(transport, transport_list, transports) {
1165 transport = list_entry(pos, struct sctp_transport,
1166 transports);
1167 sctp_mark_missing(q, &transport->transmitted, transport, 1154 sctp_mark_missing(q, &transport->transmitted, transport,
1168 highest_new_tsn, count_of_newacks); 1155 highest_new_tsn, count_of_newacks);
1169 } 1156 }
@@ -1220,9 +1207,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
1220 if (!q->empty) 1207 if (!q->empty)
1221 goto finish; 1208 goto finish;
1222 1209
1223 list_for_each(pos, transport_list) { 1210 list_for_each_entry(transport, transport_list, transports) {
1224 transport = list_entry(pos, struct sctp_transport,
1225 transports);
1226 q->empty = q->empty && list_empty(&transport->transmitted); 1211 q->empty = q->empty && list_empty(&transport->transmitted);
1227 if (!q->empty) 1212 if (!q->empty)
1228 goto finish; 1213 goto finish;
@@ -1596,14 +1581,12 @@ static void sctp_mark_missing(struct sctp_outq *q,
1596 int count_of_newacks) 1581 int count_of_newacks)
1597{ 1582{
1598 struct sctp_chunk *chunk; 1583 struct sctp_chunk *chunk;
1599 struct list_head *pos;
1600 __u32 tsn; 1584 __u32 tsn;
1601 char do_fast_retransmit = 0; 1585 char do_fast_retransmit = 0;
1602 struct sctp_transport *primary = q->asoc->peer.primary_path; 1586 struct sctp_transport *primary = q->asoc->peer.primary_path;
1603 1587
1604 list_for_each(pos, transmitted_queue) { 1588 list_for_each_entry(chunk, transmitted_queue, transmitted_list) {
1605 1589
1606 chunk = list_entry(pos, struct sctp_chunk, transmitted_list);
1607 tsn = ntohl(chunk->subh.data_hdr->tsn); 1590 tsn = ntohl(chunk->subh.data_hdr->tsn);
1608 1591
1609 /* RFC 2960 7.2.4, sctpimpguide-05 2.8.2 M3) Examine all 1592 /* RFC 2960 7.2.4, sctpimpguide-05 2.8.2 M3) Examine all
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 99062f5f42e3..0aba759cb9b7 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -124,7 +124,6 @@ void sctp_snmp_proc_exit(void)
124/* Dump local addresses of an association/endpoint. */ 124/* Dump local addresses of an association/endpoint. */
125static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_common *epb) 125static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_common *epb)
126{ 126{
127 struct list_head *pos;
128 struct sctp_association *asoc; 127 struct sctp_association *asoc;
129 struct sctp_sockaddr_entry *laddr; 128 struct sctp_sockaddr_entry *laddr;
130 struct sctp_transport *peer; 129 struct sctp_transport *peer;
@@ -137,8 +136,7 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo
137 primary = &peer->saddr; 136 primary = &peer->saddr;
138 } 137 }
139 138
140 list_for_each(pos, &epb->bind_addr.address_list) { 139 list_for_each_entry(laddr, &epb->bind_addr.address_list, list) {
141 laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
142 addr = &laddr->a; 140 addr = &laddr->a;
143 af = sctp_get_af_specific(addr->sa.sa_family); 141 af = sctp_get_af_specific(addr->sa.sa_family);
144 if (primary && af->cmp_addr(addr, primary)) { 142 if (primary && af->cmp_addr(addr, primary)) {
@@ -151,14 +149,13 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo
151/* Dump remote addresses of an association. */ 149/* Dump remote addresses of an association. */
152static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_association *assoc) 150static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_association *assoc)
153{ 151{
154 struct list_head *pos;
155 struct sctp_transport *transport; 152 struct sctp_transport *transport;
156 union sctp_addr *addr, *primary; 153 union sctp_addr *addr, *primary;
157 struct sctp_af *af; 154 struct sctp_af *af;
158 155
159 primary = &assoc->peer.primary_addr; 156 primary = &assoc->peer.primary_addr;
160 list_for_each(pos, &assoc->peer.transport_addr_list) { 157 list_for_each_entry(transport, &assoc->peer.transport_addr_list,
161 transport = list_entry(pos, struct sctp_transport, transports); 158 transports) {
162 addr = &transport->ipaddr; 159 addr = &transport->ipaddr;
163 af = sctp_get_af_specific(addr->sa.sa_family); 160 af = sctp_get_af_specific(addr->sa.sa_family);
164 if (af->cmp_addr(addr, primary)) { 161 if (af->cmp_addr(addr, primary)) {
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index c8982452580e..0679bddf3a95 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2246,8 +2246,8 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
2246 * high (for example, implementations MAY use the size of the receiver 2246 * high (for example, implementations MAY use the size of the receiver
2247 * advertised window). 2247 * advertised window).
2248 */ 2248 */
2249 list_for_each(pos, &asoc->peer.transport_addr_list) { 2249 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
2250 transport = list_entry(pos, struct sctp_transport, transports); 2250 transports) {
2251 transport->ssthresh = asoc->peer.i.a_rwnd; 2251 transport->ssthresh = asoc->peer.i.a_rwnd;
2252 } 2252 }
2253 2253
@@ -3043,7 +3043,6 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
3043 union sctp_addr addr; 3043 union sctp_addr addr;
3044 struct sctp_bind_addr *bp = &asoc->base.bind_addr; 3044 struct sctp_bind_addr *bp = &asoc->base.bind_addr;
3045 union sctp_addr_param *addr_param; 3045 union sctp_addr_param *addr_param;
3046 struct list_head *pos;
3047 struct sctp_transport *transport; 3046 struct sctp_transport *transport;
3048 struct sctp_sockaddr_entry *saddr; 3047 struct sctp_sockaddr_entry *saddr;
3049 int retval = 0; 3048 int retval = 0;
@@ -3071,9 +3070,8 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
3071 local_bh_disable(); 3070 local_bh_disable();
3072 retval = sctp_del_bind_addr(bp, &addr); 3071 retval = sctp_del_bind_addr(bp, &addr);
3073 local_bh_enable(); 3072 local_bh_enable();
3074 list_for_each(pos, &asoc->peer.transport_addr_list) { 3073 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
3075 transport = list_entry(pos, struct sctp_transport, 3074 transports) {
3076 transports);
3077 dst_release(transport->dst); 3075 dst_release(transport->dst);
3078 sctp_transport_route(transport, NULL, 3076 sctp_transport_route(transport, NULL,
3079 sctp_sk(asoc->base.sk)); 3077 sctp_sk(asoc->base.sk));
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 02bf32c30263..5fdb623d8281 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -545,14 +545,12 @@ static void sctp_cmd_hb_timers_start(sctp_cmd_seq_t *cmds,
545 struct sctp_association *asoc) 545 struct sctp_association *asoc)
546{ 546{
547 struct sctp_transport *t; 547 struct sctp_transport *t;
548 struct list_head *pos;
549 548
550 /* Start a heartbeat timer for each transport on the association. 549 /* Start a heartbeat timer for each transport on the association.
551 * hold a reference on the transport to make sure none of 550 * hold a reference on the transport to make sure none of
552 * the needed data structures go away. 551 * the needed data structures go away.
553 */ 552 */
554 list_for_each(pos, &asoc->peer.transport_addr_list) { 553 list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) {
555 t = list_entry(pos, struct sctp_transport, transports);
556 554
557 if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t))) 555 if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t)))
558 sctp_transport_hold(t); 556 sctp_transport_hold(t);
@@ -563,12 +561,11 @@ static void sctp_cmd_hb_timers_stop(sctp_cmd_seq_t *cmds,
563 struct sctp_association *asoc) 561 struct sctp_association *asoc)
564{ 562{
565 struct sctp_transport *t; 563 struct sctp_transport *t;
566 struct list_head *pos;
567 564
568 /* Stop all heartbeat timers. */ 565 /* Stop all heartbeat timers. */
569 566
570 list_for_each(pos, &asoc->peer.transport_addr_list) { 567 list_for_each_entry(t, &asoc->peer.transport_addr_list,
571 t = list_entry(pos, struct sctp_transport, transports); 568 transports) {
572 if (del_timer(&t->hb_timer)) 569 if (del_timer(&t->hb_timer))
573 sctp_transport_put(t); 570 sctp_transport_put(t);
574 } 571 }
@@ -579,10 +576,9 @@ static void sctp_cmd_t3_rtx_timers_stop(sctp_cmd_seq_t *cmds,
579 struct sctp_association *asoc) 576 struct sctp_association *asoc)
580{ 577{
581 struct sctp_transport *t; 578 struct sctp_transport *t;
582 struct list_head *pos;
583 579
584 list_for_each(pos, &asoc->peer.transport_addr_list) { 580 list_for_each_entry(t, &asoc->peer.transport_addr_list,
585 t = list_entry(pos, struct sctp_transport, transports); 581 transports) {
586 if (timer_pending(&t->T3_rtx_timer) && 582 if (timer_pending(&t->T3_rtx_timer) &&
587 del_timer(&t->T3_rtx_timer)) { 583 del_timer(&t->T3_rtx_timer)) {
588 sctp_transport_put(t); 584 sctp_transport_put(t);
@@ -1065,7 +1061,6 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1065 struct sctp_chunk *new_obj; 1061 struct sctp_chunk *new_obj;
1066 struct sctp_chunk *chunk = NULL; 1062 struct sctp_chunk *chunk = NULL;
1067 struct sctp_packet *packet; 1063 struct sctp_packet *packet;
1068 struct list_head *pos;
1069 struct timer_list *timer; 1064 struct timer_list *timer;
1070 unsigned long timeout; 1065 unsigned long timeout;
1071 struct sctp_transport *t; 1066 struct sctp_transport *t;
@@ -1397,9 +1392,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1397 /* If we've sent any data bundled with 1392 /* If we've sent any data bundled with
1398 * COOKIE-ECHO we need to resend. 1393 * COOKIE-ECHO we need to resend.
1399 */ 1394 */
1400 list_for_each(pos, &asoc->peer.transport_addr_list) { 1395 list_for_each_entry(t, &asoc->peer.transport_addr_list,
1401 t = list_entry(pos, struct sctp_transport, 1396 transports) {
1402 transports);
1403 sctp_retransmit_mark(&asoc->outqueue, t, 1397 sctp_retransmit_mark(&asoc->outqueue, t,
1404 SCTP_RTXR_T1_RTX); 1398 SCTP_RTXR_T1_RTX);
1405 } 1399 }
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index b534dbef864f..622284805500 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -1226,7 +1226,6 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,
1226 sctp_cmd_seq_t *commands) 1226 sctp_cmd_seq_t *commands)
1227{ 1227{
1228 struct sctp_transport *new_addr, *addr; 1228 struct sctp_transport *new_addr, *addr;
1229 struct list_head *pos, *pos2;
1230 int found; 1229 int found;
1231 1230
1232 /* Implementor's Guide - Sectin 5.2.2 1231 /* Implementor's Guide - Sectin 5.2.2
@@ -1243,12 +1242,11 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,
1243 new_addr = NULL; 1242 new_addr = NULL;
1244 found = 0; 1243 found = 0;
1245 1244
1246 list_for_each(pos, &new_asoc->peer.transport_addr_list) { 1245 list_for_each_entry(new_addr, &new_asoc->peer.transport_addr_list,
1247 new_addr = list_entry(pos, struct sctp_transport, transports); 1246 transports) {
1248 found = 0; 1247 found = 0;
1249 list_for_each(pos2, &asoc->peer.transport_addr_list) { 1248 list_for_each_entry(addr, &asoc->peer.transport_addr_list,
1250 addr = list_entry(pos2, struct sctp_transport, 1249 transports) {
1251 transports);
1252 if (sctp_cmp_addr_exact(&new_addr->ipaddr, 1250 if (sctp_cmp_addr_exact(&new_addr->ipaddr,
1253 &addr->ipaddr)) { 1251 &addr->ipaddr)) {
1254 found = 1; 1252 found = 1;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 025f467d80dd..8c90289ba400 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -513,7 +513,6 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
513 union sctp_addr saveaddr; 513 union sctp_addr saveaddr;
514 void *addr_buf; 514 void *addr_buf;
515 struct sctp_af *af; 515 struct sctp_af *af;
516 struct list_head *pos;
517 struct list_head *p; 516 struct list_head *p;
518 int i; 517 int i;
519 int retval = 0; 518 int retval = 0;
@@ -527,8 +526,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
527 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n", 526 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n",
528 __func__, sk, addrs, addrcnt); 527 __func__, sk, addrs, addrcnt);
529 528
530 list_for_each(pos, &ep->asocs) { 529 list_for_each_entry(asoc, &ep->asocs, asocs) {
531 asoc = list_entry(pos, struct sctp_association, asocs);
532 530
533 if (!asoc->peer.asconf_capable) 531 if (!asoc->peer.asconf_capable)
534 continue; 532 continue;
@@ -699,7 +697,6 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
699 union sctp_addr *laddr; 697 union sctp_addr *laddr;
700 void *addr_buf; 698 void *addr_buf;
701 struct sctp_af *af; 699 struct sctp_af *af;
702 struct list_head *pos, *pos1;
703 struct sctp_sockaddr_entry *saddr; 700 struct sctp_sockaddr_entry *saddr;
704 int i; 701 int i;
705 int retval = 0; 702 int retval = 0;
@@ -713,8 +710,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
713 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n", 710 SCTP_DEBUG_PRINTK("%s: (sk: %p, addrs: %p, addrcnt: %d)\n",
714 __func__, sk, addrs, addrcnt); 711 __func__, sk, addrs, addrcnt);
715 712
716 list_for_each(pos, &ep->asocs) { 713 list_for_each_entry(asoc, &ep->asocs, asocs) {
717 asoc = list_entry(pos, struct sctp_association, asocs);
718 714
719 if (!asoc->peer.asconf_capable) 715 if (!asoc->peer.asconf_capable)
720 continue; 716 continue;
@@ -787,9 +783,8 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
787 * as some of the addresses in the bind address list are 783 * as some of the addresses in the bind address list are
788 * about to be deleted and cannot be used as source addresses. 784 * about to be deleted and cannot be used as source addresses.
789 */ 785 */
790 list_for_each(pos1, &asoc->peer.transport_addr_list) { 786 list_for_each_entry(transport, &asoc->peer.transport_addr_list,
791 transport = list_entry(pos1, struct sctp_transport, 787 transports) {
792 transports);
793 dst_release(transport->dst); 788 dst_release(transport->dst);
794 sctp_transport_route(transport, NULL, 789 sctp_transport_route(transport, NULL,
795 sctp_sk(asoc->base.sk)); 790 sctp_sk(asoc->base.sk));
@@ -1397,7 +1392,6 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1397 long timeo; 1392 long timeo;
1398 __u16 sinfo_flags = 0; 1393 __u16 sinfo_flags = 0;
1399 struct sctp_datamsg *datamsg; 1394 struct sctp_datamsg *datamsg;
1400 struct list_head *pos;
1401 int msg_flags = msg->msg_flags; 1395 int msg_flags = msg->msg_flags;
1402 1396
1403 SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %zu)\n", 1397 SCTP_DEBUG_PRINTK("sctp_sendmsg(sk: %p, msg: %p, msg_len: %zu)\n",
@@ -1727,8 +1721,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
1727 } 1721 }
1728 1722
1729 /* Now send the (possibly) fragmented message. */ 1723 /* Now send the (possibly) fragmented message. */
1730 list_for_each(pos, &datamsg->chunks) { 1724 list_for_each_entry(chunk, &datamsg->chunks, frag_list) {
1731 chunk = list_entry(pos, struct sctp_chunk, frag_list);
1732 sctp_chunk_hold(chunk); 1725 sctp_chunk_hold(chunk);
1733 1726
1734 /* Do accounting for the write space. */ 1727 /* Do accounting for the write space. */
@@ -2301,11 +2294,8 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
2301 * transport. 2294 * transport.
2302 */ 2295 */
2303 if (!trans && asoc) { 2296 if (!trans && asoc) {
2304 struct list_head *pos; 2297 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2305 2298 transports) {
2306 list_for_each(pos, &asoc->peer.transport_addr_list) {
2307 trans = list_entry(pos, struct sctp_transport,
2308 transports);
2309 sctp_apply_peer_addr_params(&params, trans, asoc, sp, 2299 sctp_apply_peer_addr_params(&params, trans, asoc, sp,
2310 hb_change, pmtud_change, 2300 hb_change, pmtud_change,
2311 sackdelay_change); 2301 sackdelay_change);
@@ -2396,11 +2386,8 @@ static int sctp_setsockopt_delayed_ack_time(struct sock *sk,
2396 2386
2397 /* If change is for association, also apply to each transport. */ 2387 /* If change is for association, also apply to each transport. */
2398 if (asoc) { 2388 if (asoc) {
2399 struct list_head *pos; 2389 list_for_each_entry(trans, &asoc->peer.transport_addr_list,
2400 2390 transports) {
2401 list_for_each(pos, &asoc->peer.transport_addr_list) {
2402 trans = list_entry(pos, struct sctp_transport,
2403 transports);
2404 if (params.assoc_value) { 2391 if (params.assoc_value) {
2405 trans->sackdelay = 2392 trans->sackdelay =
2406 msecs_to_jiffies(params.assoc_value); 2393 msecs_to_jiffies(params.assoc_value);
@@ -2632,13 +2619,10 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, int o
2632 if (assocparams.sasoc_asocmaxrxt != 0) { 2619 if (assocparams.sasoc_asocmaxrxt != 0) {
2633 __u32 path_sum = 0; 2620 __u32 path_sum = 0;
2634 int paths = 0; 2621 int paths = 0;
2635 struct list_head *pos;
2636 struct sctp_transport *peer_addr; 2622 struct sctp_transport *peer_addr;
2637 2623
2638 list_for_each(pos, &asoc->peer.transport_addr_list) { 2624 list_for_each_entry(peer_addr, &asoc->peer.transport_addr_list,
2639 peer_addr = list_entry(pos, 2625 transports) {
2640 struct sctp_transport,
2641 transports);
2642 path_sum += peer_addr->pathmaxrxt; 2626 path_sum += peer_addr->pathmaxrxt;
2643 paths++; 2627 paths++;
2644 } 2628 }
@@ -2716,7 +2700,6 @@ static int sctp_setsockopt_mappedv4(struct sock *sk, char __user *optval, int op
2716static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optlen) 2700static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optlen)
2717{ 2701{
2718 struct sctp_association *asoc; 2702 struct sctp_association *asoc;
2719 struct list_head *pos;
2720 struct sctp_sock *sp = sctp_sk(sk); 2703 struct sctp_sock *sp = sctp_sk(sk);
2721 int val; 2704 int val;
2722 2705
@@ -2729,8 +2712,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, int optl
2729 sp->user_frag = val; 2712 sp->user_frag = val;
2730 2713
2731 /* Update the frag_point of the existing associations. */ 2714 /* Update the frag_point of the existing associations. */
2732 list_for_each(pos, &(sp->ep->asocs)) { 2715 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
2733 asoc = list_entry(pos, struct sctp_association, asocs);
2734 asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu); 2716 asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu);
2735 } 2717 }
2736 2718
@@ -4151,7 +4133,6 @@ static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
4151 int __user *optlen) 4133 int __user *optlen)
4152{ 4134{
4153 struct sctp_association *asoc; 4135 struct sctp_association *asoc;
4154 struct list_head *pos;
4155 int cnt = 0; 4136 int cnt = 0;
4156 struct sctp_getaddrs_old getaddrs; 4137 struct sctp_getaddrs_old getaddrs;
4157 struct sctp_transport *from; 4138 struct sctp_transport *from;
@@ -4176,8 +4157,8 @@ static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len,
4176 return -EINVAL; 4157 return -EINVAL;
4177 4158
4178 to = (void __user *)getaddrs.addrs; 4159 to = (void __user *)getaddrs.addrs;
4179 list_for_each(pos, &asoc->peer.transport_addr_list) { 4160 list_for_each_entry(from, &asoc->peer.transport_addr_list,
4180 from = list_entry(pos, struct sctp_transport, transports); 4161 transports) {
4181 memcpy(&temp, &from->ipaddr, sizeof(temp)); 4162 memcpy(&temp, &from->ipaddr, sizeof(temp));
4182 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4163 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4183 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; 4164 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
@@ -4200,7 +4181,6 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
4200 char __user *optval, int __user *optlen) 4181 char __user *optval, int __user *optlen)
4201{ 4182{
4202 struct sctp_association *asoc; 4183 struct sctp_association *asoc;
4203 struct list_head *pos;
4204 int cnt = 0; 4184 int cnt = 0;
4205 struct sctp_getaddrs getaddrs; 4185 struct sctp_getaddrs getaddrs;
4206 struct sctp_transport *from; 4186 struct sctp_transport *from;
@@ -4225,8 +4205,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
4225 to = optval + offsetof(struct sctp_getaddrs,addrs); 4205 to = optval + offsetof(struct sctp_getaddrs,addrs);
4226 space_left = len - offsetof(struct sctp_getaddrs,addrs); 4206 space_left = len - offsetof(struct sctp_getaddrs,addrs);
4227 4207
4228 list_for_each(pos, &asoc->peer.transport_addr_list) { 4208 list_for_each_entry(from, &asoc->peer.transport_addr_list,
4229 from = list_entry(pos, struct sctp_transport, transports); 4209 transports) {
4230 memcpy(&temp, &from->ipaddr, sizeof(temp)); 4210 memcpy(&temp, &from->ipaddr, sizeof(temp));
4231 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); 4211 sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
4232 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; 4212 addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len;
@@ -6193,11 +6173,9 @@ do_nonblock:
6193void sctp_write_space(struct sock *sk) 6173void sctp_write_space(struct sock *sk)
6194{ 6174{
6195 struct sctp_association *asoc; 6175 struct sctp_association *asoc;
6196 struct list_head *pos;
6197 6176
6198 /* Wake up the tasks in each wait queue. */ 6177 /* Wake up the tasks in each wait queue. */
6199 list_for_each(pos, &((sctp_sk(sk))->ep->asocs)) { 6178 list_for_each_entry(asoc, &((sctp_sk(sk))->ep->asocs), asocs) {
6200 asoc = list_entry(pos, struct sctp_association, asocs);
6201 __sctp_write_space(asoc); 6179 __sctp_write_space(asoc);
6202 } 6180 }
6203} 6181}