patch-2.3.10 linux/net/ipv4/proc.c
Next file: linux/net/ipv4/raw.c
Previous file: linux/net/ipv4/icmp.c
Back to the patch index
Back to the overall index
- Lines: 199
- Date:
Sat Jul 3 17:57:22 1999
- Orig file:
v2.3.9/linux/net/ipv4/proc.c
- Orig date:
Wed May 26 18:14:37 1999
diff -u --recursive --new-file v2.3.9/linux/net/ipv4/proc.c linux/net/ipv4/proc.c
@@ -7,7 +7,7 @@
* PROC file system. It is mainly used for debugging and
* statistics.
*
- * Version: $Id: proc.c,v 1.35 1999/05/27 00:37:38 davem Exp $
+ * Version: $Id: proc.c,v 1.36 1999/07/02 11:26:34 davem Exp $
*
* Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Gerald J. Heim, <heim@peanuts.informatik.uni-tuebingen.de>
@@ -49,189 +49,6 @@
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/raw.h>
-
-/* Format a single open_request into tmpbuf. */
-static inline void get__openreq(struct sock *sk, struct open_request *req,
- char *tmpbuf,
- int i)
-{
- sprintf(tmpbuf, "%4d: %08lX:%04X %08lX:%04X"
- " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u",
- i,
- (long unsigned int)req->af.v4_req.loc_addr,
- ntohs(sk->sport),
- (long unsigned int)req->af.v4_req.rmt_addr,
- ntohs(req->rmt_port),
- TCP_SYN_RECV,
- 0,0, /* could print option size, but that is af dependent. */
- 1, /* timers active (only the expire timer) */
- (unsigned long)(req->expires - jiffies),
- req->retrans,
- sk->socket ? sk->socket->inode->i_uid : 0,
- 0, /* non standard timer */
- 0 /* open_requests have no inode */
- );
-}
-
-/* Format a single socket into tmpbuf. */
-static inline void get__sock(struct sock *sp, char *tmpbuf, int i, int format)
-{
- unsigned long dest, src;
- unsigned short destp, srcp;
- int timer_active, timer_active1, timer_active2;
- int tw_bucket = 0;
- unsigned long timer_expires;
- struct tcp_opt *tp = &sp->tp_pinfo.af_tcp;
-
- dest = sp->daddr;
- src = sp->rcv_saddr;
- destp = sp->dport;
- srcp = sp->sport;
-
- /* FIXME: The fact that retransmit_timer occurs as a field
- * in two different parts of the socket structure is,
- * to say the least, confusing. This code now uses the
- * right retransmit_timer variable, but I'm not sure
- * the rest of the timer stuff is still correct.
- * In particular I'm not sure what the timeout value
- * is suppose to reflect (as opposed to tm->when). -- erics
- */
-
- destp = ntohs(destp);
- srcp = ntohs(srcp);
- if((format == 0) && (sp->state == TCP_TIME_WAIT)) {
- extern int tcp_tw_death_row_slot;
- struct tcp_tw_bucket *tw = (struct tcp_tw_bucket *)sp;
- int slot_dist;
-
- tw_bucket = 1;
- timer_active1 = timer_active2 = 0;
- timer_active = 3;
- slot_dist = tw->death_slot;
- if(slot_dist > tcp_tw_death_row_slot)
- slot_dist = (TCP_TWKILL_SLOTS - slot_dist) + tcp_tw_death_row_slot;
- else
- slot_dist = tcp_tw_death_row_slot - slot_dist;
- timer_expires = jiffies + (slot_dist * TCP_TWKILL_PERIOD);
- } else {
- timer_active1 = tp->retransmit_timer.prev != NULL;
- timer_active2 = sp->timer.prev != NULL;
- timer_active = 0;
- timer_expires = (unsigned) -1;
- }
- if (timer_active1 && tp->retransmit_timer.expires < timer_expires) {
- timer_active = 1;
- timer_expires = tp->retransmit_timer.expires;
- }
- if (timer_active2 && sp->timer.expires < timer_expires) {
- timer_active = 2;
- timer_expires = sp->timer.expires;
- }
- if(timer_active == 0)
- timer_expires = jiffies;
- sprintf(tmpbuf, "%4d: %08lX:%04X %08lX:%04X"
- " %02X %08X:%08X %02X:%08lX %08X %5d %8d %ld",
- i, src, srcp, dest, destp, sp->state,
- (tw_bucket ?
- 0 :
- (format == 0) ?
- tp->write_seq-tp->snd_una : atomic_read(&sp->wmem_alloc)),
- (tw_bucket ?
- 0 :
- (format == 0) ?
- tp->rcv_nxt-tp->copied_seq: atomic_read(&sp->rmem_alloc)),
- timer_active, timer_expires-jiffies,
- (tw_bucket ? 0 : tp->retransmits),
- (!tw_bucket && sp->socket) ? sp->socket->inode->i_uid : 0,
- (!tw_bucket && timer_active) ? sp->timeout : 0,
- (!tw_bucket && sp->socket) ? sp->socket->inode->i_ino : 0);
-}
-
-/*
- * Get__netinfo returns the length of that string.
- *
- * KNOWN BUGS
- * As in get_unix_netinfo, the buffer might be too small. If this
- * happens, get__netinfo returns only part of the available infos.
- *
- * Assumes that buffer length is a multiply of 128 - if not it will
- * write past the end.
- */
-static int
-get__netinfo(struct proto *pro, char *buffer, int format, char **start, off_t offset, int length)
-{
- struct sock *sp, *next;
- int len=0, i = 0;
- off_t pos=0;
- off_t begin;
- char tmpbuf[129];
-
- if (offset < 128)
- len += sprintf(buffer, "%-127s\n",
- " sl local_address rem_address st tx_queue "
- "rx_queue tr tm->when retrnsmt uid timeout inode");
- pos = 128;
- SOCKHASH_LOCK_READ();
- sp = pro->sklist_next;
- while(sp != (struct sock *)pro) {
- if (format == 0 && sp->state == TCP_LISTEN) {
- struct open_request *req;
-
- for (req = sp->tp_pinfo.af_tcp.syn_wait_queue; req;
- i++, req = req->dl_next) {
- if (req->sk)
- continue;
- pos += 128;
- if (pos < offset)
- continue;
- get__openreq(sp, req, tmpbuf, i);
- len += sprintf(buffer+len, "%-127s\n", tmpbuf);
- if(len >= length)
- goto out;
- }
- }
-
- pos += 128;
- if (pos < offset)
- goto next;
-
- get__sock(sp, tmpbuf, i, format);
-
- len += sprintf(buffer+len, "%-127s\n", tmpbuf);
- if(len >= length)
- break;
- next:
- next = sp->sklist_next;
- sp = next;
- i++;
- }
-out:
- SOCKHASH_UNLOCK_READ();
-
- begin = len - (pos - offset);
- *start = buffer + begin;
- len -= begin;
- if(len>length)
- len = length;
- if (len<0)
- len = 0;
- return len;
-}
-
-int tcp_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
-{
- return get__netinfo(&tcp_prot, buffer,0, start, offset, length);
-}
-
-int udp_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
-{
- return get__netinfo(&udp_prot, buffer,1, start, offset, length);
-}
-
-int raw_get_info(char *buffer, char **start, off_t offset, int length, int dummy)
-{
- return get__netinfo(&raw_prot, buffer,1, start, offset, length);
-}
/*
* Report socket allocation statistics [mea@utu.fi]
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)