Commit 49392e5e authored by Vlad Yasevich's avatar Vlad Yasevich Committed by Sridhar Samudrala

[SCTP]: sctp doesn't show all associations/endpoints in /proc

When creating a very large number of associations (and endpoints),
/proc/assocs and /proc/eps will not show all of them.  As a result
netstat will not show all of the either.  This is particularly evident
when creating 1000+ associations (or endpoints).  As an example with
1500 tcp style associations over loopback, netstat showed 1420 on my
system instead of 3000.

The reason for this is that the seq_operations start method is invoked
multiple times bacause of the amount of data that is provided.  The
start method always increments the position parameter and since we use
the position as the hash bucket id, we end up skipping hash buckets.

This patch corrects this situation and get's rid of the silly hash-1
decrement.
Signed-off-by: default avatarVlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: default avatarSridhar Samudrala <sri@us.ibm.com>
parent 9834a2bb
...@@ -176,7 +176,7 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa ...@@ -176,7 +176,7 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa
static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos) static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos)
{ {
if (*pos > sctp_ep_hashsize) if (*pos >= sctp_ep_hashsize)
return NULL; return NULL;
if (*pos < 0) if (*pos < 0)
...@@ -185,8 +185,6 @@ static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -185,8 +185,6 @@ static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos)
if (*pos == 0) if (*pos == 0)
seq_printf(seq, " ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS\n"); seq_printf(seq, " ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS\n");
++*pos;
return (void *)pos; return (void *)pos;
} }
...@@ -198,11 +196,9 @@ static void sctp_eps_seq_stop(struct seq_file *seq, void *v) ...@@ -198,11 +196,9 @@ static void sctp_eps_seq_stop(struct seq_file *seq, void *v)
static void * sctp_eps_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void * sctp_eps_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{ {
if (*pos > sctp_ep_hashsize) if (++*pos >= sctp_ep_hashsize)
return NULL; return NULL;
++*pos;
return pos; return pos;
} }
...@@ -216,17 +212,17 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v) ...@@ -216,17 +212,17 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
struct sock *sk; struct sock *sk;
int hash = *(int *)v; int hash = *(int *)v;
if (hash > sctp_ep_hashsize) if (hash >= sctp_ep_hashsize)
return -ENOMEM; return -ENOMEM;
head = &sctp_ep_hashtable[hash-1]; head = &sctp_ep_hashtable[hash];
sctp_local_bh_disable(); sctp_local_bh_disable();
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);
sk = epb->sk; sk = epb->sk;
seq_printf(seq, "%8p %8p %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, seq_printf(seq, "%8p %8p %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk,
sctp_sk(sk)->type, sk->sk_state, hash-1, sctp_sk(sk)->type, sk->sk_state, hash,
epb->bind_addr.port, epb->bind_addr.port,
sock_i_uid(sk), sock_i_ino(sk)); sock_i_uid(sk), sock_i_ino(sk));
...@@ -283,7 +279,7 @@ void sctp_eps_proc_exit(void) ...@@ -283,7 +279,7 @@ void sctp_eps_proc_exit(void)
static void * sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos) static void * sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos)
{ {
if (*pos > sctp_assoc_hashsize) if (*pos >= sctp_assoc_hashsize)
return NULL; return NULL;
if (*pos < 0) if (*pos < 0)
...@@ -293,8 +289,6 @@ static void * sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos) ...@@ -293,8 +289,6 @@ static void * sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos)
seq_printf(seq, " ASSOC SOCK STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT " seq_printf(seq, " ASSOC SOCK STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT "
"RPORT LADDRS <-> RADDRS\n"); "RPORT LADDRS <-> RADDRS\n");
++*pos;
return (void *)pos; return (void *)pos;
} }
...@@ -306,11 +300,9 @@ static void sctp_assocs_seq_stop(struct seq_file *seq, void *v) ...@@ -306,11 +300,9 @@ static void sctp_assocs_seq_stop(struct seq_file *seq, void *v)
static void * sctp_assocs_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void * sctp_assocs_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{ {
if (*pos > sctp_assoc_hashsize) if (++*pos >= sctp_assoc_hashsize)
return NULL; return NULL;
++*pos;
return pos; return pos;
} }
...@@ -323,10 +315,10 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v) ...@@ -323,10 +315,10 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
struct sock *sk; struct sock *sk;
int hash = *(int *)v; int hash = *(int *)v;
if (hash > sctp_assoc_hashsize) if (hash >= sctp_assoc_hashsize)
return -ENOMEM; return -ENOMEM;
head = &sctp_assoc_hashtable[hash-1]; head = &sctp_assoc_hashtable[hash];
sctp_local_bh_disable(); sctp_local_bh_disable();
read_lock(&head->lock); read_lock(&head->lock);
for (epb = head->chain; epb; epb = epb->next) { for (epb = head->chain; epb; epb = epb->next) {
...@@ -335,7 +327,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v) ...@@ -335,7 +327,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, seq_printf(seq,
"%8p %8p %-3d %-3d %-2d %-4d %4d %8d %8d %7d %5lu %-5d %5d ", "%8p %8p %-3d %-3d %-2d %-4d %4d %8d %8d %7d %5lu %-5d %5d ",
assoc, sk, sctp_sk(sk)->type, sk->sk_state, assoc, sk, sctp_sk(sk)->type, sk->sk_state,
assoc->state, hash-1, assoc->assoc_id, assoc->state, hash, assoc->assoc_id,
(sk->sk_rcvbuf - assoc->rwnd), (sk->sk_rcvbuf - assoc->rwnd),
assoc->sndbuf_used, assoc->sndbuf_used,
sock_i_uid(sk), sock_i_ino(sk), sock_i_uid(sk), sock_i_ino(sk),
......
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