diff options
author | Xin Long <lucien.xin@gmail.com> | 2017-12-14 19:41:27 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-15 21:52:22 +0300 |
commit | 0fc2ea922c8ad5520c80f03facbf396c81dce802 (patch) | |
tree | ffcbe8fc12f45a2ca745bcc48b81ec2fbca4985b /include/net/sctp | |
parent | 8e0c3b73cec1b943affde91b3c412ad8266b4694 (diff) | |
download | linux-0fc2ea922c8ad5520c80f03facbf396c81dce802.tar.xz |
sctp: implement validate_ftsn for sctp_stream_interleave
validate_ftsn is added as a member of sctp_stream_interleave, used to
validate ssn/chunk type for fwdtsn or mid (message id)/chunk type for
ifwdtsn, called in sctp_sf_eat_fwd_tsn, just as validate_data.
If this check fails, an abort packet will be sent, as said in section
2.3.1 of RFC8260.
As ifwdtsn and fwdtsn chunks have different length, it also defines
ftsn_chunk_len for sctp_stream_interleave to describe the chunk size.
Then it replaces all sizeof(struct sctp_fwdtsn_chunk) with
sctp_ftsnchk_len.
It also adds the process for ifwdtsn in rx path. As Marcelo pointed
out, there's no need to add event table for ifwdtsn, but just share
prsctp_chunk_event_table with fwdtsn's. It would drop fwdtsn chunk
for ifwdtsn and drop ifwdtsn chunk for fwdtsn by calling validate_ftsn
in sctp_sf_eat_fwd_tsn.
After this patch, the ifwdtsn can be accepted.
Note that this patch also removes the sctp.intl_enable check for
idata chunks in sctp_chunk_event_lookup, as it will do this check
in validate_data later.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo R. Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sctp')
-rw-r--r-- | include/net/sctp/stream_interleave.h | 2 | ||||
-rw-r--r-- | include/net/sctp/structs.h | 10 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/net/sctp/stream_interleave.h b/include/net/sctp/stream_interleave.h index 66267dbcecba..0db15b50c5e6 100644 --- a/include/net/sctp/stream_interleave.h +++ b/include/net/sctp/stream_interleave.h @@ -33,6 +33,7 @@ struct sctp_stream_interleave { __u16 data_chunk_len; + __u16 ftsn_chunk_len; /* (I-)DATA process */ struct sctp_chunk *(*make_datafrag)(const struct sctp_association *asoc, const struct sctp_sndrcvinfo *sinfo, @@ -49,6 +50,7 @@ struct sctp_stream_interleave { void (*abort_pd)(struct sctp_ulpq *ulpq, gfp_t gfp); /* (I-)FORWARD-TSN process */ void (*generate_ftsn)(struct sctp_outq *q, __u32 ctsn); + bool (*validate_ftsn)(struct sctp_chunk *chunk); }; void sctp_stream_interleave_init(struct sctp_stream *stream); diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index b7720d65a975..8ac4d5cdbfed 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -1443,6 +1443,16 @@ static inline __u16 sctp_datahdr_len(const struct sctp_stream *stream) return stream->si->data_chunk_len - sizeof(struct sctp_chunkhdr); } +static inline __u16 sctp_ftsnchk_len(const struct sctp_stream *stream) +{ + return stream->si->ftsn_chunk_len; +} + +static inline __u16 sctp_ftsnhdr_len(const struct sctp_stream *stream) +{ + return stream->si->ftsn_chunk_len - sizeof(struct sctp_chunkhdr); +} + /* SCTP_GET_ASSOC_STATS counters */ struct sctp_priv_assoc_stats { /* Maximum observed rto in the association during subsequent |