Improve the scalability by using the local and remote port when

putting inps in the tcpephash.

MFC after: 3 days.
This commit is contained in:
Michael Tuexen 2010-11-09 16:18:32 +00:00
parent 8b4da1c3d9
commit 034b88b092

View File

@ -567,8 +567,8 @@ sctp_add_addr_to_vrf(uint32_t vrf_id, void *ifn, uint32_t ifn_index,
} else {
if (sctp_ifap->ifn_p) {
/*
* The last IFN gets the address, remove
* the old one
* The last IFN gets the address, remove the
* old one
*/
SCTPDBG(SCTP_DEBUG_PCB4, "Moving ifa %p from %s (0x%x) to %s (0x%x)\n",
sctp_ifap, sctp_ifap->ifn_p->ifn_name,
@ -849,7 +849,7 @@ sctp_tcb_special_locate(struct sctp_inpcb **inp_p, struct sockaddr *from,
} else {
return NULL;
}
ephead = &SCTP_BASE_INFO(sctp_tcpephash)[SCTP_PCBHASH_ALLADDR((lport), SCTP_BASE_INFO(hashtcpmark))];
ephead = &SCTP_BASE_INFO(sctp_tcpephash)[SCTP_PCBHASH_ALLADDR((lport | rport), SCTP_BASE_INFO(hashtcpmark))];
/*
* Ok now for each of the guys in this bucket we must look and see:
* - Does the remote port match. - Does there single association's
@ -1771,6 +1771,7 @@ sctp_pcb_findep(struct sockaddr *nam, int find_tcp_pool, int have_lock,
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
int lport;
unsigned int i;
if (nam->sa_family == AF_INET) {
sin = (struct sockaddr_in *)nam;
@ -1797,17 +1798,22 @@ sctp_pcb_findep(struct sockaddr *nam, int find_tcp_pool, int have_lock,
/*
* If the TCP model exists it could be that the main listening
* endpoint is gone but there exists a connected socket for this guy
* yet. If so we can return the first one that we find. This may NOT
* be the correct one so the caller should be wary on the return
* INP. Currently the only caller that sets this flag is in bindx
* where we are verifying that a user CAN bind the address. He
* either has bound it already, or someone else has, or its open to
* bind, so this is good enough.
* endpoint is gone but there still exists a connected socket for
* this guy. If so we can return the first one that we find. This
* may NOT be the correct one so the caller should be wary on the
* returned INP. Currently the only caller that sets find_tcp_pool
* is in bindx where we are verifying that a user CAN bind the
* address. He either has bound it already, or someone else has, or
* its open to bind, so this is good enough.
*/
if (inp == NULL && find_tcp_pool) {
head = &SCTP_BASE_INFO(sctp_tcpephash)[SCTP_PCBHASH_ALLADDR(lport, SCTP_BASE_INFO(hashtcpmark))];
inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
for (i = 0; i < SCTP_BASE_INFO(hashtcpmark) + 1; i++) {
head = &SCTP_BASE_INFO(sctp_tcpephash)[i];
inp = sctp_endpoint_probe(nam, head, lport, vrf_id);
if (inp) {
break;
}
}
}
if (inp) {
SCTP_INP_INCR_REF(inp);
@ -2603,8 +2609,7 @@ sctp_move_pcb_and_assoc(struct sctp_inpcb *old_inp, struct sctp_inpcb *new_inp,
LIST_REMOVE(stcb, sctp_tcbasocidhash);
}
/* Now insert the new_inp into the TCP connected hash */
head = &SCTP_BASE_INFO(sctp_tcpephash)[SCTP_PCBHASH_ALLADDR((lport),
SCTP_BASE_INFO(hashtcpmark))];
head = &SCTP_BASE_INFO(sctp_tcpephash)[SCTP_PCBHASH_ALLADDR((lport | rport), SCTP_BASE_INFO(hashtcpmark))];
LIST_INSERT_HEAD(head, new_inp, sctp_hash);
/* Its safe to access */
@ -3089,12 +3094,10 @@ sctp_inpcb_bind(struct socket *so, struct sockaddr *addr,
/* find the bucket */
if (port_reuse_active) {
/* Put it into tcp 1-2-1 hash */
head = &SCTP_BASE_INFO(sctp_tcpephash)[SCTP_PCBHASH_ALLADDR((lport),
SCTP_BASE_INFO(hashtcpmark))];
head = &SCTP_BASE_INFO(sctp_tcpephash)[SCTP_PCBHASH_ALLADDR(lport, SCTP_BASE_INFO(hashtcpmark))];
inp->sctp_flags |= SCTP_PCB_FLAGS_IN_TCPPOOL;
} else {
head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(lport,
SCTP_BASE_INFO(hashmark))];
head = &SCTP_BASE_INFO(sctp_ephash)[SCTP_PCBHASH_ALLADDR(lport, SCTP_BASE_INFO(hashmark))];
}
/* put it in the bucket */
LIST_INSERT_HEAD(head, inp, sctp_hash);
@ -3716,8 +3719,8 @@ sctp_add_remote_addr(struct sctp_tcb *stcb, struct sockaddr *newaddr,
{
/*
* The following is redundant to the same lines in the
* sctp_aloc_assoc() but is needed since others call the add
* address function
* sctp_aloc_assoc() but is needed since others call the add address
* function
*/
struct sctp_nets *net, *netfirst;
int addr_inscope;
@ -5159,10 +5162,10 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre
SCTP_INP_RUNLOCK(inp);
/*
* This will start the kill timer (if we are the
* last one) since we hold an increment yet. But this
* is the only safe way to do this since otherwise
* if the socket closes at the same time we are here
* we might collide in the cleanup.
* last one) since we hold an increment yet. But
* this is the only safe way to do this since
* otherwise if the socket closes at the same time
* we are here we might collide in the cleanup.
*/
sctp_inpcb_free(inp,
SCTP_FREE_SHOULD_USE_GRACEFUL_CLOSE,
@ -6676,12 +6679,12 @@ sctp_drain_mbufs(struct sctp_inpcb *inp, struct sctp_tcb *stcb)
}
/*
* Another issue, in un-setting the TSN's in the mapping array we
* DID NOT adjust the highest_tsn marker. This will cause one of two
* things to occur. It may cause us to do extra work in checking for
* our mapping array movement. More importantly it may cause us to
* SACK every datagram. This may not be a bad thing though since we
* will recover once we get our cum-ack above and all this stuff we
* dumped recovered.
* DID NOT adjust the highest_tsn marker. This will cause one of
* two things to occur. It may cause us to do extra work in checking
* for our mapping array movement. More importantly it may cause us
* to SACK every datagram. This may not be a bad thing though since
* we will recover once we get our cum-ack above and all this stuff
* we dumped recovered.
*/
}