patch-2.0.30 linux/net/ipv4/proc.c
Next file: linux/net/ipv4/protocol.c
Previous file: linux/net/ipv4/packet.c
Back to the patch index
Back to the overall index
- Lines: 157
- Date:
Tue Apr 8 08:47:47 1997
- Orig file:
v2.0.29/linux/net/ipv4/proc.c
- Orig date:
Mon Jun 3 04:23:42 1996
diff -u --recursive --new-file v2.0.29/linux/net/ipv4/proc.c linux/net/ipv4/proc.c
@@ -57,21 +57,16 @@
static int
get__netinfo(struct proto *pro, char *buffer, int format, char **start, off_t offset, int length)
{
- struct sock **s_array;
struct sock *sp;
- int i;
- int timer_active;
- int timer_active1;
- int timer_active2;
+ int timer_active, timer_active1, timer_active2;
unsigned long timer_expires;
unsigned long dest, src;
unsigned short destp, srcp;
- int len=0;
+ int len=0, i = 0;
off_t pos=0;
off_t begin;
char tmpbuf[129];
- s_array = pro->sock_array;
if (offset < 128)
len += sprintf(buffer, "%-127s\n",
" sl local_address rem_address st tx_queue "
@@ -83,71 +78,62 @@
* a memory timer destroy. Instead of playing with timers we just
* concede defeat and cli().
*/
- for(i = 0; i < SOCK_ARRAY_SIZE; i++)
- {
- cli();
- sp = s_array[i];
- while(sp != NULL)
- {
- pos += 128;
- if (pos < offset)
- {
- sp = sp->next;
- continue;
- }
- dest = sp->daddr;
- src = sp->saddr;
- destp = sp->dummy_th.dest;
- srcp = sp->dummy_th.source;
-
- /* Since we are Little Endian we need to swap the bytes :-( */
- destp = ntohs(destp);
- srcp = ntohs(srcp);
- timer_active1 = del_timer(&sp->retransmit_timer);
- timer_active2 = del_timer(&sp->timer);
- if (!timer_active1) sp->retransmit_timer.expires=0;
- if (!timer_active2) sp->timer.expires=0;
- timer_active=0;
- timer_expires=(unsigned)-1;
- if (timer_active1 &&
- sp->retransmit_timer.expires < timer_expires) {
- timer_active=timer_active1;
- timer_expires=sp->retransmit_timer.expires;
- }
- if (timer_active2 &&
- sp->timer.expires < timer_expires) {
- timer_active=timer_active2;
- timer_expires=sp->timer.expires;
- }
- sprintf(tmpbuf, "%4d: %08lX:%04X %08lX:%04X"
- " %02X %08X:%08X %02X:%08lX %08X %5d %8d %ld",
- i, src, srcp, dest, destp, sp->state,
- format==0?sp->write_seq-sp->rcv_ack_seq:sp->wmem_alloc,
- format==0?sp->acked_seq-sp->copied_seq:sp->rmem_alloc,
- timer_active, timer_expires-jiffies, (unsigned) sp->retransmits,
- (sp->socket&&SOCK_INODE(sp->socket))?SOCK_INODE(sp->socket)->i_uid:0,
- timer_active?sp->timeout:0,
- sp->socket && SOCK_INODE(sp->socket) ?
- SOCK_INODE(sp->socket)->i_ino : 0);
- if (timer_active1) add_timer(&sp->retransmit_timer);
- if (timer_active2) add_timer(&sp->timer);
- len += sprintf(buffer+len, "%-127s\n", tmpbuf);
- /*
- * All sockets with (port mod SOCK_ARRAY_SIZE) = i
- * are kept in sock_array[i], so we must follow the
- * 'next' link to get them all.
- */
- if(len >= length)
- break;
- sp = sp->next;
+ start_bh_atomic();
+ sp = pro->sklist_next;
+ while(sp != (struct sock *)pro) {
+ pos += 128;
+ if (pos < offset)
+ goto next;
+
+ dest = sp->daddr;
+ src = sp->saddr;
+ destp = sp->dummy_th.dest;
+ srcp = sp->dummy_th.source;
+
+ /* Since we are Little Endian we need to swap the bytes :-( */
+ destp = ntohs(destp);
+ srcp = ntohs(srcp);
+ timer_active1 = del_timer(&sp->retransmit_timer);
+ timer_active2 = del_timer(&sp->timer);
+ if (!timer_active1) sp->retransmit_timer.expires=0;
+ if (!timer_active2) sp->timer.expires=0;
+ timer_active=0;
+ timer_expires=(unsigned)-1;
+ if (timer_active1 &&
+ sp->retransmit_timer.expires < timer_expires) {
+ timer_active=timer_active1;
+ timer_expires=sp->retransmit_timer.expires;
}
- sti(); /* We only turn interrupts back on for a moment,
- but because the interrupt queues anything built
- up before this will clear before we jump back
- and cli(), so it's not as bad as it looks */
- if(len>= length)
+ if (timer_active2 &&
+ sp->timer.expires < timer_expires) {
+ timer_active=timer_active2;
+ timer_expires=sp->timer.expires;
+ }
+ sprintf(tmpbuf, "%4d: %08lX:%04X %08lX:%04X"
+ " %02X %08X:%08X %02X:%08lX %08X %5d %8d %ld",
+ i, src, srcp, dest, destp, sp->state,
+ format==0?sp->write_seq-sp->rcv_ack_seq:sp->wmem_alloc,
+ format==0?sp->acked_seq-sp->copied_seq:sp->rmem_alloc,
+ timer_active, timer_expires-jiffies, (unsigned) sp->retransmits,
+ (sp->socket&&SOCK_INODE(sp->socket))?SOCK_INODE(sp->socket)->i_uid:0,
+ timer_active?sp->timeout:0,
+ sp->socket && SOCK_INODE(sp->socket) ?
+ SOCK_INODE(sp->socket)->i_ino : 0);
+ if (timer_active1) add_timer(&sp->retransmit_timer);
+ if (timer_active2) add_timer(&sp->timer);
+ len += sprintf(buffer+len, "%-127s\n", tmpbuf);
+ /*
+ * All sockets are kept in the protocols sklist, so we
+ * follow the 'next' link to get them all.
+ */
+ if(len >= length)
break;
+ next:
+ sp = sp->sklist_next;
+ i++;
}
+ end_bh_atomic();
+
begin = len - (pos - offset);
*start = buffer + begin;
len -= begin;
@@ -186,7 +172,6 @@
int len = socket_get_info(buffer,start,offset,length);
- len += sprintf(buffer+len,"SOCK_ARRAY_SIZE=%d\n",SOCK_ARRAY_SIZE);
len += sprintf(buffer+len,"TCP: inuse %d highest %d\n",
tcp_prot.inuse, tcp_prot.highestinuse);
len += sprintf(buffer+len,"UDP: inuse %d highest %d\n",
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov