diff options
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/Kconfig | 12 | ||||
-rw-r--r-- | net/sctp/Makefile | 3 | ||||
-rw-r--r-- | net/sctp/associola.c | 15 | ||||
-rw-r--r-- | net/sctp/chunk.c | 4 | ||||
-rw-r--r-- | net/sctp/endpointola.c | 2 | ||||
-rw-r--r-- | net/sctp/ipv6.c | 27 | ||||
-rw-r--r-- | net/sctp/output.c | 27 | ||||
-rw-r--r-- | net/sctp/outqueue.c | 96 | ||||
-rw-r--r-- | net/sctp/probe.c | 214 | ||||
-rw-r--r-- | net/sctp/proc.c | 3 | ||||
-rw-r--r-- | net/sctp/protocol.c | 9 | ||||
-rw-r--r-- | net/sctp/sm_make_chunk.c | 28 | ||||
-rw-r--r-- | net/sctp/sm_sideeffect.c | 12 | ||||
-rw-r--r-- | net/sctp/socket.c | 41 | ||||
-rw-r--r-- | net/sctp/transport.c | 61 | ||||
-rw-r--r-- | net/sctp/ulpqueue.c | 2 |
16 files changed, 359 insertions, 197 deletions
diff --git a/net/sctp/Kconfig b/net/sctp/Kconfig index 58b3e882a187..126b014eb79b 100644 --- a/net/sctp/Kconfig +++ b/net/sctp/Kconfig | |||
@@ -37,6 +37,18 @@ menuconfig IP_SCTP | |||
37 | 37 | ||
38 | if IP_SCTP | 38 | if IP_SCTP |
39 | 39 | ||
40 | config NET_SCTPPROBE | ||
41 | tristate "SCTP: Association probing" | ||
42 | depends on PROC_FS && KPROBES | ||
43 | ---help--- | ||
44 | This module allows for capturing the changes to SCTP association | ||
45 | state in response to incoming packets. It is used for debugging | ||
46 | SCTP congestion control algorithms. If you don't understand | ||
47 | what was just said, you don't need it: say N. | ||
48 | |||
49 | To compile this code as a module, choose M here: the | ||
50 | module will be called sctp_probe. | ||
51 | |||
40 | config SCTP_DBG_MSG | 52 | config SCTP_DBG_MSG |
41 | bool "SCTP: Debug messages" | 53 | bool "SCTP: Debug messages" |
42 | help | 54 | help |
diff --git a/net/sctp/Makefile b/net/sctp/Makefile index 6b794734380a..5c30b7a873df 100644 --- a/net/sctp/Makefile +++ b/net/sctp/Makefile | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_IP_SCTP) += sctp.o | 5 | obj-$(CONFIG_IP_SCTP) += sctp.o |
6 | obj-$(CONFIG_NET_SCTPPROBE) += sctp_probe.o | ||
6 | 7 | ||
7 | sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \ | 8 | sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \ |
8 | protocol.o endpointola.o associola.o \ | 9 | protocol.o endpointola.o associola.o \ |
@@ -11,6 +12,8 @@ sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \ | |||
11 | tsnmap.o bind_addr.o socket.o primitive.o \ | 12 | tsnmap.o bind_addr.o socket.o primitive.o \ |
12 | output.o input.o debug.o ssnmap.o auth.o | 13 | output.o input.o debug.o ssnmap.o auth.o |
13 | 14 | ||
15 | sctp_probe-y := probe.o | ||
16 | |||
14 | sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o | 17 | sctp-$(CONFIG_SCTP_DBG_OBJCNT) += objcnt.o |
15 | sctp-$(CONFIG_PROC_FS) += proc.o | 18 | sctp-$(CONFIG_PROC_FS) += proc.o |
16 | sctp-$(CONFIG_SYSCTL) += sysctl.o | 19 | sctp-$(CONFIG_SYSCTL) += sysctl.o |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 99c93ee98ad9..e41feff19e43 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -87,9 +87,6 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
87 | /* Retrieve the SCTP per socket area. */ | 87 | /* Retrieve the SCTP per socket area. */ |
88 | sp = sctp_sk((struct sock *)sk); | 88 | sp = sctp_sk((struct sock *)sk); |
89 | 89 | ||
90 | /* Init all variables to a known value. */ | ||
91 | memset(asoc, 0, sizeof(struct sctp_association)); | ||
92 | |||
93 | /* Discarding const is appropriate here. */ | 90 | /* Discarding const is appropriate here. */ |
94 | asoc->ep = (struct sctp_endpoint *)ep; | 91 | asoc->ep = (struct sctp_endpoint *)ep; |
95 | sctp_endpoint_hold(asoc->ep); | 92 | sctp_endpoint_hold(asoc->ep); |
@@ -762,7 +759,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
762 | asoc->peer.retran_path = peer; | 759 | asoc->peer.retran_path = peer; |
763 | } | 760 | } |
764 | 761 | ||
765 | if (asoc->peer.active_path == asoc->peer.retran_path) { | 762 | if (asoc->peer.active_path == asoc->peer.retran_path && |
763 | peer->state != SCTP_UNCONFIRMED) { | ||
766 | asoc->peer.retran_path = peer; | 764 | asoc->peer.retran_path = peer; |
767 | } | 765 | } |
768 | 766 | ||
@@ -818,8 +816,6 @@ void sctp_assoc_del_nonprimary_peers(struct sctp_association *asoc, | |||
818 | if (t != primary) | 816 | if (t != primary) |
819 | sctp_assoc_rm_peer(asoc, t); | 817 | sctp_assoc_rm_peer(asoc, t); |
820 | } | 818 | } |
821 | |||
822 | return; | ||
823 | } | 819 | } |
824 | 820 | ||
825 | /* Engage in transport control operations. | 821 | /* Engage in transport control operations. |
@@ -1320,12 +1316,13 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc) | |||
1320 | /* Keep track of the next transport in case | 1316 | /* Keep track of the next transport in case |
1321 | * we don't find any active transport. | 1317 | * we don't find any active transport. |
1322 | */ | 1318 | */ |
1323 | if (!next) | 1319 | if (t->state != SCTP_UNCONFIRMED && !next) |
1324 | next = t; | 1320 | next = t; |
1325 | } | 1321 | } |
1326 | } | 1322 | } |
1327 | 1323 | ||
1328 | asoc->peer.retran_path = t; | 1324 | if (t) |
1325 | asoc->peer.retran_path = t; | ||
1329 | 1326 | ||
1330 | SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association" | 1327 | SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_update_retran_path:association" |
1331 | " %p addr: ", | 1328 | " %p addr: ", |
@@ -1485,7 +1482,7 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned len) | |||
1485 | if (asoc->rwnd >= len) { | 1482 | if (asoc->rwnd >= len) { |
1486 | asoc->rwnd -= len; | 1483 | asoc->rwnd -= len; |
1487 | if (over) { | 1484 | if (over) { |
1488 | asoc->rwnd_press = asoc->rwnd; | 1485 | asoc->rwnd_press += asoc->rwnd; |
1489 | asoc->rwnd = 0; | 1486 | asoc->rwnd = 0; |
1490 | } | 1487 | } |
1491 | } else { | 1488 | } else { |
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c index 3eab6db59a37..476caaf100ed 100644 --- a/net/sctp/chunk.c +++ b/net/sctp/chunk.c | |||
@@ -58,9 +58,9 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg) | |||
58 | msg->send_failed = 0; | 58 | msg->send_failed = 0; |
59 | msg->send_error = 0; | 59 | msg->send_error = 0; |
60 | msg->can_abandon = 0; | 60 | msg->can_abandon = 0; |
61 | msg->can_delay = 1; | ||
61 | msg->expires_at = 0; | 62 | msg->expires_at = 0; |
62 | INIT_LIST_HEAD(&msg->chunks); | 63 | INIT_LIST_HEAD(&msg->chunks); |
63 | msg->msg_size = 0; | ||
64 | } | 64 | } |
65 | 65 | ||
66 | /* Allocate and initialize datamsg. */ | 66 | /* Allocate and initialize datamsg. */ |
@@ -157,7 +157,6 @@ static void sctp_datamsg_assign(struct sctp_datamsg *msg, struct sctp_chunk *chu | |||
157 | { | 157 | { |
158 | sctp_datamsg_hold(msg); | 158 | sctp_datamsg_hold(msg); |
159 | chunk->msg = msg; | 159 | chunk->msg = msg; |
160 | msg->msg_size += chunk->skb->len; | ||
161 | } | 160 | } |
162 | 161 | ||
163 | 162 | ||
@@ -247,6 +246,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc, | |||
247 | if (msg_len >= first_len) { | 246 | if (msg_len >= first_len) { |
248 | msg_len -= first_len; | 247 | msg_len -= first_len; |
249 | whole = 1; | 248 | whole = 1; |
249 | msg->can_delay = 0; | ||
250 | } | 250 | } |
251 | 251 | ||
252 | /* How many full sized? How many bytes leftover? */ | 252 | /* How many full sized? How many bytes leftover? */ |
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 7ec09ba03a1c..e10acc01c75f 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
@@ -70,8 +70,6 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
70 | struct sctp_shared_key *null_key; | 70 | struct sctp_shared_key *null_key; |
71 | int err; | 71 | int err; |
72 | 72 | ||
73 | memset(ep, 0, sizeof(struct sctp_endpoint)); | ||
74 | |||
75 | ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp); | 73 | ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp); |
76 | if (!ep->digest) | 74 | if (!ep->digest) |
77 | return NULL; | 75 | return NULL; |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 9fb5d37c37ad..732689140fb8 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -232,7 +232,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport) | |||
232 | if (!(transport->param_flags & SPP_PMTUD_ENABLE)) | 232 | if (!(transport->param_flags & SPP_PMTUD_ENABLE)) |
233 | skb->local_df = 1; | 233 | skb->local_df = 1; |
234 | 234 | ||
235 | return ip6_xmit(sk, skb, &fl, np->opt, 0); | 235 | return ip6_xmit(sk, skb, &fl, np->opt); |
236 | } | 236 | } |
237 | 237 | ||
238 | /* Returns the dst cache entry for the given source and destination ip | 238 | /* Returns the dst cache entry for the given source and destination ip |
@@ -277,20 +277,7 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc, | |||
277 | static inline int sctp_v6_addr_match_len(union sctp_addr *s1, | 277 | static inline int sctp_v6_addr_match_len(union sctp_addr *s1, |
278 | union sctp_addr *s2) | 278 | union sctp_addr *s2) |
279 | { | 279 | { |
280 | struct in6_addr *a1 = &s1->v6.sin6_addr; | 280 | return ipv6_addr_diff(&s1->v6.sin6_addr, &s2->v6.sin6_addr); |
281 | struct in6_addr *a2 = &s2->v6.sin6_addr; | ||
282 | int i, j; | ||
283 | |||
284 | for (i = 0; i < 4 ; i++) { | ||
285 | __be32 a1xora2; | ||
286 | |||
287 | a1xora2 = a1->s6_addr32[i] ^ a2->s6_addr32[i]; | ||
288 | |||
289 | if ((j = fls(ntohl(a1xora2)))) | ||
290 | return (i * 32 + 32 - j); | ||
291 | } | ||
292 | |||
293 | return (i*32); | ||
294 | } | 281 | } |
295 | 282 | ||
296 | /* Fills in the source address(saddr) based on the destination address(daddr) | 283 | /* Fills in the source address(saddr) based on the destination address(daddr) |
@@ -372,13 +359,13 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist, | |||
372 | } | 359 | } |
373 | 360 | ||
374 | read_lock_bh(&in6_dev->lock); | 361 | read_lock_bh(&in6_dev->lock); |
375 | for (ifp = in6_dev->addr_list; ifp; ifp = ifp->if_next) { | 362 | list_for_each_entry(ifp, &in6_dev->addr_list, if_list) { |
376 | /* Add the address to the local list. */ | 363 | /* Add the address to the local list. */ |
377 | addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC); | 364 | addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC); |
378 | if (addr) { | 365 | if (addr) { |
379 | addr->a.v6.sin6_family = AF_INET6; | 366 | addr->a.v6.sin6_family = AF_INET6; |
380 | addr->a.v6.sin6_port = 0; | 367 | addr->a.v6.sin6_port = 0; |
381 | addr->a.v6.sin6_addr = ifp->addr; | 368 | ipv6_addr_copy(&addr->a.v6.sin6_addr, &ifp->addr); |
382 | addr->a.v6.sin6_scope_id = dev->ifindex; | 369 | addr->a.v6.sin6_scope_id = dev->ifindex; |
383 | addr->valid = 1; | 370 | addr->valid = 1; |
384 | INIT_LIST_HEAD(&addr->list); | 371 | INIT_LIST_HEAD(&addr->list); |
@@ -419,7 +406,7 @@ static void sctp_v6_from_sk(union sctp_addr *addr, struct sock *sk) | |||
419 | { | 406 | { |
420 | addr->v6.sin6_family = AF_INET6; | 407 | addr->v6.sin6_family = AF_INET6; |
421 | addr->v6.sin6_port = 0; | 408 | addr->v6.sin6_port = 0; |
422 | addr->v6.sin6_addr = inet6_sk(sk)->rcv_saddr; | 409 | ipv6_addr_copy(&addr->v6.sin6_addr, &inet6_sk(sk)->rcv_saddr); |
423 | } | 410 | } |
424 | 411 | ||
425 | /* Initialize sk->sk_rcv_saddr from sctp_addr. */ | 412 | /* Initialize sk->sk_rcv_saddr from sctp_addr. */ |
@@ -432,7 +419,7 @@ static void sctp_v6_to_sk_saddr(union sctp_addr *addr, struct sock *sk) | |||
432 | inet6_sk(sk)->rcv_saddr.s6_addr32[3] = | 419 | inet6_sk(sk)->rcv_saddr.s6_addr32[3] = |
433 | addr->v4.sin_addr.s_addr; | 420 | addr->v4.sin_addr.s_addr; |
434 | } else { | 421 | } else { |
435 | inet6_sk(sk)->rcv_saddr = addr->v6.sin6_addr; | 422 | ipv6_addr_copy(&inet6_sk(sk)->rcv_saddr, &addr->v6.sin6_addr); |
436 | } | 423 | } |
437 | } | 424 | } |
438 | 425 | ||
@@ -445,7 +432,7 @@ static void sctp_v6_to_sk_daddr(union sctp_addr *addr, struct sock *sk) | |||
445 | inet6_sk(sk)->daddr.s6_addr32[2] = htonl(0x0000ffff); | 432 | inet6_sk(sk)->daddr.s6_addr32[2] = htonl(0x0000ffff); |
446 | inet6_sk(sk)->daddr.s6_addr32[3] = addr->v4.sin_addr.s_addr; | 433 | inet6_sk(sk)->daddr.s6_addr32[3] = addr->v4.sin_addr.s_addr; |
447 | } else { | 434 | } else { |
448 | inet6_sk(sk)->daddr = addr->v6.sin6_addr; | 435 | ipv6_addr_copy(&inet6_sk(sk)->daddr, &addr->v6.sin6_addr); |
449 | } | 436 | } |
450 | } | 437 | } |
451 | 438 | ||
diff --git a/net/sctp/output.c b/net/sctp/output.c index fad261d41ec2..a646681f5acd 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
@@ -429,24 +429,17 @@ int sctp_packet_transmit(struct sctp_packet *packet) | |||
429 | list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { | 429 | list_for_each_entry_safe(chunk, tmp, &packet->chunk_list, list) { |
430 | list_del_init(&chunk->list); | 430 | list_del_init(&chunk->list); |
431 | if (sctp_chunk_is_data(chunk)) { | 431 | if (sctp_chunk_is_data(chunk)) { |
432 | /* 6.3.1 C4) When data is in flight and when allowed | ||
433 | * by rule C5, a new RTT measurement MUST be made each | ||
434 | * round trip. Furthermore, new RTT measurements | ||
435 | * SHOULD be made no more than once per round-trip | ||
436 | * for a given destination transport address. | ||
437 | */ | ||
432 | 438 | ||
433 | if (!chunk->resent) { | 439 | if (!tp->rto_pending) { |
434 | 440 | chunk->rtt_in_progress = 1; | |
435 | /* 6.3.1 C4) When data is in flight and when allowed | 441 | tp->rto_pending = 1; |
436 | * by rule C5, a new RTT measurement MUST be made each | ||
437 | * round trip. Furthermore, new RTT measurements | ||
438 | * SHOULD be made no more than once per round-trip | ||
439 | * for a given destination transport address. | ||
440 | */ | ||
441 | |||
442 | if (!tp->rto_pending) { | ||
443 | chunk->rtt_in_progress = 1; | ||
444 | tp->rto_pending = 1; | ||
445 | } | ||
446 | } | 442 | } |
447 | |||
448 | chunk->resent = 1; | ||
449 | |||
450 | has_data = 1; | 443 | has_data = 1; |
451 | } | 444 | } |
452 | 445 | ||
@@ -681,7 +674,7 @@ static sctp_xmit_t sctp_packet_can_append_data(struct sctp_packet *packet, | |||
681 | * Don't delay large message writes that may have been | 674 | * Don't delay large message writes that may have been |
682 | * fragmeneted into small peices. | 675 | * fragmeneted into small peices. |
683 | */ | 676 | */ |
684 | if ((len < max) && (chunk->msg->msg_size < max)) { | 677 | if ((len < max) && chunk->msg->can_delay) { |
685 | retval = SCTP_XMIT_NAGLE_DELAY; | 678 | retval = SCTP_XMIT_NAGLE_DELAY; |
686 | goto finish; | 679 | goto finish; |
687 | } | 680 | } |
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index abfc0b8dee74..c04b2eb59186 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c | |||
@@ -62,7 +62,7 @@ static void sctp_check_transmitted(struct sctp_outq *q, | |||
62 | struct list_head *transmitted_queue, | 62 | struct list_head *transmitted_queue, |
63 | struct sctp_transport *transport, | 63 | struct sctp_transport *transport, |
64 | struct sctp_sackhdr *sack, | 64 | struct sctp_sackhdr *sack, |
65 | __u32 highest_new_tsn); | 65 | __u32 *highest_new_tsn); |
66 | 66 | ||
67 | static void sctp_mark_missing(struct sctp_outq *q, | 67 | static void sctp_mark_missing(struct sctp_outq *q, |
68 | struct list_head *transmitted_queue, | 68 | struct list_head *transmitted_queue, |
@@ -80,7 +80,6 @@ static inline void sctp_outq_head_data(struct sctp_outq *q, | |||
80 | { | 80 | { |
81 | list_add(&ch->list, &q->out_chunk_list); | 81 | list_add(&ch->list, &q->out_chunk_list); |
82 | q->out_qlen += ch->skb->len; | 82 | q->out_qlen += ch->skb->len; |
83 | return; | ||
84 | } | 83 | } |
85 | 84 | ||
86 | /* Take data from the front of the queue. */ | 85 | /* Take data from the front of the queue. */ |
@@ -103,7 +102,6 @@ static inline void sctp_outq_tail_data(struct sctp_outq *q, | |||
103 | { | 102 | { |
104 | list_add_tail(&ch->list, &q->out_chunk_list); | 103 | list_add_tail(&ch->list, &q->out_chunk_list); |
105 | q->out_qlen += ch->skb->len; | 104 | q->out_qlen += ch->skb->len; |
106 | return; | ||
107 | } | 105 | } |
108 | 106 | ||
109 | /* | 107 | /* |
@@ -308,7 +306,7 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk) | |||
308 | /* If it is data, queue it up, otherwise, send it | 306 | /* If it is data, queue it up, otherwise, send it |
309 | * immediately. | 307 | * immediately. |
310 | */ | 308 | */ |
311 | if (SCTP_CID_DATA == chunk->chunk_hdr->type) { | 309 | if (sctp_chunk_is_data(chunk)) { |
312 | /* Is it OK to queue data chunks? */ | 310 | /* Is it OK to queue data chunks? */ |
313 | /* From 9. Termination of Association | 311 | /* From 9. Termination of Association |
314 | * | 312 | * |
@@ -598,11 +596,23 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, | |||
598 | if (fast_rtx && !chunk->fast_retransmit) | 596 | if (fast_rtx && !chunk->fast_retransmit) |
599 | continue; | 597 | continue; |
600 | 598 | ||
599 | redo: | ||
601 | /* Attempt to append this chunk to the packet. */ | 600 | /* Attempt to append this chunk to the packet. */ |
602 | status = sctp_packet_append_chunk(pkt, chunk); | 601 | status = sctp_packet_append_chunk(pkt, chunk); |
603 | 602 | ||
604 | switch (status) { | 603 | switch (status) { |
605 | case SCTP_XMIT_PMTU_FULL: | 604 | case SCTP_XMIT_PMTU_FULL: |
605 | if (!pkt->has_data && !pkt->has_cookie_echo) { | ||
606 | /* If this packet did not contain DATA then | ||
607 | * retransmission did not happen, so do it | ||
608 | * again. We'll ignore the error here since | ||
609 | * control chunks are already freed so there | ||
610 | * is nothing we can do. | ||
611 | */ | ||
612 | sctp_packet_transmit(pkt); | ||
613 | goto redo; | ||
614 | } | ||
615 | |||
606 | /* Send this packet. */ | 616 | /* Send this packet. */ |
607 | error = sctp_packet_transmit(pkt); | 617 | error = sctp_packet_transmit(pkt); |
608 | 618 | ||
@@ -647,14 +657,6 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, | |||
647 | if (chunk->fast_retransmit == SCTP_NEED_FRTX) | 657 | if (chunk->fast_retransmit == SCTP_NEED_FRTX) |
648 | chunk->fast_retransmit = SCTP_DONT_FRTX; | 658 | chunk->fast_retransmit = SCTP_DONT_FRTX; |
649 | 659 | ||
650 | /* Force start T3-rtx timer when fast retransmitting | ||
651 | * the earliest outstanding TSN | ||
652 | */ | ||
653 | if (!timer && fast_rtx && | ||
654 | ntohl(chunk->subh.data_hdr->tsn) == | ||
655 | asoc->ctsn_ack_point + 1) | ||
656 | timer = 2; | ||
657 | |||
658 | q->empty = 0; | 660 | q->empty = 0; |
659 | break; | 661 | break; |
660 | } | 662 | } |
@@ -854,6 +856,12 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout) | |||
854 | if (status != SCTP_XMIT_OK) { | 856 | if (status != SCTP_XMIT_OK) { |
855 | /* put the chunk back */ | 857 | /* put the chunk back */ |
856 | list_add(&chunk->list, &q->control_chunk_list); | 858 | list_add(&chunk->list, &q->control_chunk_list); |
859 | } else if (chunk->chunk_hdr->type == SCTP_CID_FWD_TSN) { | ||
860 | /* PR-SCTP C5) If a FORWARD TSN is sent, the | ||
861 | * sender MUST assure that at least one T3-rtx | ||
862 | * timer is running. | ||
863 | */ | ||
864 | sctp_transport_reset_timers(transport); | ||
857 | } | 865 | } |
858 | break; | 866 | break; |
859 | 867 | ||
@@ -906,8 +914,7 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout) | |||
906 | rtx_timeout, &start_timer); | 914 | rtx_timeout, &start_timer); |
907 | 915 | ||
908 | if (start_timer) | 916 | if (start_timer) |
909 | sctp_transport_reset_timers(transport, | 917 | sctp_transport_reset_timers(transport); |
910 | start_timer-1); | ||
911 | 918 | ||
912 | /* This can happen on COOKIE-ECHO resend. Only | 919 | /* This can happen on COOKIE-ECHO resend. Only |
913 | * one chunk can get bundled with a COOKIE-ECHO. | 920 | * one chunk can get bundled with a COOKIE-ECHO. |
@@ -1040,7 +1047,7 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout) | |||
1040 | list_add_tail(&chunk->transmitted_list, | 1047 | list_add_tail(&chunk->transmitted_list, |
1041 | &transport->transmitted); | 1048 | &transport->transmitted); |
1042 | 1049 | ||
1043 | sctp_transport_reset_timers(transport, 0); | 1050 | sctp_transport_reset_timers(transport); |
1044 | 1051 | ||
1045 | q->empty = 0; | 1052 | q->empty = 0; |
1046 | 1053 | ||
@@ -1100,32 +1107,6 @@ static void sctp_sack_update_unack_data(struct sctp_association *assoc, | |||
1100 | assoc->unack_data = unack_data; | 1107 | assoc->unack_data = unack_data; |
1101 | } | 1108 | } |
1102 | 1109 | ||
1103 | /* Return the highest new tsn that is acknowledged by the given SACK chunk. */ | ||
1104 | static __u32 sctp_highest_new_tsn(struct sctp_sackhdr *sack, | ||
1105 | struct sctp_association *asoc) | ||
1106 | { | ||
1107 | struct sctp_transport *transport; | ||
1108 | struct sctp_chunk *chunk; | ||
1109 | __u32 highest_new_tsn, tsn; | ||
1110 | struct list_head *transport_list = &asoc->peer.transport_addr_list; | ||
1111 | |||
1112 | highest_new_tsn = ntohl(sack->cum_tsn_ack); | ||
1113 | |||
1114 | list_for_each_entry(transport, transport_list, transports) { | ||
1115 | list_for_each_entry(chunk, &transport->transmitted, | ||
1116 | transmitted_list) { | ||
1117 | tsn = ntohl(chunk->subh.data_hdr->tsn); | ||
1118 | |||
1119 | if (!chunk->tsn_gap_acked && | ||
1120 | TSN_lt(highest_new_tsn, tsn) && | ||
1121 | sctp_acked(sack, tsn)) | ||
1122 | highest_new_tsn = tsn; | ||
1123 | } | ||
1124 | } | ||
1125 | |||
1126 | return highest_new_tsn; | ||
1127 | } | ||
1128 | |||
1129 | /* This is where we REALLY process a SACK. | 1110 | /* This is where we REALLY process a SACK. |
1130 | * | 1111 | * |
1131 | * Process the SACK against the outqueue. Mostly, this just frees | 1112 | * Process the SACK against the outqueue. Mostly, this just frees |
@@ -1145,6 +1126,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack) | |||
1145 | struct sctp_transport *primary = asoc->peer.primary_path; | 1126 | struct sctp_transport *primary = asoc->peer.primary_path; |
1146 | int count_of_newacks = 0; | 1127 | int count_of_newacks = 0; |
1147 | int gap_ack_blocks; | 1128 | int gap_ack_blocks; |
1129 | u8 accum_moved = 0; | ||
1148 | 1130 | ||
1149 | /* Grab the association's destination address list. */ | 1131 | /* Grab the association's destination address list. */ |
1150 | transport_list = &asoc->peer.transport_addr_list; | 1132 | transport_list = &asoc->peer.transport_addr_list; |
@@ -1193,18 +1175,15 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack) | |||
1193 | if (gap_ack_blocks) | 1175 | if (gap_ack_blocks) |
1194 | highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end); | 1176 | highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end); |
1195 | 1177 | ||
1196 | if (TSN_lt(asoc->highest_sacked, highest_tsn)) { | 1178 | if (TSN_lt(asoc->highest_sacked, highest_tsn)) |
1197 | highest_new_tsn = highest_tsn; | ||
1198 | asoc->highest_sacked = highest_tsn; | 1179 | asoc->highest_sacked = highest_tsn; |
1199 | } else { | ||
1200 | highest_new_tsn = sctp_highest_new_tsn(sack, asoc); | ||
1201 | } | ||
1202 | 1180 | ||
1181 | highest_new_tsn = sack_ctsn; | ||
1203 | 1182 | ||
1204 | /* Run through the retransmit queue. Credit bytes received | 1183 | /* Run through the retransmit queue. Credit bytes received |
1205 | * and free those chunks that we can. | 1184 | * and free those chunks that we can. |
1206 | */ | 1185 | */ |
1207 | sctp_check_transmitted(q, &q->retransmit, NULL, sack, highest_new_tsn); | 1186 | sctp_check_transmitted(q, &q->retransmit, NULL, sack, &highest_new_tsn); |
1208 | 1187 | ||
1209 | /* Run through the transmitted queue. | 1188 | /* Run through the transmitted queue. |
1210 | * Credit bytes received and free those chunks which we can. | 1189 | * Credit bytes received and free those chunks which we can. |
@@ -1213,7 +1192,7 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack) | |||
1213 | */ | 1192 | */ |
1214 | list_for_each_entry(transport, transport_list, transports) { | 1193 | list_for_each_entry(transport, transport_list, transports) { |
1215 | sctp_check_transmitted(q, &transport->transmitted, | 1194 | sctp_check_transmitted(q, &transport->transmitted, |
1216 | transport, sack, highest_new_tsn); | 1195 | transport, sack, &highest_new_tsn); |
1217 | /* | 1196 | /* |
1218 | * SFR-CACC algorithm: | 1197 | * SFR-CACC algorithm: |
1219 | * C) Let count_of_newacks be the number of | 1198 | * C) Let count_of_newacks be the number of |
@@ -1223,16 +1202,22 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack) | |||
1223 | count_of_newacks ++; | 1202 | count_of_newacks ++; |
1224 | } | 1203 | } |
1225 | 1204 | ||
1205 | /* Move the Cumulative TSN Ack Point if appropriate. */ | ||
1206 | if (TSN_lt(asoc->ctsn_ack_point, sack_ctsn)) { | ||
1207 | asoc->ctsn_ack_point = sack_ctsn; | ||
1208 | accum_moved = 1; | ||
1209 | } | ||
1210 | |||
1226 | if (gap_ack_blocks) { | 1211 | if (gap_ack_blocks) { |
1212 | |||
1213 | if (asoc->fast_recovery && accum_moved) | ||
1214 | highest_new_tsn = highest_tsn; | ||
1215 | |||
1227 | list_for_each_entry(transport, transport_list, transports) | 1216 | list_for_each_entry(transport, transport_list, transports) |
1228 | sctp_mark_missing(q, &transport->transmitted, transport, | 1217 | sctp_mark_missing(q, &transport->transmitted, transport, |
1229 | highest_new_tsn, count_of_newacks); | 1218 | highest_new_tsn, count_of_newacks); |
1230 | } | 1219 | } |
1231 | 1220 | ||
1232 | /* Move the Cumulative TSN Ack Point if appropriate. */ | ||
1233 | if (TSN_lt(asoc->ctsn_ack_point, sack_ctsn)) | ||
1234 | asoc->ctsn_ack_point = sack_ctsn; | ||
1235 | |||
1236 | /* Update unack_data field in the assoc. */ | 1221 | /* Update unack_data field in the assoc. */ |
1237 | sctp_sack_update_unack_data(asoc, sack); | 1222 | sctp_sack_update_unack_data(asoc, sack); |
1238 | 1223 | ||
@@ -1315,7 +1300,7 @@ static void sctp_check_transmitted(struct sctp_outq *q, | |||
1315 | struct list_head *transmitted_queue, | 1300 | struct list_head *transmitted_queue, |
1316 | struct sctp_transport *transport, | 1301 | struct sctp_transport *transport, |
1317 | struct sctp_sackhdr *sack, | 1302 | struct sctp_sackhdr *sack, |
1318 | __u32 highest_new_tsn_in_sack) | 1303 | __u32 *highest_new_tsn_in_sack) |
1319 | { | 1304 | { |
1320 | struct list_head *lchunk; | 1305 | struct list_head *lchunk; |
1321 | struct sctp_chunk *tchunk; | 1306 | struct sctp_chunk *tchunk; |
@@ -1387,7 +1372,6 @@ static void sctp_check_transmitted(struct sctp_outq *q, | |||
1387 | * instance). | 1372 | * instance). |
1388 | */ | 1373 | */ |
1389 | if (!tchunk->tsn_gap_acked && | 1374 | if (!tchunk->tsn_gap_acked && |
1390 | !tchunk->resent && | ||
1391 | tchunk->rtt_in_progress) { | 1375 | tchunk->rtt_in_progress) { |
1392 | tchunk->rtt_in_progress = 0; | 1376 | tchunk->rtt_in_progress = 0; |
1393 | rtt = jiffies - tchunk->sent_at; | 1377 | rtt = jiffies - tchunk->sent_at; |
@@ -1404,6 +1388,7 @@ static void sctp_check_transmitted(struct sctp_outq *q, | |||
1404 | */ | 1388 | */ |
1405 | if (!tchunk->tsn_gap_acked) { | 1389 | if (!tchunk->tsn_gap_acked) { |
1406 | tchunk->tsn_gap_acked = 1; | 1390 | tchunk->tsn_gap_acked = 1; |
1391 | *highest_new_tsn_in_sack = tsn; | ||
1407 | bytes_acked += sctp_data_size(tchunk); | 1392 | bytes_acked += sctp_data_size(tchunk); |
1408 | if (!tchunk->transport) | 1393 | if (!tchunk->transport) |
1409 | migrate_bytes += sctp_data_size(tchunk); | 1394 | migrate_bytes += sctp_data_size(tchunk); |
@@ -1677,7 +1662,8 @@ static void sctp_mark_missing(struct sctp_outq *q, | |||
1677 | struct sctp_chunk *chunk; | 1662 | struct sctp_chunk *chunk; |
1678 | __u32 tsn; | 1663 | __u32 tsn; |
1679 | char do_fast_retransmit = 0; | 1664 | char do_fast_retransmit = 0; |
1680 | struct sctp_transport *primary = q->asoc->peer.primary_path; | 1665 | struct sctp_association *asoc = q->asoc; |
1666 | struct sctp_transport *primary = asoc->peer.primary_path; | ||
1681 | 1667 | ||
1682 | list_for_each_entry(chunk, transmitted_queue, transmitted_list) { | 1668 | list_for_each_entry(chunk, transmitted_queue, transmitted_list) { |
1683 | 1669 | ||
diff --git a/net/sctp/probe.c b/net/sctp/probe.c new file mode 100644 index 000000000000..db3a42b8b349 --- /dev/null +++ b/net/sctp/probe.c | |||
@@ -0,0 +1,214 @@ | |||
1 | /* | ||
2 | * sctp_probe - Observe the SCTP flow with kprobes. | ||
3 | * | ||
4 | * The idea for this came from Werner Almesberger's umlsim | ||
5 | * Copyright (C) 2004, Stephen Hemminger <shemminger@osdl.org> | ||
6 | * | ||
7 | * Modified for SCTP from Stephen Hemminger's code | ||
8 | * Copyright (C) 2010, Wei Yongjun <yjwei@cn.fujitsu.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/kprobes.h> | ||
27 | #include <linux/socket.h> | ||
28 | #include <linux/sctp.h> | ||
29 | #include <linux/proc_fs.h> | ||
30 | #include <linux/vmalloc.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/kfifo.h> | ||
33 | #include <linux/time.h> | ||
34 | #include <net/net_namespace.h> | ||
35 | |||
36 | #include <net/sctp/sctp.h> | ||
37 | #include <net/sctp/sm.h> | ||
38 | |||
39 | MODULE_AUTHOR("Wei Yongjun <yjwei@cn.fujitsu.com>"); | ||
40 | MODULE_DESCRIPTION("SCTP snooper"); | ||
41 | MODULE_LICENSE("GPL"); | ||
42 | |||
43 | static int port __read_mostly = 0; | ||
44 | MODULE_PARM_DESC(port, "Port to match (0=all)"); | ||
45 | module_param(port, int, 0); | ||
46 | |||
47 | static int bufsize __read_mostly = 64 * 1024; | ||
48 | MODULE_PARM_DESC(bufsize, "Log buffer size (default 64k)"); | ||
49 | module_param(bufsize, int, 0); | ||
50 | |||
51 | static int full __read_mostly = 1; | ||
52 | MODULE_PARM_DESC(full, "Full log (1=every ack packet received, 0=only cwnd changes)"); | ||
53 | module_param(full, int, 0); | ||
54 | |||
55 | static const char procname[] = "sctpprobe"; | ||
56 | |||
57 | static struct { | ||
58 | struct kfifo fifo; | ||
59 | spinlock_t lock; | ||
60 | wait_queue_head_t wait; | ||
61 | struct timespec tstart; | ||
62 | } sctpw; | ||
63 | |||
64 | static void printl(const char *fmt, ...) | ||
65 | { | ||
66 | va_list args; | ||
67 | int len; | ||
68 | char tbuf[256]; | ||
69 | |||
70 | va_start(args, fmt); | ||
71 | len = vscnprintf(tbuf, sizeof(tbuf), fmt, args); | ||
72 | va_end(args); | ||
73 | |||
74 | kfifo_in_locked(&sctpw.fifo, tbuf, len, &sctpw.lock); | ||
75 | wake_up(&sctpw.wait); | ||
76 | } | ||
77 | |||
78 | static int sctpprobe_open(struct inode *inode, struct file *file) | ||
79 | { | ||
80 | kfifo_reset(&sctpw.fifo); | ||
81 | getnstimeofday(&sctpw.tstart); | ||
82 | |||
83 | return 0; | ||
84 | } | ||
85 | |||
86 | static ssize_t sctpprobe_read(struct file *file, char __user *buf, | ||
87 | size_t len, loff_t *ppos) | ||
88 | { | ||
89 | int error = 0, cnt = 0; | ||
90 | unsigned char *tbuf; | ||
91 | |||
92 | if (!buf) | ||
93 | return -EINVAL; | ||
94 | |||
95 | if (len == 0) | ||
96 | return 0; | ||
97 | |||
98 | tbuf = vmalloc(len); | ||
99 | if (!tbuf) | ||
100 | return -ENOMEM; | ||
101 | |||
102 | error = wait_event_interruptible(sctpw.wait, | ||
103 | kfifo_len(&sctpw.fifo) != 0); | ||
104 | if (error) | ||
105 | goto out_free; | ||
106 | |||
107 | cnt = kfifo_out_locked(&sctpw.fifo, tbuf, len, &sctpw.lock); | ||
108 | error = copy_to_user(buf, tbuf, cnt) ? -EFAULT : 0; | ||
109 | |||
110 | out_free: | ||
111 | vfree(tbuf); | ||
112 | |||
113 | return error ? error : cnt; | ||
114 | } | ||
115 | |||
116 | static const struct file_operations sctpprobe_fops = { | ||
117 | .owner = THIS_MODULE, | ||
118 | .open = sctpprobe_open, | ||
119 | .read = sctpprobe_read, | ||
120 | }; | ||
121 | |||
122 | sctp_disposition_t jsctp_sf_eat_sack(const struct sctp_endpoint *ep, | ||
123 | const struct sctp_association *asoc, | ||
124 | const sctp_subtype_t type, | ||
125 | void *arg, | ||
126 | sctp_cmd_seq_t *commands) | ||
127 | { | ||
128 | struct sctp_transport *sp; | ||
129 | static __u32 lcwnd = 0; | ||
130 | struct timespec now; | ||
131 | |||
132 | sp = asoc->peer.primary_path; | ||
133 | |||
134 | if ((full || sp->cwnd != lcwnd) && | ||
135 | (!port || asoc->peer.port == port || | ||
136 | ep->base.bind_addr.port == port)) { | ||
137 | lcwnd = sp->cwnd; | ||
138 | |||
139 | getnstimeofday(&now); | ||
140 | now = timespec_sub(now, sctpw.tstart); | ||
141 | |||
142 | printl("%lu.%06lu ", (unsigned long) now.tv_sec, | ||
143 | (unsigned long) now.tv_nsec / NSEC_PER_USEC); | ||
144 | |||
145 | printl("%p %5d %5d %5d %8d %5d ", asoc, | ||
146 | ep->base.bind_addr.port, asoc->peer.port, | ||
147 | asoc->pathmtu, asoc->peer.rwnd, asoc->unack_data); | ||
148 | |||
149 | list_for_each_entry(sp, &asoc->peer.transport_addr_list, | ||
150 | transports) { | ||
151 | if (sp == asoc->peer.primary_path) | ||
152 | printl("*"); | ||
153 | |||
154 | if (sp->ipaddr.sa.sa_family == AF_INET) | ||
155 | printl("%pI4 ", &sp->ipaddr.v4.sin_addr); | ||
156 | else | ||
157 | printl("%pI6 ", &sp->ipaddr.v6.sin6_addr); | ||
158 | |||
159 | printl("%2u %8u %8u %8u %8u %8u ", | ||
160 | sp->state, sp->cwnd, sp->ssthresh, | ||
161 | sp->flight_size, sp->partial_bytes_acked, | ||
162 | sp->pathmtu); | ||
163 | } | ||
164 | printl("\n"); | ||
165 | } | ||
166 | |||
167 | jprobe_return(); | ||
168 | return 0; | ||
169 | } | ||
170 | |||
171 | static struct jprobe sctp_recv_probe = { | ||
172 | .kp = { | ||
173 | .symbol_name = "sctp_sf_eat_sack_6_2", | ||
174 | }, | ||
175 | .entry = jsctp_sf_eat_sack, | ||
176 | }; | ||
177 | |||
178 | static __init int sctpprobe_init(void) | ||
179 | { | ||
180 | int ret = -ENOMEM; | ||
181 | |||
182 | init_waitqueue_head(&sctpw.wait); | ||
183 | spin_lock_init(&sctpw.lock); | ||
184 | if (kfifo_alloc(&sctpw.fifo, bufsize, GFP_KERNEL)) | ||
185 | return ret; | ||
186 | |||
187 | if (!proc_net_fops_create(&init_net, procname, S_IRUSR, | ||
188 | &sctpprobe_fops)) | ||
189 | goto free_kfifo; | ||
190 | |||
191 | ret = register_jprobe(&sctp_recv_probe); | ||
192 | if (ret) | ||
193 | goto remove_proc; | ||
194 | |||
195 | pr_info("SCTP probe registered (port=%d)\n", port); | ||
196 | |||
197 | return 0; | ||
198 | |||
199 | remove_proc: | ||
200 | proc_net_remove(&init_net, procname); | ||
201 | free_kfifo: | ||
202 | kfifo_free(&sctpw.fifo); | ||
203 | return ret; | ||
204 | } | ||
205 | |||
206 | static __exit void sctpprobe_exit(void) | ||
207 | { | ||
208 | kfifo_free(&sctpw.fifo); | ||
209 | proc_net_remove(&init_net, procname); | ||
210 | unregister_jprobe(&sctp_recv_probe); | ||
211 | } | ||
212 | |||
213 | module_init(sctpprobe_init); | ||
214 | module_exit(sctpprobe_exit); | ||
diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 784bcc9a979d..61aacfbbaa92 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c | |||
@@ -181,7 +181,6 @@ static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos) | |||
181 | 181 | ||
182 | static void sctp_eps_seq_stop(struct seq_file *seq, void *v) | 182 | static void sctp_eps_seq_stop(struct seq_file *seq, void *v) |
183 | { | 183 | { |
184 | return; | ||
185 | } | 184 | } |
186 | 185 | ||
187 | 186 | ||
@@ -286,7 +285,6 @@ static void * sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos) | |||
286 | 285 | ||
287 | static void sctp_assocs_seq_stop(struct seq_file *seq, void *v) | 286 | static void sctp_assocs_seq_stop(struct seq_file *seq, void *v) |
288 | { | 287 | { |
289 | return; | ||
290 | } | 288 | } |
291 | 289 | ||
292 | 290 | ||
@@ -409,7 +407,6 @@ static void *sctp_remaddr_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
409 | 407 | ||
410 | static void sctp_remaddr_seq_stop(struct seq_file *seq, void *v) | 408 | static void sctp_remaddr_seq_stop(struct seq_file *seq, void *v) |
411 | { | 409 | { |
412 | return; | ||
413 | } | 410 | } |
414 | 411 | ||
415 | static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) | 412 | static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index a56f98e82f92..182749867c72 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -474,13 +474,17 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc, | |||
474 | 474 | ||
475 | memset(&fl, 0x0, sizeof(struct flowi)); | 475 | memset(&fl, 0x0, sizeof(struct flowi)); |
476 | fl.fl4_dst = daddr->v4.sin_addr.s_addr; | 476 | fl.fl4_dst = daddr->v4.sin_addr.s_addr; |
477 | fl.fl_ip_dport = daddr->v4.sin_port; | ||
477 | fl.proto = IPPROTO_SCTP; | 478 | fl.proto = IPPROTO_SCTP; |
478 | if (asoc) { | 479 | if (asoc) { |
479 | fl.fl4_tos = RT_CONN_FLAGS(asoc->base.sk); | 480 | fl.fl4_tos = RT_CONN_FLAGS(asoc->base.sk); |
480 | fl.oif = asoc->base.sk->sk_bound_dev_if; | 481 | fl.oif = asoc->base.sk->sk_bound_dev_if; |
482 | fl.fl_ip_sport = htons(asoc->base.bind_addr.port); | ||
481 | } | 483 | } |
482 | if (saddr) | 484 | if (saddr) { |
483 | fl.fl4_src = saddr->v4.sin_addr.s_addr; | 485 | fl.fl4_src = saddr->v4.sin_addr.s_addr; |
486 | fl.fl_ip_sport = saddr->v4.sin_port; | ||
487 | } | ||
484 | 488 | ||
485 | SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ", | 489 | SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ", |
486 | __func__, &fl.fl4_dst, &fl.fl4_src); | 490 | __func__, &fl.fl4_dst, &fl.fl4_src); |
@@ -528,6 +532,7 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc, | |||
528 | if ((laddr->state == SCTP_ADDR_SRC) && | 532 | if ((laddr->state == SCTP_ADDR_SRC) && |
529 | (AF_INET == laddr->a.sa.sa_family)) { | 533 | (AF_INET == laddr->a.sa.sa_family)) { |
530 | fl.fl4_src = laddr->a.v4.sin_addr.s_addr; | 534 | fl.fl4_src = laddr->a.v4.sin_addr.s_addr; |
535 | fl.fl_ip_sport = laddr->a.v4.sin_port; | ||
531 | if (!ip_route_output_key(&init_net, &rt, &fl)) { | 536 | if (!ip_route_output_key(&init_net, &rt, &fl)) { |
532 | dst = &rt->u.dst; | 537 | dst = &rt->u.dst; |
533 | goto out_unlock; | 538 | goto out_unlock; |
@@ -854,7 +859,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, | |||
854 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; | 859 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; |
855 | 860 | ||
856 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); | 861 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); |
857 | return ip_queue_xmit(skb, 0); | 862 | return ip_queue_xmit(skb); |
858 | } | 863 | } |
859 | 864 | ||
860 | static struct sctp_af sctp_af_inet; | 865 | static struct sctp_af sctp_af_inet; |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 30c1767186b8..bd2a50b482ac 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -141,7 +141,7 @@ int sctp_init_cause_fixed(struct sctp_chunk *chunk, __be16 cause_code, | |||
141 | len = sizeof(sctp_errhdr_t) + paylen; | 141 | len = sizeof(sctp_errhdr_t) + paylen; |
142 | err.length = htons(len); | 142 | err.length = htons(len); |
143 | 143 | ||
144 | if (skb_tailroom(chunk->skb) > len) | 144 | if (skb_tailroom(chunk->skb) < len) |
145 | return -ENOSPC; | 145 | return -ENOSPC; |
146 | chunk->subh.err_hdr = sctp_addto_chunk_fixed(chunk, | 146 | chunk->subh.err_hdr = sctp_addto_chunk_fixed(chunk, |
147 | sizeof(sctp_errhdr_t), | 147 | sizeof(sctp_errhdr_t), |
@@ -445,10 +445,17 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | |||
445 | if (!retval) | 445 | if (!retval) |
446 | goto nomem_chunk; | 446 | goto nomem_chunk; |
447 | 447 | ||
448 | /* Per the advice in RFC 2960 6.4, send this reply to | 448 | /* RFC 2960 6.4 Multi-homed SCTP Endpoints |
449 | * the source of the INIT packet. | 449 | * |
450 | * An endpoint SHOULD transmit reply chunks (e.g., SACK, | ||
451 | * HEARTBEAT ACK, * etc.) to the same destination transport | ||
452 | * address from which it received the DATA or control chunk | ||
453 | * to which it is replying. | ||
454 | * | ||
455 | * [INIT ACK back to where the INIT came from.] | ||
450 | */ | 456 | */ |
451 | retval->transport = chunk->transport; | 457 | retval->transport = chunk->transport; |
458 | |||
452 | retval->subh.init_hdr = | 459 | retval->subh.init_hdr = |
453 | sctp_addto_chunk(retval, sizeof(initack), &initack); | 460 | sctp_addto_chunk(retval, sizeof(initack), &initack); |
454 | retval->param_hdr.v = sctp_addto_chunk(retval, addrs_len, addrs.v); | 461 | retval->param_hdr.v = sctp_addto_chunk(retval, addrs_len, addrs.v); |
@@ -487,18 +494,6 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | |||
487 | /* We need to remove the const qualifier at this point. */ | 494 | /* We need to remove the const qualifier at this point. */ |
488 | retval->asoc = (struct sctp_association *) asoc; | 495 | retval->asoc = (struct sctp_association *) asoc; |
489 | 496 | ||
490 | /* RFC 2960 6.4 Multi-homed SCTP Endpoints | ||
491 | * | ||
492 | * An endpoint SHOULD transmit reply chunks (e.g., SACK, | ||
493 | * HEARTBEAT ACK, * etc.) to the same destination transport | ||
494 | * address from which it received the DATA or control chunk | ||
495 | * to which it is replying. | ||
496 | * | ||
497 | * [INIT ACK back to where the INIT came from.] | ||
498 | */ | ||
499 | if (chunk) | ||
500 | retval->transport = chunk->transport; | ||
501 | |||
502 | nomem_chunk: | 497 | nomem_chunk: |
503 | kfree(cookie); | 498 | kfree(cookie); |
504 | nomem_cookie: | 499 | nomem_cookie: |
@@ -1254,7 +1249,6 @@ struct sctp_chunk *sctp_chunkify(struct sk_buff *skb, | |||
1254 | INIT_LIST_HEAD(&retval->list); | 1249 | INIT_LIST_HEAD(&retval->list); |
1255 | retval->skb = skb; | 1250 | retval->skb = skb; |
1256 | retval->asoc = (struct sctp_association *)asoc; | 1251 | retval->asoc = (struct sctp_association *)asoc; |
1257 | retval->resent = 0; | ||
1258 | retval->has_tsn = 0; | 1252 | retval->has_tsn = 0; |
1259 | retval->has_ssn = 0; | 1253 | retval->has_ssn = 0; |
1260 | retval->rtt_in_progress = 0; | 1254 | retval->rtt_in_progress = 0; |
@@ -1421,7 +1415,7 @@ void *sctp_addto_chunk(struct sctp_chunk *chunk, int len, const void *data) | |||
1421 | void *sctp_addto_chunk_fixed(struct sctp_chunk *chunk, | 1415 | void *sctp_addto_chunk_fixed(struct sctp_chunk *chunk, |
1422 | int len, const void *data) | 1416 | int len, const void *data) |
1423 | { | 1417 | { |
1424 | if (skb_tailroom(chunk->skb) > len) | 1418 | if (skb_tailroom(chunk->skb) >= len) |
1425 | return sctp_addto_chunk(chunk, len, data); | 1419 | return sctp_addto_chunk(chunk, len, data); |
1426 | else | 1420 | else |
1427 | return NULL; | 1421 | return NULL; |
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index eb1f42f45fdd..f5e5e27cac5e 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c | |||
@@ -732,11 +732,15 @@ static void sctp_cmd_setup_t2(sctp_cmd_seq_t *cmds, | |||
732 | { | 732 | { |
733 | struct sctp_transport *t; | 733 | struct sctp_transport *t; |
734 | 734 | ||
735 | t = sctp_assoc_choose_alter_transport(asoc, | 735 | if (chunk->transport) |
736 | t = chunk->transport; | ||
737 | else { | ||
738 | t = sctp_assoc_choose_alter_transport(asoc, | ||
736 | asoc->shutdown_last_sent_to); | 739 | asoc->shutdown_last_sent_to); |
740 | chunk->transport = t; | ||
741 | } | ||
737 | asoc->shutdown_last_sent_to = t; | 742 | asoc->shutdown_last_sent_to = t; |
738 | asoc->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = t->rto; | 743 | asoc->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] = t->rto; |
739 | chunk->transport = t; | ||
740 | } | 744 | } |
741 | 745 | ||
742 | /* Helper function to change the state of an association. */ | 746 | /* Helper function to change the state of an association. */ |
@@ -888,8 +892,6 @@ static void sctp_cmd_process_fwdtsn(struct sctp_ulpq *ulpq, | |||
888 | sctp_walk_fwdtsn(skip, chunk) { | 892 | sctp_walk_fwdtsn(skip, chunk) { |
889 | sctp_ulpq_skip(ulpq, ntohs(skip->stream), ntohs(skip->ssn)); | 893 | sctp_ulpq_skip(ulpq, ntohs(skip->stream), ntohs(skip->ssn)); |
890 | } | 894 | } |
891 | |||
892 | return; | ||
893 | } | 895 | } |
894 | 896 | ||
895 | /* Helper function to remove the association non-primary peer | 897 | /* Helper function to remove the association non-primary peer |
@@ -908,8 +910,6 @@ static void sctp_cmd_del_non_primary(struct sctp_association *asoc) | |||
908 | sctp_assoc_del_peer(asoc, &t->ipaddr); | 910 | sctp_assoc_del_peer(asoc, &t->ipaddr); |
909 | } | 911 | } |
910 | } | 912 | } |
911 | |||
912 | return; | ||
913 | } | 913 | } |
914 | 914 | ||
915 | /* Helper function to set sk_err on a 1-1 style socket. */ | 915 | /* Helper function to set sk_err on a 1-1 style socket. */ |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 44a1ab03a3f0..ca44917872d2 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -3720,9 +3720,6 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3720 | 3720 | ||
3721 | SCTP_DBG_OBJCNT_INC(sock); | 3721 | SCTP_DBG_OBJCNT_INC(sock); |
3722 | 3722 | ||
3723 | /* Set socket backlog limit. */ | ||
3724 | sk->sk_backlog.limit = sysctl_sctp_rmem[1]; | ||
3725 | |||
3726 | local_bh_disable(); | 3723 | local_bh_disable(); |
3727 | percpu_counter_inc(&sctp_sockets_allocated); | 3724 | percpu_counter_inc(&sctp_sockets_allocated); |
3728 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | 3725 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); |
@@ -4387,7 +4384,7 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len, | |||
4387 | transports) { | 4384 | transports) { |
4388 | memcpy(&temp, &from->ipaddr, sizeof(temp)); | 4385 | memcpy(&temp, &from->ipaddr, sizeof(temp)); |
4389 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); | 4386 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); |
4390 | addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; | 4387 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; |
4391 | if (space_left < addrlen) | 4388 | if (space_left < addrlen) |
4392 | return -ENOMEM; | 4389 | return -ENOMEM; |
4393 | if (copy_to_user(to, &temp, addrlen)) | 4390 | if (copy_to_user(to, &temp, addrlen)) |
@@ -5436,6 +5433,8 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) | |||
5436 | rover++; | 5433 | rover++; |
5437 | if ((rover < low) || (rover > high)) | 5434 | if ((rover < low) || (rover > high)) |
5438 | rover = low; | 5435 | rover = low; |
5436 | if (inet_is_reserved_local_port(rover)) | ||
5437 | continue; | ||
5439 | index = sctp_phashfn(rover); | 5438 | index = sctp_phashfn(rover); |
5440 | head = &sctp_port_hashtable[index]; | 5439 | head = &sctp_port_hashtable[index]; |
5441 | sctp_spin_lock(&head->lock); | 5440 | sctp_spin_lock(&head->lock); |
@@ -5482,7 +5481,6 @@ pp_found: | |||
5482 | */ | 5481 | */ |
5483 | int reuse = sk->sk_reuse; | 5482 | int reuse = sk->sk_reuse; |
5484 | struct sock *sk2; | 5483 | struct sock *sk2; |
5485 | struct hlist_node *node; | ||
5486 | 5484 | ||
5487 | SCTP_DEBUG_PRINTK("sctp_get_port() found a possible match\n"); | 5485 | SCTP_DEBUG_PRINTK("sctp_get_port() found a possible match\n"); |
5488 | if (pp->fastreuse && sk->sk_reuse && | 5486 | if (pp->fastreuse && sk->sk_reuse && |
@@ -5703,7 +5701,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
5703 | struct sctp_sock *sp = sctp_sk(sk); | 5701 | struct sctp_sock *sp = sctp_sk(sk); |
5704 | unsigned int mask; | 5702 | unsigned int mask; |
5705 | 5703 | ||
5706 | poll_wait(file, sk->sk_sleep, wait); | 5704 | poll_wait(file, sk_sleep(sk), wait); |
5707 | 5705 | ||
5708 | /* A TCP-style listening socket becomes readable when the accept queue | 5706 | /* A TCP-style listening socket becomes readable when the accept queue |
5709 | * is not empty. | 5707 | * is not empty. |
@@ -5944,7 +5942,7 @@ static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p) | |||
5944 | int error; | 5942 | int error; |
5945 | DEFINE_WAIT(wait); | 5943 | DEFINE_WAIT(wait); |
5946 | 5944 | ||
5947 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 5945 | prepare_to_wait_exclusive(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); |
5948 | 5946 | ||
5949 | /* Socket errors? */ | 5947 | /* Socket errors? */ |
5950 | error = sock_error(sk); | 5948 | error = sock_error(sk); |
@@ -5981,14 +5979,14 @@ static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p) | |||
5981 | sctp_lock_sock(sk); | 5979 | sctp_lock_sock(sk); |
5982 | 5980 | ||
5983 | ready: | 5981 | ready: |
5984 | finish_wait(sk->sk_sleep, &wait); | 5982 | finish_wait(sk_sleep(sk), &wait); |
5985 | return 0; | 5983 | return 0; |
5986 | 5984 | ||
5987 | interrupted: | 5985 | interrupted: |
5988 | error = sock_intr_errno(*timeo_p); | 5986 | error = sock_intr_errno(*timeo_p); |
5989 | 5987 | ||
5990 | out: | 5988 | out: |
5991 | finish_wait(sk->sk_sleep, &wait); | 5989 | finish_wait(sk_sleep(sk), &wait); |
5992 | *err = error; | 5990 | *err = error; |
5993 | return error; | 5991 | return error; |
5994 | } | 5992 | } |
@@ -6062,14 +6060,14 @@ static void __sctp_write_space(struct sctp_association *asoc) | |||
6062 | wake_up_interruptible(&asoc->wait); | 6060 | wake_up_interruptible(&asoc->wait); |
6063 | 6061 | ||
6064 | if (sctp_writeable(sk)) { | 6062 | if (sctp_writeable(sk)) { |
6065 | if (sk->sk_sleep && waitqueue_active(sk->sk_sleep)) | 6063 | if (sk_sleep(sk) && waitqueue_active(sk_sleep(sk))) |
6066 | wake_up_interruptible(sk->sk_sleep); | 6064 | wake_up_interruptible(sk_sleep(sk)); |
6067 | 6065 | ||
6068 | /* Note that we try to include the Async I/O support | 6066 | /* Note that we try to include the Async I/O support |
6069 | * here by modeling from the current TCP/UDP code. | 6067 | * here by modeling from the current TCP/UDP code. |
6070 | * We have not tested with it yet. | 6068 | * We have not tested with it yet. |
6071 | */ | 6069 | */ |
6072 | if (sock->fasync_list && | 6070 | if (sock->wq->fasync_list && |
6073 | !(sk->sk_shutdown & SEND_SHUTDOWN)) | 6071 | !(sk->sk_shutdown & SEND_SHUTDOWN)) |
6074 | sock_wake_async(sock, | 6072 | sock_wake_async(sock, |
6075 | SOCK_WAKE_SPACE, POLL_OUT); | 6073 | SOCK_WAKE_SPACE, POLL_OUT); |
@@ -6191,12 +6189,15 @@ do_nonblock: | |||
6191 | 6189 | ||
6192 | void sctp_data_ready(struct sock *sk, int len) | 6190 | void sctp_data_ready(struct sock *sk, int len) |
6193 | { | 6191 | { |
6194 | read_lock_bh(&sk->sk_callback_lock); | 6192 | struct socket_wq *wq; |
6195 | if (sk_has_sleeper(sk)) | 6193 | |
6196 | wake_up_interruptible_sync_poll(sk->sk_sleep, POLLIN | | 6194 | rcu_read_lock(); |
6195 | wq = rcu_dereference(sk->sk_wq); | ||
6196 | if (wq_has_sleeper(wq)) | ||
6197 | wake_up_interruptible_sync_poll(&wq->wait, POLLIN | | ||
6197 | POLLRDNORM | POLLRDBAND); | 6198 | POLLRDNORM | POLLRDBAND); |
6198 | sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); | 6199 | sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); |
6199 | read_unlock_bh(&sk->sk_callback_lock); | 6200 | rcu_read_unlock(); |
6200 | } | 6201 | } |
6201 | 6202 | ||
6202 | /* If socket sndbuf has changed, wake up all per association waiters. */ | 6203 | /* If socket sndbuf has changed, wake up all per association waiters. */ |
@@ -6307,7 +6308,7 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo) | |||
6307 | 6308 | ||
6308 | 6309 | ||
6309 | for (;;) { | 6310 | for (;;) { |
6310 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, | 6311 | prepare_to_wait_exclusive(sk_sleep(sk), &wait, |
6311 | TASK_INTERRUPTIBLE); | 6312 | TASK_INTERRUPTIBLE); |
6312 | 6313 | ||
6313 | if (list_empty(&ep->asocs)) { | 6314 | if (list_empty(&ep->asocs)) { |
@@ -6333,7 +6334,7 @@ static int sctp_wait_for_accept(struct sock *sk, long timeo) | |||
6333 | break; | 6334 | break; |
6334 | } | 6335 | } |
6335 | 6336 | ||
6336 | finish_wait(sk->sk_sleep, &wait); | 6337 | finish_wait(sk_sleep(sk), &wait); |
6337 | 6338 | ||
6338 | return err; | 6339 | return err; |
6339 | } | 6340 | } |
@@ -6343,7 +6344,7 @@ static void sctp_wait_for_close(struct sock *sk, long timeout) | |||
6343 | DEFINE_WAIT(wait); | 6344 | DEFINE_WAIT(wait); |
6344 | 6345 | ||
6345 | do { | 6346 | do { |
6346 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 6347 | prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); |
6347 | if (list_empty(&sctp_sk(sk)->ep->asocs)) | 6348 | if (list_empty(&sctp_sk(sk)->ep->asocs)) |
6348 | break; | 6349 | break; |
6349 | sctp_release_sock(sk); | 6350 | sctp_release_sock(sk); |
@@ -6351,7 +6352,7 @@ static void sctp_wait_for_close(struct sock *sk, long timeout) | |||
6351 | sctp_lock_sock(sk); | 6352 | sctp_lock_sock(sk); |
6352 | } while (!signal_pending(current) && timeout); | 6353 | } while (!signal_pending(current) && timeout); |
6353 | 6354 | ||
6354 | finish_wait(sk->sk_sleep, &wait); | 6355 | finish_wait(sk_sleep(sk), &wait); |
6355 | } | 6356 | } |
6356 | 6357 | ||
6357 | static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk) | 6358 | static void sctp_skb_set_owner_r_frag(struct sk_buff *skb, struct sock *sk) |
diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 165d54e07fcd..132046cb82fc 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c | |||
@@ -64,9 +64,6 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
64 | /* Copy in the address. */ | 64 | /* Copy in the address. */ |
65 | peer->ipaddr = *addr; | 65 | peer->ipaddr = *addr; |
66 | peer->af_specific = sctp_get_af_specific(addr->sa.sa_family); | 66 | peer->af_specific = sctp_get_af_specific(addr->sa.sa_family); |
67 | peer->asoc = NULL; | ||
68 | |||
69 | peer->dst = NULL; | ||
70 | memset(&peer->saddr, 0, sizeof(union sctp_addr)); | 67 | memset(&peer->saddr, 0, sizeof(union sctp_addr)); |
71 | 68 | ||
72 | /* From 6.3.1 RTO Calculation: | 69 | /* From 6.3.1 RTO Calculation: |
@@ -76,34 +73,21 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
76 | * parameter 'RTO.Initial'. | 73 | * parameter 'RTO.Initial'. |
77 | */ | 74 | */ |
78 | peer->rto = msecs_to_jiffies(sctp_rto_initial); | 75 | peer->rto = msecs_to_jiffies(sctp_rto_initial); |
79 | peer->rtt = 0; | ||
80 | peer->rttvar = 0; | ||
81 | peer->srtt = 0; | ||
82 | peer->rto_pending = 0; | ||
83 | peer->hb_sent = 0; | ||
84 | peer->fast_recovery = 0; | ||
85 | 76 | ||
86 | peer->last_time_heard = jiffies; | 77 | peer->last_time_heard = jiffies; |
87 | peer->last_time_ecne_reduced = jiffies; | 78 | peer->last_time_ecne_reduced = jiffies; |
88 | 79 | ||
89 | peer->init_sent_count = 0; | ||
90 | |||
91 | peer->param_flags = SPP_HB_DISABLE | | 80 | peer->param_flags = SPP_HB_DISABLE | |
92 | SPP_PMTUD_ENABLE | | 81 | SPP_PMTUD_ENABLE | |
93 | SPP_SACKDELAY_ENABLE; | 82 | SPP_SACKDELAY_ENABLE; |
94 | peer->hbinterval = 0; | ||
95 | 83 | ||
96 | /* Initialize the default path max_retrans. */ | 84 | /* Initialize the default path max_retrans. */ |
97 | peer->pathmaxrxt = sctp_max_retrans_path; | 85 | peer->pathmaxrxt = sctp_max_retrans_path; |
98 | peer->error_count = 0; | ||
99 | 86 | ||
100 | INIT_LIST_HEAD(&peer->transmitted); | 87 | INIT_LIST_HEAD(&peer->transmitted); |
101 | INIT_LIST_HEAD(&peer->send_ready); | 88 | INIT_LIST_HEAD(&peer->send_ready); |
102 | INIT_LIST_HEAD(&peer->transports); | 89 | INIT_LIST_HEAD(&peer->transports); |
103 | 90 | ||
104 | peer->T3_rtx_timer.expires = 0; | ||
105 | peer->hb_timer.expires = 0; | ||
106 | |||
107 | setup_timer(&peer->T3_rtx_timer, sctp_generate_t3_rtx_event, | 91 | setup_timer(&peer->T3_rtx_timer, sctp_generate_t3_rtx_event, |
108 | (unsigned long)peer); | 92 | (unsigned long)peer); |
109 | setup_timer(&peer->hb_timer, sctp_generate_heartbeat_event, | 93 | setup_timer(&peer->hb_timer, sctp_generate_heartbeat_event, |
@@ -115,15 +99,6 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
115 | get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce)); | 99 | get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce)); |
116 | 100 | ||
117 | atomic_set(&peer->refcnt, 1); | 101 | atomic_set(&peer->refcnt, 1); |
118 | peer->dead = 0; | ||
119 | |||
120 | peer->malloced = 0; | ||
121 | |||
122 | /* Initialize the state information for SFR-CACC */ | ||
123 | peer->cacc.changeover_active = 0; | ||
124 | peer->cacc.cycling_changeover = 0; | ||
125 | peer->cacc.next_tsn_at_change = 0; | ||
126 | peer->cacc.cacc_saw_newack = 0; | ||
127 | 102 | ||
128 | return peer; | 103 | return peer; |
129 | } | 104 | } |
@@ -201,7 +176,7 @@ static void sctp_transport_destroy(struct sctp_transport *transport) | |||
201 | /* Start T3_rtx timer if it is not already running and update the heartbeat | 176 | /* Start T3_rtx timer if it is not already running and update the heartbeat |
202 | * timer. This routine is called every time a DATA chunk is sent. | 177 | * timer. This routine is called every time a DATA chunk is sent. |
203 | */ | 178 | */ |
204 | void sctp_transport_reset_timers(struct sctp_transport *transport, int force) | 179 | void sctp_transport_reset_timers(struct sctp_transport *transport) |
205 | { | 180 | { |
206 | /* RFC 2960 6.3.2 Retransmission Timer Rules | 181 | /* RFC 2960 6.3.2 Retransmission Timer Rules |
207 | * | 182 | * |
@@ -211,7 +186,7 @@ void sctp_transport_reset_timers(struct sctp_transport *transport, int force) | |||
211 | * address. | 186 | * address. |
212 | */ | 187 | */ |
213 | 188 | ||
214 | if (force || !timer_pending(&transport->T3_rtx_timer)) | 189 | if (!timer_pending(&transport->T3_rtx_timer)) |
215 | if (!mod_timer(&transport->T3_rtx_timer, | 190 | if (!mod_timer(&transport->T3_rtx_timer, |
216 | jiffies + transport->rto)) | 191 | jiffies + transport->rto)) |
217 | sctp_transport_hold(transport); | 192 | sctp_transport_hold(transport); |
@@ -409,15 +384,16 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) | |||
409 | void sctp_transport_raise_cwnd(struct sctp_transport *transport, | 384 | void sctp_transport_raise_cwnd(struct sctp_transport *transport, |
410 | __u32 sack_ctsn, __u32 bytes_acked) | 385 | __u32 sack_ctsn, __u32 bytes_acked) |
411 | { | 386 | { |
387 | struct sctp_association *asoc = transport->asoc; | ||
412 | __u32 cwnd, ssthresh, flight_size, pba, pmtu; | 388 | __u32 cwnd, ssthresh, flight_size, pba, pmtu; |
413 | 389 | ||
414 | cwnd = transport->cwnd; | 390 | cwnd = transport->cwnd; |
415 | flight_size = transport->flight_size; | 391 | flight_size = transport->flight_size; |
416 | 392 | ||
417 | /* See if we need to exit Fast Recovery first */ | 393 | /* See if we need to exit Fast Recovery first */ |
418 | if (transport->fast_recovery && | 394 | if (asoc->fast_recovery && |
419 | TSN_lte(transport->fast_recovery_exit, sack_ctsn)) | 395 | TSN_lte(asoc->fast_recovery_exit, sack_ctsn)) |
420 | transport->fast_recovery = 0; | 396 | asoc->fast_recovery = 0; |
421 | 397 | ||
422 | /* The appropriate cwnd increase algorithm is performed if, and only | 398 | /* The appropriate cwnd increase algorithm is performed if, and only |
423 | * if the cumulative TSN whould advanced and the congestion window is | 399 | * if the cumulative TSN whould advanced and the congestion window is |
@@ -446,7 +422,7 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport, | |||
446 | * 2) the destination's path MTU. This upper bound protects | 422 | * 2) the destination's path MTU. This upper bound protects |
447 | * against the ACK-Splitting attack outlined in [SAVAGE99]. | 423 | * against the ACK-Splitting attack outlined in [SAVAGE99]. |
448 | */ | 424 | */ |
449 | if (transport->fast_recovery) | 425 | if (asoc->fast_recovery) |
450 | return; | 426 | return; |
451 | 427 | ||
452 | if (bytes_acked > pmtu) | 428 | if (bytes_acked > pmtu) |
@@ -497,6 +473,8 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport, | |||
497 | void sctp_transport_lower_cwnd(struct sctp_transport *transport, | 473 | void sctp_transport_lower_cwnd(struct sctp_transport *transport, |
498 | sctp_lower_cwnd_t reason) | 474 | sctp_lower_cwnd_t reason) |
499 | { | 475 | { |
476 | struct sctp_association *asoc = transport->asoc; | ||
477 | |||
500 | switch (reason) { | 478 | switch (reason) { |
501 | case SCTP_LOWER_CWND_T3_RTX: | 479 | case SCTP_LOWER_CWND_T3_RTX: |
502 | /* RFC 2960 Section 7.2.3, sctpimpguide | 480 | /* RFC 2960 Section 7.2.3, sctpimpguide |
@@ -507,11 +485,11 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, | |||
507 | * partial_bytes_acked = 0 | 485 | * partial_bytes_acked = 0 |
508 | */ | 486 | */ |
509 | transport->ssthresh = max(transport->cwnd/2, | 487 | transport->ssthresh = max(transport->cwnd/2, |
510 | 4*transport->asoc->pathmtu); | 488 | 4*asoc->pathmtu); |
511 | transport->cwnd = transport->asoc->pathmtu; | 489 | transport->cwnd = asoc->pathmtu; |
512 | 490 | ||
513 | /* T3-rtx also clears fast recovery on the transport */ | 491 | /* T3-rtx also clears fast recovery */ |
514 | transport->fast_recovery = 0; | 492 | asoc->fast_recovery = 0; |
515 | break; | 493 | break; |
516 | 494 | ||
517 | case SCTP_LOWER_CWND_FAST_RTX: | 495 | case SCTP_LOWER_CWND_FAST_RTX: |
@@ -527,15 +505,15 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, | |||
527 | * cwnd = ssthresh | 505 | * cwnd = ssthresh |
528 | * partial_bytes_acked = 0 | 506 | * partial_bytes_acked = 0 |
529 | */ | 507 | */ |
530 | if (transport->fast_recovery) | 508 | if (asoc->fast_recovery) |
531 | return; | 509 | return; |
532 | 510 | ||
533 | /* Mark Fast recovery */ | 511 | /* Mark Fast recovery */ |
534 | transport->fast_recovery = 1; | 512 | asoc->fast_recovery = 1; |
535 | transport->fast_recovery_exit = transport->asoc->next_tsn - 1; | 513 | asoc->fast_recovery_exit = asoc->next_tsn - 1; |
536 | 514 | ||
537 | transport->ssthresh = max(transport->cwnd/2, | 515 | transport->ssthresh = max(transport->cwnd/2, |
538 | 4*transport->asoc->pathmtu); | 516 | 4*asoc->pathmtu); |
539 | transport->cwnd = transport->ssthresh; | 517 | transport->cwnd = transport->ssthresh; |
540 | break; | 518 | break; |
541 | 519 | ||
@@ -555,7 +533,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, | |||
555 | if (time_after(jiffies, transport->last_time_ecne_reduced + | 533 | if (time_after(jiffies, transport->last_time_ecne_reduced + |
556 | transport->rtt)) { | 534 | transport->rtt)) { |
557 | transport->ssthresh = max(transport->cwnd/2, | 535 | transport->ssthresh = max(transport->cwnd/2, |
558 | 4*transport->asoc->pathmtu); | 536 | 4*asoc->pathmtu); |
559 | transport->cwnd = transport->ssthresh; | 537 | transport->cwnd = transport->ssthresh; |
560 | transport->last_time_ecne_reduced = jiffies; | 538 | transport->last_time_ecne_reduced = jiffies; |
561 | } | 539 | } |
@@ -571,7 +549,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport, | |||
571 | * interval. | 549 | * interval. |
572 | */ | 550 | */ |
573 | transport->cwnd = max(transport->cwnd/2, | 551 | transport->cwnd = max(transport->cwnd/2, |
574 | 4*transport->asoc->pathmtu); | 552 | 4*asoc->pathmtu); |
575 | break; | 553 | break; |
576 | } | 554 | } |
577 | 555 | ||
@@ -656,7 +634,6 @@ void sctp_transport_reset(struct sctp_transport *t) | |||
656 | t->error_count = 0; | 634 | t->error_count = 0; |
657 | t->rto_pending = 0; | 635 | t->rto_pending = 0; |
658 | t->hb_sent = 0; | 636 | t->hb_sent = 0; |
659 | t->fast_recovery = 0; | ||
660 | 637 | ||
661 | /* Initialize the state information for SFR-CACC */ | 638 | /* Initialize the state information for SFR-CACC */ |
662 | t->cacc.changeover_active = 0; | 639 | t->cacc.changeover_active = 0; |
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c index 3a448536f0b6..c7f7e49609cb 100644 --- a/net/sctp/ulpqueue.c +++ b/net/sctp/ulpqueue.c | |||
@@ -955,7 +955,6 @@ void sctp_ulpq_skip(struct sctp_ulpq *ulpq, __u16 sid, __u16 ssn) | |||
955 | * ordering and deliver them if needed. | 955 | * ordering and deliver them if needed. |
956 | */ | 956 | */ |
957 | sctp_ulpq_reap_ordered(ulpq, sid); | 957 | sctp_ulpq_reap_ordered(ulpq, sid); |
958 | return; | ||
959 | } | 958 | } |
960 | 959 | ||
961 | static __u16 sctp_ulpq_renege_list(struct sctp_ulpq *ulpq, | 960 | static __u16 sctp_ulpq_renege_list(struct sctp_ulpq *ulpq, |
@@ -1064,7 +1063,6 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, | |||
1064 | } | 1063 | } |
1065 | 1064 | ||
1066 | sk_mem_reclaim(asoc->base.sk); | 1065 | sk_mem_reclaim(asoc->base.sk); |
1067 | return; | ||
1068 | } | 1066 | } |
1069 | 1067 | ||
1070 | 1068 | ||