linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xin Long <lucien.xin@gmail.com>
To: network dev <netdev@vger.kernel.org>, linux-sctp@vger.kernel.org
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	davem@davemloft.net
Subject: [PATCH net-next 15/27] sctp: add rfc6525 section 5.1.4 and 6.3.3
Date: Sun, 01 Jan 2017 11:20:32 +0000	[thread overview]
Message-ID: <ef7d01cf1d5826e694a08303ee0b36c00201c666.1483269426.git.lucien.xin@gmail.com> (raw)
In-Reply-To: <6a74f5a3ac408f20816a8c79edd6b9922ed3b573.1483269426.git.lucien.xin@gmail.com>

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

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

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

diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index 1f4518b..c1c77c8 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -118,6 +118,7 @@ typedef __s32 sctp_assoc_t;
 #define SCTP_RECONFIG_SUPPORTED	117
 #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 e62872c..bcefc55 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3914,6 +3914,60 @@ 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;
+	struct sctp_chunk *chunk = NULL;
+	sctp_assoc_t associd;
+	int retval = -EINVAL;
+	__u16 i;
+
+	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;
+
+	if (!asoc->peer.reconf_capable ||
+	    !(asoc->strreset_enable & SCTP_ENABLE_RESET_ASSOC_REQ)) {
+		retval = -ENOPROTOOPT;
+		goto out;
+	}
+
+	if (asoc->strreset_outstanding) {
+		retval = -EINPROGRESS;
+		goto out;
+	}
+
+	chunk = sctp_make_strreset_tsnreq(asoc);
+	if (!chunk)
+		goto out;
+
+	for (i = 0; i < asoc->streamoutcnt; i++)
+		asoc->streamout[i].state = SCTP_STREAM_CLOSED;
+
+	asoc->strreset_outstanding = 1;
+	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;
+	}
+
+out:
+	return retval;
+}
+
 /* API 6.2 setsockopt(), getsockopt()
  *
  * Applications use setsockopt() and getsockopt() to set or retrieve
@@ -4089,6 +4143,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;
-- 
2.1.0


  reply	other threads:[~2017-01-01 11:20 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01 11:20 [PATCH net-next 00/27] sctp: implement rfc6525 sctp stream reconf Xin Long
2017-01-01 11:20 ` [PATCH net-next 01/27] sctp: add stream arrays in asoc Xin Long
2017-01-01 11:20   ` [PATCH net-next 02/27] sctp: replace ssnmap with asoc stream arrays Xin Long
2017-01-01 11:20     ` [PATCH net-next 03/27] sctp: remove asoc ssnmap and ssnmap.c Xin Long
2017-01-01 11:20       ` [PATCH net-next 04/27] sctp: add rfc6525 section 3.1 Xin Long
2017-01-01 11:20         ` [PATCH net-next 05/27] sctp: add rfc6525 section 4.1-4.2 Xin Long
2017-01-01 11:20           ` [PATCH net-next 06/27] sctp: add rfc6525 section 4.3 Xin Long
2017-01-01 11:20             ` [PATCH net-next 07/27] sctp: add rfc6525 section 4.4 Xin Long
2017-01-01 11:20               ` [PATCH net-next 08/27] sctp: add rfc6525 section 4.5-4.6 Xin Long
2017-01-01 11:20                 ` [PATCH net-next 09/27] sctp: add stream reconf timer Xin Long
2017-01-01 11:20                   ` [PATCH net-next 10/27] sctp: add stream reconf primitive Xin Long
2017-01-01 11:20                     ` [PATCH net-next 11/27] sctp: add reconf_enable in asoc ep and netns Xin Long
2017-01-01 11:20                       ` [PATCH net-next 12/27] sctp: add get and set sockopt for reconf_enable Xin Long
2017-01-01 11:20                         ` [PATCH net-next 13/27] sctp: add rfc6525 section 6.3.1 Xin Long
2017-01-01 11:20                           ` [PATCH net-next 14/27] sctp: add rfc6525 section 5.1.2-5.1.3 and 6.3.2 Xin Long
2017-01-01 11:20                             ` Xin Long [this message]
2017-01-01 11:20                               ` [PATCH net-next 16/27] sctp: add rfc6525 section 5.1.5-5.1.6 and 6.3.4 Xin Long
2017-01-01 11:20                                 ` [PATCH net-next 17/27] sctp: add rfc6525 section 6.1.1 Xin Long
2017-01-01 11:20                                   ` [PATCH net-next 18/27] sctp: add rfc6525 section 6.1.2 Xin Long
2017-01-01 11:20                                     ` [PATCH net-next 19/27] sctp: add rfc6525 section 6.1.3 Xin Long
2017-01-01 11:20                                       ` [PATCH net-next 20/27] sctp: add rfc6525 section 5.2.2 Xin Long
2017-01-01 11:20                                         ` [PATCH net-next 21/27] sctp: add rfc6525 section 5.2.3 Xin Long
2017-01-01 11:20                                           ` [PATCH net-next 22/27] sctp: add rfc6525 section 5.2.4 Xin Long
2017-01-01 11:20                                             ` [PATCH net-next 23/27] sctp: add rfc6525 section 5.2.5 Xin Long
2017-01-01 11:20                                               ` [PATCH net-next 24/27] sctp: add rfc6525 section 5.2.6 Xin Long
2017-01-01 11:20                                                 ` [PATCH net-next 25/27] sctp: add rfc6525 section 5.2.7 Xin Long
2017-01-01 11:20                                                   ` [PATCH net-next 26/27] sctp: add sctp reconf chunk process Xin Long
2017-01-01 11:20                                                     ` [PATCH net-next 27/27] sctp: add reconf chunk event Xin Long
2017-01-01 12:14                                             ` [PATCH net-next 22/27] sctp: add rfc6525 section 5.2.4 kbuild test robot
2017-01-01 13:26                                               ` Xin Long
2017-01-01 16:32                                                 ` David Miller
2017-01-02 13:43                                                   ` Xin Long
2017-01-01 12:02                                         ` [PATCH net-next 20/27] sctp: add rfc6525 section 5.2.2 kbuild test robot
2017-01-01 13:23                                           ` Xin Long
2017-01-01 11:32 ` [PATCH net-next 00/27] sctp: implement rfc6525 sctp stream reconf Xin Long
2017-01-01 16:30 ` David Miller
2017-01-02 13:42   ` Xin Long

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ef7d01cf1d5826e694a08303ee0b36c00201c666.1483269426.git.lucien.xin@gmail.com \
    --to=lucien.xin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-sctp@vger.kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).