summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2019-01-28 02:08:23 -0500
committerDavid S. Miller <davem@davemloft.net>2019-01-30 03:44:06 -0500
commit80df2704a375bb4b3c9c5cce9c00052361b16d61 (patch)
tree2bb7fa56869240519a17020cde93742bdeb2b3b1
parentbde52726430755a25e1c28e26e7fa4a7967d4680 (diff)
sctp: introduce SCTP_FUTURE/CURRENT/ALL_ASSOC
This patch is to add 3 constants SCTP_FUTURE_ASSOC, SCTP_CURRENT_ASSOC and SCTP_ALL_ASSOC for reserved assoc_ids, as defined in rfc6458#section-7.2. And add the process for them when doing lookup and inserting in sctp_id2assoc and sctp_assoc_set_id. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/uapi/linux/sctp.h4
-rw-r--r--net/sctp/associola.c7
-rw-r--r--net/sctp/socket.c2
3 files changed, 10 insertions, 3 deletions
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index d584073532b8..b8f2c4d56532 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -59,6 +59,10 @@
59 59
60typedef __s32 sctp_assoc_t; 60typedef __s32 sctp_assoc_t;
61 61
62#define SCTP_FUTURE_ASSOC 0
63#define SCTP_CURRENT_ASSOC 1
64#define SCTP_ALL_ASSOC 2
65
62/* The following symbols come from the Sockets API Extensions for 66/* The following symbols come from the Sockets API Extensions for
63 * SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>. 67 * SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>.
64 */ 68 */
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 201c888604e4..b99f163e33ac 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1651,8 +1651,11 @@ int sctp_assoc_set_id(struct sctp_association *asoc, gfp_t gfp)
1651 if (preload) 1651 if (preload)
1652 idr_preload(gfp); 1652 idr_preload(gfp);
1653 spin_lock_bh(&sctp_assocs_id_lock); 1653 spin_lock_bh(&sctp_assocs_id_lock);
1654 /* 0 is not a valid assoc_id, must be >= 1 */ 1654 /* 0, 1, 2 are used as SCTP_FUTURE_ASSOC, SCTP_CURRENT_ASSOC and
1655 ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, 1, 0, GFP_NOWAIT); 1655 * SCTP_ALL_ASSOC, so an available id must be > SCTP_ALL_ASSOC.
1656 */
1657 ret = idr_alloc_cyclic(&sctp_assocs_id, asoc, SCTP_ALL_ASSOC + 1, 0,
1658 GFP_NOWAIT);
1656 spin_unlock_bh(&sctp_assocs_id_lock); 1659 spin_unlock_bh(&sctp_assocs_id_lock);
1657 if (preload) 1660 if (preload)
1658 idr_preload_end(); 1661 idr_preload_end();
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index f93c3cf9e567..a52d132470ea 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -248,7 +248,7 @@ struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id)
248 } 248 }
249 249
250 /* Otherwise this is a UDP-style socket. */ 250 /* Otherwise this is a UDP-style socket. */
251 if (!id || (id == (sctp_assoc_t)-1)) 251 if (id <= SCTP_ALL_ASSOC)
252 return NULL; 252 return NULL;
253 253
254 spin_lock_bh(&sctp_assocs_id_lock); 254 spin_lock_bh(&sctp_assocs_id_lock);