patch-2.1.28 linux/net/ipv4/proc.c

Next file: linux/net/ipv4/raw.c
Previous file: linux/net/ipv4/packet.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.27/linux/net/ipv4/proc.c linux/net/ipv4/proc.c
@@ -57,22 +57,17 @@
 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;
 	struct tcp_opt *tp;
-	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 "
@@ -85,72 +80,56 @@
  *	concede defeat and cli().
  */
 	start_bh_atomic();
-
-	for(i = 0; i < SOCK_ARRAY_SIZE; i++) 
-	{
-		sp = s_array[i];
-
-		while(sp != NULL) 
-		{
-			pos += 128;
-			if (pos < offset)
-			{
-				sp = sp->next;
-				continue;
-			}
-
-			tp = &(sp->tp_pinfo.af_tcp);
-
-			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-tp->snd_una:sp->wmem_alloc, 
-				format==0?tp->rcv_nxt-sp->copied_seq:sp->rmem_alloc,
-				timer_active, timer_expires-jiffies, (unsigned) sp->retransmits,
-				sp->socket ? sp->socket->inode->i_uid:0,
-				timer_active?sp->timeout:0,
-				sp->socket ? sp->socket->inode->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;
+	sp = pro->sklist_next;
+	while(sp != (struct sock *)pro) {
+		pos += 128;
+		if (pos < offset)
+			goto next;
+
+		tp = &(sp->tp_pinfo.af_tcp);
+		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;
 		}
-		if(len>= length)
+		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-tp->snd_una:sp->wmem_alloc, 
+			format==0?tp->rcv_nxt-sp->copied_seq:sp->rmem_alloc,
+			timer_active, timer_expires-jiffies, (unsigned) sp->retransmits,
+			sp->socket ? sp->socket->inode->i_uid:0,
+			timer_active?sp->timeout:0,
+			sp->socket ? sp->socket->inode->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);
+		if(len >= length)
 			break;
+	next:
+		sp = sp->sklist_next;
+		i++;
 	}
 	end_bh_atomic();
+
 	begin = len - (pos - offset);
 	*start = buffer + begin;
 	len -= begin;
@@ -189,7 +168,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