Commit e1fc3b14 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

sctp: Make sysctl tunables per net

Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f53b5b09
...@@ -36,6 +36,96 @@ struct netns_sctp { ...@@ -36,6 +36,96 @@ struct netns_sctp {
/* Lock that protects the local_addr_list writers */ /* Lock that protects the local_addr_list writers */
spinlock_t local_addr_lock; spinlock_t local_addr_lock;
/* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values
*
* The following protocol parameters are RECOMMENDED:
*
* RTO.Initial - 3 seconds
* RTO.Min - 1 second
* RTO.Max - 60 seconds
* RTO.Alpha - 1/8 (3 when converted to right shifts.)
* RTO.Beta - 1/4 (2 when converted to right shifts.)
*/
unsigned int rto_initial;
unsigned int rto_min;
unsigned int rto_max;
/* Note: rto_alpha and rto_beta are really defined as inverse
* powers of two to facilitate integer operations.
*/
int rto_alpha;
int rto_beta;
/* Max.Burst - 4 */
int max_burst;
/* Whether Cookie Preservative is enabled(1) or not(0) */
int cookie_preserve_enable;
/* Valid.Cookie.Life - 60 seconds */
unsigned int valid_cookie_life;
/* Delayed SACK timeout 200ms default*/
unsigned int sack_timeout;
/* HB.interval - 30 seconds */
unsigned int hb_interval;
/* Association.Max.Retrans - 10 attempts
* Path.Max.Retrans - 5 attempts (per destination address)
* Max.Init.Retransmits - 8 attempts
*/
int max_retrans_association;
int max_retrans_path;
int max_retrans_init;
/* Potentially-Failed.Max.Retrans sysctl value
* taken from:
* http://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05
*/
int pf_retrans;
/*
* Policy for preforming sctp/socket accounting
* 0 - do socket level accounting, all assocs share sk_sndbuf
* 1 - do sctp accounting, each asoc may use sk_sndbuf bytes
*/
int sndbuf_policy;
/*
* Policy for preforming sctp/socket accounting
* 0 - do socket level accounting, all assocs share sk_rcvbuf
* 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes
*/
int rcvbuf_policy;
int default_auto_asconf;
/* Flag to indicate if addip is enabled. */
int addip_enable;
int addip_noauth;
/* Flag to indicate if PR-SCTP is enabled. */
int prsctp_enable;
/* Flag to idicate if SCTP-AUTH is enabled */
int auth_enable;
/*
* Policy to control SCTP IPv4 address scoping
* 0 - Disable IPv4 address scoping
* 1 - Enable IPv4 address scoping
* 2 - Selectively allow only IPv4 private addresses
* 3 - Selectively allow only IPv4 link local address
*/
int scope_policy;
/* Threshold for rwnd update SACKS. Receive buffer shifted this many
* bits is an indicator of when to send and window update SACK.
*/
int rwnd_upd_shift;
/* Threshold for autoclose timeout, in seconds. */
unsigned long max_autoclose;
}; };
#endif /* __NETNS_SCTP_H__ */ #endif /* __NETNS_SCTP_H__ */
...@@ -119,69 +119,6 @@ struct sctp_hashbucket { ...@@ -119,69 +119,6 @@ struct sctp_hashbucket {
/* The SCTP globals structure. */ /* The SCTP globals structure. */
extern struct sctp_globals { extern struct sctp_globals {
/* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values
*
* The following protocol parameters are RECOMMENDED:
*
* RTO.Initial - 3 seconds
* RTO.Min - 1 second
* RTO.Max - 60 seconds
* RTO.Alpha - 1/8 (3 when converted to right shifts.)
* RTO.Beta - 1/4 (2 when converted to right shifts.)
*/
unsigned int rto_initial;
unsigned int rto_min;
unsigned int rto_max;
/* Note: rto_alpha and rto_beta are really defined as inverse
* powers of two to facilitate integer operations.
*/
int rto_alpha;
int rto_beta;
/* Max.Burst - 4 */
int max_burst;
/* Whether Cookie Preservative is enabled(1) or not(0) */
int cookie_preserve_enable;
/* Valid.Cookie.Life - 60 seconds */
unsigned int valid_cookie_life;
/* Delayed SACK timeout 200ms default*/
unsigned int sack_timeout;
/* HB.interval - 30 seconds */
unsigned int hb_interval;
/* Association.Max.Retrans - 10 attempts
* Path.Max.Retrans - 5 attempts (per destination address)
* Max.Init.Retransmits - 8 attempts
*/
int max_retrans_association;
int max_retrans_path;
int max_retrans_init;
/* Potentially-Failed.Max.Retrans sysctl value
* taken from:
* http://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05
*/
int pf_retrans;
/*
* Policy for preforming sctp/socket accounting
* 0 - do socket level accounting, all assocs share sk_sndbuf
* 1 - do sctp accounting, each asoc may use sk_sndbuf bytes
*/
int sndbuf_policy;
/*
* Policy for preforming sctp/socket accounting
* 0 - do socket level accounting, all assocs share sk_rcvbuf
* 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes
*/
int rcvbuf_policy;
/* The following variables are implementation specific. */ /* The following variables are implementation specific. */
/* Default initialization values to be applied to new associations. */ /* Default initialization values to be applied to new associations. */
...@@ -205,56 +142,11 @@ extern struct sctp_globals { ...@@ -205,56 +142,11 @@ extern struct sctp_globals {
int port_hashsize; int port_hashsize;
struct sctp_bind_hashbucket *port_hashtable; struct sctp_bind_hashbucket *port_hashtable;
int default_auto_asconf;
/* Flag to indicate if addip is enabled. */
int addip_enable;
int addip_noauth_enable;
/* Flag to indicate if PR-SCTP is enabled. */
int prsctp_enable;
/* Flag to idicate if SCTP-AUTH is enabled */
int auth_enable;
/*
* Policy to control SCTP IPv4 address scoping
* 0 - Disable IPv4 address scoping
* 1 - Enable IPv4 address scoping
* 2 - Selectively allow only IPv4 private addresses
* 3 - Selectively allow only IPv4 link local address
*/
int ipv4_scope_policy;
/* Flag to indicate whether computing and verifying checksum /* Flag to indicate whether computing and verifying checksum
* is disabled. */ * is disabled. */
bool checksum_disable; bool checksum_disable;
/* Threshold for rwnd update SACKS. Receive buffer shifted this many
* bits is an indicator of when to send and window update SACK.
*/
int rwnd_update_shift;
/* Threshold for autoclose timeout, in seconds. */
unsigned long max_autoclose;
} sctp_globals; } sctp_globals;
#define sctp_rto_initial (sctp_globals.rto_initial)
#define sctp_rto_min (sctp_globals.rto_min)
#define sctp_rto_max (sctp_globals.rto_max)
#define sctp_rto_alpha (sctp_globals.rto_alpha)
#define sctp_rto_beta (sctp_globals.rto_beta)
#define sctp_max_burst (sctp_globals.max_burst)
#define sctp_valid_cookie_life (sctp_globals.valid_cookie_life)
#define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable)
#define sctp_max_retrans_association (sctp_globals.max_retrans_association)
#define sctp_sndbuf_policy (sctp_globals.sndbuf_policy)
#define sctp_rcvbuf_policy (sctp_globals.rcvbuf_policy)
#define sctp_max_retrans_path (sctp_globals.max_retrans_path)
#define sctp_pf_retrans (sctp_globals.pf_retrans)
#define sctp_max_retrans_init (sctp_globals.max_retrans_init)
#define sctp_sack_timeout (sctp_globals.sack_timeout)
#define sctp_hb_interval (sctp_globals.hb_interval)
#define sctp_max_instreams (sctp_globals.max_instreams) #define sctp_max_instreams (sctp_globals.max_instreams)
#define sctp_max_outstreams (sctp_globals.max_outstreams) #define sctp_max_outstreams (sctp_globals.max_outstreams)
#define sctp_address_families (sctp_globals.address_families) #define sctp_address_families (sctp_globals.address_families)
...@@ -264,15 +156,7 @@ extern struct sctp_globals { ...@@ -264,15 +156,7 @@ extern struct sctp_globals {
#define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable)
#define sctp_port_hashsize (sctp_globals.port_hashsize) #define sctp_port_hashsize (sctp_globals.port_hashsize)
#define sctp_port_hashtable (sctp_globals.port_hashtable) #define sctp_port_hashtable (sctp_globals.port_hashtable)
#define sctp_default_auto_asconf (sctp_globals.default_auto_asconf)
#define sctp_scope_policy (sctp_globals.ipv4_scope_policy)
#define sctp_addip_enable (sctp_globals.addip_enable)
#define sctp_addip_noauth (sctp_globals.addip_noauth_enable)
#define sctp_prsctp_enable (sctp_globals.prsctp_enable)
#define sctp_auth_enable (sctp_globals.auth_enable)
#define sctp_checksum_disable (sctp_globals.checksum_disable) #define sctp_checksum_disable (sctp_globals.checksum_disable)
#define sctp_rwnd_upd_shift (sctp_globals.rwnd_update_shift)
#define sctp_max_autoclose (sctp_globals.max_autoclose)
/* SCTP Socket type: UDP or TCP style. */ /* SCTP Socket type: UDP or TCP style. */
typedef enum { typedef enum {
......
...@@ -82,6 +82,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a ...@@ -82,6 +82,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
sctp_scope_t scope, sctp_scope_t scope,
gfp_t gfp) gfp_t gfp)
{ {
struct net *net = sock_net(sk);
struct sctp_sock *sp; struct sctp_sock *sp;
int i; int i;
sctp_paramhdr_t *p; sctp_paramhdr_t *p;
...@@ -124,7 +125,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a ...@@ -124,7 +125,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
* socket values. * socket values.
*/ */
asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt; asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt;
asoc->pf_retrans = sctp_pf_retrans; asoc->pf_retrans = net->sctp.pf_retrans;
asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial); asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial);
asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max); asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max);
...@@ -175,7 +176,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a ...@@ -175,7 +176,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0; asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0;
asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
min_t(unsigned long, sp->autoclose, sctp_max_autoclose) * HZ; min_t(unsigned long, sp->autoclose, net->sctp.max_autoclose) * HZ;
/* Initializes the timers */ /* Initializes the timers */
for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
...@@ -281,7 +282,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a ...@@ -281,7 +282,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
* and will revert old behavior. * and will revert old behavior.
*/ */
asoc->peer.asconf_capable = 0; asoc->peer.asconf_capable = 0;
if (sctp_addip_noauth) if (net->sctp.addip_noauth)
asoc->peer.asconf_capable = 1; asoc->peer.asconf_capable = 1;
asoc->asconf_addr_del_pending = NULL; asoc->asconf_addr_del_pending = NULL;
asoc->src_out_of_asoc_ok = 0; asoc->src_out_of_asoc_ok = 0;
...@@ -1418,6 +1419,7 @@ void sctp_assoc_sync_pmtu(struct sock *sk, struct sctp_association *asoc) ...@@ -1418,6 +1419,7 @@ void sctp_assoc_sync_pmtu(struct sock *sk, struct sctp_association *asoc)
/* Should we send a SACK to update our peer? */ /* Should we send a SACK to update our peer? */
static inline int sctp_peer_needs_update(struct sctp_association *asoc) static inline int sctp_peer_needs_update(struct sctp_association *asoc)
{ {
struct net *net = sock_net(asoc->base.sk);
switch (asoc->state) { switch (asoc->state) {
case SCTP_STATE_ESTABLISHED: case SCTP_STATE_ESTABLISHED:
case SCTP_STATE_SHUTDOWN_PENDING: case SCTP_STATE_SHUTDOWN_PENDING:
...@@ -1425,7 +1427,7 @@ static inline int sctp_peer_needs_update(struct sctp_association *asoc) ...@@ -1425,7 +1427,7 @@ static inline int sctp_peer_needs_update(struct sctp_association *asoc)
case SCTP_STATE_SHUTDOWN_SENT: case SCTP_STATE_SHUTDOWN_SENT:
if ((asoc->rwnd > asoc->a_rwnd) && if ((asoc->rwnd > asoc->a_rwnd) &&
((asoc->rwnd - asoc->a_rwnd) >= max_t(__u32, ((asoc->rwnd - asoc->a_rwnd) >= max_t(__u32,
(asoc->base.sk->sk_rcvbuf >> sctp_rwnd_upd_shift), (asoc->base.sk->sk_rcvbuf >> net->sctp.rwnd_upd_shift),
asoc->pathmtu))) asoc->pathmtu)))
return 1; return 1;
break; break;
......
...@@ -392,13 +392,14 @@ int sctp_auth_asoc_copy_shkeys(const struct sctp_endpoint *ep, ...@@ -392,13 +392,14 @@ int sctp_auth_asoc_copy_shkeys(const struct sctp_endpoint *ep,
*/ */
int sctp_auth_asoc_init_active_key(struct sctp_association *asoc, gfp_t gfp) int sctp_auth_asoc_init_active_key(struct sctp_association *asoc, gfp_t gfp)
{ {
struct net *net = sock_net(asoc->base.sk);
struct sctp_auth_bytes *secret; struct sctp_auth_bytes *secret;
struct sctp_shared_key *ep_key; struct sctp_shared_key *ep_key;
/* If we don't support AUTH, or peer is not capable /* If we don't support AUTH, or peer is not capable
* we don't need to do anything. * we don't need to do anything.
*/ */
if (!sctp_auth_enable || !asoc->peer.auth_capable) if (!net->sctp.auth_enable || !asoc->peer.auth_capable)
return 0; return 0;
/* If the key_id is non-zero and we couldn't find an /* If the key_id is non-zero and we couldn't find an
...@@ -445,11 +446,12 @@ struct sctp_shared_key *sctp_auth_get_shkey( ...@@ -445,11 +446,12 @@ struct sctp_shared_key *sctp_auth_get_shkey(
*/ */
int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp)
{ {
struct net *net = sock_net(ep->base.sk);
struct crypto_hash *tfm = NULL; struct crypto_hash *tfm = NULL;
__u16 id; __u16 id;
/* if the transforms are already allocted, we are done */ /* if the transforms are already allocted, we are done */
if (!sctp_auth_enable) { if (!net->sctp.auth_enable) {
ep->auth_hmacs = NULL; ep->auth_hmacs = NULL;
return 0; return 0;
} }
...@@ -674,7 +676,12 @@ static int __sctp_auth_cid(sctp_cid_t chunk, struct sctp_chunks_param *param) ...@@ -674,7 +676,12 @@ static int __sctp_auth_cid(sctp_cid_t chunk, struct sctp_chunks_param *param)
/* Check if peer requested that this chunk is authenticated */ /* Check if peer requested that this chunk is authenticated */
int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc) int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc)
{ {
if (!sctp_auth_enable || !asoc || !asoc->peer.auth_capable) struct net *net;
if (!asoc)
return 0;
net = sock_net(asoc->base.sk);
if (!net->sctp.auth_enable || !asoc->peer.auth_capable)
return 0; return 0;
return __sctp_auth_cid(chunk, asoc->peer.peer_chunks); return __sctp_auth_cid(chunk, asoc->peer.peer_chunks);
...@@ -683,7 +690,12 @@ int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc) ...@@ -683,7 +690,12 @@ int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc)
/* Check if we requested that peer authenticate this chunk. */ /* Check if we requested that peer authenticate this chunk. */
int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc) int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc)
{ {
if (!sctp_auth_enable || !asoc) struct net *net;
if (!asoc)
return 0;
net = sock_net(asoc->base.sk);
if (!net->sctp.auth_enable);
return 0; return 0;
return __sctp_auth_cid(chunk, return __sctp_auth_cid(chunk,
......
...@@ -512,7 +512,7 @@ int sctp_in_scope(struct net *net, const union sctp_addr *addr, sctp_scope_t sco ...@@ -512,7 +512,7 @@ int sctp_in_scope(struct net *net, const union sctp_addr *addr, sctp_scope_t sco
* Address scoping can be selectively controlled via sysctl * Address scoping can be selectively controlled via sysctl
* option * option
*/ */
switch (sctp_scope_policy) { switch (net->sctp.scope_policy) {
case SCTP_SCOPE_POLICY_DISABLE: case SCTP_SCOPE_POLICY_DISABLE:
return 1; return 1;
case SCTP_SCOPE_POLICY_ENABLE: case SCTP_SCOPE_POLICY_ENABLE:
......
...@@ -65,6 +65,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -65,6 +65,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
struct sock *sk, struct sock *sk,
gfp_t gfp) gfp_t gfp)
{ {
struct net *net = sock_net(sk);
struct sctp_hmac_algo_param *auth_hmacs = NULL; struct sctp_hmac_algo_param *auth_hmacs = NULL;
struct sctp_chunks_param *auth_chunks = NULL; struct sctp_chunks_param *auth_chunks = NULL;
struct sctp_shared_key *null_key; struct sctp_shared_key *null_key;
...@@ -74,7 +75,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -74,7 +75,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
if (!ep->digest) if (!ep->digest)
return NULL; return NULL;
if (sctp_auth_enable) { if (net->sctp.auth_enable) {
/* Allocate space for HMACS and CHUNKS authentication /* Allocate space for HMACS and CHUNKS authentication
* variables. There are arrays that we encode directly * variables. There are arrays that we encode directly
* into parameters to make the rest of the operations easier. * into parameters to make the rest of the operations easier.
...@@ -106,7 +107,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -106,7 +107,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
/* If the Add-IP functionality is enabled, we must /* If the Add-IP functionality is enabled, we must
* authenticate, ASCONF and ASCONF-ACK chunks * authenticate, ASCONF and ASCONF-ACK chunks
*/ */
if (sctp_addip_enable) { if (net->sctp.addip_enable) {
auth_chunks->chunks[0] = SCTP_CID_ASCONF; auth_chunks->chunks[0] = SCTP_CID_ASCONF;
auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK;
auth_chunks->param_hdr.length = auth_chunks->param_hdr.length =
...@@ -140,14 +141,14 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, ...@@ -140,14 +141,14 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
INIT_LIST_HEAD(&ep->asocs); INIT_LIST_HEAD(&ep->asocs);
/* Use SCTP specific send buffer space queues. */ /* Use SCTP specific send buffer space queues. */
ep->sndbuf_policy = sctp_sndbuf_policy; ep->sndbuf_policy = net->sctp.sndbuf_policy;
sk->sk_data_ready = sctp_data_ready; sk->sk_data_ready = sctp_data_ready;
sk->sk_write_space = sctp_write_space; sk->sk_write_space = sctp_write_space;
sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
/* Get the receive buffer policy for this endpoint */ /* Get the receive buffer policy for this endpoint */
ep->rcvbuf_policy = sctp_rcvbuf_policy; ep->rcvbuf_policy = net->sctp.rcvbuf_policy;
/* Initialize the secret key used with cookie. */ /* Initialize the secret key used with cookie. */
get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE); get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE);
......
...@@ -1094,7 +1094,7 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net, ...@@ -1094,7 +1094,7 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net,
break; break;
case SCTP_CID_ASCONF: case SCTP_CID_ASCONF:
if (have_auth || sctp_addip_noauth) if (have_auth || net->sctp.addip_noauth)
asoc = __sctp_rcv_asconf_lookup( asoc = __sctp_rcv_asconf_lookup(
net, ch, laddr, net, ch, laddr,
sctp_hdr(skb)->source, sctp_hdr(skb)->source,
......
...@@ -1169,6 +1169,70 @@ static int sctp_net_init(struct net *net) ...@@ -1169,6 +1169,70 @@ static int sctp_net_init(struct net *net)
{ {
int status; int status;
/*
* 14. Suggested SCTP Protocol Parameter Values
*/
/* The following protocol parameters are RECOMMENDED: */
/* RTO.Initial - 3 seconds */
net->sctp.rto_initial = SCTP_RTO_INITIAL;
/* RTO.Min - 1 second */
net->sctp.rto_min = SCTP_RTO_MIN;
/* RTO.Max - 60 seconds */
net->sctp.rto_max = SCTP_RTO_MAX;
/* RTO.Alpha - 1/8 */
net->sctp.rto_alpha = SCTP_RTO_ALPHA;
/* RTO.Beta - 1/4 */
net->sctp.rto_beta = SCTP_RTO_BETA;
/* Valid.Cookie.Life - 60 seconds */
net->sctp.valid_cookie_life = SCTP_DEFAULT_COOKIE_LIFE;
/* Whether Cookie Preservative is enabled(1) or not(0) */
net->sctp.cookie_preserve_enable = 1;
/* Max.Burst - 4 */
net->sctp.max_burst = SCTP_DEFAULT_MAX_BURST;
/* Association.Max.Retrans - 10 attempts
* Path.Max.Retrans - 5 attempts (per destination address)
* Max.Init.Retransmits - 8 attempts
*/
net->sctp.max_retrans_association = 10;
net->sctp.max_retrans_path = 5;
net->sctp.max_retrans_init = 8;
/* Sendbuffer growth - do per-socket accounting */
net->sctp.sndbuf_policy = 0;
/* Rcvbuffer growth - do per-socket accounting */
net->sctp.rcvbuf_policy = 0;
/* HB.interval - 30 seconds */
net->sctp.hb_interval = SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
/* delayed SACK timeout */
net->sctp.sack_timeout = SCTP_DEFAULT_TIMEOUT_SACK;
/* Disable ADDIP by default. */
net->sctp.addip_enable = 0;
net->sctp.addip_noauth = 0;
net->sctp.default_auto_asconf = 0;
/* Enable PR-SCTP by default. */
net->sctp.prsctp_enable = 1;
/* Disable AUTH by default. */
net->sctp.auth_enable = 0;
/* Set SCOPE policy to enabled */
net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE;
/* Set the default rwnd update threshold */
net->sctp.rwnd_upd_shift = SCTP_DEFAULT_RWND_SHIFT;
/* Initialize maximum autoclose timeout. */
net->sctp.max_autoclose = INT_MAX / HZ;
status = sctp_sysctl_net_register(net); status = sctp_sysctl_net_register(net);
if (status) if (status)
goto err_sysctl_register; goto err_sysctl_register;
...@@ -1272,59 +1336,12 @@ SCTP_STATIC __init int sctp_init(void) ...@@ -1272,59 +1336,12 @@ SCTP_STATIC __init int sctp_init(void)
if (status) if (status)
goto err_percpu_counter_init; goto err_percpu_counter_init;
/*
* 14. Suggested SCTP Protocol Parameter Values
*/
/* The following protocol parameters are RECOMMENDED: */
/* RTO.Initial - 3 seconds */
sctp_rto_initial = SCTP_RTO_INITIAL;
/* RTO.Min - 1 second */
sctp_rto_min = SCTP_RTO_MIN;
/* RTO.Max - 60 seconds */
sctp_rto_max = SCTP_RTO_MAX;
/* RTO.Alpha - 1/8 */
sctp_rto_alpha = SCTP_RTO_ALPHA;
/* RTO.Beta - 1/4 */
sctp_rto_beta = SCTP_RTO_BETA;
/* Valid.Cookie.Life - 60 seconds */
sctp_valid_cookie_life = SCTP_DEFAULT_COOKIE_LIFE;
/* Whether Cookie Preservative is enabled(1) or not(0) */
sctp_cookie_preserve_enable = 1;
/* Max.Burst - 4 */
sctp_max_burst = SCTP_DEFAULT_MAX_BURST;
/* Association.Max.Retrans - 10 attempts
* Path.Max.Retrans - 5 attempts (per destination address)
* Max.Init.Retransmits - 8 attempts
*/
sctp_max_retrans_association = 10;
sctp_max_retrans_path = 5;
sctp_max_retrans_init = 8;
/* Sendbuffer growth - do per-socket accounting */
sctp_sndbuf_policy = 0;
/* Rcvbuffer growth - do per-socket accounting */
sctp_rcvbuf_policy = 0;
/* HB.interval - 30 seconds */
sctp_hb_interval = SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
/* delayed SACK timeout */
sctp_sack_timeout = SCTP_DEFAULT_TIMEOUT_SACK;
/* Implementation specific variables. */ /* Implementation specific variables. */
/* Initialize default stream count setup information. */ /* Initialize default stream count setup information. */
sctp_max_instreams = SCTP_DEFAULT_INSTREAMS; sctp_max_instreams = SCTP_DEFAULT_INSTREAMS;
sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS; sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS;
/* Initialize maximum autoclose timeout. */
sctp_max_autoclose = INT_MAX / HZ;
/* Initialize handle used for association ids. */ /* Initialize handle used for association ids. */
idr_init(&sctp_assocs_id); idr_init(&sctp_assocs_id);
...@@ -1411,23 +1428,6 @@ SCTP_STATIC __init int sctp_init(void) ...@@ -1411,23 +1428,6 @@ SCTP_STATIC __init int sctp_init(void)
pr_info("Hash tables configured (established %d bind %d)\n", pr_info("Hash tables configured (established %d bind %d)\n",
sctp_assoc_hashsize, sctp_port_hashsize); sctp_assoc_hashsize, sctp_port_hashsize);
/* Disable ADDIP by default. */
sctp_addip_enable = 0;
sctp_addip_noauth = 0;
sctp_default_auto_asconf = 0;
/* Enable PR-SCTP by default. */
sctp_prsctp_enable = 1;
/* Disable AUTH by default. */
sctp_auth_enable = 0;
/* Set SCOPE policy to enabled */
sctp_scope_policy = SCTP_SCOPE_POLICY_ENABLE;
/* Set the default rwnd update threshold */
sctp_rwnd_upd_shift = SCTP_DEFAULT_RWND_SHIFT;
sctp_sysctl_register(); sctp_sysctl_register();
INIT_LIST_HEAD(&sctp_address_families); INIT_LIST_HEAD(&sctp_address_families);
......
...@@ -198,6 +198,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, ...@@ -198,6 +198,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
const struct sctp_bind_addr *bp, const struct sctp_bind_addr *bp,
gfp_t gfp, int vparam_len) gfp_t gfp, int vparam_len)
{ {
struct net *net = sock_net(asoc->base.sk);
sctp_inithdr_t init; sctp_inithdr_t init;
union sctp_params addrs; union sctp_params addrs;
size_t chunksize; size_t chunksize;
...@@ -237,7 +238,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, ...@@ -237,7 +238,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
chunksize += WORD_ROUND(SCTP_SAT_LEN(num_types)); chunksize += WORD_ROUND(SCTP_SAT_LEN(num_types));
chunksize += sizeof(ecap_param); chunksize += sizeof(ecap_param);
if (sctp_prsctp_enable) if (net->sctp.prsctp_enable)
chunksize += sizeof(prsctp_param); chunksize += sizeof(prsctp_param);
/* ADDIP: Section 4.2.7: /* ADDIP: Section 4.2.7:
...@@ -245,7 +246,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, ...@@ -245,7 +246,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
* the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and
* INIT-ACK parameters. * INIT-ACK parameters.
*/ */
if (sctp_addip_enable) { if (net->sctp.addip_enable) {
extensions[num_ext] = SCTP_CID_ASCONF; extensions[num_ext] = SCTP_CID_ASCONF;
extensions[num_ext+1] = SCTP_CID_ASCONF_ACK; extensions[num_ext+1] = SCTP_CID_ASCONF_ACK;
num_ext += 2; num_ext += 2;
...@@ -257,7 +258,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, ...@@ -257,7 +258,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
chunksize += vparam_len; chunksize += vparam_len;
/* Account for AUTH related parameters */ /* Account for AUTH related parameters */
if (sctp_auth_enable) { if (net->sctp.auth_enable) {
/* Add random parameter length*/ /* Add random parameter length*/
chunksize += sizeof(asoc->c.auth_random); chunksize += sizeof(asoc->c.auth_random);
...@@ -331,7 +332,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, ...@@ -331,7 +332,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
sctp_addto_param(retval, num_ext, extensions); sctp_addto_param(retval, num_ext, extensions);
} }
if (sctp_prsctp_enable) if (net->sctp.prsctp_enable)
sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param);
if (sp->adaptation_ind) { if (sp->adaptation_ind) {
...@@ -342,7 +343,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, ...@@ -342,7 +343,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
} }
/* Add SCTP-AUTH chunks to the parameter list */ /* Add SCTP-AUTH chunks to the parameter list */
if (sctp_auth_enable) { if (net->sctp.auth_enable) {
sctp_addto_chunk(retval, sizeof(asoc->c.auth_random), sctp_addto_chunk(retval, sizeof(asoc->c.auth_random),
asoc->c.auth_random); asoc->c.auth_random);
if (auth_hmacs) if (auth_hmacs)
...@@ -1964,10 +1965,10 @@ static int sctp_verify_ext_param(struct net *net, union sctp_params param) ...@@ -1964,10 +1965,10 @@ static int sctp_verify_ext_param(struct net *net, union sctp_params param)
* only if ADD-IP is turned on and we are not backward-compatible * only if ADD-IP is turned on and we are not backward-compatible
* mode. * mode.
*/ */
if (sctp_addip_noauth) if (net->sctp.addip_noauth)
return 1; return 1;
if (sctp_addip_enable && !have_auth && have_asconf) if (net->sctp.addip_enable && !have_auth && have_asconf)
return 0; return 0;
return 1; return 1;
...@@ -1976,13 +1977,14 @@ static int sctp_verify_ext_param(struct net *net, union sctp_params param) ...@@ -1976,13 +1977,14 @@ static int sctp_verify_ext_param(struct net *net, union sctp_params param)
static void sctp_process_ext_param(struct sctp_association *asoc, static void sctp_process_ext_param(struct sctp_association *asoc,
union sctp_params param) union sctp_params param)
{ {
struct net *net = sock_net(asoc->base.sk);
__u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t); __u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t);
int i; int i;
for (i = 0; i < num_ext; i++) { for (i = 0; i < num_ext; i++) {
switch (param.ext->chunks[i]) { switch (param.ext->chunks[i]) {
case SCTP_CID_FWD_TSN: case SCTP_CID_FWD_TSN:
if (sctp_prsctp_enable && if (net->sctp.prsctp_enable &&
!asoc->peer.prsctp_capable) !asoc->peer.prsctp_capable)
asoc->peer.prsctp_capable = 1; asoc->peer.prsctp_capable = 1;
break; break;
...@@ -1990,12 +1992,12 @@ static void sctp_process_ext_param(struct sctp_association *asoc, ...@@ -1990,12 +1992,12 @@ static void sctp_process_ext_param(struct sctp_association *asoc,
/* if the peer reports AUTH, assume that he /* if the peer reports AUTH, assume that he
* supports AUTH. * supports AUTH.
*/ */
if (sctp_auth_enable) if (net->sctp.auth_enable)
asoc->peer.auth_capable = 1; asoc->peer.auth_capable = 1;
break; break;
case SCTP_CID_ASCONF: case SCTP_CID_ASCONF:
case SCTP_CID_ASCONF_ACK: case SCTP_CID_ASCONF_ACK:
if (sctp_addip_enable) if (net->sctp.addip_enable)
asoc->peer.asconf_capable = 1; asoc->peer.asconf_capable = 1;
break; break;
default: default:
...@@ -2116,7 +2118,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net, ...@@ -2116,7 +2118,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
break; break;
case SCTP_PARAM_SET_PRIMARY: case SCTP_PARAM_SET_PRIMARY:
if (sctp_addip_enable) if (net->sctp.addip_enable)
break; break;
goto fallthrough; goto fallthrough;
...@@ -2127,12 +2129,12 @@ static sctp_ierror_t sctp_verify_param(struct net *net, ...@@ -2127,12 +2129,12 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
break; break;
case SCTP_PARAM_FWD_TSN_SUPPORT: case SCTP_PARAM_FWD_TSN_SUPPORT:
if (sctp_prsctp_enable) if (net->sctp.prsctp_enable)
break; break;
goto fallthrough; goto fallthrough;
case SCTP_PARAM_RANDOM: case SCTP_PARAM_RANDOM:
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
goto fallthrough; goto fallthrough;
/* SCTP-AUTH: Secion 6.1 /* SCTP-AUTH: Secion 6.1
...@@ -2149,7 +2151,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net, ...@@ -2149,7 +2151,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
break; break;
case SCTP_PARAM_CHUNKS: case SCTP_PARAM_CHUNKS:
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
goto fallthrough; goto fallthrough;
/* SCTP-AUTH: Section 3.2 /* SCTP-AUTH: Section 3.2
...@@ -2165,7 +2167,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net, ...@@ -2165,7 +2167,7 @@ static sctp_ierror_t sctp_verify_param(struct net *net,
break; break;
case SCTP_PARAM_HMAC_ALGO: case SCTP_PARAM_HMAC_ALGO:
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
goto fallthrough; goto fallthrough;
hmacs = (struct sctp_hmac_algo_param *)param.p; hmacs = (struct sctp_hmac_algo_param *)param.p;
...@@ -2271,6 +2273,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, ...@@ -2271,6 +2273,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
const union sctp_addr *peer_addr, const union sctp_addr *peer_addr,
sctp_init_chunk_t *peer_init, gfp_t gfp) sctp_init_chunk_t *peer_init, gfp_t gfp)
{ {
struct net *net = sock_net(asoc->base.sk);
union sctp_params param; union sctp_params param;
struct sctp_transport *transport; struct sctp_transport *transport;
struct list_head *pos, *temp; struct list_head *pos, *temp;
...@@ -2327,7 +2330,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, ...@@ -2327,7 +2330,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
* also give us an option to silently ignore the packet, which * also give us an option to silently ignore the packet, which
* is what we'll do here. * is what we'll do here.
*/ */
if (!sctp_addip_noauth && if (!net->sctp.addip_noauth &&
(asoc->peer.asconf_capable && !asoc->peer.auth_capable)) { (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) {
asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP | asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP |
SCTP_PARAM_DEL_IP | SCTP_PARAM_DEL_IP |
...@@ -2502,7 +2505,7 @@ static int sctp_process_param(struct sctp_association *asoc, ...@@ -2502,7 +2505,7 @@ static int sctp_process_param(struct sctp_association *asoc,
break; break;
case SCTP_PARAM_COOKIE_PRESERVATIVE: case SCTP_PARAM_COOKIE_PRESERVATIVE:
if (!sctp_cookie_preserve_enable) if (!net->sctp.cookie_preserve_enable)
break; break;
stale = ntohl(param.life->lifespan_increment); stale = ntohl(param.life->lifespan_increment);
...@@ -2582,7 +2585,7 @@ static int sctp_process_param(struct sctp_association *asoc, ...@@ -2582,7 +2585,7 @@ static int sctp_process_param(struct sctp_association *asoc,
break; break;
case SCTP_PARAM_SET_PRIMARY: case SCTP_PARAM_SET_PRIMARY:
if (!sctp_addip_enable) if (!net->sctp.addip_enable)
goto fall_through; goto fall_through;
addr_param = param.v + sizeof(sctp_addip_param_t); addr_param = param.v + sizeof(sctp_addip_param_t);
...@@ -2609,7 +2612,7 @@ static int sctp_process_param(struct sctp_association *asoc, ...@@ -2609,7 +2612,7 @@ static int sctp_process_param(struct sctp_association *asoc,
break; break;
case SCTP_PARAM_FWD_TSN_SUPPORT: case SCTP_PARAM_FWD_TSN_SUPPORT:
if (sctp_prsctp_enable) { if (net->sctp.prsctp_enable) {
asoc->peer.prsctp_capable = 1; asoc->peer.prsctp_capable = 1;
break; break;
} }
...@@ -2617,7 +2620,7 @@ static int sctp_process_param(struct sctp_association *asoc, ...@@ -2617,7 +2620,7 @@ static int sctp_process_param(struct sctp_association *asoc,
goto fall_through; goto fall_through;
case SCTP_PARAM_RANDOM: case SCTP_PARAM_RANDOM:
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
goto fall_through; goto fall_through;
/* Save peer's random parameter */ /* Save peer's random parameter */
...@@ -2630,7 +2633,7 @@ static int sctp_process_param(struct sctp_association *asoc, ...@@ -2630,7 +2633,7 @@ static int sctp_process_param(struct sctp_association *asoc,
break; break;
case SCTP_PARAM_HMAC_ALGO: case SCTP_PARAM_HMAC_ALGO:
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
goto fall_through; goto fall_through;
/* Save peer's HMAC list */ /* Save peer's HMAC list */
...@@ -2646,7 +2649,7 @@ static int sctp_process_param(struct sctp_association *asoc, ...@@ -2646,7 +2649,7 @@ static int sctp_process_param(struct sctp_association *asoc,
break; break;
case SCTP_PARAM_CHUNKS: case SCTP_PARAM_CHUNKS:
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
goto fall_through; goto fall_through;
asoc->peer.peer_chunks = kmemdup(param.p, asoc->peer.peer_chunks = kmemdup(param.p,
......
...@@ -3586,7 +3586,7 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net, ...@@ -3586,7 +3586,7 @@ sctp_disposition_t sctp_sf_do_asconf(struct net *net,
* is received unauthenticated it MUST be silently discarded as * is received unauthenticated it MUST be silently discarded as
* described in [I-D.ietf-tsvwg-sctp-auth]. * described in [I-D.ietf-tsvwg-sctp-auth].
*/ */
if (!sctp_addip_noauth && !chunk->auth) if (!net->sctp.addip_noauth && !chunk->auth)
return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
/* Make sure that the ASCONF ADDIP chunk has a valid length. */ /* Make sure that the ASCONF ADDIP chunk has a valid length. */
...@@ -3713,7 +3713,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, ...@@ -3713,7 +3713,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net,
* is received unauthenticated it MUST be silently discarded as * is received unauthenticated it MUST be silently discarded as
* described in [I-D.ietf-tsvwg-sctp-auth]. * described in [I-D.ietf-tsvwg-sctp-auth].
*/ */
if (!sctp_addip_noauth && !asconf_ack->auth) if (!net->sctp.addip_noauth && !asconf_ack->auth)
return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands);
/* Make sure that the ADDIP chunk has a valid length. */ /* Make sure that the ADDIP chunk has a valid length. */
......
...@@ -918,12 +918,12 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net, ...@@ -918,12 +918,12 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
if (cid <= SCTP_CID_BASE_MAX) if (cid <= SCTP_CID_BASE_MAX)
return &chunk_event_table[cid][state]; return &chunk_event_table[cid][state];
if (sctp_prsctp_enable) { if (net->sctp.prsctp_enable) {
if (cid == SCTP_CID_FWD_TSN) if (cid == SCTP_CID_FWD_TSN)
return &prsctp_chunk_event_table[0][state]; return &prsctp_chunk_event_table[0][state];
} }
if (sctp_addip_enable) { if (net->sctp.addip_enable) {
if (cid == SCTP_CID_ASCONF) if (cid == SCTP_CID_ASCONF)
return &addip_chunk_event_table[0][state]; return &addip_chunk_event_table[0][state];
...@@ -931,7 +931,7 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net, ...@@ -931,7 +931,7 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
return &addip_chunk_event_table[1][state]; return &addip_chunk_event_table[1][state];
} }
if (sctp_auth_enable) { if (net->sctp.auth_enable) {
if (cid == SCTP_CID_AUTH) if (cid == SCTP_CID_AUTH)
return &auth_chunk_event_table[0][state]; return &auth_chunk_event_table[0][state];
} }
......
...@@ -516,6 +516,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk, ...@@ -516,6 +516,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
struct sockaddr *addrs, struct sockaddr *addrs,
int addrcnt) int addrcnt)
{ {
struct net *net = sock_net(sk);
struct sctp_sock *sp; struct sctp_sock *sp;
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
struct sctp_association *asoc; struct sctp_association *asoc;
...@@ -530,7 +531,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk, ...@@ -530,7 +531,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
int i; int i;
int retval = 0; int retval = 0;
if (!sctp_addip_enable) if (!net->sctp.addip_enable)
return retval; return retval;
sp = sctp_sk(sk); sp = sctp_sk(sk);
...@@ -718,6 +719,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk, ...@@ -718,6 +719,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
struct sockaddr *addrs, struct sockaddr *addrs,
int addrcnt) int addrcnt)
{ {
struct net *net = sock_net(sk);
struct sctp_sock *sp; struct sctp_sock *sp;
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
struct sctp_association *asoc; struct sctp_association *asoc;
...@@ -733,7 +735,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk, ...@@ -733,7 +735,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
int stored = 0; int stored = 0;
chunk = NULL; chunk = NULL;
if (!sctp_addip_enable) if (!net->sctp.addip_enable)
return retval; return retval;
sp = sctp_sk(sk); sp = sctp_sk(sk);
...@@ -3039,6 +3041,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned ...@@ -3039,6 +3041,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval, static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval,
unsigned int optlen) unsigned int optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_sock *sp; struct sctp_sock *sp;
struct sctp_association *asoc = NULL; struct sctp_association *asoc = NULL;
struct sctp_setpeerprim prim; struct sctp_setpeerprim prim;
...@@ -3048,7 +3051,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva ...@@ -3048,7 +3051,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
sp = sctp_sk(sk); sp = sctp_sk(sk);
if (!sctp_addip_enable) if (!net->sctp.addip_enable)
return -EPERM; return -EPERM;
if (optlen != sizeof(struct sctp_setpeerprim)) if (optlen != sizeof(struct sctp_setpeerprim))
...@@ -3285,9 +3288,10 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, ...@@ -3285,9 +3288,10 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk,
char __user *optval, char __user *optval,
unsigned int optlen) unsigned int optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_authchunk val; struct sctp_authchunk val;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (optlen != sizeof(struct sctp_authchunk)) if (optlen != sizeof(struct sctp_authchunk))
...@@ -3317,11 +3321,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, ...@@ -3317,11 +3321,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk,
char __user *optval, char __user *optval,
unsigned int optlen) unsigned int optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_hmacalgo *hmacs; struct sctp_hmacalgo *hmacs;
u32 idents; u32 idents;
int err; int err;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (optlen < sizeof(struct sctp_hmacalgo)) if (optlen < sizeof(struct sctp_hmacalgo))
...@@ -3354,11 +3359,12 @@ static int sctp_setsockopt_auth_key(struct sock *sk, ...@@ -3354,11 +3359,12 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
char __user *optval, char __user *optval,
unsigned int optlen) unsigned int optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_authkey *authkey; struct sctp_authkey *authkey;
struct sctp_association *asoc; struct sctp_association *asoc;
int ret; int ret;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (optlen <= sizeof(struct sctp_authkey)) if (optlen <= sizeof(struct sctp_authkey))
...@@ -3395,10 +3401,11 @@ static int sctp_setsockopt_active_key(struct sock *sk, ...@@ -3395,10 +3401,11 @@ static int sctp_setsockopt_active_key(struct sock *sk,
char __user *optval, char __user *optval,
unsigned int optlen) unsigned int optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_authkeyid val; struct sctp_authkeyid val;
struct sctp_association *asoc; struct sctp_association *asoc;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (optlen != sizeof(struct sctp_authkeyid)) if (optlen != sizeof(struct sctp_authkeyid))
...@@ -3423,10 +3430,11 @@ static int sctp_setsockopt_del_key(struct sock *sk, ...@@ -3423,10 +3430,11 @@ static int sctp_setsockopt_del_key(struct sock *sk,
char __user *optval, char __user *optval,
unsigned int optlen) unsigned int optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_authkeyid val; struct sctp_authkeyid val;
struct sctp_association *asoc; struct sctp_association *asoc;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (optlen != sizeof(struct sctp_authkeyid)) if (optlen != sizeof(struct sctp_authkeyid))
...@@ -3849,6 +3857,7 @@ SCTP_STATIC int sctp_ioctl(struct sock *sk, int cmd, unsigned long arg) ...@@ -3849,6 +3857,7 @@ SCTP_STATIC int sctp_ioctl(struct sock *sk, int cmd, unsigned long arg)
*/ */
SCTP_STATIC int sctp_init_sock(struct sock *sk) SCTP_STATIC int sctp_init_sock(struct sock *sk)
{ {
struct net *net = sock_net(sk);
struct sctp_endpoint *ep; struct sctp_endpoint *ep;
struct sctp_sock *sp; struct sctp_sock *sp;
...@@ -3878,7 +3887,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) ...@@ -3878,7 +3887,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
sp->default_timetolive = 0; sp->default_timetolive = 0;
sp->default_rcv_context = 0; sp->default_rcv_context = 0;
sp->max_burst = sctp_max_burst; sp->max_burst = net->sctp.max_burst;
/* Initialize default setup parameters. These parameters /* Initialize default setup parameters. These parameters
* can be modified with the SCTP_INITMSG socket option or * can be modified with the SCTP_INITMSG socket option or
...@@ -3886,24 +3895,24 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) ...@@ -3886,24 +3895,24 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
*/ */
sp->initmsg.sinit_num_ostreams = sctp_max_outstreams; sp->initmsg.sinit_num_ostreams = sctp_max_outstreams;
sp->initmsg.sinit_max_instreams = sctp_max_instreams; sp->initmsg.sinit_max_instreams = sctp_max_instreams;
sp->initmsg.sinit_max_attempts = sctp_max_retrans_init; sp->initmsg.sinit_max_attempts = net->sctp.max_retrans_init;
sp->initmsg.sinit_max_init_timeo = sctp_rto_max; sp->initmsg.sinit_max_init_timeo = net->sctp.rto_max;
/* Initialize default RTO related parameters. These parameters can /* Initialize default RTO related parameters. These parameters can
* be modified for with the SCTP_RTOINFO socket option. * be modified for with the SCTP_RTOINFO socket option.
*/ */
sp->rtoinfo.srto_initial = sctp_rto_initial; sp->rtoinfo.srto_initial = net->sctp.rto_initial;
sp->rtoinfo.srto_max = sctp_rto_max; sp->rtoinfo.srto_max = net->sctp.rto_max;
sp->rtoinfo.srto_min = sctp_rto_min; sp->rtoinfo.srto_min = net->sctp.rto_min;
/* Initialize default association related parameters. These parameters /* Initialize default association related parameters. These parameters
* can be modified with the SCTP_ASSOCINFO socket option. * can be modified with the SCTP_ASSOCINFO socket option.
*/ */
sp->assocparams.sasoc_asocmaxrxt = sctp_max_retrans_association; sp->assocparams.sasoc_asocmaxrxt = net->sctp.max_retrans_association;
sp->assocparams.sasoc_number_peer_destinations = 0; sp->assocparams.sasoc_number_peer_destinations = 0;
sp->assocparams.sasoc_peer_rwnd = 0; sp->assocparams.sasoc_peer_rwnd = 0;
sp->assocparams.sasoc_local_rwnd = 0; sp->assocparams.sasoc_local_rwnd = 0;
sp->assocparams.sasoc_cookie_life = sctp_valid_cookie_life; sp->assocparams.sasoc_cookie_life = net->sctp.valid_cookie_life;
/* Initialize default event subscriptions. By default, all the /* Initialize default event subscriptions. By default, all the
* options are off. * options are off.
...@@ -3913,10 +3922,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) ...@@ -3913,10 +3922,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
/* Default Peer Address Parameters. These defaults can /* Default Peer Address Parameters. These defaults can
* be modified via SCTP_PEER_ADDR_PARAMS * be modified via SCTP_PEER_ADDR_PARAMS
*/ */
sp->hbinterval = sctp_hb_interval; sp->hbinterval = net->sctp.hb_interval;
sp->pathmaxrxt = sctp_max_retrans_path; sp->pathmaxrxt = net->sctp.max_retrans_path;
sp->pathmtu = 0; // allow default discovery sp->pathmtu = 0; // allow default discovery
sp->sackdelay = sctp_sack_timeout; sp->sackdelay = net->sctp.sack_timeout;
sp->sackfreq = 2; sp->sackfreq = 2;
sp->param_flags = SPP_HB_ENABLE | sp->param_flags = SPP_HB_ENABLE |
SPP_PMTUD_ENABLE | SPP_PMTUD_ENABLE |
...@@ -3967,10 +3976,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) ...@@ -3967,10 +3976,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
local_bh_disable(); local_bh_disable();
percpu_counter_inc(&sctp_sockets_allocated); percpu_counter_inc(&sctp_sockets_allocated);
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); sock_prot_inuse_add(net, sk->sk_prot, 1);
if (sctp_default_auto_asconf) { if (net->sctp.default_auto_asconf) {
list_add_tail(&sp->auto_asconf_list, list_add_tail(&sp->auto_asconf_list,
&sock_net(sk)->sctp.auto_asconf_splist); &net->sctp.auto_asconf_splist);
sp->do_auto_asconf = 1; sp->do_auto_asconf = 1;
} else } else
sp->do_auto_asconf = 0; sp->do_auto_asconf = 0;
...@@ -5307,12 +5316,13 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len, ...@@ -5307,12 +5316,13 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_hmacalgo __user *p = (void __user *)optval; struct sctp_hmacalgo __user *p = (void __user *)optval;
struct sctp_hmac_algo_param *hmacs; struct sctp_hmac_algo_param *hmacs;
__u16 data_len = 0; __u16 data_len = 0;
u32 num_idents; u32 num_idents;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
hmacs = sctp_sk(sk)->ep->auth_hmacs_list; hmacs = sctp_sk(sk)->ep->auth_hmacs_list;
...@@ -5336,10 +5346,11 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, ...@@ -5336,10 +5346,11 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len,
static int sctp_getsockopt_active_key(struct sock *sk, int len, static int sctp_getsockopt_active_key(struct sock *sk, int len,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_authkeyid val; struct sctp_authkeyid val;
struct sctp_association *asoc; struct sctp_association *asoc;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (len < sizeof(struct sctp_authkeyid)) if (len < sizeof(struct sctp_authkeyid))
...@@ -5368,6 +5379,7 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len, ...@@ -5368,6 +5379,7 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len,
static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_authchunks __user *p = (void __user *)optval; struct sctp_authchunks __user *p = (void __user *)optval;
struct sctp_authchunks val; struct sctp_authchunks val;
struct sctp_association *asoc; struct sctp_association *asoc;
...@@ -5375,7 +5387,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, ...@@ -5375,7 +5387,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
u32 num_chunks = 0; u32 num_chunks = 0;
char __user *to; char __user *to;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (len < sizeof(struct sctp_authchunks)) if (len < sizeof(struct sctp_authchunks))
...@@ -5411,6 +5423,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, ...@@ -5411,6 +5423,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,
static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
char __user *optval, int __user *optlen) char __user *optval, int __user *optlen)
{ {
struct net *net = sock_net(sk);
struct sctp_authchunks __user *p = (void __user *)optval; struct sctp_authchunks __user *p = (void __user *)optval;
struct sctp_authchunks val; struct sctp_authchunks val;
struct sctp_association *asoc; struct sctp_association *asoc;
...@@ -5418,7 +5431,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, ...@@ -5418,7 +5431,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len,
u32 num_chunks = 0; u32 num_chunks = 0;
char __user *to; char __user *to;
if (!sctp_auth_enable) if (!net->sctp.auth_enable)
return -EACCES; return -EACCES;
if (len < sizeof(struct sctp_authchunks)) if (len < sizeof(struct sctp_authchunks))
......
...@@ -63,9 +63,35 @@ extern int sysctl_sctp_rmem[3]; ...@@ -63,9 +63,35 @@ extern int sysctl_sctp_rmem[3];
extern int sysctl_sctp_wmem[3]; extern int sysctl_sctp_wmem[3];
static ctl_table sctp_table[] = { static ctl_table sctp_table[] = {
{
.procname = "sctp_mem",
.data = &sysctl_sctp_mem,
.maxlen = sizeof(sysctl_sctp_mem),
.mode = 0644,
.proc_handler = proc_doulongvec_minmax
},
{
.procname = "sctp_rmem",
.data = &sysctl_sctp_rmem,
.maxlen = sizeof(sysctl_sctp_rmem),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "sctp_wmem",
.data = &sysctl_sctp_wmem,
.maxlen = sizeof(sysctl_sctp_wmem),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{ /* sentinel */ }
};
static ctl_table sctp_net_table[] = {
{ {
.procname = "rto_initial", .procname = "rto_initial",
.data = &sctp_rto_initial, .data = &init_net.sctp.rto_initial,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(unsigned int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
...@@ -74,7 +100,7 @@ static ctl_table sctp_table[] = { ...@@ -74,7 +100,7 @@ static ctl_table sctp_table[] = {
}, },
{ {
.procname = "rto_min", .procname = "rto_min",
.data = &sctp_rto_min, .data = &init_net.sctp.rto_min,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(unsigned int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
...@@ -83,7 +109,7 @@ static ctl_table sctp_table[] = { ...@@ -83,7 +109,7 @@ static ctl_table sctp_table[] = {
}, },
{ {
.procname = "rto_max", .procname = "rto_max",
.data = &sctp_rto_max, .data = &init_net.sctp.rto_max,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(unsigned int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
...@@ -91,17 +117,22 @@ static ctl_table sctp_table[] = { ...@@ -91,17 +117,22 @@ static ctl_table sctp_table[] = {
.extra2 = &timer_max .extra2 = &timer_max
}, },
{ {
.procname = "valid_cookie_life", .procname = "rto_alpha_exp_divisor",
.data = &sctp_valid_cookie_life, .data = &init_net.sctp.rto_alpha,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0444,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec,
.extra1 = &one, },
.extra2 = &timer_max {
.procname = "rto_beta_exp_divisor",
.data = &init_net.sctp.rto_beta,
.maxlen = sizeof(int),
.mode = 0444,
.proc_handler = proc_dointvec,
}, },
{ {
.procname = "max_burst", .procname = "max_burst",
.data = &sctp_max_burst, .data = &init_net.sctp.max_burst,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
...@@ -109,31 +140,42 @@ static ctl_table sctp_table[] = { ...@@ -109,31 +140,42 @@ static ctl_table sctp_table[] = {
.extra2 = &int_max .extra2 = &int_max
}, },
{ {
.procname = "association_max_retrans", .procname = "cookie_preserve_enable",
.data = &sctp_max_retrans_association, .data = &init_net.sctp.cookie_preserve_enable,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "valid_cookie_life",
.data = &init_net.sctp.valid_cookie_life,
.maxlen = sizeof(unsigned int),
.mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &one, .extra1 = &one,
.extra2 = &int_max .extra2 = &timer_max
}, },
{ {
.procname = "sndbuf_policy", .procname = "sack_timeout",
.data = &sctp_sndbuf_policy, .data = &init_net.sctp.sack_timeout,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &sack_timer_min,
.extra2 = &sack_timer_max,
}, },
{ {
.procname = "rcvbuf_policy", .procname = "hb_interval",
.data = &sctp_rcvbuf_policy, .data = &init_net.sctp.hb_interval,
.maxlen = sizeof(int), .maxlen = sizeof(unsigned int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec_minmax,
.extra1 = &one,
.extra2 = &timer_max
}, },
{ {
.procname = "path_max_retrans", .procname = "association_max_retrans",
.data = &sctp_max_retrans_path, .data = &init_net.sctp.max_retrans_association,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
...@@ -141,17 +183,17 @@ static ctl_table sctp_table[] = { ...@@ -141,17 +183,17 @@ static ctl_table sctp_table[] = {
.extra2 = &int_max .extra2 = &int_max
}, },
{ {
.procname = "pf_retrans", .procname = "path_max_retrans",
.data = &sctp_pf_retrans, .data = &init_net.sctp.max_retrans_path,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &zero, .extra1 = &one,
.extra2 = &int_max .extra2 = &int_max
}, },
{ {
.procname = "max_init_retransmits", .procname = "max_init_retransmits",
.data = &sctp_max_retrans_init, .data = &init_net.sctp.max_retrans_init,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
...@@ -159,103 +201,66 @@ static ctl_table sctp_table[] = { ...@@ -159,103 +201,66 @@ static ctl_table sctp_table[] = {
.extra2 = &int_max .extra2 = &int_max
}, },
{ {
.procname = "hb_interval", .procname = "pf_retrans",
.data = &sctp_hb_interval, .data = &init_net.sctp.pf_retrans,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
.extra1 = &one, .extra1 = &zero,
.extra2 = &timer_max .extra2 = &int_max
}, },
{ {
.procname = "cookie_preserve_enable", .procname = "sndbuf_policy",
.data = &sctp_cookie_preserve_enable, .data = &init_net.sctp.sndbuf_policy,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec,
}, },
{ {
.procname = "rto_alpha_exp_divisor", .procname = "rcvbuf_policy",
.data = &sctp_rto_alpha, .data = &init_net.sctp.rcvbuf_policy,
.maxlen = sizeof(int),
.mode = 0444,
.proc_handler = proc_dointvec,
},
{
.procname = "rto_beta_exp_divisor",
.data = &sctp_rto_beta,
.maxlen = sizeof(int),
.mode = 0444,
.proc_handler = proc_dointvec,
},
{
.procname = "addip_enable",
.data = &sctp_addip_enable,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec,
}, },
{ {
.procname = "default_auto_asconf", .procname = "default_auto_asconf",
.data = &sctp_default_auto_asconf, .data = &init_net.sctp.default_auto_asconf,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec,
}, },
{ {
.procname = "prsctp_enable", .procname = "addip_enable",
.data = &sctp_prsctp_enable, .data = &init_net.sctp.addip_enable,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec,
}, },
{ {
.procname = "sack_timeout", .procname = "addip_noauth_enable",
.data = &sctp_sack_timeout, .data = &init_net.sctp.addip_noauth,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax,
.extra1 = &sack_timer_min,
.extra2 = &sack_timer_max,
},
{
.procname = "sctp_mem",
.data = &sysctl_sctp_mem,
.maxlen = sizeof(sysctl_sctp_mem),
.mode = 0644,
.proc_handler = proc_doulongvec_minmax
},
{
.procname = "sctp_rmem",
.data = &sysctl_sctp_rmem,
.maxlen = sizeof(sysctl_sctp_rmem),
.mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec,
}, },
{ {
.procname = "sctp_wmem", .procname = "prsctp_enable",
.data = &sysctl_sctp_wmem, .data = &init_net.sctp.prsctp_enable,
.maxlen = sizeof(sysctl_sctp_wmem),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.procname = "auth_enable",
.data = &sctp_auth_enable,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec,
}, },
{ {
.procname = "addip_noauth_enable", .procname = "auth_enable",
.data = &sctp_addip_noauth, .data = &init_net.sctp.auth_enable,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec, .proc_handler = proc_dointvec,
}, },
{ {
.procname = "addr_scope_policy", .procname = "addr_scope_policy",
.data = &sctp_scope_policy, .data = &init_net.sctp.scope_policy,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = proc_dointvec_minmax, .proc_handler = proc_dointvec_minmax,
...@@ -264,7 +269,7 @@ static ctl_table sctp_table[] = { ...@@ -264,7 +269,7 @@ static ctl_table sctp_table[] = {
}, },
{ {
.procname = "rwnd_update_shift", .procname = "rwnd_update_shift",
.data = &sctp_rwnd_upd_shift, .data = &init_net.sctp.rwnd_upd_shift,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_minmax, .proc_handler = &proc_dointvec_minmax,
...@@ -273,7 +278,7 @@ static ctl_table sctp_table[] = { ...@@ -273,7 +278,7 @@ static ctl_table sctp_table[] = {
}, },
{ {
.procname = "max_autoclose", .procname = "max_autoclose",
.data = &sctp_max_autoclose, .data = &init_net.sctp.max_autoclose,
.maxlen = sizeof(unsigned long), .maxlen = sizeof(unsigned long),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_doulongvec_minmax, .proc_handler = &proc_doulongvec_minmax,
...@@ -284,18 +289,18 @@ static ctl_table sctp_table[] = { ...@@ -284,18 +289,18 @@ static ctl_table sctp_table[] = {
{ /* sentinel */ } { /* sentinel */ }
}; };
static ctl_table sctp_net_table[] = {
{ /* sentinel */ }
};
int sctp_sysctl_net_register(struct net *net) int sctp_sysctl_net_register(struct net *net)
{ {
struct ctl_table *table; struct ctl_table *table;
int i;
table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
if (!table) if (!table)
return -ENOMEM; return -ENOMEM;
for (i = 0; table[i].data; i++)
table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp;
net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table);
return 0; return 0;
} }
......
...@@ -77,7 +77,7 @@ static struct sctp_transport *sctp_transport_init(struct net *net, ...@@ -77,7 +77,7 @@ static struct sctp_transport *sctp_transport_init(struct net *net,
* given destination transport address, set RTO to the protocol * given destination transport address, set RTO to the protocol
* parameter 'RTO.Initial'. * parameter 'RTO.Initial'.
*/ */
peer->rto = msecs_to_jiffies(sctp_rto_initial); peer->rto = msecs_to_jiffies(net->sctp.rto_initial);
peer->last_time_heard = jiffies; peer->last_time_heard = jiffies;
peer->last_time_ecne_reduced = jiffies; peer->last_time_ecne_reduced = jiffies;
...@@ -87,8 +87,8 @@ static struct sctp_transport *sctp_transport_init(struct net *net, ...@@ -87,8 +87,8 @@ static struct sctp_transport *sctp_transport_init(struct net *net,
SPP_SACKDELAY_ENABLE; SPP_SACKDELAY_ENABLE;
/* Initialize the default path max_retrans. */ /* Initialize the default path max_retrans. */
peer->pathmaxrxt = sctp_max_retrans_path; peer->pathmaxrxt = net->sctp.max_retrans_path;
peer->pf_retrans = sctp_pf_retrans; peer->pf_retrans = net->sctp.pf_retrans;
INIT_LIST_HEAD(&peer->transmitted); INIT_LIST_HEAD(&peer->transmitted);
INIT_LIST_HEAD(&peer->send_ready); INIT_LIST_HEAD(&peer->send_ready);
...@@ -318,6 +318,7 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) ...@@ -318,6 +318,7 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
SCTP_ASSERT(tp->rto_pending, "rto_pending not set", return); SCTP_ASSERT(tp->rto_pending, "rto_pending not set", return);
if (tp->rttvar || tp->srtt) { if (tp->rttvar || tp->srtt) {
struct net *net = sock_net(tp->asoc->base.sk);
/* 6.3.1 C3) When a new RTT measurement R' is made, set /* 6.3.1 C3) When a new RTT measurement R' is made, set
* RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'| * RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'|
* SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R' * SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R'
...@@ -329,10 +330,10 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) ...@@ -329,10 +330,10 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
* For example, assuming the default value of RTO.Alpha of * For example, assuming the default value of RTO.Alpha of
* 1/8, rto_alpha would be expressed as 3. * 1/8, rto_alpha would be expressed as 3.
*/ */
tp->rttvar = tp->rttvar - (tp->rttvar >> sctp_rto_beta) tp->rttvar = tp->rttvar - (tp->rttvar >> net->sctp.rto_beta)
+ ((abs(tp->srtt - rtt)) >> sctp_rto_beta); + ((abs(tp->srtt - rtt)) >> net->sctp.rto_beta);
tp->srtt = tp->srtt - (tp->srtt >> sctp_rto_alpha) tp->srtt = tp->srtt - (tp->srtt >> net->sctp.rto_alpha)
+ (rtt >> sctp_rto_alpha); + (rtt >> net->sctp.rto_alpha);
} else { } else {
/* 6.3.1 C2) When the first RTT measurement R is made, set /* 6.3.1 C2) When the first RTT measurement R is made, set
* SRTT <- R, RTTVAR <- R/2. * SRTT <- R, RTTVAR <- R/2.
......
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