Skip to content

Commit e38d86b

Browse files
lxinkuba-moo
authored andcommitted
sctp: add the error cause for new encapsulation port restart
This patch is to add the function to make the abort chunk with the error cause for new encapsulation port restart, defined on Section 4.4 in draft-tuexen-tsvwg-sctp-udp-encaps-cons-03. v1->v2: - no change. v2->v3: - no need to call htons() when setting nep.cur_port/new_port. Signed-off-by: Xin Long <[email protected]> Acked-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 259db53 commit e38d86b

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

include/linux/sctp.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,13 @@ enum sctp_error {
482482
* 11 Restart of an association with new addresses
483483
* 12 User Initiated Abort
484484
* 13 Protocol Violation
485+
* 14 Restart of an Association with New Encapsulation Port
485486
*/
486487

487488
SCTP_ERROR_RESTART = cpu_to_be16(0x0b),
488489
SCTP_ERROR_USER_ABORT = cpu_to_be16(0x0c),
489490
SCTP_ERROR_PROTO_VIOLATION = cpu_to_be16(0x0d),
491+
SCTP_ERROR_NEW_ENCAP_PORT = cpu_to_be16(0x0e),
490492

491493
/* ADDIP Section 3.3 New Error Causes
492494
*
@@ -793,4 +795,22 @@ enum {
793795
SCTP_FLOWLABEL_VAL_MASK = 0xfffff
794796
};
795797

798+
/* UDP Encapsulation
799+
* draft-tuexen-tsvwg-sctp-udp-encaps-cons-03.html#section-4-4
800+
*
801+
* The error cause indicating an "Restart of an Association with
802+
* New Encapsulation Port"
803+
*
804+
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
805+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
806+
* | Cause Code = 14 | Cause Length = 8 |
807+
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
808+
* | Current Encapsulation Port | New Encapsulation Port |
809+
* +-------------------------------+-------------------------------+
810+
*/
811+
struct sctp_new_encap_port_hdr {
812+
__be16 cur_port;
813+
__be16 new_port;
814+
};
815+
796816
#endif /* __LINUX_SCTP_H__ */

include/net/sctp/sm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ struct sctp_chunk *sctp_make_violation_paramlen(
221221
struct sctp_chunk *sctp_make_violation_max_retrans(
222222
const struct sctp_association *asoc,
223223
const struct sctp_chunk *chunk);
224+
struct sctp_chunk *sctp_make_new_encap_port(
225+
const struct sctp_association *asoc,
226+
const struct sctp_chunk *chunk);
224227
struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
225228
const struct sctp_transport *transport);
226229
struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *asoc,

net/sctp/sm_make_chunk.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,26 @@ struct sctp_chunk *sctp_make_violation_max_retrans(
11421142
return retval;
11431143
}
11441144

1145+
struct sctp_chunk *sctp_make_new_encap_port(const struct sctp_association *asoc,
1146+
const struct sctp_chunk *chunk)
1147+
{
1148+
struct sctp_new_encap_port_hdr nep;
1149+
struct sctp_chunk *retval;
1150+
1151+
retval = sctp_make_abort(asoc, chunk,
1152+
sizeof(struct sctp_errhdr) + sizeof(nep));
1153+
if (!retval)
1154+
goto nodata;
1155+
1156+
sctp_init_cause(retval, SCTP_ERROR_NEW_ENCAP_PORT, sizeof(nep));
1157+
nep.cur_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
1158+
nep.new_port = chunk->transport->encap_port;
1159+
sctp_addto_chunk(retval, sizeof(nep), &nep);
1160+
1161+
nodata:
1162+
return retval;
1163+
}
1164+
11451165
/* Make a HEARTBEAT chunk. */
11461166
struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
11471167
const struct sctp_transport *transport)

0 commit comments

Comments
 (0)