[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 1 Jan 2017 19:20:32 +0800
From: Xin Long <lucien.xin@...il.com>
To: network dev <netdev@...r.kernel.org>, linux-sctp@...r.kernel.org
Cc: Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
Neil Horman <nhorman@...driver.com>, davem@...emloft.net
Subject: [PATCH net-next 15/27] sctp: add rfc6525 section 5.1.4 and 6.3.3
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@...il.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
Powered by blists - more mailing lists