Commit 0ac1077e authored by Xin Long's avatar Xin Long Committed by David S. Miller

sctp: get pr_assoc and pr_stream all status with SCTP_PR_SCTP_ALL instead

According to rfc7496 section 4.3 or 4.4:

   sprstat_policy:  This parameter indicates for which PR-SCTP policy
      the user wants the information.  It is an error to use
      SCTP_PR_SCTP_NONE in sprstat_policy.  If SCTP_PR_SCTP_ALL is used,
      the counters provided are aggregated over all supported policies.

We change to dump pr_assoc and pr_stream all status by SCTP_PR_SCTP_ALL
instead, and return error for SCTP_PR_SCTP_NONE, as it also said "It is
an error to use SCTP_PR_SCTP_NONE in sprstat_policy. "

Fixes: 826d253d ("sctp: add SCTP_PR_ASSOC_STATUS on sctp sockopt")
Fixes: d229d48d ("sctp: add SCTP_PR_STREAM_STATUS sockopt for prsctp")
Reported-by: default avatarYing Xu <yinxu@redhat.com>
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bd8be2cf
...@@ -301,6 +301,7 @@ enum sctp_sinfo_flags { ...@@ -301,6 +301,7 @@ enum sctp_sinfo_flags {
SCTP_SACK_IMMEDIATELY = (1 << 3), /* SACK should be sent without delay. */ SCTP_SACK_IMMEDIATELY = (1 << 3), /* SACK should be sent without delay. */
/* 2 bits here have been used by SCTP_PR_SCTP_MASK */ /* 2 bits here have been used by SCTP_PR_SCTP_MASK */
SCTP_SENDALL = (1 << 6), SCTP_SENDALL = (1 << 6),
SCTP_PR_SCTP_ALL = (1 << 7),
SCTP_NOTIFICATION = MSG_NOTIFICATION, /* Next message is not user msg but notification. */ SCTP_NOTIFICATION = MSG_NOTIFICATION, /* Next message is not user msg but notification. */
SCTP_EOF = MSG_FIN, /* Initiate graceful shutdown process. */ SCTP_EOF = MSG_FIN, /* Initiate graceful shutdown process. */
}; };
......
...@@ -7100,14 +7100,14 @@ static int sctp_getsockopt_pr_assocstatus(struct sock *sk, int len, ...@@ -7100,14 +7100,14 @@ static int sctp_getsockopt_pr_assocstatus(struct sock *sk, int len,
} }
policy = params.sprstat_policy; policy = params.sprstat_policy;
if (policy & ~SCTP_PR_SCTP_MASK) if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)))
goto out; goto out;
asoc = sctp_id2assoc(sk, params.sprstat_assoc_id); asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
if (!asoc) if (!asoc)
goto out; goto out;
if (policy == SCTP_PR_SCTP_NONE) { if (policy & SCTP_PR_SCTP_ALL) {
params.sprstat_abandoned_unsent = 0; params.sprstat_abandoned_unsent = 0;
params.sprstat_abandoned_sent = 0; params.sprstat_abandoned_sent = 0;
for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) { for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) {
...@@ -7159,7 +7159,7 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len, ...@@ -7159,7 +7159,7 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len,
} }
policy = params.sprstat_policy; policy = params.sprstat_policy;
if (policy & ~SCTP_PR_SCTP_MASK) if (!policy || (policy & ~(SCTP_PR_SCTP_MASK | SCTP_PR_SCTP_ALL)))
goto out; goto out;
asoc = sctp_id2assoc(sk, params.sprstat_assoc_id); asoc = sctp_id2assoc(sk, params.sprstat_assoc_id);
...@@ -7175,7 +7175,7 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len, ...@@ -7175,7 +7175,7 @@ static int sctp_getsockopt_pr_streamstatus(struct sock *sk, int len,
goto out; goto out;
} }
if (policy == SCTP_PR_SCTP_NONE) { if (policy == SCTP_PR_SCTP_ALL) {
params.sprstat_abandoned_unsent = 0; params.sprstat_abandoned_unsent = 0;
params.sprstat_abandoned_sent = 0; params.sprstat_abandoned_sent = 0;
for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) { for (policy = 0; policy <= SCTP_PR_INDEX(MAX); policy++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment