Skip to content

Commit

Permalink
Merge branch 'pending' of master.kernel.org:/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/vxy/lksctp-dev
  • Loading branch information
David S. Miller committed Nov 13, 2007
2 parents 91cf45f + 9abed24 commit bce9432
Show file tree
Hide file tree
Showing 19 changed files with 220 additions and 194 deletions.
1 change: 1 addition & 0 deletions include/net/sctp/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ typedef enum {
SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */
SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */
SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */
SCTP_CMD_T1_RETRAN, /* Mark for retransmission after T1 timeout */
SCTP_CMD_LAST
} sctp_verb_t;

Expand Down
3 changes: 3 additions & 0 deletions include/net/sctp/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ typedef enum {
SCTP_IERROR_AUTH_BAD_HMAC,
SCTP_IERROR_AUTH_BAD_KEYID,
SCTP_IERROR_PROTO_VIOLATION,
SCTP_IERROR_ERROR,
SCTP_IERROR_ABORT,
} sctp_ierror_t;


Expand Down Expand Up @@ -407,6 +409,7 @@ typedef enum {
SCTP_RTXR_T3_RTX,
SCTP_RTXR_FAST_RTX,
SCTP_RTXR_PMTUD,
SCTP_RTXR_T1_RTX,
} sctp_retransmit_reason_t;

/* Reasons to lower cwnd. */
Expand Down
5 changes: 4 additions & 1 deletion include/net/sctp/sctp.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@


#ifdef TEST_FRAME
#undef CONFIG_PROC_FS
#undef CONFIG_SCTP_DBG_OBJCNT
#undef CONFIG_SYSCTL
#endif /* TEST_FRAME */
Expand Down Expand Up @@ -267,6 +266,7 @@ enum
SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS,
SCTP_MIB_DELAY_SACK_EXPIREDS,
SCTP_MIB_AUTOCLOSE_EXPIREDS,
SCTP_MIB_T1_RETRANSMITS,
SCTP_MIB_T3_RETRANSMITS,
SCTP_MIB_PMTUD_RETRANSMITS,
SCTP_MIB_FAST_RETRANSMITS,
Expand Down Expand Up @@ -664,6 +664,9 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
return (h & (sctp_assoc_hashsize-1));
}

#define sctp_for_each_hentry(epb, node, head) \
hlist_for_each_entry(epb, node, head, node)

/* Is a socket of this style? */
#define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style))
static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style)
Expand Down
22 changes: 10 additions & 12 deletions include/net/sctp/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,19 @@ struct crypto_hash;
struct sctp_bind_bucket {
unsigned short port;
unsigned short fastreuse;
struct sctp_bind_bucket *next;
struct sctp_bind_bucket **pprev;
struct hlist_node node;
struct hlist_head owner;
};

struct sctp_bind_hashbucket {
spinlock_t lock;
struct sctp_bind_bucket *chain;
struct hlist_head chain;
};

/* Used for hashing all associations. */
struct sctp_hashbucket {
rwlock_t lock;
struct sctp_ep_common *chain;
struct hlist_head chain;
} __attribute__((__aligned__(8)));


Expand Down Expand Up @@ -212,6 +211,7 @@ extern struct sctp_globals {

/* 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;
Expand Down Expand Up @@ -249,6 +249,7 @@ extern struct sctp_globals {
#define sctp_local_addr_list (sctp_globals.local_addr_list)
#define sctp_local_addr_lock (sctp_globals.addr_list_lock)
#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)

Expand Down Expand Up @@ -873,10 +874,11 @@ struct sctp_transport {
* address list derived from the INIT or INIT ACK chunk, a
* number of data elements needs to be maintained including:
*/
__u32 rtt; /* This is the most recent RTT. */

/* RTO : The current retransmission timeout value. */
unsigned long rto;
unsigned long last_rto;

__u32 rtt; /* This is the most recent RTT. */

/* RTTVAR : The current RTT variation. */
__u32 rttvar;
Expand Down Expand Up @@ -1184,9 +1186,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
int flags);
int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
__u8 use_as_src, gfp_t gfp);
int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
void fastcall (*rcu_call)(struct rcu_head *,
void (*func)(struct rcu_head *)));
int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
struct sctp_sock *);
union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
Expand Down Expand Up @@ -1229,8 +1229,7 @@ typedef enum {

struct sctp_ep_common {
/* Fields to help us manage our entries in the hash tables. */
struct sctp_ep_common *next;
struct sctp_ep_common **pprev;
struct hlist_node node;
int hashent;

/* Runtime type information. What kind of endpoint is this? */
Expand Down Expand Up @@ -1541,7 +1540,6 @@ struct sctp_association {
__u8 asconf_capable; /* Does peer support ADDIP? */
__u8 prsctp_capable; /* Can peer do PR-SCTP? */
__u8 auth_capable; /* Is peer doing SCTP-AUTH? */
__u8 addip_capable; /* Can peer do ADD-IP */

__u32 adaptation_ind; /* Adaptation Code point. */

Expand Down
10 changes: 7 additions & 3 deletions net/sctp/associola.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,14 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
*/
asoc->peer.sack_needed = 1;

/* Assume that the peer recongizes ASCONF until reported otherwise
* via an ERROR chunk.
/* Assume that the peer will tell us if he recognizes ASCONF
* as part of INIT exchange.
* The sctp_addip_noauth option is there for backward compatibilty
* and will revert old behavior.
*/
asoc->peer.asconf_capable = 1;
asoc->peer.asconf_capable = 0;
if (sctp_addip_noauth)
asoc->peer.asconf_capable = 1;

/* Create an input queue. */
sctp_inq_init(&asoc->base.inqueue);
Expand Down
13 changes: 3 additions & 10 deletions net/sctp/bind_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
/* Delete an address from the bind address list in the SCTP_bind_addr
* structure.
*/
int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr,
void fastcall (*rcu_call)(struct rcu_head *head,
void (*func)(struct rcu_head *head)))
int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr)
{
struct sctp_sockaddr_entry *addr, *temp;

Expand All @@ -198,15 +196,10 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr,
}
}

/* Call the rcu callback provided in the args. This function is
* called by both BH packet processing and user side socket option
* processing, but it works on different lists in those 2 contexts.
* Each context provides it's own callback, whether call_rcu_bh()
* or call_rcu(), to make sure that we wait for an appropriate time.
*/
if (addr && !addr->valid) {
rcu_call(&addr->rcu, sctp_local_addr_free);
call_rcu(&addr->rcu, sctp_local_addr_free);
SCTP_DBG_OBJCNT_DEC(addr);
return 0;
}

return -EINVAL;
Expand Down
35 changes: 23 additions & 12 deletions net/sctp/endpointola.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,35 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
const union sctp_addr *paddr,
struct sctp_transport **transport)
{
struct sctp_association *asoc = NULL;
struct sctp_transport *t = NULL;
struct sctp_hashbucket *head;
struct sctp_ep_common *epb;
struct hlist_node *node;
int hash;
int rport;
struct sctp_association *asoc;
struct list_head *pos;

*transport = NULL;
rport = ntohs(paddr->v4.sin_port);

list_for_each(pos, &ep->asocs) {
asoc = list_entry(pos, struct sctp_association, asocs);
if (rport == asoc->peer.port) {
*transport = sctp_assoc_lookup_paddr(asoc, paddr);

if (*transport)
return asoc;
hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport);
head = &sctp_assoc_hashtable[hash];
read_lock(&head->lock);
sctp_for_each_hentry(epb, node, &head->chain) {
asoc = sctp_assoc(epb);
if (asoc->ep != ep || rport != asoc->peer.port)
goto next;

t = sctp_assoc_lookup_paddr(asoc, paddr);
if (t) {
*transport = t;
break;
}
next:
asoc = NULL;
}

*transport = NULL;
return NULL;
read_unlock(&head->lock);
return asoc;
}

/* Lookup association on an endpoint based on a peer address. BH-safe. */
Expand Down
43 changes: 11 additions & 32 deletions net/sctp/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ static int sctp_rcv_ootb(struct sk_buff *skb)
/* Insert endpoint into the hash table. */
static void __sctp_hash_endpoint(struct sctp_endpoint *ep)
{
struct sctp_ep_common **epp;
struct sctp_ep_common *epb;
struct sctp_hashbucket *head;

Expand All @@ -666,12 +665,7 @@ static void __sctp_hash_endpoint(struct sctp_endpoint *ep)
head = &sctp_ep_hashtable[epb->hashent];

sctp_write_lock(&head->lock);
epp = &head->chain;
epb->next = *epp;
if (epb->next)
(*epp)->pprev = &epb->next;
*epp = epb;
epb->pprev = epp;
hlist_add_head(&epb->node, &head->chain);
sctp_write_unlock(&head->lock);
}

Expand All @@ -691,19 +685,15 @@ static void __sctp_unhash_endpoint(struct sctp_endpoint *ep)

epb = &ep->base;

if (hlist_unhashed(&epb->node))
return;

epb->hashent = sctp_ep_hashfn(epb->bind_addr.port);

head = &sctp_ep_hashtable[epb->hashent];

sctp_write_lock(&head->lock);

if (epb->pprev) {
if (epb->next)
epb->next->pprev = epb->pprev;
*epb->pprev = epb->next;
epb->pprev = NULL;
}

__hlist_del(&epb->node);
sctp_write_unlock(&head->lock);
}

Expand All @@ -721,12 +711,13 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l
struct sctp_hashbucket *head;
struct sctp_ep_common *epb;
struct sctp_endpoint *ep;
struct hlist_node *node;
int hash;

hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port));
head = &sctp_ep_hashtable[hash];
read_lock(&head->lock);
for (epb = head->chain; epb; epb = epb->next) {
sctp_for_each_hentry(epb, node, &head->chain) {
ep = sctp_ep(epb);
if (sctp_endpoint_is_match(ep, laddr))
goto hit;
Expand All @@ -744,7 +735,6 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l
/* Insert association into the hash table. */
static void __sctp_hash_established(struct sctp_association *asoc)
{
struct sctp_ep_common **epp;
struct sctp_ep_common *epb;
struct sctp_hashbucket *head;

Expand All @@ -756,12 +746,7 @@ static void __sctp_hash_established(struct sctp_association *asoc)
head = &sctp_assoc_hashtable[epb->hashent];

sctp_write_lock(&head->lock);
epp = &head->chain;
epb->next = *epp;
if (epb->next)
(*epp)->pprev = &epb->next;
*epp = epb;
epb->pprev = epp;
hlist_add_head(&epb->node, &head->chain);
sctp_write_unlock(&head->lock);
}

Expand Down Expand Up @@ -790,14 +775,7 @@ static void __sctp_unhash_established(struct sctp_association *asoc)
head = &sctp_assoc_hashtable[epb->hashent];

sctp_write_lock(&head->lock);

if (epb->pprev) {
if (epb->next)
epb->next->pprev = epb->pprev;
*epb->pprev = epb->next;
epb->pprev = NULL;
}

__hlist_del(&epb->node);
sctp_write_unlock(&head->lock);
}

Expand All @@ -822,6 +800,7 @@ static struct sctp_association *__sctp_lookup_association(
struct sctp_ep_common *epb;
struct sctp_association *asoc;
struct sctp_transport *transport;
struct hlist_node *node;
int hash;

/* Optimize here for direct hit, only listening connections can
Expand All @@ -830,7 +809,7 @@ static struct sctp_association *__sctp_lookup_association(
hash = sctp_assoc_hashfn(ntohs(local->v4.sin_port), ntohs(peer->v4.sin_port));
head = &sctp_assoc_hashtable[hash];
read_lock(&head->lock);
for (epb = head->chain; epb; epb = epb->next) {
sctp_for_each_hentry(epb, node, &head->chain) {
asoc = sctp_assoc(epb);
transport = sctp_assoc_is_match(asoc, local, peer);
if (transport)
Expand Down
4 changes: 4 additions & 0 deletions net/sctp/inqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ void sctp_inq_free(struct sctp_inq *queue)
void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk)
{
/* Directly call the packet handling routine. */
if (chunk->rcvr->dead) {
sctp_chunk_free(chunk);
return;
}

/* We are now calling this either from the soft interrupt
* or from the backlog processing.
Expand Down
Loading

0 comments on commit bce9432

Please sign in to comment.