forked from luck/tmp_suning_uos_patched
sctp: add SCTP_EXPOSE_POTENTIALLY_FAILED_STATE sockopt
This is a sockopt defined in section 7.3 of rfc7829: "Exposing the Potentially Failed Path State", by which users can change pf_expose per sock and asoc. The new sockopt SCTP_EXPOSE_POTENTIALLY_FAILED_STATE is also known as SCTP_EXPOSE_PF_STATE for short. v2->v3: - return -EINVAL if params.assoc_value > SCTP_PF_EXPOSE_MAX. - define SCTP_EXPOSE_PF_STATE SCTP_EXPOSE_POTENTIALLY_FAILED_STATE. v3->v4: - improve changelog. Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
768e15182d
commit
8d2a6935d8
|
@ -137,6 +137,8 @@ typedef __s32 sctp_assoc_t;
|
||||||
#define SCTP_ASCONF_SUPPORTED 128
|
#define SCTP_ASCONF_SUPPORTED 128
|
||||||
#define SCTP_AUTH_SUPPORTED 129
|
#define SCTP_AUTH_SUPPORTED 129
|
||||||
#define SCTP_ECN_SUPPORTED 130
|
#define SCTP_ECN_SUPPORTED 130
|
||||||
|
#define SCTP_EXPOSE_POTENTIALLY_FAILED_STATE 131
|
||||||
|
#define SCTP_EXPOSE_PF_STATE SCTP_EXPOSE_POTENTIALLY_FAILED_STATE
|
||||||
|
|
||||||
/* PR-SCTP policies */
|
/* PR-SCTP policies */
|
||||||
#define SCTP_PR_SCTP_NONE 0x0000
|
#define SCTP_PR_SCTP_NONE 0x0000
|
||||||
|
|
|
@ -4589,6 +4589,40 @@ static int sctp_setsockopt_ecn_supported(struct sock *sk,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sctp_setsockopt_pf_expose(struct sock *sk,
|
||||||
|
char __user *optval,
|
||||||
|
unsigned int optlen)
|
||||||
|
{
|
||||||
|
struct sctp_assoc_value params;
|
||||||
|
struct sctp_association *asoc;
|
||||||
|
int retval = -EINVAL;
|
||||||
|
|
||||||
|
if (optlen != sizeof(params))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (copy_from_user(¶ms, optval, optlen)) {
|
||||||
|
retval = -EFAULT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.assoc_value > SCTP_PF_EXPOSE_MAX)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
asoc = sctp_id2assoc(sk, params.assoc_id);
|
||||||
|
if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
|
||||||
|
sctp_style(sk, UDP))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (asoc)
|
||||||
|
asoc->pf_expose = params.assoc_value;
|
||||||
|
else
|
||||||
|
sctp_sk(sk)->pf_expose = params.assoc_value;
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/* API 6.2 setsockopt(), getsockopt()
|
/* API 6.2 setsockopt(), getsockopt()
|
||||||
*
|
*
|
||||||
* Applications use setsockopt() and getsockopt() to set or retrieve
|
* Applications use setsockopt() and getsockopt() to set or retrieve
|
||||||
|
@ -4798,6 +4832,9 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
|
||||||
case SCTP_ECN_SUPPORTED:
|
case SCTP_ECN_SUPPORTED:
|
||||||
retval = sctp_setsockopt_ecn_supported(sk, optval, optlen);
|
retval = sctp_setsockopt_ecn_supported(sk, optval, optlen);
|
||||||
break;
|
break;
|
||||||
|
case SCTP_EXPOSE_POTENTIALLY_FAILED_STATE:
|
||||||
|
retval = sctp_setsockopt_pf_expose(sk, optval, optlen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
retval = -ENOPROTOOPT;
|
retval = -ENOPROTOOPT;
|
||||||
break;
|
break;
|
||||||
|
@ -7909,6 +7946,45 @@ static int sctp_getsockopt_ecn_supported(struct sock *sk, int len,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sctp_getsockopt_pf_expose(struct sock *sk, int len,
|
||||||
|
char __user *optval,
|
||||||
|
int __user *optlen)
|
||||||
|
{
|
||||||
|
struct sctp_assoc_value params;
|
||||||
|
struct sctp_association *asoc;
|
||||||
|
int retval = -EFAULT;
|
||||||
|
|
||||||
|
if (len < sizeof(params)) {
|
||||||
|
retval = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = sizeof(params);
|
||||||
|
if (copy_from_user(¶ms, optval, len))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
asoc = sctp_id2assoc(sk, params.assoc_id);
|
||||||
|
if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC &&
|
||||||
|
sctp_style(sk, UDP)) {
|
||||||
|
retval = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
params.assoc_value = asoc ? asoc->pf_expose
|
||||||
|
: sctp_sk(sk)->pf_expose;
|
||||||
|
|
||||||
|
if (put_user(len, optlen))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (copy_to_user(optval, ¶ms, len))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
retval = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
static int sctp_getsockopt(struct sock *sk, int level, int optname,
|
static int sctp_getsockopt(struct sock *sk, int level, int optname,
|
||||||
char __user *optval, int __user *optlen)
|
char __user *optval, int __user *optlen)
|
||||||
{
|
{
|
||||||
|
@ -8121,6 +8197,9 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
|
||||||
case SCTP_ECN_SUPPORTED:
|
case SCTP_ECN_SUPPORTED:
|
||||||
retval = sctp_getsockopt_ecn_supported(sk, len, optval, optlen);
|
retval = sctp_getsockopt_ecn_supported(sk, len, optval, optlen);
|
||||||
break;
|
break;
|
||||||
|
case SCTP_EXPOSE_POTENTIALLY_FAILED_STATE:
|
||||||
|
retval = sctp_getsockopt_pf_expose(sk, len, optval, optlen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
retval = -ENOPROTOOPT;
|
retval = -ENOPROTOOPT;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user