Skip to content

Commit a000c01

Browse files
Wei Yongjundavem330
authored andcommitted
sctp: stop pending timers and purge queues when peer restart asoc
If the peer restart the asoc, we should not only fail any unsent/unacked data, but also stop the T3-rtx, SACK, T4-rto timers, and teardown ASCONF queues. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b10cec8 commit a000c01

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

include/net/sctp/command.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ typedef enum {
107107
SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */
108108
SCTP_CMD_SEND_MSG, /* Send the whole use message */
109109
SCTP_CMD_SEND_NEXT_ASCONF, /* Send the next ASCONF after ACK */
110+
SCTP_CMD_PURGE_ASCONF_QUEUE, /* Purge all asconf queues.*/
110111
SCTP_CMD_LAST
111112
} sctp_verb_t;
112113

include/net/sctp/structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc);
19931993
struct sctp_chunk *sctp_assoc_lookup_asconf_ack(
19941994
const struct sctp_association *asoc,
19951995
__be32 serial);
1996-
1996+
void sctp_asconf_queue_teardown(struct sctp_association *asoc);
19971997

19981998
int sctp_cmp_addr_exact(const union sctp_addr *ss1,
19991999
const union sctp_addr *ss2);

net/sctp/associola.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,7 @@ void sctp_association_free(struct sctp_association *asoc)
444444

445445
asoc->peer.transport_count = 0;
446446

447-
/* Free any cached ASCONF_ACK chunk. */
448-
sctp_assoc_free_asconf_acks(asoc);
449-
450-
/* Free the ASCONF queue. */
451-
sctp_assoc_free_asconf_queue(asoc);
452-
453-
/* Free any cached ASCONF chunk. */
454-
if (asoc->addip_last_asconf)
455-
sctp_chunk_free(asoc->addip_last_asconf);
447+
sctp_asconf_queue_teardown(asoc);
456448

457449
/* AUTH - Free the endpoint shared keys */
458450
sctp_auth_destroy_keys(&asoc->endpoint_shared_keys);
@@ -1646,3 +1638,16 @@ struct sctp_chunk *sctp_assoc_lookup_asconf_ack(
16461638

16471639
return NULL;
16481640
}
1641+
1642+
void sctp_asconf_queue_teardown(struct sctp_association *asoc)
1643+
{
1644+
/* Free any cached ASCONF_ACK chunk. */
1645+
sctp_assoc_free_asconf_acks(asoc);
1646+
1647+
/* Free the ASCONF queue. */
1648+
sctp_assoc_free_asconf_queue(asoc);
1649+
1650+
/* Free any cached ASCONF chunk. */
1651+
if (asoc->addip_last_asconf)
1652+
sctp_chunk_free(asoc->addip_last_asconf);
1653+
}

net/sctp/sm_sideeffect.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,9 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
16701670
case SCTP_CMD_SEND_NEXT_ASCONF:
16711671
sctp_cmd_send_asconf(asoc);
16721672
break;
1673+
case SCTP_CMD_PURGE_ASCONF_QUEUE:
1674+
sctp_asconf_queue_teardown(asoc);
1675+
break;
16731676
default:
16741677
pr_warn("Impossible command: %u, %p\n",
16751678
cmd->verb, cmd->obj.ptr);

net/sctp/sm_statefuns.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,11 +1718,21 @@ static sctp_disposition_t sctp_sf_do_dupcook_a(const struct sctp_endpoint *ep,
17181718
return SCTP_DISPOSITION_CONSUME;
17191719
}
17201720

1721-
/* For now, fail any unsent/unacked data. Consider the optional
1722-
* choice of resending of this data.
1721+
/* For now, stop pending T3-rtx and SACK timers, fail any unsent/unacked
1722+
* data. Consider the optional choice of resending of this data.
17231723
*/
1724+
sctp_add_cmd_sf(commands, SCTP_CMD_T3_RTX_TIMERS_STOP, SCTP_NULL());
1725+
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
1726+
SCTP_TO(SCTP_EVENT_TIMEOUT_SACK));
17241727
sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_OUTQUEUE, SCTP_NULL());
17251728

1729+
/* Stop pending T4-rto timer, teardown ASCONF queue, ASCONF-ACK queue
1730+
* and ASCONF-ACK cache.
1731+
*/
1732+
sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
1733+
SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
1734+
sctp_add_cmd_sf(commands, SCTP_CMD_PURGE_ASCONF_QUEUE, SCTP_NULL());
1735+
17261736
repl = sctp_make_cookie_ack(new_asoc, chunk);
17271737
if (!repl)
17281738
goto nomem;

0 commit comments

Comments
 (0)