aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2012-11-20 05:14:30 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-20 15:50:37 -0500
commitde4594a51c904ddcd6c3a6cdd100f7c1d94d3239 (patch)
tree717425cdc0617de66ac42d14902f09ee513db856 /net/sctp
parent388dfc2d2d9c43c251921a397d6fe5ef7dc34731 (diff)
sctp: send abort chunk when max_retrans exceeded
In the event that an association exceeds its max_retrans attempts, we should send an ABORT chunk indicating that we are closing the assocation as a result. Because of the nature of the error, its unlikely to be received, but its a nice clean way to close the association if it does make it through, and it will give anyone watching via tcpdump a clue as to what happened. Change notes: v2) * Removed erroneous changes from sctp_make_violation_parmlen Signed-off-by: Neil Horman <nhorman@tuxdriver.com> CC: Vlad Yasevich <vyasevich@gmail.com> CC: "David S. Miller" <davem@davemloft.net> CC: linux-sctp@vger.kernel.org Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r--net/sctp/sm_make_chunk.c19
-rw-r--r--net/sctp/sm_sideeffect.c9
2 files changed, 27 insertions, 1 deletions
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index fbe1636309a7..e0f01a4e8cd6 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1090,6 +1090,25 @@ nodata:
1090 return retval; 1090 return retval;
1091} 1091}
1092 1092
1093struct sctp_chunk *sctp_make_violation_max_retrans(
1094 const struct sctp_association *asoc,
1095 const struct sctp_chunk *chunk)
1096{
1097 struct sctp_chunk *retval;
1098 static const char error[] = "Association exceeded its max_retans count";
1099 size_t payload_len = sizeof(error) + sizeof(sctp_errhdr_t);
1100
1101 retval = sctp_make_abort(asoc, chunk, payload_len);
1102 if (!retval)
1103 goto nodata;
1104
1105 sctp_init_cause(retval, SCTP_ERROR_PROTO_VIOLATION, sizeof(error));
1106 sctp_addto_chunk(retval, sizeof(error), error);
1107
1108nodata:
1109 return retval;
1110}
1111
1093/* Make a HEARTBEAT chunk. */ 1112/* Make a HEARTBEAT chunk. */
1094struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc, 1113struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
1095 const struct sctp_transport *transport) 1114 const struct sctp_transport *transport)
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 6eecf7e6338d..c0769569b05d 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -577,7 +577,7 @@ static void sctp_cmd_assoc_failed(sctp_cmd_seq_t *commands,
577 unsigned int error) 577 unsigned int error)
578{ 578{
579 struct sctp_ulpevent *event; 579 struct sctp_ulpevent *event;
580 580 struct sctp_chunk *abort;
581 /* Cancel any partial delivery in progress. */ 581 /* Cancel any partial delivery in progress. */
582 sctp_ulpq_abort_pd(&asoc->ulpq, GFP_ATOMIC); 582 sctp_ulpq_abort_pd(&asoc->ulpq, GFP_ATOMIC);
583 583
@@ -593,6 +593,13 @@ static void sctp_cmd_assoc_failed(sctp_cmd_seq_t *commands,
593 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, 593 sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP,
594 SCTP_ULPEVENT(event)); 594 SCTP_ULPEVENT(event));
595 595
596 if (asoc->overall_error_count >= asoc->max_retrans) {
597 abort = sctp_make_violation_max_retrans(asoc, chunk);
598 if (abort)
599 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
600 SCTP_CHUNK(abort));
601 }
602
596 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 603 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
597 SCTP_STATE(SCTP_STATE_CLOSED)); 604 SCTP_STATE(SCTP_STATE_CLOSED));
598 605