mirror of https://gitee.com/openkylin/linux.git
sctp: add stream interleave enable members and sockopt
This patch adds intl_enable in asoc and netns, and strm_interleave in sctp_sock to indicate if stream interleave is enabled and supported. netns intl_enable would be set via procfs, but that is not added yet until all stream interleave codes are completely implemented; asoc intl_enable will be set when doing 4-shakehands. sp strm_interleave can be set by sockopt SCTP_INTERLEAVING_SUPPORTED which is also added in this patch. This socket option is defined in section 4.3.1 of RFC8260. Note that strm_interleave can only be set by sockopt when both netns intl_enable and sp frag_interleave are set. Signed-off-by: Xin Long <lucien.xin@gmail.com> Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Acked-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
92ff426450
commit
772a58693f
|
@ -122,9 +122,12 @@ struct netns_sctp {
|
||||||
/* Flag to indicate if PR-CONFIG is enabled. */
|
/* Flag to indicate if PR-CONFIG is enabled. */
|
||||||
int reconf_enable;
|
int reconf_enable;
|
||||||
|
|
||||||
/* Flag to idicate if SCTP-AUTH is enabled */
|
/* Flag to indicate if SCTP-AUTH is enabled */
|
||||||
int auth_enable;
|
int auth_enable;
|
||||||
|
|
||||||
|
/* Flag to indicate if stream interleave is enabled */
|
||||||
|
int intl_enable;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Policy to control SCTP IPv4 address scoping
|
* Policy to control SCTP IPv4 address scoping
|
||||||
* 0 - Disable IPv4 address scoping
|
* 0 - Disable IPv4 address scoping
|
||||||
|
|
|
@ -217,6 +217,7 @@ struct sctp_sock {
|
||||||
disable_fragments:1,
|
disable_fragments:1,
|
||||||
v4mapped:1,
|
v4mapped:1,
|
||||||
frag_interleave:1,
|
frag_interleave:1,
|
||||||
|
strm_interleave:1,
|
||||||
recvrcvinfo:1,
|
recvrcvinfo:1,
|
||||||
recvnxtinfo:1,
|
recvnxtinfo:1,
|
||||||
data_ready_signalled:1;
|
data_ready_signalled:1;
|
||||||
|
@ -1940,6 +1941,7 @@ struct sctp_association {
|
||||||
__u8 need_ecne:1, /* Need to send an ECNE Chunk? */
|
__u8 need_ecne:1, /* Need to send an ECNE Chunk? */
|
||||||
temp:1, /* Is it a temporary association? */
|
temp:1, /* Is it a temporary association? */
|
||||||
force_delay:1,
|
force_delay:1,
|
||||||
|
intl_enable:1,
|
||||||
prsctp_enable:1,
|
prsctp_enable:1,
|
||||||
reconf_enable:1;
|
reconf_enable:1;
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,7 @@ typedef __s32 sctp_assoc_t;
|
||||||
#define SCTP_SOCKOPT_PEELOFF_FLAGS 122
|
#define SCTP_SOCKOPT_PEELOFF_FLAGS 122
|
||||||
#define SCTP_STREAM_SCHEDULER 123
|
#define SCTP_STREAM_SCHEDULER 123
|
||||||
#define SCTP_STREAM_SCHEDULER_VALUE 124
|
#define SCTP_STREAM_SCHEDULER_VALUE 124
|
||||||
|
#define SCTP_INTERLEAVING_SUPPORTED 125
|
||||||
|
|
||||||
/* PR-SCTP policies */
|
/* PR-SCTP policies */
|
||||||
#define SCTP_PR_SCTP_NONE 0x0000
|
#define SCTP_PR_SCTP_NONE 0x0000
|
||||||
|
|
|
@ -3350,7 +3350,10 @@ static int sctp_setsockopt_fragment_interleave(struct sock *sk,
|
||||||
if (get_user(val, (int __user *)optval))
|
if (get_user(val, (int __user *)optval))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
sctp_sk(sk)->frag_interleave = (val == 0) ? 0 : 1;
|
sctp_sk(sk)->frag_interleave = !!val;
|
||||||
|
|
||||||
|
if (!sctp_sk(sk)->frag_interleave)
|
||||||
|
sctp_sk(sk)->strm_interleave = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4019,6 +4022,40 @@ static int sctp_setsockopt_scheduler_value(struct sock *sk,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sctp_setsockopt_interleaving_supported(struct sock *sk,
|
||||||
|
char __user *optval,
|
||||||
|
unsigned int optlen)
|
||||||
|
{
|
||||||
|
struct sctp_sock *sp = sctp_sk(sk);
|
||||||
|
struct net *net = sock_net(sk);
|
||||||
|
struct sctp_assoc_value params;
|
||||||
|
int retval = -EINVAL;
|
||||||
|
|
||||||
|
if (optlen < sizeof(params))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
optlen = sizeof(params);
|
||||||
|
if (copy_from_user(¶ms, optval, optlen)) {
|
||||||
|
retval = -EFAULT;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.assoc_id)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!net->sctp.intl_enable || !sp->frag_interleave) {
|
||||||
|
retval = -EPERM;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
sp->strm_interleave = !!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
|
||||||
|
@ -4206,6 +4243,10 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
|
||||||
case SCTP_STREAM_SCHEDULER_VALUE:
|
case SCTP_STREAM_SCHEDULER_VALUE:
|
||||||
retval = sctp_setsockopt_scheduler_value(sk, optval, optlen);
|
retval = sctp_setsockopt_scheduler_value(sk, optval, optlen);
|
||||||
break;
|
break;
|
||||||
|
case SCTP_INTERLEAVING_SUPPORTED:
|
||||||
|
retval = sctp_setsockopt_interleaving_supported(sk, optval,
|
||||||
|
optlen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
retval = -ENOPROTOOPT;
|
retval = -ENOPROTOOPT;
|
||||||
break;
|
break;
|
||||||
|
@ -6969,6 +7010,47 @@ static int sctp_getsockopt_scheduler_value(struct sock *sk, int len,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sctp_getsockopt_interleaving_supported(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_value = asoc->intl_enable;
|
||||||
|
} else if (!params.assoc_id) {
|
||||||
|
struct sctp_sock *sp = sctp_sk(sk);
|
||||||
|
|
||||||
|
params.assoc_value = sp->strm_interleave;
|
||||||
|
} else {
|
||||||
|
retval = -EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
@ -7159,6 +7241,10 @@ static int sctp_getsockopt(struct sock *sk, int level, int optname,
|
||||||
retval = sctp_getsockopt_scheduler_value(sk, len, optval,
|
retval = sctp_getsockopt_scheduler_value(sk, len, optval,
|
||||||
optlen);
|
optlen);
|
||||||
break;
|
break;
|
||||||
|
case SCTP_INTERLEAVING_SUPPORTED:
|
||||||
|
retval = sctp_getsockopt_interleaving_supported(sk, len, optval,
|
||||||
|
optlen);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
retval = -ENOPROTOOPT;
|
retval = -ENOPROTOOPT;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue