All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add streams
@ 2017-02-08 17:18 ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

Patch 4/6 is to implement sender-side procedures for the SSN/TSN Reset
Request Parameter described in rfc6525 section 5.1.4, patch 3/6 is
ahead of it to define a function to make the request chunk for it.

Patch 6/6 is to implement sender-side procedures for the Add Incoming
and Outgoing Streams Request Parameter Request Parameter described in
rfc6525 section 5.1.5 and 5.1.6, patch 5/6 is ahead of it to define a
function to make the request chunk for it.

Patch 2/6 is a fix to recover streams states when it fails to send
request and Patch 1/6 is to drop some unncessary __packed from some
old structures.

v1->v2:
  - put these into a smaller group.
  - rename some temporary variables in the codes.
  - rename the titles of the commits and improve some changelogs.
v2->v3:
  - re-split the patchset and make sure it has no dead codes for review.
  - move some codes into stream.c from socket.c.
v3->v4:
  - add one more patch to fix a send reset stream request issue.
  - doing actual work only when request is sent successfully.
  - reduce some indents in sctp_send_add_streams.
v4->v5:
  - close streams before sending request and recover them when sending
    fails in patch 1/5 and patch 3/5
v5->v6:
  - add patch 1/6 to drop some unncessary __packed from some old structures.
  - remove __packed from some new structures in patch 3/6 and 5/6.
  - define unsigned int outcnt and incnt to make codes smaller in patch 6/6.
  - use krealloc instead of kcalloc and remove ksize check in patch 6/6, as
    ksize check is acutally used in krealloc already.

Xin Long (6):
  sctp: drop unnecessary __packed from some stream reconf structures
  sctp: streams should be recovered when it fails to send request.
  sctp: add support for generating stream reconf ssn/tsn reset request
    chunk
  sctp: implement sender-side procedures for SSN/TSN Reset Request
    Parameter
  sctp: add support for generating stream reconf add incoming/outgoing
    streams request chunk
  sctp: implement sender-side procedures for Add Incoming/Outgoing
    Streams Request Parameter

 include/linux/sctp.h      |  18 +++++--
 include/net/sctp/sctp.h   |   3 ++
 include/net/sctp/sm.h     |   5 ++
 include/uapi/linux/sctp.h |   8 +++
 net/sctp/sm_make_chunk.c  |  75 ++++++++++++++++++++++++++
 net/sctp/socket.c         |  58 ++++++++++++++++++++
 net/sctp/stream.c         | 134 +++++++++++++++++++++++++++++++++++++++++++++-
 7 files changed, 297 insertions(+), 4 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add streams
@ 2017-02-08 17:18 ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

Patch 4/6 is to implement sender-side procedures for the SSN/TSN Reset
Request Parameter described in rfc6525 section 5.1.4, patch 3/6 is
ahead of it to define a function to make the request chunk for it.

Patch 6/6 is to implement sender-side procedures for the Add Incoming
and Outgoing Streams Request Parameter Request Parameter described in
rfc6525 section 5.1.5 and 5.1.6, patch 5/6 is ahead of it to define a
function to make the request chunk for it.

Patch 2/6 is a fix to recover streams states when it fails to send
request and Patch 1/6 is to drop some unncessary __packed from some
old structures.

v1->v2:
  - put these into a smaller group.
  - rename some temporary variables in the codes.
  - rename the titles of the commits and improve some changelogs.
v2->v3:
  - re-split the patchset and make sure it has no dead codes for review.
  - move some codes into stream.c from socket.c.
v3->v4:
  - add one more patch to fix a send reset stream request issue.
  - doing actual work only when request is sent successfully.
  - reduce some indents in sctp_send_add_streams.
v4->v5:
  - close streams before sending request and recover them when sending
    fails in patch 1/5 and patch 3/5
v5->v6:
  - add patch 1/6 to drop some unncessary __packed from some old structures.
  - remove __packed from some new structures in patch 3/6 and 5/6.
  - define unsigned int outcnt and incnt to make codes smaller in patch 6/6.
  - use krealloc instead of kcalloc and remove ksize check in patch 6/6, as
    ksize check is acutally used in krealloc already.

Xin Long (6):
  sctp: drop unnecessary __packed from some stream reconf structures
  sctp: streams should be recovered when it fails to send request.
  sctp: add support for generating stream reconf ssn/tsn reset request
    chunk
  sctp: implement sender-side procedures for SSN/TSN Reset Request
    Parameter
  sctp: add support for generating stream reconf add incoming/outgoing
    streams request chunk
  sctp: implement sender-side procedures for Add Incoming/Outgoing
    Streams Request Parameter

 include/linux/sctp.h      |  18 +++++--
 include/net/sctp/sctp.h   |   3 ++
 include/net/sctp/sm.h     |   5 ++
 include/uapi/linux/sctp.h |   8 +++
 net/sctp/sm_make_chunk.c  |  75 ++++++++++++++++++++++++++
 net/sctp/socket.c         |  58 ++++++++++++++++++++
 net/sctp/stream.c         | 134 +++++++++++++++++++++++++++++++++++++++++++++-
 7 files changed, 297 insertions(+), 4 deletions(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 1/6] sctp: drop unnecessary __packed from some stream reconf structures
  2017-02-08 17:18 ` Xin Long
@ 2017-02-08 17:18   ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

commit 85c727b59483 ("sctp: drop __packed from almost all SCTP structures")
has removed __packed from almost all SCTP structures. But there still are
three structures where it should be dropped.

This patch is to remove it from some stream reconf structures.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/linux/sctp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index 2408c68..d74fca3 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -721,7 +721,7 @@ struct sctp_infox {
 struct sctp_reconf_chunk {
 	sctp_chunkhdr_t chunk_hdr;
 	__u8 params[0];
-} __packed;
+};
 
 struct sctp_strreset_outreq {
 	sctp_paramhdr_t param_hdr;
@@ -729,12 +729,12 @@ struct sctp_strreset_outreq {
 	__u32 response_seq;
 	__u32 send_reset_at_tsn;
 	__u16 list_of_streams[0];
-} __packed;
+};
 
 struct sctp_strreset_inreq {
 	sctp_paramhdr_t param_hdr;
 	__u32 request_seq;
 	__u16 list_of_streams[0];
-} __packed;
+};
 
 #endif /* __LINUX_SCTP_H__ */
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 1/6] sctp: drop unnecessary __packed from some stream reconf structures
@ 2017-02-08 17:18   ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

commit 85c727b59483 ("sctp: drop __packed from almost all SCTP structures")
has removed __packed from almost all SCTP structures. But there still are
three structures where it should be dropped.

This patch is to remove it from some stream reconf structures.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/linux/sctp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index 2408c68..d74fca3 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -721,7 +721,7 @@ struct sctp_infox {
 struct sctp_reconf_chunk {
 	sctp_chunkhdr_t chunk_hdr;
 	__u8 params[0];
-} __packed;
+};
 
 struct sctp_strreset_outreq {
 	sctp_paramhdr_t param_hdr;
@@ -729,12 +729,12 @@ struct sctp_strreset_outreq {
 	__u32 response_seq;
 	__u32 send_reset_at_tsn;
 	__u16 list_of_streams[0];
-} __packed;
+};
 
 struct sctp_strreset_inreq {
 	sctp_paramhdr_t param_hdr;
 	__u32 request_seq;
 	__u16 list_of_streams[0];
-} __packed;
+};
 
 #endif /* __LINUX_SCTP_H__ */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 2/6] sctp: streams should be recovered when it fails to send request.
  2017-02-08 17:18   ` Xin Long
@ 2017-02-08 17:18     ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

Now when sending stream reset request, it closes the streams to
block further xmit of data until this request is completed, then
calls sctp_send_reconf to send the chunk.

But if sctp_send_reconf returns err, and it doesn't recover the
streams' states back,  which means the request chunk would not be
queued and sent, so the asoc will get stuck, streams are closed
and no packet is even queued.

This patch is to fix it by recovering the streams' states when
it fails to send the request, it is also to fix a return value.

Fixes: 7f9d68ac944e ("sctp: implement sender-side procedures for SSN Reset Request Parameter")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/stream.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 13d5e07..6a686e3 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -136,8 +136,10 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 				goto out;
 
 	chunk = sctp_make_strreset_req(asoc, str_nums, str_list, out, in);
-	if (!chunk)
+	if (!chunk) {
+		retval = -ENOMEM;
 		goto out;
+	}
 
 	if (out) {
 		if (str_nums)
@@ -149,7 +151,6 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 				stream->out[i].state = SCTP_STREAM_CLOSED;
 	}
 
-	asoc->strreset_outstanding = out + in;
 	asoc->strreset_chunk = chunk;
 	sctp_chunk_hold(asoc->strreset_chunk);
 
@@ -157,8 +158,22 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 	if (retval) {
 		sctp_chunk_put(asoc->strreset_chunk);
 		asoc->strreset_chunk = NULL;
+		if (!out)
+			goto out;
+
+		if (str_nums)
+			for (i = 0; i < str_nums; i++)
+				stream->out[str_list[i]].state =
+						       SCTP_STREAM_OPEN;
+		else
+			for (i = 0; i < stream->outcnt; i++)
+				stream->out[i].state = SCTP_STREAM_OPEN;
+
+		goto out;
 	}
 
+	asoc->strreset_outstanding = out + in;
+
 out:
 	return retval;
 }
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 2/6] sctp: streams should be recovered when it fails to send request.
@ 2017-02-08 17:18     ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

Now when sending stream reset request, it closes the streams to
block further xmit of data until this request is completed, then
calls sctp_send_reconf to send the chunk.

But if sctp_send_reconf returns err, and it doesn't recover the
streams' states back,  which means the request chunk would not be
queued and sent, so the asoc will get stuck, streams are closed
and no packet is even queued.

This patch is to fix it by recovering the streams' states when
it fails to send the request, it is also to fix a return value.

Fixes: 7f9d68ac944e ("sctp: implement sender-side procedures for SSN Reset Request Parameter")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/sctp/stream.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 13d5e07..6a686e3 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -136,8 +136,10 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 				goto out;
 
 	chunk = sctp_make_strreset_req(asoc, str_nums, str_list, out, in);
-	if (!chunk)
+	if (!chunk) {
+		retval = -ENOMEM;
 		goto out;
+	}
 
 	if (out) {
 		if (str_nums)
@@ -149,7 +151,6 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 				stream->out[i].state = SCTP_STREAM_CLOSED;
 	}
 
-	asoc->strreset_outstanding = out + in;
 	asoc->strreset_chunk = chunk;
 	sctp_chunk_hold(asoc->strreset_chunk);
 
@@ -157,8 +158,22 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 	if (retval) {
 		sctp_chunk_put(asoc->strreset_chunk);
 		asoc->strreset_chunk = NULL;
+		if (!out)
+			goto out;
+
+		if (str_nums)
+			for (i = 0; i < str_nums; i++)
+				stream->out[str_list[i]].state +						       SCTP_STREAM_OPEN;
+		else
+			for (i = 0; i < stream->outcnt; i++)
+				stream->out[i].state = SCTP_STREAM_OPEN;
+
+		goto out;
 	}
 
+	asoc->strreset_outstanding = out + in;
+
 out:
 	return retval;
 }
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chunk
  2017-02-08 17:18     ` Xin Long
@ 2017-02-08 17:18       ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to define SSN/TSN Reset Request Parameter described
in rfc6525 section 4.3.

It's also to drop some unnecessary __packed in include/linux/sctp.h.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/linux/sctp.h     |  5 +++++
 include/net/sctp/sm.h    |  2 ++
 net/sctp/sm_make_chunk.c | 29 +++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index d74fca3..71c0d41 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -737,4 +737,9 @@ struct sctp_strreset_inreq {
 	__u16 list_of_streams[0];
 };
 
+struct sctp_strreset_tsnreq {
+	sctp_paramhdr_t param_hdr;
+	__u32 request_seq;
+};
+
 #endif /* __LINUX_SCTP_H__ */
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 430ed13..ac37c17 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -265,6 +265,8 @@ struct sctp_chunk *sctp_make_strreset_req(
 				const struct sctp_association *asoc,
 				__u16 stream_num, __u16 *stream_list,
 				bool out, bool in);
+struct sctp_chunk *sctp_make_strreset_tsnreq(
+				const struct sctp_association *asoc);
 void sctp_chunk_assign_tsn(struct sctp_chunk *);
 void sctp_chunk_assign_ssn(struct sctp_chunk *);
 
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index c7d3249..749842a 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -3658,3 +3658,32 @@ struct sctp_chunk *sctp_make_strreset_req(
 
 	return retval;
 }
+
+/* RE-CONFIG 4.3 (SSN/TSN RESET ALL)
+ *   0                   1                   2                   3
+ *   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
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |     Parameter Type = 15       |      Parameter Length = 8     |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |         Re-configuration Request Sequence Number              |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct sctp_chunk *sctp_make_strreset_tsnreq(
+				const struct sctp_association *asoc)
+{
+	struct sctp_strreset_tsnreq tsnreq;
+	__u16 length = sizeof(tsnreq);
+	struct sctp_chunk *retval;
+
+	retval = sctp_make_reconf(asoc, length);
+	if (!retval)
+		return NULL;
+
+	tsnreq.param_hdr.type = SCTP_PARAM_RESET_TSN_REQUEST;
+	tsnreq.param_hdr.length = htons(length);
+	tsnreq.request_seq = htonl(asoc->strreset_outseq);
+
+	sctp_addto_chunk(retval, sizeof(tsnreq), &tsnreq);
+
+	return retval;
+}
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chunk
@ 2017-02-08 17:18       ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to define SSN/TSN Reset Request Parameter described
in rfc6525 section 4.3.

It's also to drop some unnecessary __packed in include/linux/sctp.h.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/linux/sctp.h     |  5 +++++
 include/net/sctp/sm.h    |  2 ++
 net/sctp/sm_make_chunk.c | 29 +++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index d74fca3..71c0d41 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -737,4 +737,9 @@ struct sctp_strreset_inreq {
 	__u16 list_of_streams[0];
 };
 
+struct sctp_strreset_tsnreq {
+	sctp_paramhdr_t param_hdr;
+	__u32 request_seq;
+};
+
 #endif /* __LINUX_SCTP_H__ */
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index 430ed13..ac37c17 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -265,6 +265,8 @@ struct sctp_chunk *sctp_make_strreset_req(
 				const struct sctp_association *asoc,
 				__u16 stream_num, __u16 *stream_list,
 				bool out, bool in);
+struct sctp_chunk *sctp_make_strreset_tsnreq(
+				const struct sctp_association *asoc);
 void sctp_chunk_assign_tsn(struct sctp_chunk *);
 void sctp_chunk_assign_ssn(struct sctp_chunk *);
 
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index c7d3249..749842a 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -3658,3 +3658,32 @@ struct sctp_chunk *sctp_make_strreset_req(
 
 	return retval;
 }
+
+/* RE-CONFIG 4.3 (SSN/TSN RESET ALL)
+ *   0                   1                   2                   3
+ *   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
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |     Parameter Type = 15       |      Parameter Length = 8     |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |         Re-configuration Request Sequence Number              |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct sctp_chunk *sctp_make_strreset_tsnreq(
+				const struct sctp_association *asoc)
+{
+	struct sctp_strreset_tsnreq tsnreq;
+	__u16 length = sizeof(tsnreq);
+	struct sctp_chunk *retval;
+
+	retval = sctp_make_reconf(asoc, length);
+	if (!retval)
+		return NULL;
+
+	tsnreq.param_hdr.type = SCTP_PARAM_RESET_TSN_REQUEST;
+	tsnreq.param_hdr.length = htons(length);
+	tsnreq.request_seq = htonl(asoc->strreset_outseq);
+
+	sctp_addto_chunk(retval, sizeof(tsnreq), &tsnreq);
+
+	return retval;
+}
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter
  2017-02-08 17:18       ` Xin Long
@ 2017-02-08 17:18         ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to implement Sender-Side Procedures for the SSN/TSN
Reset Request Parameter descibed in rfc6525 section 5.1.4.

It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
for users.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sctp.h   |  1 +
 include/uapi/linux/sctp.h |  1 +
 net/sctp/socket.c         | 29 +++++++++++++++++++++++++++++
 net/sctp/stream.c         | 40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 480b65a..b60ca14 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -198,6 +198,7 @@ int sctp_offload_init(void);
  */
 int sctp_send_reset_streams(struct sctp_association *asoc,
 			    struct sctp_reset_streams *params);
+int sctp_send_reset_assoc(struct sctp_association *asoc);
 
 /*
  * Module global variables
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index 03c27ce..c0bd8c3 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -117,6 +117,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_PR_ASSOC_STATUS	115
 #define SCTP_ENABLE_STREAM_RESET	118
 #define SCTP_RESET_STREAMS	119
+#define SCTP_RESET_ASSOC	120
 
 /* PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE	0x0000
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a8b4252f..45a7c41 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3818,6 +3818,32 @@ static int sctp_setsockopt_reset_streams(struct sock *sk,
 	return retval;
 }
 
+static int sctp_setsockopt_reset_assoc(struct sock *sk,
+				       char __user *optval,
+				       unsigned int optlen)
+{
+	struct sctp_association *asoc;
+	sctp_assoc_t associd;
+	int retval = -EINVAL;
+
+	if (optlen != sizeof(associd))
+		goto out;
+
+	if (copy_from_user(&associd, optval, optlen)) {
+		retval = -EFAULT;
+		goto out;
+	}
+
+	asoc = sctp_id2assoc(sk, associd);
+	if (!asoc)
+		goto out;
+
+	retval = sctp_send_reset_assoc(asoc);
+
+out:
+	return retval;
+}
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -3990,6 +4016,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
 	case SCTP_RESET_STREAMS:
 		retval = sctp_setsockopt_reset_streams(sk, optval, optlen);
 		break;
+	case SCTP_RESET_ASSOC:
+		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 6a686e3..53e49fc 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -177,3 +177,43 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 out:
 	return retval;
 }
+
+int sctp_send_reset_assoc(struct sctp_association *asoc)
+{
+	struct sctp_chunk *chunk = NULL;
+	int retval;
+	__u16 i;
+
+	if (!asoc->peer.reconf_capable ||
+	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
+		return -ENOPROTOOPT;
+
+	if (asoc->strreset_outstanding)
+		return -EINPROGRESS;
+
+	chunk = sctp_make_strreset_tsnreq(asoc);
+	if (!chunk)
+		return -ENOMEM;
+
+	/* Block further xmit of data until this request is completed */
+	for (i = 0; i < asoc->stream->outcnt; i++)
+		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
+
+	asoc->strreset_chunk = chunk;
+	sctp_chunk_hold(asoc->strreset_chunk);
+
+	retval = sctp_send_reconf(asoc, chunk);
+	if (retval) {
+		sctp_chunk_put(asoc->strreset_chunk);
+		asoc->strreset_chunk = NULL;
+
+		for (i = 0; i < asoc->stream->outcnt; i++)
+			asoc->stream->out[i].state = SCTP_STREAM_OPEN;
+
+		return retval;
+	}
+
+	asoc->strreset_outstanding = 1;
+
+	return 0;
+}
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter
@ 2017-02-08 17:18         ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to implement Sender-Side Procedures for the SSN/TSN
Reset Request Parameter descibed in rfc6525 section 5.1.4.

It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
for users.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sctp.h   |  1 +
 include/uapi/linux/sctp.h |  1 +
 net/sctp/socket.c         | 29 +++++++++++++++++++++++++++++
 net/sctp/stream.c         | 40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 480b65a..b60ca14 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -198,6 +198,7 @@ int sctp_offload_init(void);
  */
 int sctp_send_reset_streams(struct sctp_association *asoc,
 			    struct sctp_reset_streams *params);
+int sctp_send_reset_assoc(struct sctp_association *asoc);
 
 /*
  * Module global variables
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index 03c27ce..c0bd8c3 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -117,6 +117,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_PR_ASSOC_STATUS	115
 #define SCTP_ENABLE_STREAM_RESET	118
 #define SCTP_RESET_STREAMS	119
+#define SCTP_RESET_ASSOC	120
 
 /* PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE	0x0000
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index a8b4252f..45a7c41 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3818,6 +3818,32 @@ static int sctp_setsockopt_reset_streams(struct sock *sk,
 	return retval;
 }
 
+static int sctp_setsockopt_reset_assoc(struct sock *sk,
+				       char __user *optval,
+				       unsigned int optlen)
+{
+	struct sctp_association *asoc;
+	sctp_assoc_t associd;
+	int retval = -EINVAL;
+
+	if (optlen != sizeof(associd))
+		goto out;
+
+	if (copy_from_user(&associd, optval, optlen)) {
+		retval = -EFAULT;
+		goto out;
+	}
+
+	asoc = sctp_id2assoc(sk, associd);
+	if (!asoc)
+		goto out;
+
+	retval = sctp_send_reset_assoc(asoc);
+
+out:
+	return retval;
+}
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -3990,6 +4016,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
 	case SCTP_RESET_STREAMS:
 		retval = sctp_setsockopt_reset_streams(sk, optval, optlen);
 		break;
+	case SCTP_RESET_ASSOC:
+		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 6a686e3..53e49fc 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -177,3 +177,43 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
 out:
 	return retval;
 }
+
+int sctp_send_reset_assoc(struct sctp_association *asoc)
+{
+	struct sctp_chunk *chunk = NULL;
+	int retval;
+	__u16 i;
+
+	if (!asoc->peer.reconf_capable ||
+	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
+		return -ENOPROTOOPT;
+
+	if (asoc->strreset_outstanding)
+		return -EINPROGRESS;
+
+	chunk = sctp_make_strreset_tsnreq(asoc);
+	if (!chunk)
+		return -ENOMEM;
+
+	/* Block further xmit of data until this request is completed */
+	for (i = 0; i < asoc->stream->outcnt; i++)
+		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
+
+	asoc->strreset_chunk = chunk;
+	sctp_chunk_hold(asoc->strreset_chunk);
+
+	retval = sctp_send_reconf(asoc, chunk);
+	if (retval) {
+		sctp_chunk_put(asoc->strreset_chunk);
+		asoc->strreset_chunk = NULL;
+
+		for (i = 0; i < asoc->stream->outcnt; i++)
+			asoc->stream->out[i].state = SCTP_STREAM_OPEN;
+
+		return retval;
+	}
+
+	asoc->strreset_outstanding = 1;
+
+	return 0;
+}
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams request chunk
  2017-02-08 17:18         ` Xin Long
@ 2017-02-08 17:18           ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to define Add Incoming/Outgoing Streams Request
Parameter described in rfc6525 section 4.5 and 4.6. They can
be in one same chunk trunk as rfc6525 section 3.1-7 describes,
so make them in one function.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/linux/sctp.h     |  7 +++++++
 include/net/sctp/sm.h    |  3 +++
 net/sctp/sm_make_chunk.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index 71c0d41..b055788 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -742,4 +742,11 @@ struct sctp_strreset_tsnreq {
 	__u32 request_seq;
 };
 
+struct sctp_strreset_addstrm {
+	sctp_paramhdr_t param_hdr;
+	__u32 request_seq;
+	__u16 number_of_streams;
+	__u16 reserved;
+};
+
 #endif /* __LINUX_SCTP_H__ */
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index ac37c17..3675fde 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -267,6 +267,9 @@ struct sctp_chunk *sctp_make_strreset_req(
 				bool out, bool in);
 struct sctp_chunk *sctp_make_strreset_tsnreq(
 				const struct sctp_association *asoc);
+struct sctp_chunk *sctp_make_strreset_addstrm(
+				const struct sctp_association *asoc,
+				__u16 out, __u16 in);
 void sctp_chunk_assign_tsn(struct sctp_chunk *);
 void sctp_chunk_assign_ssn(struct sctp_chunk *);
 
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 749842a..7f8dbf2 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -3687,3 +3687,49 @@ struct sctp_chunk *sctp_make_strreset_tsnreq(
 
 	return retval;
 }
+
+/* RE-CONFIG 4.5/4.6 (ADD STREAM)
+ *   0                   1                   2                   3
+ *   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
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |     Parameter Type = 17       |      Parameter Length = 12    |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |          Re-configuration Request Sequence Number             |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |      Number of new streams    |         Reserved              |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct sctp_chunk *sctp_make_strreset_addstrm(
+				const struct sctp_association *asoc,
+				__u16 out, __u16 in)
+{
+	struct sctp_strreset_addstrm addstrm;
+	__u16 size = sizeof(addstrm);
+	struct sctp_chunk *retval;
+
+	retval = sctp_make_reconf(asoc, (!!out + !!in) * size);
+	if (!retval)
+		return NULL;
+
+	if (out) {
+		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_OUT_STREAMS;
+		addstrm.param_hdr.length = htons(size);
+		addstrm.number_of_streams = htons(out);
+		addstrm.request_seq = htonl(asoc->strreset_outseq);
+		addstrm.reserved = 0;
+
+		sctp_addto_chunk(retval, size, &addstrm);
+	}
+
+	if (in) {
+		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_IN_STREAMS;
+		addstrm.param_hdr.length = htons(size);
+		addstrm.number_of_streams = htons(in);
+		addstrm.request_seq = htonl(asoc->strreset_outseq + !!out);
+		addstrm.reserved = 0;
+
+		sctp_addto_chunk(retval, size, &addstrm);
+	}
+
+	return retval;
+}
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams
@ 2017-02-08 17:18           ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to define Add Incoming/Outgoing Streams Request
Parameter described in rfc6525 section 4.5 and 4.6. They can
be in one same chunk trunk as rfc6525 section 3.1-7 describes,
so make them in one function.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/linux/sctp.h     |  7 +++++++
 include/net/sctp/sm.h    |  3 +++
 net/sctp/sm_make_chunk.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/include/linux/sctp.h b/include/linux/sctp.h
index 71c0d41..b055788 100644
--- a/include/linux/sctp.h
+++ b/include/linux/sctp.h
@@ -742,4 +742,11 @@ struct sctp_strreset_tsnreq {
 	__u32 request_seq;
 };
 
+struct sctp_strreset_addstrm {
+	sctp_paramhdr_t param_hdr;
+	__u32 request_seq;
+	__u16 number_of_streams;
+	__u16 reserved;
+};
+
 #endif /* __LINUX_SCTP_H__ */
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index ac37c17..3675fde 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -267,6 +267,9 @@ struct sctp_chunk *sctp_make_strreset_req(
 				bool out, bool in);
 struct sctp_chunk *sctp_make_strreset_tsnreq(
 				const struct sctp_association *asoc);
+struct sctp_chunk *sctp_make_strreset_addstrm(
+				const struct sctp_association *asoc,
+				__u16 out, __u16 in);
 void sctp_chunk_assign_tsn(struct sctp_chunk *);
 void sctp_chunk_assign_ssn(struct sctp_chunk *);
 
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 749842a..7f8dbf2 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -3687,3 +3687,49 @@ struct sctp_chunk *sctp_make_strreset_tsnreq(
 
 	return retval;
 }
+
+/* RE-CONFIG 4.5/4.6 (ADD STREAM)
+ *   0                   1                   2                   3
+ *   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
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |     Parameter Type = 17       |      Parameter Length = 12    |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |          Re-configuration Request Sequence Number             |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *  |      Number of new streams    |         Reserved              |
+ *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+struct sctp_chunk *sctp_make_strreset_addstrm(
+				const struct sctp_association *asoc,
+				__u16 out, __u16 in)
+{
+	struct sctp_strreset_addstrm addstrm;
+	__u16 size = sizeof(addstrm);
+	struct sctp_chunk *retval;
+
+	retval = sctp_make_reconf(asoc, (!!out + !!in) * size);
+	if (!retval)
+		return NULL;
+
+	if (out) {
+		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_OUT_STREAMS;
+		addstrm.param_hdr.length = htons(size);
+		addstrm.number_of_streams = htons(out);
+		addstrm.request_seq = htonl(asoc->strreset_outseq);
+		addstrm.reserved = 0;
+
+		sctp_addto_chunk(retval, size, &addstrm);
+	}
+
+	if (in) {
+		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_IN_STREAMS;
+		addstrm.param_hdr.length = htons(size);
+		addstrm.number_of_streams = htons(in);
+		addstrm.request_seq = htonl(asoc->strreset_outseq + !!out);
+		addstrm.reserved = 0;
+
+		sctp_addto_chunk(retval, size, &addstrm);
+	}
+
+	return retval;
+}
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Request Parameter
  2017-02-08 17:18           ` [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams Xin Long
@ 2017-02-08 17:18             ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to implement Sender-Side Procedures for the Add
Outgoing and Incoming Streams Request Parameter described in
rfc6525 section 5.1.5-5.1.6.

It is also to add sockopt SCTP_ADD_STREAMS in rfc6525 section
6.3.4 for users.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sctp.h   |  2 ++
 include/uapi/linux/sctp.h |  7 +++++
 net/sctp/socket.c         | 29 ++++++++++++++++++
 net/sctp/stream.c         | 77 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index b60ca14..6dfc553 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -199,6 +199,8 @@ int sctp_offload_init(void);
 int sctp_send_reset_streams(struct sctp_association *asoc,
 			    struct sctp_reset_streams *params);
 int sctp_send_reset_assoc(struct sctp_association *asoc);
+int sctp_send_add_streams(struct sctp_association *asoc,
+			  struct sctp_add_streams *params);
 
 /*
  * Module global variables
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index c0bd8c3..a91a9cc 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -118,6 +118,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_ENABLE_STREAM_RESET	118
 #define SCTP_RESET_STREAMS	119
 #define SCTP_RESET_ASSOC	120
+#define SCTP_ADD_STREAMS	121
 
 /* PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE	0x0000
@@ -1027,4 +1028,10 @@ struct sctp_reset_streams {
 	uint16_t srs_stream_list[];	/* list if srs_num_streams is not 0 */
 };
 
+struct sctp_add_streams {
+	sctp_assoc_t sas_assoc_id;
+	uint16_t sas_instrms;
+	uint16_t sas_outstrms;
+};
+
 #endif /* _UAPI_SCTP_H */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 45a7c41..75f35ce 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3844,6 +3844,32 @@ static int sctp_setsockopt_reset_assoc(struct sock *sk,
 	return retval;
 }
 
+static int sctp_setsockopt_add_streams(struct sock *sk,
+				       char __user *optval,
+				       unsigned int optlen)
+{
+	struct sctp_association *asoc;
+	struct sctp_add_streams params;
+	int retval = -EINVAL;
+
+	if (optlen != sizeof(params))
+		goto out;
+
+	if (copy_from_user(&params, optval, optlen)) {
+		retval = -EFAULT;
+		goto out;
+	}
+
+	asoc = sctp_id2assoc(sk, params.sas_assoc_id);
+	if (!asoc)
+		goto out;
+
+	retval = sctp_send_add_streams(asoc, &params);
+
+out:
+	return retval;
+}
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -4019,6 +4045,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
 	case SCTP_RESET_ASSOC:
 		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
 		break;
+	case SCTP_ADD_STREAMS:
+		retval = sctp_setsockopt_add_streams(sk, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 53e49fc..eb02490 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -217,3 +217,80 @@ int sctp_send_reset_assoc(struct sctp_association *asoc)
 
 	return 0;
 }
+
+int sctp_send_add_streams(struct sctp_association *asoc,
+			  struct sctp_add_streams *params)
+{
+	struct sctp_stream *stream = asoc->stream;
+	struct sctp_chunk *chunk = NULL;
+	int retval = -ENOMEM;
+	__u32 outcnt, incnt;
+	__u16 out, in;
+
+	if (!asoc->peer.reconf_capable ||
+	    !(asoc->strreset_enable & SCTP_ENABLE_CHANGE_ASSOC_REQ)) {
+		retval = -ENOPROTOOPT;
+		goto out;
+	}
+
+	if (asoc->strreset_outstanding) {
+		retval = -EINPROGRESS;
+		goto out;
+	}
+
+	out = params->sas_outstrms;
+	in  = params->sas_instrms;
+	outcnt = stream->outcnt + out;
+	incnt = stream->incnt + in;
+	if (outcnt > SCTP_MAX_STREAM || incnt > SCTP_MAX_STREAM ||
+	    (!out && !in)) {
+		retval = -EINVAL;
+		goto out;
+	}
+
+	if (out) {
+		struct sctp_stream_out *streamout;
+
+		streamout = krealloc(stream->out, outcnt * sizeof(*streamout),
+				     GFP_KERNEL);
+		if (!streamout)
+			goto out;
+
+		memset(streamout + stream->outcnt, 0, out * sizeof(*streamout));
+		stream->out = streamout;
+	}
+
+	if (in) {
+		struct sctp_stream_in *streamin;
+
+		streamin = krealloc(stream->in, incnt * sizeof(*streamin),
+				    GFP_KERNEL);
+		if (!streamin)
+			goto out;
+
+		memset(streamin + stream->incnt, 0, in * sizeof(*streamin));
+		stream->in = streamin;
+	}
+
+	chunk = sctp_make_strreset_addstrm(asoc, out, in);
+	if (!chunk)
+		goto out;
+
+	asoc->strreset_chunk = chunk;
+	sctp_chunk_hold(asoc->strreset_chunk);
+
+	retval = sctp_send_reconf(asoc, chunk);
+	if (retval) {
+		sctp_chunk_put(asoc->strreset_chunk);
+		asoc->strreset_chunk = NULL;
+		goto out;
+	}
+
+	stream->incnt = incnt;
+	stream->outcnt = outcnt;
+
+	asoc->strreset_outstanding = !!out + !!in;
+
+out:
+	return retval;
+}
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Requ
@ 2017-02-08 17:18             ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-08 17:18 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, Vlad Yasevich, davem

This patch is to implement Sender-Side Procedures for the Add
Outgoing and Incoming Streams Request Parameter described in
rfc6525 section 5.1.5-5.1.6.

It is also to add sockopt SCTP_ADD_STREAMS in rfc6525 section
6.3.4 for users.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 include/net/sctp/sctp.h   |  2 ++
 include/uapi/linux/sctp.h |  7 +++++
 net/sctp/socket.c         | 29 ++++++++++++++++++
 net/sctp/stream.c         | 77 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+)

diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index b60ca14..6dfc553 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -199,6 +199,8 @@ int sctp_offload_init(void);
 int sctp_send_reset_streams(struct sctp_association *asoc,
 			    struct sctp_reset_streams *params);
 int sctp_send_reset_assoc(struct sctp_association *asoc);
+int sctp_send_add_streams(struct sctp_association *asoc,
+			  struct sctp_add_streams *params);
 
 /*
  * Module global variables
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index c0bd8c3..a91a9cc 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -118,6 +118,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_ENABLE_STREAM_RESET	118
 #define SCTP_RESET_STREAMS	119
 #define SCTP_RESET_ASSOC	120
+#define SCTP_ADD_STREAMS	121
 
 /* PR-SCTP policies */
 #define SCTP_PR_SCTP_NONE	0x0000
@@ -1027,4 +1028,10 @@ struct sctp_reset_streams {
 	uint16_t srs_stream_list[];	/* list if srs_num_streams is not 0 */
 };
 
+struct sctp_add_streams {
+	sctp_assoc_t sas_assoc_id;
+	uint16_t sas_instrms;
+	uint16_t sas_outstrms;
+};
+
 #endif /* _UAPI_SCTP_H */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 45a7c41..75f35ce 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3844,6 +3844,32 @@ static int sctp_setsockopt_reset_assoc(struct sock *sk,
 	return retval;
 }
 
+static int sctp_setsockopt_add_streams(struct sock *sk,
+				       char __user *optval,
+				       unsigned int optlen)
+{
+	struct sctp_association *asoc;
+	struct sctp_add_streams params;
+	int retval = -EINVAL;
+
+	if (optlen != sizeof(params))
+		goto out;
+
+	if (copy_from_user(&params, optval, optlen)) {
+		retval = -EFAULT;
+		goto out;
+	}
+
+	asoc = sctp_id2assoc(sk, params.sas_assoc_id);
+	if (!asoc)
+		goto out;
+
+	retval = sctp_send_add_streams(asoc, &params);
+
+out:
+	return retval;
+}
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -4019,6 +4045,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
 	case SCTP_RESET_ASSOC:
 		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
 		break;
+	case SCTP_ADD_STREAMS:
+		retval = sctp_setsockopt_add_streams(sk, optval, optlen);
+		break;
 	default:
 		retval = -ENOPROTOOPT;
 		break;
diff --git a/net/sctp/stream.c b/net/sctp/stream.c
index 53e49fc..eb02490 100644
--- a/net/sctp/stream.c
+++ b/net/sctp/stream.c
@@ -217,3 +217,80 @@ int sctp_send_reset_assoc(struct sctp_association *asoc)
 
 	return 0;
 }
+
+int sctp_send_add_streams(struct sctp_association *asoc,
+			  struct sctp_add_streams *params)
+{
+	struct sctp_stream *stream = asoc->stream;
+	struct sctp_chunk *chunk = NULL;
+	int retval = -ENOMEM;
+	__u32 outcnt, incnt;
+	__u16 out, in;
+
+	if (!asoc->peer.reconf_capable ||
+	    !(asoc->strreset_enable & SCTP_ENABLE_CHANGE_ASSOC_REQ)) {
+		retval = -ENOPROTOOPT;
+		goto out;
+	}
+
+	if (asoc->strreset_outstanding) {
+		retval = -EINPROGRESS;
+		goto out;
+	}
+
+	out = params->sas_outstrms;
+	in  = params->sas_instrms;
+	outcnt = stream->outcnt + out;
+	incnt = stream->incnt + in;
+	if (outcnt > SCTP_MAX_STREAM || incnt > SCTP_MAX_STREAM ||
+	    (!out && !in)) {
+		retval = -EINVAL;
+		goto out;
+	}
+
+	if (out) {
+		struct sctp_stream_out *streamout;
+
+		streamout = krealloc(stream->out, outcnt * sizeof(*streamout),
+				     GFP_KERNEL);
+		if (!streamout)
+			goto out;
+
+		memset(streamout + stream->outcnt, 0, out * sizeof(*streamout));
+		stream->out = streamout;
+	}
+
+	if (in) {
+		struct sctp_stream_in *streamin;
+
+		streamin = krealloc(stream->in, incnt * sizeof(*streamin),
+				    GFP_KERNEL);
+		if (!streamin)
+			goto out;
+
+		memset(streamin + stream->incnt, 0, in * sizeof(*streamin));
+		stream->in = streamin;
+	}
+
+	chunk = sctp_make_strreset_addstrm(asoc, out, in);
+	if (!chunk)
+		goto out;
+
+	asoc->strreset_chunk = chunk;
+	sctp_chunk_hold(asoc->strreset_chunk);
+
+	retval = sctp_send_reconf(asoc, chunk);
+	if (retval) {
+		sctp_chunk_put(asoc->strreset_chunk);
+		asoc->strreset_chunk = NULL;
+		goto out;
+	}
+
+	stream->incnt = incnt;
+	stream->outcnt = outcnt;
+
+	asoc->strreset_outstanding = !!out + !!in;
+
+out:
+	return retval;
+}
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter
  2017-02-08 17:18         ` Xin Long
@ 2017-02-08 21:48           ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:48 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

Hi Xin,

On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
> This patch is to implement Sender-Side Procedures for the SSN/TSN
> Reset Request Parameter descibed in rfc6525 section 5.1.4.
> 
> It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
> for users.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
...
> +
> +int sctp_send_reset_assoc(struct sctp_association *asoc)
> +{
> +	struct sctp_chunk *chunk = NULL;
> +	int retval;
> +	__u16 i;
> +
> +	if (!asoc->peer.reconf_capable ||
> +	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
> +		return -ENOPROTOOPT;
> +
> +	if (asoc->strreset_outstanding)
> +		return -EINPROGRESS;
> +
> +	chunk = sctp_make_strreset_tsnreq(asoc);
          ^--- refcnf = 1 (as per sctp_chunkify())

> +	if (!chunk)
> +		return -ENOMEM;
> +
> +	/* Block further xmit of data until this request is completed */
> +	for (i = 0; i < asoc->stream->outcnt; i++)
> +		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
> +
> +	asoc->strreset_chunk = chunk;
> +	sctp_chunk_hold(asoc->strreset_chunk);
                                 ^--- refcnf = 2
> +
> +	retval = sctp_send_reconf(asoc, chunk);
> +	if (retval) {
> +		sctp_chunk_put(asoc->strreset_chunk);
                                          ^--- refcnf = 1

Won't we leak the chunk here?


> +		asoc->strreset_chunk = NULL;
> +
> +		for (i = 0; i < asoc->stream->outcnt; i++)
> +			asoc->stream->out[i].state = SCTP_STREAM_OPEN;
> +
> +		return retval;
> +	}
> +
> +	asoc->strreset_outstanding = 1;
> +
> +	return 0;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete
@ 2017-02-08 21:48           ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:48 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

Hi Xin,

On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
> This patch is to implement Sender-Side Procedures for the SSN/TSN
> Reset Request Parameter descibed in rfc6525 section 5.1.4.
> 
> It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
> for users.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
...
> +
> +int sctp_send_reset_assoc(struct sctp_association *asoc)
> +{
> +	struct sctp_chunk *chunk = NULL;
> +	int retval;
> +	__u16 i;
> +
> +	if (!asoc->peer.reconf_capable ||
> +	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
> +		return -ENOPROTOOPT;
> +
> +	if (asoc->strreset_outstanding)
> +		return -EINPROGRESS;
> +
> +	chunk = sctp_make_strreset_tsnreq(asoc);
          ^--- refcnf = 1 (as per sctp_chunkify())

> +	if (!chunk)
> +		return -ENOMEM;
> +
> +	/* Block further xmit of data until this request is completed */
> +	for (i = 0; i < asoc->stream->outcnt; i++)
> +		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
> +
> +	asoc->strreset_chunk = chunk;
> +	sctp_chunk_hold(asoc->strreset_chunk);
                                 ^--- refcnf = 2
> +
> +	retval = sctp_send_reconf(asoc, chunk);
> +	if (retval) {
> +		sctp_chunk_put(asoc->strreset_chunk);
                                          ^--- refcnf = 1

Won't we leak the chunk here?


> +		asoc->strreset_chunk = NULL;
> +
> +		for (i = 0; i < asoc->stream->outcnt; i++)
> +			asoc->stream->out[i].state = SCTP_STREAM_OPEN;
> +
> +		return retval;
> +	}
> +
> +	asoc->strreset_outstanding = 1;
> +
> +	return 0;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter
  2017-02-08 21:48           ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete Marcelo Ricardo Leitner
@ 2017-02-08 21:50             ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:50 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Wed, Feb 08, 2017 at 07:48:01PM -0200, Marcelo Ricardo Leitner wrote:
> Hi Xin,
> 
> On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
> > This patch is to implement Sender-Side Procedures for the SSN/TSN
> > Reset Request Parameter descibed in rfc6525 section 5.1.4.
> > 
> > It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
> > for users.
> > 
> > Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ...
> > +
> > +int sctp_send_reset_assoc(struct sctp_association *asoc)
> > +{
> > +	struct sctp_chunk *chunk = NULL;
> > +	int retval;
> > +	__u16 i;
> > +
> > +	if (!asoc->peer.reconf_capable ||
> > +	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
> > +		return -ENOPROTOOPT;
> > +
> > +	if (asoc->strreset_outstanding)
> > +		return -EINPROGRESS;
> > +
> > +	chunk = sctp_make_strreset_tsnreq(asoc);
>           ^--- refcnf = 1 (as per sctp_chunkify())
> 
> > +	if (!chunk)
> > +		return -ENOMEM;
> > +
> > +	/* Block further xmit of data until this request is completed */
> > +	for (i = 0; i < asoc->stream->outcnt; i++)
> > +		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
> > +
> > +	asoc->strreset_chunk = chunk;
> > +	sctp_chunk_hold(asoc->strreset_chunk);
>                                  ^--- refcnf = 2
> > +
> > +	retval = sctp_send_reconf(asoc, chunk);
> > +	if (retval) {
> > +		sctp_chunk_put(asoc->strreset_chunk);
>                                           ^--- refcnf = 1
> 
> Won't we leak the chunk here?

No we won't, sctp_send_reconf() frees it for us, aye.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete
@ 2017-02-08 21:50             ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:50 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Wed, Feb 08, 2017 at 07:48:01PM -0200, Marcelo Ricardo Leitner wrote:
> Hi Xin,
> 
> On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
> > This patch is to implement Sender-Side Procedures for the SSN/TSN
> > Reset Request Parameter descibed in rfc6525 section 5.1.4.
> > 
> > It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
> > for users.
> > 
> > Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ...
> > +
> > +int sctp_send_reset_assoc(struct sctp_association *asoc)
> > +{
> > +	struct sctp_chunk *chunk = NULL;
> > +	int retval;
> > +	__u16 i;
> > +
> > +	if (!asoc->peer.reconf_capable ||
> > +	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
> > +		return -ENOPROTOOPT;
> > +
> > +	if (asoc->strreset_outstanding)
> > +		return -EINPROGRESS;
> > +
> > +	chunk = sctp_make_strreset_tsnreq(asoc);
>           ^--- refcnf = 1 (as per sctp_chunkify())
> 
> > +	if (!chunk)
> > +		return -ENOMEM;
> > +
> > +	/* Block further xmit of data until this request is completed */
> > +	for (i = 0; i < asoc->stream->outcnt; i++)
> > +		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
> > +
> > +	asoc->strreset_chunk = chunk;
> > +	sctp_chunk_hold(asoc->strreset_chunk);
>                                  ^--- refcnf = 2
> > +
> > +	retval = sctp_send_reconf(asoc, chunk);
> > +	if (retval) {
> > +		sctp_chunk_put(asoc->strreset_chunk);
>                                           ^--- refcnf = 1
> 
> Won't we leak the chunk here?

No we won't, sctp_send_reconf() frees it for us, aye.



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 1/6] sctp: drop unnecessary __packed from some stream reconf structures
  2017-02-08 17:18   ` Xin Long
@ 2017-02-08 21:56     ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:56 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:15AM +0800, Xin Long wrote:
> commit 85c727b59483 ("sctp: drop __packed from almost all SCTP structures")
> has removed __packed from almost all SCTP structures. But there still are
> three structures where it should be dropped.
> 
> This patch is to remove it from some stream reconf structures.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/linux/sctp.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
> index 2408c68..d74fca3 100644
> --- a/include/linux/sctp.h
> +++ b/include/linux/sctp.h
> @@ -721,7 +721,7 @@ struct sctp_infox {
>  struct sctp_reconf_chunk {
>  	sctp_chunkhdr_t chunk_hdr;
>  	__u8 params[0];
> -} __packed;
> +};
>  
>  struct sctp_strreset_outreq {
>  	sctp_paramhdr_t param_hdr;
> @@ -729,12 +729,12 @@ struct sctp_strreset_outreq {
>  	__u32 response_seq;
>  	__u32 send_reset_at_tsn;
>  	__u16 list_of_streams[0];
> -} __packed;
> +};
>  
>  struct sctp_strreset_inreq {
>  	sctp_paramhdr_t param_hdr;
>  	__u32 request_seq;
>  	__u16 list_of_streams[0];
> -} __packed;
> +};
>  
>  #endif /* __LINUX_SCTP_H__ */
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 1/6] sctp: drop unnecessary __packed from some stream reconf structures
@ 2017-02-08 21:56     ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:56 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:15AM +0800, Xin Long wrote:
> commit 85c727b59483 ("sctp: drop __packed from almost all SCTP structures")
> has removed __packed from almost all SCTP structures. But there still are
> three structures where it should be dropped.
> 
> This patch is to remove it from some stream reconf structures.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/linux/sctp.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
> index 2408c68..d74fca3 100644
> --- a/include/linux/sctp.h
> +++ b/include/linux/sctp.h
> @@ -721,7 +721,7 @@ struct sctp_infox {
>  struct sctp_reconf_chunk {
>  	sctp_chunkhdr_t chunk_hdr;
>  	__u8 params[0];
> -} __packed;
> +};
>  
>  struct sctp_strreset_outreq {
>  	sctp_paramhdr_t param_hdr;
> @@ -729,12 +729,12 @@ struct sctp_strreset_outreq {
>  	__u32 response_seq;
>  	__u32 send_reset_at_tsn;
>  	__u16 list_of_streams[0];
> -} __packed;
> +};
>  
>  struct sctp_strreset_inreq {
>  	sctp_paramhdr_t param_hdr;
>  	__u32 request_seq;
>  	__u16 list_of_streams[0];
> -} __packed;
> +};
>  
>  #endif /* __LINUX_SCTP_H__ */
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 2/6] sctp: streams should be recovered when it fails to send request.
  2017-02-08 17:18     ` Xin Long
@ 2017-02-08 21:56       ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:56 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:16AM +0800, Xin Long wrote:
> Now when sending stream reset request, it closes the streams to
> block further xmit of data until this request is completed, then
> calls sctp_send_reconf to send the chunk.
> 
> But if sctp_send_reconf returns err, and it doesn't recover the
> streams' states back,  which means the request chunk would not be
> queued and sent, so the asoc will get stuck, streams are closed
> and no packet is even queued.
> 
> This patch is to fix it by recovering the streams' states when
> it fails to send the request, it is also to fix a return value.
> 
> Fixes: 7f9d68ac944e ("sctp: implement sender-side procedures for SSN Reset Request Parameter")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  net/sctp/stream.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 13d5e07..6a686e3 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -136,8 +136,10 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  				goto out;
>  
>  	chunk = sctp_make_strreset_req(asoc, str_nums, str_list, out, in);
> -	if (!chunk)
> +	if (!chunk) {
> +		retval = -ENOMEM;
>  		goto out;
> +	}
>  
>  	if (out) {
>  		if (str_nums)
> @@ -149,7 +151,6 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  				stream->out[i].state = SCTP_STREAM_CLOSED;
>  	}
>  
> -	asoc->strreset_outstanding = out + in;
>  	asoc->strreset_chunk = chunk;
>  	sctp_chunk_hold(asoc->strreset_chunk);
>  
> @@ -157,8 +158,22 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  	if (retval) {
>  		sctp_chunk_put(asoc->strreset_chunk);
>  		asoc->strreset_chunk = NULL;
> +		if (!out)
> +			goto out;
> +
> +		if (str_nums)
> +			for (i = 0; i < str_nums; i++)
> +				stream->out[str_list[i]].state =
> +						       SCTP_STREAM_OPEN;
> +		else
> +			for (i = 0; i < stream->outcnt; i++)
> +				stream->out[i].state = SCTP_STREAM_OPEN;
> +
> +		goto out;
>  	}
>  
> +	asoc->strreset_outstanding = out + in;
> +
>  out:
>  	return retval;
>  }
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 2/6] sctp: streams should be recovered when it fails to send request.
@ 2017-02-08 21:56       ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:56 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:16AM +0800, Xin Long wrote:
> Now when sending stream reset request, it closes the streams to
> block further xmit of data until this request is completed, then
> calls sctp_send_reconf to send the chunk.
> 
> But if sctp_send_reconf returns err, and it doesn't recover the
> streams' states back,  which means the request chunk would not be
> queued and sent, so the asoc will get stuck, streams are closed
> and no packet is even queued.
> 
> This patch is to fix it by recovering the streams' states when
> it fails to send the request, it is also to fix a return value.
> 
> Fixes: 7f9d68ac944e ("sctp: implement sender-side procedures for SSN Reset Request Parameter")
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  net/sctp/stream.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 13d5e07..6a686e3 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -136,8 +136,10 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  				goto out;
>  
>  	chunk = sctp_make_strreset_req(asoc, str_nums, str_list, out, in);
> -	if (!chunk)
> +	if (!chunk) {
> +		retval = -ENOMEM;
>  		goto out;
> +	}
>  
>  	if (out) {
>  		if (str_nums)
> @@ -149,7 +151,6 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  				stream->out[i].state = SCTP_STREAM_CLOSED;
>  	}
>  
> -	asoc->strreset_outstanding = out + in;
>  	asoc->strreset_chunk = chunk;
>  	sctp_chunk_hold(asoc->strreset_chunk);
>  
> @@ -157,8 +158,22 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  	if (retval) {
>  		sctp_chunk_put(asoc->strreset_chunk);
>  		asoc->strreset_chunk = NULL;
> +		if (!out)
> +			goto out;
> +
> +		if (str_nums)
> +			for (i = 0; i < str_nums; i++)
> +				stream->out[str_list[i]].state > +						       SCTP_STREAM_OPEN;
> +		else
> +			for (i = 0; i < stream->outcnt; i++)
> +				stream->out[i].state = SCTP_STREAM_OPEN;
> +
> +		goto out;
>  	}
>  
> +	asoc->strreset_outstanding = out + in;
> +
>  out:
>  	return retval;
>  }
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chunk
  2017-02-08 17:18       ` Xin Long
@ 2017-02-08 21:57         ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:57 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:17AM +0800, Xin Long wrote:
> This patch is to define SSN/TSN Reset Request Parameter described
> in rfc6525 section 4.3.
> 
> It's also to drop some unnecessary __packed in include/linux/sctp.h.

Oups, extra line in the changelog here.

> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  include/linux/sctp.h     |  5 +++++
>  include/net/sctp/sm.h    |  2 ++
>  net/sctp/sm_make_chunk.c | 29 +++++++++++++++++++++++++++++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
> index d74fca3..71c0d41 100644
> --- a/include/linux/sctp.h
> +++ b/include/linux/sctp.h
> @@ -737,4 +737,9 @@ struct sctp_strreset_inreq {
>  	__u16 list_of_streams[0];
>  };
>  
> +struct sctp_strreset_tsnreq {
> +	sctp_paramhdr_t param_hdr;
> +	__u32 request_seq;
> +};
> +
>  #endif /* __LINUX_SCTP_H__ */
> diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
> index 430ed13..ac37c17 100644
> --- a/include/net/sctp/sm.h
> +++ b/include/net/sctp/sm.h
> @@ -265,6 +265,8 @@ struct sctp_chunk *sctp_make_strreset_req(
>  				const struct sctp_association *asoc,
>  				__u16 stream_num, __u16 *stream_list,
>  				bool out, bool in);
> +struct sctp_chunk *sctp_make_strreset_tsnreq(
> +				const struct sctp_association *asoc);
>  void sctp_chunk_assign_tsn(struct sctp_chunk *);
>  void sctp_chunk_assign_ssn(struct sctp_chunk *);
>  
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index c7d3249..749842a 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -3658,3 +3658,32 @@ struct sctp_chunk *sctp_make_strreset_req(
>  
>  	return retval;
>  }
> +
> +/* RE-CONFIG 4.3 (SSN/TSN RESET ALL)
> + *   0                   1                   2                   3
> + *   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
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |     Parameter Type = 15       |      Parameter Length = 8     |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |         Re-configuration Request Sequence Number              |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + */
> +struct sctp_chunk *sctp_make_strreset_tsnreq(
> +				const struct sctp_association *asoc)
> +{
> +	struct sctp_strreset_tsnreq tsnreq;
> +	__u16 length = sizeof(tsnreq);
> +	struct sctp_chunk *retval;
> +
> +	retval = sctp_make_reconf(asoc, length);
> +	if (!retval)
> +		return NULL;
> +
> +	tsnreq.param_hdr.type = SCTP_PARAM_RESET_TSN_REQUEST;
> +	tsnreq.param_hdr.length = htons(length);
> +	tsnreq.request_seq = htonl(asoc->strreset_outseq);
> +
> +	sctp_addto_chunk(retval, sizeof(tsnreq), &tsnreq);
> +
> +	return retval;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chun
@ 2017-02-08 21:57         ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-08 21:57 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:17AM +0800, Xin Long wrote:
> This patch is to define SSN/TSN Reset Request Parameter described
> in rfc6525 section 4.3.
> 
> It's also to drop some unnecessary __packed in include/linux/sctp.h.

Oups, extra line in the changelog here.

> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  include/linux/sctp.h     |  5 +++++
>  include/net/sctp/sm.h    |  2 ++
>  net/sctp/sm_make_chunk.c | 29 +++++++++++++++++++++++++++++
>  3 files changed, 36 insertions(+)
> 
> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
> index d74fca3..71c0d41 100644
> --- a/include/linux/sctp.h
> +++ b/include/linux/sctp.h
> @@ -737,4 +737,9 @@ struct sctp_strreset_inreq {
>  	__u16 list_of_streams[0];
>  };
>  
> +struct sctp_strreset_tsnreq {
> +	sctp_paramhdr_t param_hdr;
> +	__u32 request_seq;
> +};
> +
>  #endif /* __LINUX_SCTP_H__ */
> diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
> index 430ed13..ac37c17 100644
> --- a/include/net/sctp/sm.h
> +++ b/include/net/sctp/sm.h
> @@ -265,6 +265,8 @@ struct sctp_chunk *sctp_make_strreset_req(
>  				const struct sctp_association *asoc,
>  				__u16 stream_num, __u16 *stream_list,
>  				bool out, bool in);
> +struct sctp_chunk *sctp_make_strreset_tsnreq(
> +				const struct sctp_association *asoc);
>  void sctp_chunk_assign_tsn(struct sctp_chunk *);
>  void sctp_chunk_assign_ssn(struct sctp_chunk *);
>  
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index c7d3249..749842a 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -3658,3 +3658,32 @@ struct sctp_chunk *sctp_make_strreset_req(
>  
>  	return retval;
>  }
> +
> +/* RE-CONFIG 4.3 (SSN/TSN RESET ALL)
> + *   0                   1                   2                   3
> + *   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
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |     Parameter Type = 15       |      Parameter Length = 8     |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |         Re-configuration Request Sequence Number              |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + */
> +struct sctp_chunk *sctp_make_strreset_tsnreq(
> +				const struct sctp_association *asoc)
> +{
> +	struct sctp_strreset_tsnreq tsnreq;
> +	__u16 length = sizeof(tsnreq);
> +	struct sctp_chunk *retval;
> +
> +	retval = sctp_make_reconf(asoc, length);
> +	if (!retval)
> +		return NULL;
> +
> +	tsnreq.param_hdr.type = SCTP_PARAM_RESET_TSN_REQUEST;
> +	tsnreq.param_hdr.length = htons(length);
> +	tsnreq.request_seq = htonl(asoc->strreset_outseq);
> +
> +	sctp_addto_chunk(retval, sizeof(tsnreq), &tsnreq);
> +
> +	return retval;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chunk
  2017-02-08 21:57         ` [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chun Marcelo Ricardo Leitner
@ 2017-02-09  7:56           ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-09  7:56 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 9, 2017 at 5:57 AM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Thu, Feb 09, 2017 at 01:18:17AM +0800, Xin Long wrote:
>> This patch is to define SSN/TSN Reset Request Parameter described
>> in rfc6525 section 4.3.
>>
>> It's also to drop some unnecessary __packed in include/linux/sctp.h.
>
> Oups, extra line in the changelog here.
I've moved the "drop __packed" to patch 1/6, this line should have
been removed.
Hi, David, can you remove this line when applying ?

Thanks.

>
>>
>> Signed-off-by: Xin Long <lucien.xin@gmail.com>
>> ---
>>  include/linux/sctp.h     |  5 +++++
>>  include/net/sctp/sm.h    |  2 ++
>>  net/sctp/sm_make_chunk.c | 29 +++++++++++++++++++++++++++++
>>  3 files changed, 36 insertions(+)
>>
>> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
>> index d74fca3..71c0d41 100644
>> --- a/include/linux/sctp.h
>> +++ b/include/linux/sctp.h
>> @@ -737,4 +737,9 @@ struct sctp_strreset_inreq {
>>       __u16 list_of_streams[0];
>>  };
>>
>> +struct sctp_strreset_tsnreq {
>> +     sctp_paramhdr_t param_hdr;
>> +     __u32 request_seq;
>> +};
>> +
>>  #endif /* __LINUX_SCTP_H__ */
>> diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
>> index 430ed13..ac37c17 100644
>> --- a/include/net/sctp/sm.h
>> +++ b/include/net/sctp/sm.h
>> @@ -265,6 +265,8 @@ struct sctp_chunk *sctp_make_strreset_req(
>>                               const struct sctp_association *asoc,
>>                               __u16 stream_num, __u16 *stream_list,
>>                               bool out, bool in);
>> +struct sctp_chunk *sctp_make_strreset_tsnreq(
>> +                             const struct sctp_association *asoc);
>>  void sctp_chunk_assign_tsn(struct sctp_chunk *);
>>  void sctp_chunk_assign_ssn(struct sctp_chunk *);
>>
>> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
>> index c7d3249..749842a 100644
>> --- a/net/sctp/sm_make_chunk.c
>> +++ b/net/sctp/sm_make_chunk.c
>> @@ -3658,3 +3658,32 @@ struct sctp_chunk *sctp_make_strreset_req(
>>
>>       return retval;
>>  }
>> +
>> +/* RE-CONFIG 4.3 (SSN/TSN RESET ALL)
>> + *   0                   1                   2                   3
>> + *   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
>> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> + *  |     Parameter Type = 15       |      Parameter Length = 8     |
>> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> + *  |         Re-configuration Request Sequence Number              |
>> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> + */
>> +struct sctp_chunk *sctp_make_strreset_tsnreq(
>> +                             const struct sctp_association *asoc)
>> +{
>> +     struct sctp_strreset_tsnreq tsnreq;
>> +     __u16 length = sizeof(tsnreq);
>> +     struct sctp_chunk *retval;
>> +
>> +     retval = sctp_make_reconf(asoc, length);
>> +     if (!retval)
>> +             return NULL;
>> +
>> +     tsnreq.param_hdr.type = SCTP_PARAM_RESET_TSN_REQUEST;
>> +     tsnreq.param_hdr.length = htons(length);
>> +     tsnreq.request_seq = htonl(asoc->strreset_outseq);
>> +
>> +     sctp_addto_chunk(retval, sizeof(tsnreq), &tsnreq);
>> +
>> +     return retval;
>> +}
>> --
>> 2.1.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chun
@ 2017-02-09  7:56           ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-09  7:56 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 9, 2017 at 5:57 AM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Thu, Feb 09, 2017 at 01:18:17AM +0800, Xin Long wrote:
>> This patch is to define SSN/TSN Reset Request Parameter described
>> in rfc6525 section 4.3.
>>
>> It's also to drop some unnecessary __packed in include/linux/sctp.h.
>
> Oups, extra line in the changelog here.
I've moved the "drop __packed" to patch 1/6, this line should have
been removed.
Hi, David, can you remove this line when applying ?

Thanks.

>
>>
>> Signed-off-by: Xin Long <lucien.xin@gmail.com>
>> ---
>>  include/linux/sctp.h     |  5 +++++
>>  include/net/sctp/sm.h    |  2 ++
>>  net/sctp/sm_make_chunk.c | 29 +++++++++++++++++++++++++++++
>>  3 files changed, 36 insertions(+)
>>
>> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
>> index d74fca3..71c0d41 100644
>> --- a/include/linux/sctp.h
>> +++ b/include/linux/sctp.h
>> @@ -737,4 +737,9 @@ struct sctp_strreset_inreq {
>>       __u16 list_of_streams[0];
>>  };
>>
>> +struct sctp_strreset_tsnreq {
>> +     sctp_paramhdr_t param_hdr;
>> +     __u32 request_seq;
>> +};
>> +
>>  #endif /* __LINUX_SCTP_H__ */
>> diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
>> index 430ed13..ac37c17 100644
>> --- a/include/net/sctp/sm.h
>> +++ b/include/net/sctp/sm.h
>> @@ -265,6 +265,8 @@ struct sctp_chunk *sctp_make_strreset_req(
>>                               const struct sctp_association *asoc,
>>                               __u16 stream_num, __u16 *stream_list,
>>                               bool out, bool in);
>> +struct sctp_chunk *sctp_make_strreset_tsnreq(
>> +                             const struct sctp_association *asoc);
>>  void sctp_chunk_assign_tsn(struct sctp_chunk *);
>>  void sctp_chunk_assign_ssn(struct sctp_chunk *);
>>
>> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
>> index c7d3249..749842a 100644
>> --- a/net/sctp/sm_make_chunk.c
>> +++ b/net/sctp/sm_make_chunk.c
>> @@ -3658,3 +3658,32 @@ struct sctp_chunk *sctp_make_strreset_req(
>>
>>       return retval;
>>  }
>> +
>> +/* RE-CONFIG 4.3 (SSN/TSN RESET ALL)
>> + *   0                   1                   2                   3
>> + *   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
>> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> + *  |     Parameter Type = 15       |      Parameter Length = 8     |
>> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> + *  |         Re-configuration Request Sequence Number              |
>> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> + */
>> +struct sctp_chunk *sctp_make_strreset_tsnreq(
>> +                             const struct sctp_association *asoc)
>> +{
>> +     struct sctp_strreset_tsnreq tsnreq;
>> +     __u16 length = sizeof(tsnreq);
>> +     struct sctp_chunk *retval;
>> +
>> +     retval = sctp_make_reconf(asoc, length);
>> +     if (!retval)
>> +             return NULL;
>> +
>> +     tsnreq.param_hdr.type = SCTP_PARAM_RESET_TSN_REQUEST;
>> +     tsnreq.param_hdr.length = htons(length);
>> +     tsnreq.request_seq = htonl(asoc->strreset_outseq);
>> +
>> +     sctp_addto_chunk(retval, sizeof(tsnreq), &tsnreq);
>> +
>> +     return retval;
>> +}
>> --
>> 2.1.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter
  2017-02-08 21:50             ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete Marcelo Ricardo Leitner
@ 2017-02-09  7:58               ` Xin Long
  -1 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-09  7:58 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 9, 2017 at 5:50 AM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Wed, Feb 08, 2017 at 07:48:01PM -0200, Marcelo Ricardo Leitner wrote:
>> Hi Xin,
>>
>> On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
>> > This patch is to implement Sender-Side Procedures for the SSN/TSN
>> > Reset Request Parameter descibed in rfc6525 section 5.1.4.
>> >
>> > It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
>> > for users.
>> >
>> > Signed-off-by: Xin Long <lucien.xin@gmail.com>
>> ...
>> > +
>> > +int sctp_send_reset_assoc(struct sctp_association *asoc)
>> > +{
>> > +   struct sctp_chunk *chunk = NULL;
>> > +   int retval;
>> > +   __u16 i;
>> > +
>> > +   if (!asoc->peer.reconf_capable ||
>> > +       !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
>> > +           return -ENOPROTOOPT;
>> > +
>> > +   if (asoc->strreset_outstanding)
>> > +           return -EINPROGRESS;
>> > +
>> > +   chunk = sctp_make_strreset_tsnreq(asoc);
>>           ^--- refcnf = 1 (as per sctp_chunkify())
>>
>> > +   if (!chunk)
>> > +           return -ENOMEM;
>> > +
>> > +   /* Block further xmit of data until this request is completed */
>> > +   for (i = 0; i < asoc->stream->outcnt; i++)
>> > +           asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
>> > +
>> > +   asoc->strreset_chunk = chunk;
>> > +   sctp_chunk_hold(asoc->strreset_chunk);
>>                                  ^--- refcnf = 2
>> > +
>> > +   retval = sctp_send_reconf(asoc, chunk);
>> > +   if (retval) {
>> > +           sctp_chunk_put(asoc->strreset_chunk);
>>                                           ^--- refcnf = 1
>>
>> Won't we leak the chunk here?
>
> No we won't, sctp_send_reconf() frees it for us, aye.
yups. :)

>
>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete
@ 2017-02-09  7:58               ` Xin Long
  0 siblings, 0 replies; 38+ messages in thread
From: Xin Long @ 2017-02-09  7:58 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 9, 2017 at 5:50 AM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Wed, Feb 08, 2017 at 07:48:01PM -0200, Marcelo Ricardo Leitner wrote:
>> Hi Xin,
>>
>> On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
>> > This patch is to implement Sender-Side Procedures for the SSN/TSN
>> > Reset Request Parameter descibed in rfc6525 section 5.1.4.
>> >
>> > It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
>> > for users.
>> >
>> > Signed-off-by: Xin Long <lucien.xin@gmail.com>
>> ...
>> > +
>> > +int sctp_send_reset_assoc(struct sctp_association *asoc)
>> > +{
>> > +   struct sctp_chunk *chunk = NULL;
>> > +   int retval;
>> > +   __u16 i;
>> > +
>> > +   if (!asoc->peer.reconf_capable ||
>> > +       !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
>> > +           return -ENOPROTOOPT;
>> > +
>> > +   if (asoc->strreset_outstanding)
>> > +           return -EINPROGRESS;
>> > +
>> > +   chunk = sctp_make_strreset_tsnreq(asoc);
>>           ^--- refcnf = 1 (as per sctp_chunkify())
>>
>> > +   if (!chunk)
>> > +           return -ENOMEM;
>> > +
>> > +   /* Block further xmit of data until this request is completed */
>> > +   for (i = 0; i < asoc->stream->outcnt; i++)
>> > +           asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
>> > +
>> > +   asoc->strreset_chunk = chunk;
>> > +   sctp_chunk_hold(asoc->strreset_chunk);
>>                                  ^--- refcnf = 2
>> > +
>> > +   retval = sctp_send_reconf(asoc, chunk);
>> > +   if (retval) {
>> > +           sctp_chunk_put(asoc->strreset_chunk);
>>                                           ^--- refcnf = 1
>>
>> Won't we leak the chunk here?
>
> No we won't, sctp_send_reconf() frees it for us, aye.
yups. :)

>
>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter
  2017-02-08 17:18         ` Xin Long
@ 2017-02-09 11:23           ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-09 11:23 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
> This patch is to implement Sender-Side Procedures for the SSN/TSN
> Reset Request Parameter descibed in rfc6525 section 5.1.4.
> 
> It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
> for users.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/net/sctp/sctp.h   |  1 +
>  include/uapi/linux/sctp.h |  1 +
>  net/sctp/socket.c         | 29 +++++++++++++++++++++++++++++
>  net/sctp/stream.c         | 40 ++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 71 insertions(+)
> 
> diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
> index 480b65a..b60ca14 100644
> --- a/include/net/sctp/sctp.h
> +++ b/include/net/sctp/sctp.h
> @@ -198,6 +198,7 @@ int sctp_offload_init(void);
>   */
>  int sctp_send_reset_streams(struct sctp_association *asoc,
>  			    struct sctp_reset_streams *params);
> +int sctp_send_reset_assoc(struct sctp_association *asoc);
>  
>  /*
>   * Module global variables
> diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
> index 03c27ce..c0bd8c3 100644
> --- a/include/uapi/linux/sctp.h
> +++ b/include/uapi/linux/sctp.h
> @@ -117,6 +117,7 @@ typedef __s32 sctp_assoc_t;
>  #define SCTP_PR_ASSOC_STATUS	115
>  #define SCTP_ENABLE_STREAM_RESET	118
>  #define SCTP_RESET_STREAMS	119
> +#define SCTP_RESET_ASSOC	120
>  
>  /* PR-SCTP policies */
>  #define SCTP_PR_SCTP_NONE	0x0000
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index a8b4252f..45a7c41 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -3818,6 +3818,32 @@ static int sctp_setsockopt_reset_streams(struct sock *sk,
>  	return retval;
>  }
>  
> +static int sctp_setsockopt_reset_assoc(struct sock *sk,
> +				       char __user *optval,
> +				       unsigned int optlen)
> +{
> +	struct sctp_association *asoc;
> +	sctp_assoc_t associd;
> +	int retval = -EINVAL;
> +
> +	if (optlen != sizeof(associd))
> +		goto out;
> +
> +	if (copy_from_user(&associd, optval, optlen)) {
> +		retval = -EFAULT;
> +		goto out;
> +	}
> +
> +	asoc = sctp_id2assoc(sk, associd);
> +	if (!asoc)
> +		goto out;
> +
> +	retval = sctp_send_reset_assoc(asoc);
> +
> +out:
> +	return retval;
> +}
> +
>  /* API 6.2 setsockopt(), getsockopt()
>   *
>   * Applications use setsockopt() and getsockopt() to set or retrieve
> @@ -3990,6 +4016,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
>  	case SCTP_RESET_STREAMS:
>  		retval = sctp_setsockopt_reset_streams(sk, optval, optlen);
>  		break;
> +	case SCTP_RESET_ASSOC:
> +		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
> +		break;
>  	default:
>  		retval = -ENOPROTOOPT;
>  		break;
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 6a686e3..53e49fc 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -177,3 +177,43 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  out:
>  	return retval;
>  }
> +
> +int sctp_send_reset_assoc(struct sctp_association *asoc)
> +{
> +	struct sctp_chunk *chunk = NULL;
> +	int retval;
> +	__u16 i;
> +
> +	if (!asoc->peer.reconf_capable ||
> +	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
> +		return -ENOPROTOOPT;
> +
> +	if (asoc->strreset_outstanding)
> +		return -EINPROGRESS;
> +
> +	chunk = sctp_make_strreset_tsnreq(asoc);
> +	if (!chunk)
> +		return -ENOMEM;
> +
> +	/* Block further xmit of data until this request is completed */
> +	for (i = 0; i < asoc->stream->outcnt; i++)
> +		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
> +
> +	asoc->strreset_chunk = chunk;
> +	sctp_chunk_hold(asoc->strreset_chunk);
> +
> +	retval = sctp_send_reconf(asoc, chunk);
> +	if (retval) {
> +		sctp_chunk_put(asoc->strreset_chunk);
> +		asoc->strreset_chunk = NULL;
> +
> +		for (i = 0; i < asoc->stream->outcnt; i++)
> +			asoc->stream->out[i].state = SCTP_STREAM_OPEN;
> +
> +		return retval;
> +	}
> +
> +	asoc->strreset_outstanding = 1;
> +
> +	return 0;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete
@ 2017-02-09 11:23           ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-09 11:23 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:18AM +0800, Xin Long wrote:
> This patch is to implement Sender-Side Procedures for the SSN/TSN
> Reset Request Parameter descibed in rfc6525 section 5.1.4.
> 
> It is also to add sockopt SCTP_RESET_ASSOC in rfc6525 section 6.3.3
> for users.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/net/sctp/sctp.h   |  1 +
>  include/uapi/linux/sctp.h |  1 +
>  net/sctp/socket.c         | 29 +++++++++++++++++++++++++++++
>  net/sctp/stream.c         | 40 ++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 71 insertions(+)
> 
> diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
> index 480b65a..b60ca14 100644
> --- a/include/net/sctp/sctp.h
> +++ b/include/net/sctp/sctp.h
> @@ -198,6 +198,7 @@ int sctp_offload_init(void);
>   */
>  int sctp_send_reset_streams(struct sctp_association *asoc,
>  			    struct sctp_reset_streams *params);
> +int sctp_send_reset_assoc(struct sctp_association *asoc);
>  
>  /*
>   * Module global variables
> diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
> index 03c27ce..c0bd8c3 100644
> --- a/include/uapi/linux/sctp.h
> +++ b/include/uapi/linux/sctp.h
> @@ -117,6 +117,7 @@ typedef __s32 sctp_assoc_t;
>  #define SCTP_PR_ASSOC_STATUS	115
>  #define SCTP_ENABLE_STREAM_RESET	118
>  #define SCTP_RESET_STREAMS	119
> +#define SCTP_RESET_ASSOC	120
>  
>  /* PR-SCTP policies */
>  #define SCTP_PR_SCTP_NONE	0x0000
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index a8b4252f..45a7c41 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -3818,6 +3818,32 @@ static int sctp_setsockopt_reset_streams(struct sock *sk,
>  	return retval;
>  }
>  
> +static int sctp_setsockopt_reset_assoc(struct sock *sk,
> +				       char __user *optval,
> +				       unsigned int optlen)
> +{
> +	struct sctp_association *asoc;
> +	sctp_assoc_t associd;
> +	int retval = -EINVAL;
> +
> +	if (optlen != sizeof(associd))
> +		goto out;
> +
> +	if (copy_from_user(&associd, optval, optlen)) {
> +		retval = -EFAULT;
> +		goto out;
> +	}
> +
> +	asoc = sctp_id2assoc(sk, associd);
> +	if (!asoc)
> +		goto out;
> +
> +	retval = sctp_send_reset_assoc(asoc);
> +
> +out:
> +	return retval;
> +}
> +
>  /* API 6.2 setsockopt(), getsockopt()
>   *
>   * Applications use setsockopt() and getsockopt() to set or retrieve
> @@ -3990,6 +4016,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
>  	case SCTP_RESET_STREAMS:
>  		retval = sctp_setsockopt_reset_streams(sk, optval, optlen);
>  		break;
> +	case SCTP_RESET_ASSOC:
> +		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
> +		break;
>  	default:
>  		retval = -ENOPROTOOPT;
>  		break;
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 6a686e3..53e49fc 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -177,3 +177,43 @@ int sctp_send_reset_streams(struct sctp_association *asoc,
>  out:
>  	return retval;
>  }
> +
> +int sctp_send_reset_assoc(struct sctp_association *asoc)
> +{
> +	struct sctp_chunk *chunk = NULL;
> +	int retval;
> +	__u16 i;
> +
> +	if (!asoc->peer.reconf_capable ||
> +	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ))
> +		return -ENOPROTOOPT;
> +
> +	if (asoc->strreset_outstanding)
> +		return -EINPROGRESS;
> +
> +	chunk = sctp_make_strreset_tsnreq(asoc);
> +	if (!chunk)
> +		return -ENOMEM;
> +
> +	/* Block further xmit of data until this request is completed */
> +	for (i = 0; i < asoc->stream->outcnt; i++)
> +		asoc->stream->out[i].state = SCTP_STREAM_CLOSED;
> +
> +	asoc->strreset_chunk = chunk;
> +	sctp_chunk_hold(asoc->strreset_chunk);
> +
> +	retval = sctp_send_reconf(asoc, chunk);
> +	if (retval) {
> +		sctp_chunk_put(asoc->strreset_chunk);
> +		asoc->strreset_chunk = NULL;
> +
> +		for (i = 0; i < asoc->stream->outcnt; i++)
> +			asoc->stream->out[i].state = SCTP_STREAM_OPEN;
> +
> +		return retval;
> +	}
> +
> +	asoc->strreset_outstanding = 1;
> +
> +	return 0;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams request chunk
  2017-02-08 17:18           ` [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams Xin Long
@ 2017-02-09 11:23             ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-09 11:23 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:19AM +0800, Xin Long wrote:
> This patch is to define Add Incoming/Outgoing Streams Request
> Parameter described in rfc6525 section 4.5 and 4.6. They can
> be in one same chunk trunk as rfc6525 section 3.1-7 describes,
> so make them in one function.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/linux/sctp.h     |  7 +++++++
>  include/net/sctp/sm.h    |  3 +++
>  net/sctp/sm_make_chunk.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
> 
> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
> index 71c0d41..b055788 100644
> --- a/include/linux/sctp.h
> +++ b/include/linux/sctp.h
> @@ -742,4 +742,11 @@ struct sctp_strreset_tsnreq {
>  	__u32 request_seq;
>  };
>  
> +struct sctp_strreset_addstrm {
> +	sctp_paramhdr_t param_hdr;
> +	__u32 request_seq;
> +	__u16 number_of_streams;
> +	__u16 reserved;
> +};
> +
>  #endif /* __LINUX_SCTP_H__ */
> diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
> index ac37c17..3675fde 100644
> --- a/include/net/sctp/sm.h
> +++ b/include/net/sctp/sm.h
> @@ -267,6 +267,9 @@ struct sctp_chunk *sctp_make_strreset_req(
>  				bool out, bool in);
>  struct sctp_chunk *sctp_make_strreset_tsnreq(
>  				const struct sctp_association *asoc);
> +struct sctp_chunk *sctp_make_strreset_addstrm(
> +				const struct sctp_association *asoc,
> +				__u16 out, __u16 in);
>  void sctp_chunk_assign_tsn(struct sctp_chunk *);
>  void sctp_chunk_assign_ssn(struct sctp_chunk *);
>  
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index 749842a..7f8dbf2 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -3687,3 +3687,49 @@ struct sctp_chunk *sctp_make_strreset_tsnreq(
>  
>  	return retval;
>  }
> +
> +/* RE-CONFIG 4.5/4.6 (ADD STREAM)
> + *   0                   1                   2                   3
> + *   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
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |     Parameter Type = 17       |      Parameter Length = 12    |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |          Re-configuration Request Sequence Number             |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |      Number of new streams    |         Reserved              |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + */
> +struct sctp_chunk *sctp_make_strreset_addstrm(
> +				const struct sctp_association *asoc,
> +				__u16 out, __u16 in)
> +{
> +	struct sctp_strreset_addstrm addstrm;
> +	__u16 size = sizeof(addstrm);
> +	struct sctp_chunk *retval;
> +
> +	retval = sctp_make_reconf(asoc, (!!out + !!in) * size);
> +	if (!retval)
> +		return NULL;
> +
> +	if (out) {
> +		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_OUT_STREAMS;
> +		addstrm.param_hdr.length = htons(size);
> +		addstrm.number_of_streams = htons(out);
> +		addstrm.request_seq = htonl(asoc->strreset_outseq);
> +		addstrm.reserved = 0;
> +
> +		sctp_addto_chunk(retval, size, &addstrm);
> +	}
> +
> +	if (in) {
> +		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_IN_STREAMS;
> +		addstrm.param_hdr.length = htons(size);
> +		addstrm.number_of_streams = htons(in);
> +		addstrm.request_seq = htonl(asoc->strreset_outseq + !!out);
> +		addstrm.reserved = 0;
> +
> +		sctp_addto_chunk(retval, size, &addstrm);
> +	}
> +
> +	return retval;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing stre
@ 2017-02-09 11:23             ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-09 11:23 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:19AM +0800, Xin Long wrote:
> This patch is to define Add Incoming/Outgoing Streams Request
> Parameter described in rfc6525 section 4.5 and 4.6. They can
> be in one same chunk trunk as rfc6525 section 3.1-7 describes,
> so make them in one function.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/linux/sctp.h     |  7 +++++++
>  include/net/sctp/sm.h    |  3 +++
>  net/sctp/sm_make_chunk.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
> 
> diff --git a/include/linux/sctp.h b/include/linux/sctp.h
> index 71c0d41..b055788 100644
> --- a/include/linux/sctp.h
> +++ b/include/linux/sctp.h
> @@ -742,4 +742,11 @@ struct sctp_strreset_tsnreq {
>  	__u32 request_seq;
>  };
>  
> +struct sctp_strreset_addstrm {
> +	sctp_paramhdr_t param_hdr;
> +	__u32 request_seq;
> +	__u16 number_of_streams;
> +	__u16 reserved;
> +};
> +
>  #endif /* __LINUX_SCTP_H__ */
> diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
> index ac37c17..3675fde 100644
> --- a/include/net/sctp/sm.h
> +++ b/include/net/sctp/sm.h
> @@ -267,6 +267,9 @@ struct sctp_chunk *sctp_make_strreset_req(
>  				bool out, bool in);
>  struct sctp_chunk *sctp_make_strreset_tsnreq(
>  				const struct sctp_association *asoc);
> +struct sctp_chunk *sctp_make_strreset_addstrm(
> +				const struct sctp_association *asoc,
> +				__u16 out, __u16 in);
>  void sctp_chunk_assign_tsn(struct sctp_chunk *);
>  void sctp_chunk_assign_ssn(struct sctp_chunk *);
>  
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index 749842a..7f8dbf2 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -3687,3 +3687,49 @@ struct sctp_chunk *sctp_make_strreset_tsnreq(
>  
>  	return retval;
>  }
> +
> +/* RE-CONFIG 4.5/4.6 (ADD STREAM)
> + *   0                   1                   2                   3
> + *   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
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |     Parameter Type = 17       |      Parameter Length = 12    |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |          Re-configuration Request Sequence Number             |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + *  |      Number of new streams    |         Reserved              |
> + *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> + */
> +struct sctp_chunk *sctp_make_strreset_addstrm(
> +				const struct sctp_association *asoc,
> +				__u16 out, __u16 in)
> +{
> +	struct sctp_strreset_addstrm addstrm;
> +	__u16 size = sizeof(addstrm);
> +	struct sctp_chunk *retval;
> +
> +	retval = sctp_make_reconf(asoc, (!!out + !!in) * size);
> +	if (!retval)
> +		return NULL;
> +
> +	if (out) {
> +		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_OUT_STREAMS;
> +		addstrm.param_hdr.length = htons(size);
> +		addstrm.number_of_streams = htons(out);
> +		addstrm.request_seq = htonl(asoc->strreset_outseq);
> +		addstrm.reserved = 0;
> +
> +		sctp_addto_chunk(retval, size, &addstrm);
> +	}
> +
> +	if (in) {
> +		addstrm.param_hdr.type = SCTP_PARAM_RESET_ADD_IN_STREAMS;
> +		addstrm.param_hdr.length = htons(size);
> +		addstrm.number_of_streams = htons(in);
> +		addstrm.request_seq = htonl(asoc->strreset_outseq + !!out);
> +		addstrm.reserved = 0;
> +
> +		sctp_addto_chunk(retval, size, &addstrm);
> +	}
> +
> +	return retval;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Request Parameter
  2017-02-08 17:18             ` [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Requ Xin Long
@ 2017-02-09 11:24               ` Marcelo Ricardo Leitner
  -1 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-09 11:24 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:20AM +0800, Xin Long wrote:
> This patch is to implement Sender-Side Procedures for the Add
> Outgoing and Incoming Streams Request Parameter described in
> rfc6525 section 5.1.5-5.1.6.
> 
> It is also to add sockopt SCTP_ADD_STREAMS in rfc6525 section
> 6.3.4 for users.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/net/sctp/sctp.h   |  2 ++
>  include/uapi/linux/sctp.h |  7 +++++
>  net/sctp/socket.c         | 29 ++++++++++++++++++
>  net/sctp/stream.c         | 77 +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 115 insertions(+)
> 
> diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
> index b60ca14..6dfc553 100644
> --- a/include/net/sctp/sctp.h
> +++ b/include/net/sctp/sctp.h
> @@ -199,6 +199,8 @@ int sctp_offload_init(void);
>  int sctp_send_reset_streams(struct sctp_association *asoc,
>  			    struct sctp_reset_streams *params);
>  int sctp_send_reset_assoc(struct sctp_association *asoc);
> +int sctp_send_add_streams(struct sctp_association *asoc,
> +			  struct sctp_add_streams *params);
>  
>  /*
>   * Module global variables
> diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
> index c0bd8c3..a91a9cc 100644
> --- a/include/uapi/linux/sctp.h
> +++ b/include/uapi/linux/sctp.h
> @@ -118,6 +118,7 @@ typedef __s32 sctp_assoc_t;
>  #define SCTP_ENABLE_STREAM_RESET	118
>  #define SCTP_RESET_STREAMS	119
>  #define SCTP_RESET_ASSOC	120
> +#define SCTP_ADD_STREAMS	121
>  
>  /* PR-SCTP policies */
>  #define SCTP_PR_SCTP_NONE	0x0000
> @@ -1027,4 +1028,10 @@ struct sctp_reset_streams {
>  	uint16_t srs_stream_list[];	/* list if srs_num_streams is not 0 */
>  };
>  
> +struct sctp_add_streams {
> +	sctp_assoc_t sas_assoc_id;
> +	uint16_t sas_instrms;
> +	uint16_t sas_outstrms;
> +};
> +
>  #endif /* _UAPI_SCTP_H */
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 45a7c41..75f35ce 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -3844,6 +3844,32 @@ static int sctp_setsockopt_reset_assoc(struct sock *sk,
>  	return retval;
>  }
>  
> +static int sctp_setsockopt_add_streams(struct sock *sk,
> +				       char __user *optval,
> +				       unsigned int optlen)
> +{
> +	struct sctp_association *asoc;
> +	struct sctp_add_streams params;
> +	int retval = -EINVAL;
> +
> +	if (optlen != sizeof(params))
> +		goto out;
> +
> +	if (copy_from_user(&params, optval, optlen)) {
> +		retval = -EFAULT;
> +		goto out;
> +	}
> +
> +	asoc = sctp_id2assoc(sk, params.sas_assoc_id);
> +	if (!asoc)
> +		goto out;
> +
> +	retval = sctp_send_add_streams(asoc, &params);
> +
> +out:
> +	return retval;
> +}
> +
>  /* API 6.2 setsockopt(), getsockopt()
>   *
>   * Applications use setsockopt() and getsockopt() to set or retrieve
> @@ -4019,6 +4045,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
>  	case SCTP_RESET_ASSOC:
>  		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
>  		break;
> +	case SCTP_ADD_STREAMS:
> +		retval = sctp_setsockopt_add_streams(sk, optval, optlen);
> +		break;
>  	default:
>  		retval = -ENOPROTOOPT;
>  		break;
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 53e49fc..eb02490 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -217,3 +217,80 @@ int sctp_send_reset_assoc(struct sctp_association *asoc)
>  
>  	return 0;
>  }
> +
> +int sctp_send_add_streams(struct sctp_association *asoc,
> +			  struct sctp_add_streams *params)
> +{
> +	struct sctp_stream *stream = asoc->stream;
> +	struct sctp_chunk *chunk = NULL;
> +	int retval = -ENOMEM;
> +	__u32 outcnt, incnt;
> +	__u16 out, in;
> +
> +	if (!asoc->peer.reconf_capable ||
> +	    !(asoc->strreset_enable & SCTP_ENABLE_CHANGE_ASSOC_REQ)) {
> +		retval = -ENOPROTOOPT;
> +		goto out;
> +	}
> +
> +	if (asoc->strreset_outstanding) {
> +		retval = -EINPROGRESS;
> +		goto out;
> +	}
> +
> +	out = params->sas_outstrms;
> +	in  = params->sas_instrms;
> +	outcnt = stream->outcnt + out;
> +	incnt = stream->incnt + in;
> +	if (outcnt > SCTP_MAX_STREAM || incnt > SCTP_MAX_STREAM ||
> +	    (!out && !in)) {
> +		retval = -EINVAL;
> +		goto out;
> +	}
> +
> +	if (out) {
> +		struct sctp_stream_out *streamout;
> +
> +		streamout = krealloc(stream->out, outcnt * sizeof(*streamout),
> +				     GFP_KERNEL);
> +		if (!streamout)
> +			goto out;
> +
> +		memset(streamout + stream->outcnt, 0, out * sizeof(*streamout));
> +		stream->out = streamout;
> +	}
> +
> +	if (in) {
> +		struct sctp_stream_in *streamin;
> +
> +		streamin = krealloc(stream->in, incnt * sizeof(*streamin),
> +				    GFP_KERNEL);
> +		if (!streamin)
> +			goto out;
> +
> +		memset(streamin + stream->incnt, 0, in * sizeof(*streamin));
> +		stream->in = streamin;
> +	}
> +
> +	chunk = sctp_make_strreset_addstrm(asoc, out, in);
> +	if (!chunk)
> +		goto out;
> +
> +	asoc->strreset_chunk = chunk;
> +	sctp_chunk_hold(asoc->strreset_chunk);
> +
> +	retval = sctp_send_reconf(asoc, chunk);
> +	if (retval) {
> +		sctp_chunk_put(asoc->strreset_chunk);
> +		asoc->strreset_chunk = NULL;
> +		goto out;
> +	}
> +
> +	stream->incnt = incnt;
> +	stream->outcnt = outcnt;
> +
> +	asoc->strreset_outstanding = !!out + !!in;
> +
> +out:
> +	return retval;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams
@ 2017-02-09 11:24               ` Marcelo Ricardo Leitner
  0 siblings, 0 replies; 38+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-02-09 11:24 UTC (permalink / raw)
  To: Xin Long; +Cc: network dev, linux-sctp, Neil Horman, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:20AM +0800, Xin Long wrote:
> This patch is to implement Sender-Side Procedures for the Add
> Outgoing and Incoming Streams Request Parameter described in
> rfc6525 section 5.1.5-5.1.6.
> 
> It is also to add sockopt SCTP_ADD_STREAMS in rfc6525 section
> 6.3.4 for users.
> 
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>

> ---
>  include/net/sctp/sctp.h   |  2 ++
>  include/uapi/linux/sctp.h |  7 +++++
>  net/sctp/socket.c         | 29 ++++++++++++++++++
>  net/sctp/stream.c         | 77 +++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 115 insertions(+)
> 
> diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
> index b60ca14..6dfc553 100644
> --- a/include/net/sctp/sctp.h
> +++ b/include/net/sctp/sctp.h
> @@ -199,6 +199,8 @@ int sctp_offload_init(void);
>  int sctp_send_reset_streams(struct sctp_association *asoc,
>  			    struct sctp_reset_streams *params);
>  int sctp_send_reset_assoc(struct sctp_association *asoc);
> +int sctp_send_add_streams(struct sctp_association *asoc,
> +			  struct sctp_add_streams *params);
>  
>  /*
>   * Module global variables
> diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
> index c0bd8c3..a91a9cc 100644
> --- a/include/uapi/linux/sctp.h
> +++ b/include/uapi/linux/sctp.h
> @@ -118,6 +118,7 @@ typedef __s32 sctp_assoc_t;
>  #define SCTP_ENABLE_STREAM_RESET	118
>  #define SCTP_RESET_STREAMS	119
>  #define SCTP_RESET_ASSOC	120
> +#define SCTP_ADD_STREAMS	121
>  
>  /* PR-SCTP policies */
>  #define SCTP_PR_SCTP_NONE	0x0000
> @@ -1027,4 +1028,10 @@ struct sctp_reset_streams {
>  	uint16_t srs_stream_list[];	/* list if srs_num_streams is not 0 */
>  };
>  
> +struct sctp_add_streams {
> +	sctp_assoc_t sas_assoc_id;
> +	uint16_t sas_instrms;
> +	uint16_t sas_outstrms;
> +};
> +
>  #endif /* _UAPI_SCTP_H */
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 45a7c41..75f35ce 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -3844,6 +3844,32 @@ static int sctp_setsockopt_reset_assoc(struct sock *sk,
>  	return retval;
>  }
>  
> +static int sctp_setsockopt_add_streams(struct sock *sk,
> +				       char __user *optval,
> +				       unsigned int optlen)
> +{
> +	struct sctp_association *asoc;
> +	struct sctp_add_streams params;
> +	int retval = -EINVAL;
> +
> +	if (optlen != sizeof(params))
> +		goto out;
> +
> +	if (copy_from_user(&params, optval, optlen)) {
> +		retval = -EFAULT;
> +		goto out;
> +	}
> +
> +	asoc = sctp_id2assoc(sk, params.sas_assoc_id);
> +	if (!asoc)
> +		goto out;
> +
> +	retval = sctp_send_add_streams(asoc, &params);
> +
> +out:
> +	return retval;
> +}
> +
>  /* API 6.2 setsockopt(), getsockopt()
>   *
>   * Applications use setsockopt() and getsockopt() to set or retrieve
> @@ -4019,6 +4045,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
>  	case SCTP_RESET_ASSOC:
>  		retval = sctp_setsockopt_reset_assoc(sk, optval, optlen);
>  		break;
> +	case SCTP_ADD_STREAMS:
> +		retval = sctp_setsockopt_add_streams(sk, optval, optlen);
> +		break;
>  	default:
>  		retval = -ENOPROTOOPT;
>  		break;
> diff --git a/net/sctp/stream.c b/net/sctp/stream.c
> index 53e49fc..eb02490 100644
> --- a/net/sctp/stream.c
> +++ b/net/sctp/stream.c
> @@ -217,3 +217,80 @@ int sctp_send_reset_assoc(struct sctp_association *asoc)
>  
>  	return 0;
>  }
> +
> +int sctp_send_add_streams(struct sctp_association *asoc,
> +			  struct sctp_add_streams *params)
> +{
> +	struct sctp_stream *stream = asoc->stream;
> +	struct sctp_chunk *chunk = NULL;
> +	int retval = -ENOMEM;
> +	__u32 outcnt, incnt;
> +	__u16 out, in;
> +
> +	if (!asoc->peer.reconf_capable ||
> +	    !(asoc->strreset_enable & SCTP_ENABLE_CHANGE_ASSOC_REQ)) {
> +		retval = -ENOPROTOOPT;
> +		goto out;
> +	}
> +
> +	if (asoc->strreset_outstanding) {
> +		retval = -EINPROGRESS;
> +		goto out;
> +	}
> +
> +	out = params->sas_outstrms;
> +	in  = params->sas_instrms;
> +	outcnt = stream->outcnt + out;
> +	incnt = stream->incnt + in;
> +	if (outcnt > SCTP_MAX_STREAM || incnt > SCTP_MAX_STREAM ||
> +	    (!out && !in)) {
> +		retval = -EINVAL;
> +		goto out;
> +	}
> +
> +	if (out) {
> +		struct sctp_stream_out *streamout;
> +
> +		streamout = krealloc(stream->out, outcnt * sizeof(*streamout),
> +				     GFP_KERNEL);
> +		if (!streamout)
> +			goto out;
> +
> +		memset(streamout + stream->outcnt, 0, out * sizeof(*streamout));
> +		stream->out = streamout;
> +	}
> +
> +	if (in) {
> +		struct sctp_stream_in *streamin;
> +
> +		streamin = krealloc(stream->in, incnt * sizeof(*streamin),
> +				    GFP_KERNEL);
> +		if (!streamin)
> +			goto out;
> +
> +		memset(streamin + stream->incnt, 0, in * sizeof(*streamin));
> +		stream->in = streamin;
> +	}
> +
> +	chunk = sctp_make_strreset_addstrm(asoc, out, in);
> +	if (!chunk)
> +		goto out;
> +
> +	asoc->strreset_chunk = chunk;
> +	sctp_chunk_hold(asoc->strreset_chunk);
> +
> +	retval = sctp_send_reconf(asoc, chunk);
> +	if (retval) {
> +		sctp_chunk_put(asoc->strreset_chunk);
> +		asoc->strreset_chunk = NULL;
> +		goto out;
> +	}
> +
> +	stream->incnt = incnt;
> +	stream->outcnt = outcnt;
> +
> +	asoc->strreset_outstanding = !!out + !!in;
> +
> +out:
> +	return retval;
> +}
> -- 
> 2.1.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add streams
  2017-02-08 17:18 ` Xin Long
@ 2017-02-09 12:30   ` Neil Horman
  -1 siblings, 0 replies; 38+ messages in thread
From: Neil Horman @ 2017-02-09 12:30 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Marcelo Ricardo Leitner, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:14AM +0800, Xin Long wrote:
> Patch 4/6 is to implement sender-side procedures for the SSN/TSN Reset
> Request Parameter described in rfc6525 section 5.1.4, patch 3/6 is
> ahead of it to define a function to make the request chunk for it.
> 
> Patch 6/6 is to implement sender-side procedures for the Add Incoming
> and Outgoing Streams Request Parameter Request Parameter described in
> rfc6525 section 5.1.5 and 5.1.6, patch 5/6 is ahead of it to define a
> function to make the request chunk for it.
> 
> Patch 2/6 is a fix to recover streams states when it fails to send
> request and Patch 1/6 is to drop some unncessary __packed from some
> old structures.
> 
> v1->v2:
>   - put these into a smaller group.
>   - rename some temporary variables in the codes.
>   - rename the titles of the commits and improve some changelogs.
> v2->v3:
>   - re-split the patchset and make sure it has no dead codes for review.
>   - move some codes into stream.c from socket.c.
> v3->v4:
>   - add one more patch to fix a send reset stream request issue.
>   - doing actual work only when request is sent successfully.
>   - reduce some indents in sctp_send_add_streams.
> v4->v5:
>   - close streams before sending request and recover them when sending
>     fails in patch 1/5 and patch 3/5
> v5->v6:
>   - add patch 1/6 to drop some unncessary __packed from some old structures.
>   - remove __packed from some new structures in patch 3/6 and 5/6.
>   - define unsigned int outcnt and incnt to make codes smaller in patch 6/6.
>   - use krealloc instead of kcalloc and remove ksize check in patch 6/6, as
>     ksize check is acutally used in krealloc already.
> 
> Xin Long (6):
>   sctp: drop unnecessary __packed from some stream reconf structures
>   sctp: streams should be recovered when it fails to send request.
>   sctp: add support for generating stream reconf ssn/tsn reset request
>     chunk
>   sctp: implement sender-side procedures for SSN/TSN Reset Request
>     Parameter
>   sctp: add support for generating stream reconf add incoming/outgoing
>     streams request chunk
>   sctp: implement sender-side procedures for Add Incoming/Outgoing
>     Streams Request Parameter
> 
>  include/linux/sctp.h      |  18 +++++--
>  include/net/sctp/sctp.h   |   3 ++
>  include/net/sctp/sm.h     |   5 ++
>  include/uapi/linux/sctp.h |   8 +++
>  net/sctp/sm_make_chunk.c  |  75 ++++++++++++++++++++++++++
>  net/sctp/socket.c         |  58 ++++++++++++++++++++
>  net/sctp/stream.c         | 134 +++++++++++++++++++++++++++++++++++++++++++++-
>  7 files changed, 297 insertions(+), 4 deletions(-)
> 
> -- 
> 2.1.0
> 
> 
For the series
Acked-by: Neil Horman <nhorman@tuxdriver.com>

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add str
@ 2017-02-09 12:30   ` Neil Horman
  0 siblings, 0 replies; 38+ messages in thread
From: Neil Horman @ 2017-02-09 12:30 UTC (permalink / raw)
  To: Xin Long
  Cc: network dev, linux-sctp, Marcelo Ricardo Leitner, Vlad Yasevich, davem

On Thu, Feb 09, 2017 at 01:18:14AM +0800, Xin Long wrote:
> Patch 4/6 is to implement sender-side procedures for the SSN/TSN Reset
> Request Parameter described in rfc6525 section 5.1.4, patch 3/6 is
> ahead of it to define a function to make the request chunk for it.
> 
> Patch 6/6 is to implement sender-side procedures for the Add Incoming
> and Outgoing Streams Request Parameter Request Parameter described in
> rfc6525 section 5.1.5 and 5.1.6, patch 5/6 is ahead of it to define a
> function to make the request chunk for it.
> 
> Patch 2/6 is a fix to recover streams states when it fails to send
> request and Patch 1/6 is to drop some unncessary __packed from some
> old structures.
> 
> v1->v2:
>   - put these into a smaller group.
>   - rename some temporary variables in the codes.
>   - rename the titles of the commits and improve some changelogs.
> v2->v3:
>   - re-split the patchset and make sure it has no dead codes for review.
>   - move some codes into stream.c from socket.c.
> v3->v4:
>   - add one more patch to fix a send reset stream request issue.
>   - doing actual work only when request is sent successfully.
>   - reduce some indents in sctp_send_add_streams.
> v4->v5:
>   - close streams before sending request and recover them when sending
>     fails in patch 1/5 and patch 3/5
> v5->v6:
>   - add patch 1/6 to drop some unncessary __packed from some old structures.
>   - remove __packed from some new structures in patch 3/6 and 5/6.
>   - define unsigned int outcnt and incnt to make codes smaller in patch 6/6.
>   - use krealloc instead of kcalloc and remove ksize check in patch 6/6, as
>     ksize check is acutally used in krealloc already.
> 
> Xin Long (6):
>   sctp: drop unnecessary __packed from some stream reconf structures
>   sctp: streams should be recovered when it fails to send request.
>   sctp: add support for generating stream reconf ssn/tsn reset request
>     chunk
>   sctp: implement sender-side procedures for SSN/TSN Reset Request
>     Parameter
>   sctp: add support for generating stream reconf add incoming/outgoing
>     streams request chunk
>   sctp: implement sender-side procedures for Add Incoming/Outgoing
>     Streams Request Parameter
> 
>  include/linux/sctp.h      |  18 +++++--
>  include/net/sctp/sctp.h   |   3 ++
>  include/net/sctp/sm.h     |   5 ++
>  include/uapi/linux/sctp.h |   8 +++
>  net/sctp/sm_make_chunk.c  |  75 ++++++++++++++++++++++++++
>  net/sctp/socket.c         |  58 ++++++++++++++++++++
>  net/sctp/stream.c         | 134 +++++++++++++++++++++++++++++++++++++++++++++-
>  7 files changed, 297 insertions(+), 4 deletions(-)
> 
> -- 
> 2.1.0
> 
> 
For the series
Acked-by: Neil Horman <nhorman@tuxdriver.com>


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add streams
  2017-02-08 17:18 ` Xin Long
@ 2017-02-09 21:58   ` David Miller
  -1 siblings, 0 replies; 38+ messages in thread
From: David Miller @ 2017-02-09 21:58 UTC (permalink / raw)
  To: lucien.xin; +Cc: netdev, linux-sctp, marcelo.leitner, nhorman, vyasevich

From: Xin Long <lucien.xin@gmail.com>
Date: Thu,  9 Feb 2017 01:18:14 +0800

> Patch 4/6 is to implement sender-side procedures for the SSN/TSN Reset
> Request Parameter described in rfc6525 section 5.1.4, patch 3/6 is
> ahead of it to define a function to make the request chunk for it.
> 
> Patch 6/6 is to implement sender-side procedures for the Add Incoming
> and Outgoing Streams Request Parameter Request Parameter described in
> rfc6525 section 5.1.5 and 5.1.6, patch 5/6 is ahead of it to define a
> function to make the request chunk for it.
> 
> Patch 2/6 is a fix to recover streams states when it fails to send
> request and Patch 1/6 is to drop some unncessary __packed from some
> old structures.

Series applied with stray __packed reference removed from the commit
message of patch #3.

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add str
@ 2017-02-09 21:58   ` David Miller
  0 siblings, 0 replies; 38+ messages in thread
From: David Miller @ 2017-02-09 21:58 UTC (permalink / raw)
  To: lucien.xin; +Cc: netdev, linux-sctp, marcelo.leitner, nhorman, vyasevich

From: Xin Long <lucien.xin@gmail.com>
Date: Thu,  9 Feb 2017 01:18:14 +0800

> Patch 4/6 is to implement sender-side procedures for the SSN/TSN Reset
> Request Parameter described in rfc6525 section 5.1.4, patch 3/6 is
> ahead of it to define a function to make the request chunk for it.
> 
> Patch 6/6 is to implement sender-side procedures for the Add Incoming
> and Outgoing Streams Request Parameter Request Parameter described in
> rfc6525 section 5.1.5 and 5.1.6, patch 5/6 is ahead of it to define a
> function to make the request chunk for it.
> 
> Patch 2/6 is a fix to recover streams states when it fails to send
> request and Patch 1/6 is to drop some unncessary __packed from some
> old structures.

Series applied with stray __packed reference removed from the commit
message of patch #3.

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2017-02-09 21:58 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-08 17:18 [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add streams Xin Long
2017-02-08 17:18 ` Xin Long
2017-02-08 17:18 ` [PATCHv6 net-next 1/6] sctp: drop unnecessary __packed from some stream reconf structures Xin Long
2017-02-08 17:18   ` Xin Long
2017-02-08 17:18   ` [PATCHv6 net-next 2/6] sctp: streams should be recovered when it fails to send request Xin Long
2017-02-08 17:18     ` Xin Long
2017-02-08 17:18     ` [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chunk Xin Long
2017-02-08 17:18       ` Xin Long
2017-02-08 17:18       ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter Xin Long
2017-02-08 17:18         ` Xin Long
2017-02-08 17:18         ` [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams request chunk Xin Long
2017-02-08 17:18           ` [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams Xin Long
2017-02-08 17:18           ` [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Request Parameter Xin Long
2017-02-08 17:18             ` [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Requ Xin Long
2017-02-09 11:24             ` [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Request Parameter Marcelo Ricardo Leitner
2017-02-09 11:24               ` [PATCHv6 net-next 6/6] sctp: implement sender-side procedures for Add Incoming/Outgoing Streams Marcelo Ricardo Leitner
2017-02-09 11:23           ` [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing streams request chunk Marcelo Ricardo Leitner
2017-02-09 11:23             ` [PATCHv6 net-next 5/6] sctp: add support for generating stream reconf add incoming/outgoing stre Marcelo Ricardo Leitner
2017-02-08 21:48         ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter Marcelo Ricardo Leitner
2017-02-08 21:48           ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete Marcelo Ricardo Leitner
2017-02-08 21:50           ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter Marcelo Ricardo Leitner
2017-02-08 21:50             ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete Marcelo Ricardo Leitner
2017-02-09  7:58             ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter Xin Long
2017-02-09  7:58               ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete Xin Long
2017-02-09 11:23         ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Parameter Marcelo Ricardo Leitner
2017-02-09 11:23           ` [PATCHv6 net-next 4/6] sctp: implement sender-side procedures for SSN/TSN Reset Request Paramete Marcelo Ricardo Leitner
2017-02-08 21:57       ` [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chunk Marcelo Ricardo Leitner
2017-02-08 21:57         ` [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chun Marcelo Ricardo Leitner
2017-02-09  7:56         ` [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chunk Xin Long
2017-02-09  7:56           ` [PATCHv6 net-next 3/6] sctp: add support for generating stream reconf ssn/tsn reset request chun Xin Long
2017-02-08 21:56     ` [PATCHv6 net-next 2/6] sctp: streams should be recovered when it fails to send request Marcelo Ricardo Leitner
2017-02-08 21:56       ` Marcelo Ricardo Leitner
2017-02-08 21:56   ` [PATCHv6 net-next 1/6] sctp: drop unnecessary __packed from some stream reconf structures Marcelo Ricardo Leitner
2017-02-08 21:56     ` Marcelo Ricardo Leitner
2017-02-09 12:30 ` [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add streams Neil Horman
2017-02-09 12:30   ` [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add str Neil Horman
2017-02-09 21:58 ` [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add streams David Miller
2017-02-09 21:58   ` [PATCHv6 net-next 0/6] sctp: add sender-side procedures for stream reconf asoc reset and add str David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.