diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/sctp/socket.c | 35 |
1 files changed, 35 insertions, 0 deletions
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 | */ | ||
5468 | static 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 | |||
5463 | SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, | 5495 | SCTP_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; |