aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/sctp/user.h2
-rw-r--r--net/sctp/socket.c35
2 files changed, 37 insertions, 0 deletions
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index f205b10f0ab9..b259fc5798fb 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -118,6 +118,8 @@ enum sctp_optname {
118#define SCTP_PEER_AUTH_CHUNKS SCTP_PEER_AUTH_CHUNKS 118#define SCTP_PEER_AUTH_CHUNKS SCTP_PEER_AUTH_CHUNKS
119 SCTP_LOCAL_AUTH_CHUNKS, /* Read only */ 119 SCTP_LOCAL_AUTH_CHUNKS, /* Read only */
120#define SCTP_LOCAL_AUTH_CHUNKS SCTP_LOCAL_AUTH_CHUNKS 120#define SCTP_LOCAL_AUTH_CHUNKS SCTP_LOCAL_AUTH_CHUNKS
121 SCTP_GET_ASSOC_NUMBER, /* Read only */
122#define SCTP_GET_ASSOC_NUMBER SCTP_GET_ASSOC_NUMBER
121 123
122 124
123 /* Internal Socket Options. Some of the sctp library functions are 125 /* Internal Socket Options. Some of the sctp library functions are
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index e432927310c9..9f5fe23773a9 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -5460,6 +5460,38 @@ num:
5460 return 0; 5460 return 0;
5461} 5461}
5462 5462
5463/*
5464 * 8.2.5. Get the Current Number of Associations (SCTP_GET_ASSOC_NUMBER)
5465 * This option gets the current number of associations that are attached
5466 * to a one-to-many style socket. The option value is an uint32_t.
5467 */
5468static int sctp_getsockopt_assoc_number(struct sock *sk, int len,
5469 char __user *optval, int __user *optlen)
5470{
5471 struct sctp_sock *sp = sctp_sk(sk);
5472 struct sctp_association *asoc;
5473 u32 val = 0;
5474
5475 if (sctp_style(sk, TCP))
5476 return -EOPNOTSUPP;
5477
5478 if (len < sizeof(u32))
5479 return -EINVAL;
5480
5481 len = sizeof(u32);
5482
5483 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
5484 val++;
5485 }
5486
5487 if (put_user(len, optlen))
5488 return -EFAULT;
5489 if (copy_to_user(optval, &val, len))
5490 return -EFAULT;
5491
5492 return 0;
5493}
5494
5463SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, 5495SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
5464 char __user *optval, int __user *optlen) 5496 char __user *optval, int __user *optlen)
5465{ 5497{
@@ -5602,6 +5634,9 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
5602 retval = sctp_getsockopt_local_auth_chunks(sk, len, optval, 5634 retval = sctp_getsockopt_local_auth_chunks(sk, len, optval,
5603 optlen); 5635 optlen);
5604 break; 5636 break;
5637 case SCTP_GET_ASSOC_NUMBER:
5638 retval = sctp_getsockopt_assoc_number(sk, len, optval, optlen);
5639 break;
5605 default: 5640 default:
5606 retval = -ENOPROTOOPT; 5641 retval = -ENOPROTOOPT;
5607 break; 5642 break;