mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
sctp: add SCTP_PR_ASSOC_STATUS on sctp sockopt
This patch adds SCTP_PR_ASSOC_STATUS to sctp sockopt, which is used to dump the prsctp statistics info from the asoc. The prsctp statistics includes abandoned_sent/unsent from the asoc. abandoned_sent is the count of the packets we drop packets from retransmit/transmited queue, and abandoned_unsent is the count of the packets we drop from out_queue according to the policy. Note: another option for prsctp statistics dump described in rfc is SCTP_PR_STREAM_STATUS, which is used to dump the prsctp statistics info from each stream. But by now, linux doesn't yet have per stream statistics info, it needs rfc6525 to be implemented. As the prsctp statistics for each stream has to be based on per stream statistics, we will delay it until rfc6525 is done in linux. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f959fb442c
commit
826d253d57
3 changed files with 77 additions and 0 deletions
|
@ -6330,6 +6330,64 @@ out:
|
|||
return retval;
|
||||
}
|
||||
|
||||
static int sctp_getsockopt_pr_assocstatus(struct sock *sk, int len,
|
||||
char __user *optval,
|
||||
int __user *optlen)
|
||||
{
|
||||
struct sctp_prstatus params;
|
||||
struct sctp_association *asoc;
|
||||
int policy;
|
||||
int retval = -EINVAL;
|
||||
|
||||
if (len < sizeof(params))
|
||||
goto out;
|
||||
|
||||
len = sizeof(params);
|
||||
if (copy_from_user(¶ms, optval, len)) {
|
||||
retval = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
policy = params.sprstat_policy;
|
||||
if (policy & ~SCTP_PR_SCTP_MASK)
|
||||
goto out;
|
||||
|
||||
asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
|
||||
if (!asoc)
|
||||
goto out;
|
||||
|
||||
if (policy == SCTP_PR_SCTP_NONE) {
|
||||
params.sprstat_abandoned_unsent = 0;
|
||||
params.sprstat_abandoned_sent = 0;
|
||||
for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) {
|
||||
params.sprstat_abandoned_unsent +=
|
||||
asoc->abandoned_unsent[policy];
|
||||
params.sprstat_abandoned_sent +=
|
||||
asoc->abandoned_sent[policy];
|
||||
}
|
||||
} else {
|
||||
params.sprstat_abandoned_unsent =
|
||||
asoc->abandoned_unsent[__SCTP_PR_INDEX(policy)];
|
||||
params.sprstat_abandoned_sent =
|
||||
asoc->abandoned_sent[__SCTP_PR_INDEX(policy)];
|
||||
}
|
||||
|
||||
if (put_user(len, optlen)) {
|
||||
retval = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (copy_to_user(optval, ¶ms, len)) {
|
||||
retval = -EFAULT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
|
||||
out:
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int sctp_getsockopt(struct sock *sk, int level, int optname,
|
||||
char __user *optval, int __user *optlen)
|
||||
{
|
||||
|
@ -6490,6 +6548,10 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
|
|||
retval = sctp_getsockopt_default_prinfo(sk, len, optval,
|
||||
optlen);
|
||||
break;
|
||||
case SCTP_PR_ASSOC_STATUS:
|
||||
retval = sctp_getsockopt_pr_assocstatus(sk, len, optval,
|
||||
optlen);
|
||||
break;
|
||||
default:
|
||||
retval = -ENOPROTOOPT;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue