Commit 139b2566 authored by Sridhar Samudrala's avatar Sridhar Samudrala

[SCTP] Rename struct sctp_protocol as struct sctp_globals and define

       macros for all the global fields in the structure.

This is to avoid the confusion with the static variable sctp_protocol
of type struct inet_protocol. Also fixes some calls that pass the
global variable as an argument.
parent c2052b27
...@@ -119,12 +119,10 @@ ...@@ -119,12 +119,10 @@
*/ */
/* /*
* sctp_protocol.c * sctp/protocol.c
*/ */
extern struct sctp_protocol sctp_proto;
extern struct sock *sctp_get_ctl_sock(void); extern struct sock *sctp_get_ctl_sock(void);
extern int sctp_copy_local_addr_list(struct sctp_protocol *, extern int sctp_copy_local_addr_list(struct sctp_bind_addr *,
struct sctp_bind_addr *,
sctp_scope_t, int gfp, int flags); sctp_scope_t, int gfp, int flags);
extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family);
extern int sctp_register_pf(struct sctp_pf *, sa_family_t); extern int sctp_register_pf(struct sctp_pf *, sa_family_t);
...@@ -504,12 +502,6 @@ void sctp_put_port(struct sock *sk); ...@@ -504,12 +502,6 @@ void sctp_put_port(struct sock *sk);
/* Static inline functions. */ /* Static inline functions. */
/* Return the SCTP protocol structure. */
static inline struct sctp_protocol *sctp_get_protocol(void)
{
return &sctp_proto;
}
/* Convert from an IP version number to an Address Family symbol. */ /* Convert from an IP version number to an Address Family symbol. */
static inline int ipver2af(__u8 ipver) static inline int ipver2af(__u8 ipver)
{ {
...@@ -537,24 +529,21 @@ static inline int sctp_sanity_check(void) ...@@ -537,24 +529,21 @@ static inline int sctp_sanity_check(void)
/* This is the hash function for the SCTP port hash table. */ /* This is the hash function for the SCTP port hash table. */
static inline int sctp_phashfn(__u16 lport) static inline int sctp_phashfn(__u16 lport)
{ {
struct sctp_protocol *sctp_proto = sctp_get_protocol(); return (lport & (sctp_port_hashsize - 1));
return (lport & (sctp_proto->port_hashsize - 1));
} }
/* This is the hash function for the endpoint hash table. */ /* This is the hash function for the endpoint hash table. */
static inline int sctp_ep_hashfn(__u16 lport) static inline int sctp_ep_hashfn(__u16 lport)
{ {
struct sctp_protocol *sctp_proto = sctp_get_protocol(); return (lport & (sctp_ep_hashsize - 1));
return (lport & (sctp_proto->ep_hashsize - 1));
} }
/* This is the hash function for the association hash table. */ /* This is the hash function for the association hash table. */
static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport) static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport)
{ {
struct sctp_protocol *sctp_proto = sctp_get_protocol();
int h = (lport << 16) + rport; int h = (lport << 16) + rport;
h ^= h>>8; h ^= h>>8;
return (h & (sctp_proto->assoc_hashsize - 1)); return (h & (sctp_assoc_hashsize - 1));
} }
/* This is the hash function for the association hash table. This is /* This is the hash function for the association hash table. This is
...@@ -563,10 +552,9 @@ static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport) ...@@ -563,10 +552,9 @@ static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport)
*/ */
static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag) static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
{ {
struct sctp_protocol *sctp_proto = sctp_get_protocol();
int h = (lport << 16) + rport; int h = (lport << 16) + rport;
h ^= vtag; h ^= vtag;
return (h & (sctp_proto->assoc_hashsize-1)); return (h & (sctp_assoc_hashsize-1));
} }
/* WARNING: Do not change the layout of the members in sctp_sock! */ /* WARNING: Do not change the layout of the members in sctp_sock! */
......
...@@ -71,7 +71,7 @@ union sctp_addr { ...@@ -71,7 +71,7 @@ union sctp_addr {
}; };
/* Forward declarations for data structures. */ /* Forward declarations for data structures. */
struct sctp_protocol; struct sctp_globals;
struct sctp_endpoint; struct sctp_endpoint;
struct sctp_association; struct sctp_association;
struct sctp_transport; struct sctp_transport;
...@@ -112,8 +112,8 @@ struct sctp_hashbucket { ...@@ -112,8 +112,8 @@ struct sctp_hashbucket {
} __attribute__((__aligned__(8))); } __attribute__((__aligned__(8)));
/* The SCTP protocol structure. */ /* The SCTP globals structure. */
struct sctp_protocol { extern struct sctp_globals {
/* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values
* *
* The following protocol parameters are RECOMMENDED: * The following protocol parameters are RECOMMENDED:
...@@ -187,8 +187,33 @@ struct sctp_protocol { ...@@ -187,8 +187,33 @@ struct sctp_protocol {
*/ */
struct list_head local_addr_list; struct list_head local_addr_list;
spinlock_t local_addr_lock; spinlock_t local_addr_lock;
}; } 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_max_retrans_path (sctp_globals.max_retrans_path)
#define sctp_max_retrans_init (sctp_globals.max_retrans_init)
#define sctp_hb_interval (sctp_globals.hb_interval)
#define sctp_max_instreams (sctp_globals.max_instreams)
#define sctp_max_outstreams (sctp_globals.max_outstreams)
#define sctp_address_families (sctp_globals.address_families)
#define sctp_ep_hashsize (sctp_globals.ep_hashsize)
#define sctp_ep_hashbucket (sctp_globals.ep_hashbucket)
#define sctp_assoc_hashsize (sctp_globals.assoc_hashsize)
#define sctp_assoc_hashbucket (sctp_globals.assoc_hashbucket)
#define sctp_port_hashsize (sctp_globals.port_hashsize)
#define sctp_port_rover (sctp_globals.port_rover)
#define sctp_port_alloc_lock (sctp_globals.port_alloc_lock)
#define sctp_port_hashtable (sctp_globals.port_hashtable)
#define sctp_local_addr_list (sctp_globals.local_addr_list)
#define sctp_local_addr_lock (sctp_globals.local_addr_lock)
/* /*
* Pointers to address related SCTP functions. * Pointers to address related SCTP functions.
......
...@@ -96,7 +96,6 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc, ...@@ -96,7 +96,6 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc,
int gfp) int gfp)
{ {
struct sctp_opt *sp; struct sctp_opt *sp;
struct sctp_protocol *proto = sctp_get_protocol();
int i; int i;
/* Retrieve the SCTP per socket area. */ /* Retrieve the SCTP per socket area. */
...@@ -129,18 +128,18 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc, ...@@ -129,18 +128,18 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc,
asoc->state_timestamp = jiffies; asoc->state_timestamp = jiffies;
/* Set things that have constant value. */ /* Set things that have constant value. */
asoc->cookie_life.tv_sec = sctp_proto.valid_cookie_life / HZ; asoc->cookie_life.tv_sec = sctp_valid_cookie_life / HZ;
asoc->cookie_life.tv_usec = (sctp_proto.valid_cookie_life % HZ) * asoc->cookie_life.tv_usec = (sctp_valid_cookie_life % HZ) *
1000000L / HZ; 1000000L / HZ;
asoc->pmtu = 0; asoc->pmtu = 0;
asoc->frag_point = 0; asoc->frag_point = 0;
/* Initialize the default association max_retrans and RTO values. */ /* Initialize the default association max_retrans and RTO values. */
asoc->max_retrans = proto->max_retrans_association; asoc->max_retrans = sctp_max_retrans_association;
asoc->rto_initial = proto->rto_initial; asoc->rto_initial = sctp_rto_initial;
asoc->rto_max = proto->rto_max; asoc->rto_max = sctp_rto_max;
asoc->rto_min = proto->rto_min; asoc->rto_min = sctp_rto_min;
asoc->overall_error_threshold = asoc->max_retrans; asoc->overall_error_threshold = asoc->max_retrans;
asoc->overall_error_count = 0; asoc->overall_error_count = 0;
...@@ -148,7 +147,7 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc, ...@@ -148,7 +147,7 @@ struct sctp_association *sctp_association_init(struct sctp_association *asoc,
/* Initialize the maximum mumber of new data packets that can be sent /* Initialize the maximum mumber of new data packets that can be sent
* in a burst. * in a burst.
*/ */
asoc->max_burst = proto->max_burst; asoc->max_burst = sctp_max_burst;
/* Copy things from the endpoint. */ /* Copy things from the endpoint. */
for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) { for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) {
......
...@@ -329,12 +329,10 @@ static int sctp_copy_one_addr(struct sctp_bind_addr *dest, ...@@ -329,12 +329,10 @@ static int sctp_copy_one_addr(struct sctp_bind_addr *dest,
union sctp_addr *addr, union sctp_addr *addr,
sctp_scope_t scope, int gfp, int flags) sctp_scope_t scope, int gfp, int flags)
{ {
struct sctp_protocol *proto = sctp_get_protocol();
int error = 0; int error = 0;
if (sctp_is_any(addr)) { if (sctp_is_any(addr)) {
error = sctp_copy_local_addr_list(proto, dest, scope, error = sctp_copy_local_addr_list(dest, scope, gfp, flags);
gfp, flags);
} else if (sctp_in_scope(addr, scope)) { } else if (sctp_in_scope(addr, scope)) {
/* Now that the address is in scope, check to see if /* Now that the address is in scope, check to see if
* the address type is supported by local sock as * the address type is supported by local sock as
......
...@@ -528,7 +528,7 @@ void __sctp_hash_endpoint(struct sctp_endpoint *ep) ...@@ -528,7 +528,7 @@ void __sctp_hash_endpoint(struct sctp_endpoint *ep)
epb = &ep->base; epb = &ep->base;
epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
head = &sctp_proto.ep_hashbucket[epb->hashent]; head = &sctp_ep_hashbucket[epb->hashent];
sctp_write_lock(&head->lock); sctp_write_lock(&head->lock);
epp = &head->chain; epp = &head->chain;
...@@ -558,7 +558,7 @@ void __sctp_unhash_endpoint(struct sctp_endpoint *ep) ...@@ -558,7 +558,7 @@ void __sctp_unhash_endpoint(struct sctp_endpoint *ep)
epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);
head = &sctp_proto.ep_hashbucket[epb->hashent]; head = &sctp_ep_hashbucket[epb->hashent];
sctp_write_lock(&head->lock); sctp_write_lock(&head->lock);
...@@ -589,7 +589,7 @@ struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr) ...@@ -589,7 +589,7 @@ struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr)
int hash; int hash;
hash = sctp_ep_hashfn(laddr->v4.sin_port); hash = sctp_ep_hashfn(laddr->v4.sin_port);
head = &sctp_proto.ep_hashbucket[hash]; head = &sctp_ep_hashbucket[hash];
read_lock(&head->lock); read_lock(&head->lock);
for (epb = head->chain; epb; epb = epb->next) { for (epb = head->chain; epb; epb = epb->next) {
ep = sctp_ep(epb); ep = sctp_ep(epb);
...@@ -627,7 +627,7 @@ void __sctp_hash_established(struct sctp_association *asoc) ...@@ -627,7 +627,7 @@ void __sctp_hash_established(struct sctp_association *asoc)
/* Calculate which chain this entry will belong to. */ /* Calculate which chain this entry will belong to. */
epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port, asoc->peer.port); epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port, asoc->peer.port);
head = &sctp_proto.assoc_hashbucket[epb->hashent]; head = &sctp_assoc_hashbucket[epb->hashent];
sctp_write_lock(&head->lock); sctp_write_lock(&head->lock);
epp = &head->chain; epp = &head->chain;
...@@ -658,7 +658,7 @@ void __sctp_unhash_established(struct sctp_association *asoc) ...@@ -658,7 +658,7 @@ void __sctp_unhash_established(struct sctp_association *asoc)
epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port, epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port,
asoc->peer.port); asoc->peer.port);
head = &sctp_proto.assoc_hashbucket[epb->hashent]; head = &sctp_assoc_hashbucket[epb->hashent];
sctp_write_lock(&head->lock); sctp_write_lock(&head->lock);
...@@ -688,7 +688,7 @@ struct sctp_association *__sctp_lookup_association( ...@@ -688,7 +688,7 @@ struct sctp_association *__sctp_lookup_association(
* have wildcards anyways. * have wildcards anyways.
*/ */
hash = sctp_assoc_hashfn(local->v4.sin_port, peer->v4.sin_port); hash = sctp_assoc_hashfn(local->v4.sin_port, peer->v4.sin_port);
head = &sctp_proto.assoc_hashbucket[hash]; head = &sctp_assoc_hashbucket[hash];
read_lock(&head->lock); read_lock(&head->lock);
for (epb = head->chain; epb; epb = epb->next) { for (epb = head->chain; epb; epb = epb->next) {
asoc = sctp_assoc(epb); asoc = sctp_assoc(epb);
......
This diff is collapsed.
...@@ -1909,7 +1909,7 @@ int sctp_process_param(struct sctp_association *asoc, union sctp_params param, ...@@ -1909,7 +1909,7 @@ int sctp_process_param(struct sctp_association *asoc, union sctp_params param,
break; break;
case SCTP_PARAM_COOKIE_PRESERVATIVE: case SCTP_PARAM_COOKIE_PRESERVATIVE:
if (!sctp_proto.cookie_preserve_enable) if (!sctp_cookie_preserve_enable)
break; break;
stale = ntohl(param.life->lifespan_increment); stale = ntohl(param.life->lifespan_increment);
......
...@@ -1992,13 +1992,10 @@ SCTP_STATIC int sctp_ioctl(struct sock *sk, int cmd, unsigned long arg) ...@@ -1992,13 +1992,10 @@ 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 sctp_endpoint *ep; struct sctp_endpoint *ep;
struct sctp_protocol *proto;
struct sctp_opt *sp; struct sctp_opt *sp;
SCTP_DEBUG_PRINTK("sctp_init_sock(sk: %p)\n", sk); SCTP_DEBUG_PRINTK("sctp_init_sock(sk: %p)\n", sk);
proto = sctp_get_protocol();
sp = sctp_sk(sk); sp = sctp_sk(sk);
/* Initialize the SCTP per socket area. */ /* Initialize the SCTP per socket area. */
...@@ -2027,18 +2024,18 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) ...@@ -2027,18 +2024,18 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk)
* can be modified with the SCTP_INITMSG socket option or * can be modified with the SCTP_INITMSG socket option or
* overridden by the SCTP_INIT CMSG. * overridden by the SCTP_INIT CMSG.
*/ */
sp->initmsg.sinit_num_ostreams = proto->max_outstreams; sp->initmsg.sinit_num_ostreams = sctp_max_outstreams;
sp->initmsg.sinit_max_instreams = proto->max_instreams; sp->initmsg.sinit_max_instreams = sctp_max_instreams;
sp->initmsg.sinit_max_attempts = proto->max_retrans_init; sp->initmsg.sinit_max_attempts = sctp_max_retrans_init;
sp->initmsg.sinit_max_init_timeo = proto->rto_max / HZ; sp->initmsg.sinit_max_init_timeo = sctp_rto_max / HZ;
/* 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.
* FIXME: These are not used yet. * FIXME: These are not used yet.
*/ */
sp->rtoinfo.srto_initial = proto->rto_initial; sp->rtoinfo.srto_initial = sctp_rto_initial;
sp->rtoinfo.srto_max = proto->rto_max; sp->rtoinfo.srto_max = sctp_rto_max;
sp->rtoinfo.srto_min = proto->rto_min; sp->rtoinfo.srto_min = sctp_rto_min;
/* Initialize default event subscriptions. /* Initialize default event subscriptions.
* the struct sock is initialized to zero, so only * the struct sock is initialized to zero, so only
...@@ -2053,8 +2050,8 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) ...@@ -2053,8 +2050,8 @@ 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_SET_PEER_ADDR_PARAMS * be modified via SCTP_SET_PEER_ADDR_PARAMS
*/ */
sp->paddrparam.spp_hbinterval = proto->hb_interval / HZ; sp->paddrparam.spp_hbinterval = sctp_hb_interval / HZ;
sp->paddrparam.spp_pathmaxrxt = proto->max_retrans_path; sp->paddrparam.spp_pathmaxrxt = sctp_max_retrans_path;
/* If enabled no SCTP message fragmentation will be performed. /* If enabled no SCTP message fragmentation will be performed.
* Configure through SCTP_DISABLE_FRAGMENTS socket option. * Configure through SCTP_DISABLE_FRAGMENTS socket option.
...@@ -2947,7 +2944,6 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) ...@@ -2947,7 +2944,6 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
{ {
struct sctp_bind_hashbucket *head; /* hash list */ struct sctp_bind_hashbucket *head; /* hash list */
struct sctp_bind_bucket *pp; /* hash list port iterator */ struct sctp_bind_bucket *pp; /* hash list port iterator */
struct sctp_protocol *sctp = sctp_get_protocol();
unsigned short snum; unsigned short snum;
int ret; int ret;
...@@ -2962,8 +2958,8 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) ...@@ -2962,8 +2958,8 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
if (snum == 0) { if (snum == 0) {
/* Search for an available port. /* Search for an available port.
* *
* 'sctp->port_rover' was the last port assigned, so * 'sctp_port_rover' was the last port assigned, so
* we start to search from 'sctp->port_rover + * we start to search from 'sctp_port_rover +
* 1'. What we do is first check if port 'rover' is * 1'. What we do is first check if port 'rover' is
* already in the hash table; if not, we use that; if * already in the hash table; if not, we use that; if
* it is, we try next. * it is, we try next.
...@@ -2974,14 +2970,14 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) ...@@ -2974,14 +2970,14 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
int rover; int rover;
int index; int index;
sctp_spin_lock(&sctp->port_alloc_lock); sctp_spin_lock(&sctp_port_alloc_lock);
rover = sctp->port_rover; rover = sctp_port_rover;
do { do {
rover++; rover++;
if ((rover < low) || (rover > high)) if ((rover < low) || (rover > high))
rover = low; rover = low;
index = sctp_phashfn(rover); index = sctp_phashfn(rover);
head = &sctp->port_hashtable[index]; head = &sctp_port_hashtable[index];
sctp_spin_lock(&head->lock); sctp_spin_lock(&head->lock);
for (pp = head->chain; pp; pp = pp->next) for (pp = head->chain; pp; pp = pp->next)
if (pp->port == rover) if (pp->port == rover)
...@@ -2990,8 +2986,8 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) ...@@ -2990,8 +2986,8 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
next: next:
sctp_spin_unlock(&head->lock); sctp_spin_unlock(&head->lock);
} while (--remaining > 0); } while (--remaining > 0);
sctp->port_rover = rover; sctp_port_rover = rover;
sctp_spin_unlock(&sctp->port_alloc_lock); sctp_spin_unlock(&sctp_port_alloc_lock);
/* Exhausted local port range during search? */ /* Exhausted local port range during search? */
ret = 1; ret = 1;
...@@ -3011,7 +3007,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) ...@@ -3011,7 +3007,7 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
* to the port number (snum) - we detect that with the * to the port number (snum) - we detect that with the
* port iterator, pp being NULL. * port iterator, pp being NULL.
*/ */
head = &sctp->port_hashtable[sctp_phashfn(snum)]; head = &sctp_port_hashtable[sctp_phashfn(snum)];
sctp_spin_lock(&head->lock); sctp_spin_lock(&head->lock);
for (pp = head->chain; pp; pp = pp->next) { for (pp = head->chain; pp; pp = pp->next) {
if (pp->port == snum) if (pp->port == snum)
...@@ -3351,9 +3347,8 @@ static void sctp_bucket_destroy(struct sctp_bind_bucket *pp) ...@@ -3351,9 +3347,8 @@ static void sctp_bucket_destroy(struct sctp_bind_bucket *pp)
/* FIXME: Comments! */ /* FIXME: Comments! */
static __inline__ void __sctp_put_port(struct sock *sk) static __inline__ void __sctp_put_port(struct sock *sk)
{ {
struct sctp_protocol *sctp_proto = sctp_get_protocol();
struct sctp_bind_hashbucket *head = struct sctp_bind_hashbucket *head =
&sctp_proto->port_hashtable[sctp_phashfn(inet_sk(sk)->num)]; &sctp_port_hashtable[sctp_phashfn(inet_sk(sk)->num)];
struct sctp_bind_bucket *pp; struct sctp_bind_bucket *pp;
sctp_spin_lock(&head->lock); sctp_spin_lock(&head->lock);
......
...@@ -42,13 +42,11 @@ ...@@ -42,13 +42,11 @@
#include <net/sctp/structs.h> #include <net/sctp/structs.h>
#include <linux/sysctl.h> #include <linux/sysctl.h>
extern struct sctp_protocol sctp_proto;
static ctl_table sctp_table[] = { static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_RTO_INITIAL, .ctl_name = NET_SCTP_RTO_INITIAL,
.procname = "rto_initial", .procname = "rto_initial",
.data = &sctp_proto.rto_initial, .data = &sctp_rto_initial,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_dointvec_jiffies,
...@@ -57,7 +55,7 @@ static ctl_table sctp_table[] = { ...@@ -57,7 +55,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_RTO_MIN, .ctl_name = NET_SCTP_RTO_MIN,
.procname = "rto_min", .procname = "rto_min",
.data = &sctp_proto.rto_min, .data = &sctp_rto_min,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_dointvec_jiffies,
...@@ -66,7 +64,7 @@ static ctl_table sctp_table[] = { ...@@ -66,7 +64,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_RTO_MAX, .ctl_name = NET_SCTP_RTO_MAX,
.procname = "rto_max", .procname = "rto_max",
.data = &sctp_proto.rto_max, .data = &sctp_rto_max,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_dointvec_jiffies,
...@@ -75,7 +73,7 @@ static ctl_table sctp_table[] = { ...@@ -75,7 +73,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_VALID_COOKIE_LIFE, .ctl_name = NET_SCTP_VALID_COOKIE_LIFE,
.procname = "valid_cookie_life", .procname = "valid_cookie_life",
.data = &sctp_proto.valid_cookie_life, .data = &sctp_valid_cookie_life,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_dointvec_jiffies,
...@@ -84,7 +82,7 @@ static ctl_table sctp_table[] = { ...@@ -84,7 +82,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_MAX_BURST, .ctl_name = NET_SCTP_MAX_BURST,
.procname = "max_burst", .procname = "max_burst",
.data = &sctp_proto.max_burst, .data = &sctp_max_burst,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec .proc_handler = &proc_dointvec
...@@ -92,7 +90,7 @@ static ctl_table sctp_table[] = { ...@@ -92,7 +90,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS, .ctl_name = NET_SCTP_ASSOCIATION_MAX_RETRANS,
.procname = "association_max_retrans", .procname = "association_max_retrans",
.data = &sctp_proto.max_retrans_association, .data = &sctp_max_retrans_association,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec .proc_handler = &proc_dointvec
...@@ -100,7 +98,7 @@ static ctl_table sctp_table[] = { ...@@ -100,7 +98,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_PATH_MAX_RETRANS, .ctl_name = NET_SCTP_PATH_MAX_RETRANS,
.procname = "path_max_retrans", .procname = "path_max_retrans",
.data = &sctp_proto.max_retrans_path, .data = &sctp_max_retrans_path,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec .proc_handler = &proc_dointvec
...@@ -108,7 +106,7 @@ static ctl_table sctp_table[] = { ...@@ -108,7 +106,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS, .ctl_name = NET_SCTP_MAX_INIT_RETRANSMITS,
.procname = "max_init_retransmits", .procname = "max_init_retransmits",
.data = &sctp_proto.max_retrans_init, .data = &sctp_max_retrans_init,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec .proc_handler = &proc_dointvec
...@@ -116,7 +114,7 @@ static ctl_table sctp_table[] = { ...@@ -116,7 +114,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_HB_INTERVAL, .ctl_name = NET_SCTP_HB_INTERVAL,
.procname = "hb_interval", .procname = "hb_interval",
.data = &sctp_proto.hb_interval, .data = &sctp_hb_interval,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_dointvec_jiffies,
...@@ -125,7 +123,7 @@ static ctl_table sctp_table[] = { ...@@ -125,7 +123,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_PRESERVE_ENABLE, .ctl_name = NET_SCTP_PRESERVE_ENABLE,
.procname = "cookie_preserve_enable", .procname = "cookie_preserve_enable",
.data = &sctp_proto.cookie_preserve_enable, .data = &sctp_cookie_preserve_enable,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_jiffies, .proc_handler = &proc_dointvec_jiffies,
...@@ -134,7 +132,7 @@ static ctl_table sctp_table[] = { ...@@ -134,7 +132,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_RTO_ALPHA, .ctl_name = NET_SCTP_RTO_ALPHA,
.procname = "rto_alpha_exp_divisor", .procname = "rto_alpha_exp_divisor",
.data = &sctp_proto.rto_alpha, .data = &sctp_rto_alpha,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec .proc_handler = &proc_dointvec
...@@ -142,7 +140,7 @@ static ctl_table sctp_table[] = { ...@@ -142,7 +140,7 @@ static ctl_table sctp_table[] = {
{ {
.ctl_name = NET_SCTP_RTO_BETA, .ctl_name = NET_SCTP_RTO_BETA,
.procname = "rto_beta_exp_divisor", .procname = "rto_beta_exp_divisor",
.data = &sctp_proto.rto_beta, .data = &sctp_rto_beta,
.maxlen = sizeof(int), .maxlen = sizeof(int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec .proc_handler = &proc_dointvec
......
...@@ -82,8 +82,6 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, ...@@ -82,8 +82,6 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
const union sctp_addr *addr, const union sctp_addr *addr,
int gfp) int gfp)
{ {
struct sctp_protocol *proto = sctp_get_protocol();
/* Copy in the address. */ /* Copy in the address. */
peer->ipaddr = *addr; peer->ipaddr = *addr;
peer->af_specific = sctp_get_af_specific(addr->sa.sa_family); peer->af_specific = sctp_get_af_specific(addr->sa.sa_family);
...@@ -99,7 +97,7 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, ...@@ -99,7 +97,7 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
* parameter 'RTO.Initial'. * parameter 'RTO.Initial'.
*/ */
peer->rtt = 0; peer->rtt = 0;
peer->rto = proto->rto_initial; peer->rto = sctp_rto_initial;
peer->rttvar = 0; peer->rttvar = 0;
peer->srtt = 0; peer->srtt = 0;
peer->rto_pending = 0; peer->rto_pending = 0;
...@@ -112,7 +110,7 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, ...@@ -112,7 +110,7 @@ struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
peer->hb_allowed = 0; peer->hb_allowed = 0;
/* Initialize the default path max_retrans. */ /* Initialize the default path max_retrans. */
peer->max_retrans = proto->max_retrans_path; peer->max_retrans = sctp_max_retrans_path;
peer->error_threshold = 0; peer->error_threshold = 0;
peer->error_count = 0; peer->error_count = 0;
...@@ -272,8 +270,6 @@ void sctp_transport_put(struct sctp_transport *transport) ...@@ -272,8 +270,6 @@ void sctp_transport_put(struct sctp_transport *transport)
/* Update transport's RTO based on the newly calculated RTT. */ /* Update transport's RTO based on the newly calculated RTT. */
void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
{ {
struct sctp_protocol *proto = sctp_get_protocol();
/* Check for valid transport. */ /* Check for valid transport. */
SCTP_ASSERT(tp, "NULL transport", return); SCTP_ASSERT(tp, "NULL transport", return);
...@@ -292,10 +288,10 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) ...@@ -292,10 +288,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 >> proto->rto_beta) tp->rttvar = tp->rttvar - (tp->rttvar >> sctp_rto_beta)
+ ((abs(tp->srtt - rtt)) >> proto->rto_beta); + ((abs(tp->srtt - rtt)) >> sctp_rto_beta);
tp->srtt = tp->srtt - (tp->srtt >> proto->rto_alpha) tp->srtt = tp->srtt - (tp->srtt >> sctp_rto_alpha)
+ (rtt >> proto->rto_alpha); + (rtt >> 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