[patch] /proc/net/{tcp,udp,raw} cleanup

From: Marc Zyngier (mzyngier@freesurf.fr)
Date: Mon Sep 11 2000 - 07:14:01 EST


Hi Dave,

/proc/net/{tcp,udp,raw} show IPv4 addresses with host order, while
port is shown with network order. The included patch adds the needed
ntohl(). Not very usefull, but hopefully correct.

Tested on 2.4.0-pre8/Alpha.

        M.

--- linux/net/ipv4/tcp_ipv4.c.old Mon Sep 11 12:15:54 2000
+++ linux/net/ipv4/tcp_ipv4.c Mon Sep 11 12:21:10 2000
@@ -1983,9 +1983,9 @@
         sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
                 " %02X %08X:%08X %02X:%08X %08X %5d %8d %u %d %p",
                 i,
- req->af.v4_req.loc_addr,
+ ntohl(req->af.v4_req.loc_addr),
                 ntohs(sk->sport),
- req->af.v4_req.rmt_addr,
+ ntohl(req->af.v4_req.rmt_addr),
                 ntohs(req->rmt_port),
                 TCP_SYN_RECV,
                 0,0, /* could print option size, but that is af dependent. */
@@ -2008,8 +2008,8 @@
         unsigned long timer_expires;
         struct tcp_opt *tp = &sp->tp_pinfo.af_tcp;
 
- dest = sp->daddr;
- src = sp->rcv_saddr;
+ dest = ntohl(sp->daddr);
+ src = ntohl(sp->rcv_saddr);
         destp = ntohs(sp->dport);
         srcp = ntohs(sp->sport);
         if (tp->pending == TCP_TIME_RETRANS) {
@@ -2049,8 +2049,8 @@
         if (ttd < 0)
                 ttd = 0;
 
- dest = tw->daddr;
- src = tw->rcv_saddr;
+ dest = ntohl(tw->daddr);
+ src = ntohl(tw->rcv_saddr);
         destp = ntohs(tw->dport);
         srcp = ntohs(tw->sport);
 
--- linux/net/ipv4/udp.c.old Mon Sep 11 12:22:00 2000
+++ linux/net/ipv4/udp.c Mon Sep 11 12:23:23 2000
@@ -986,8 +986,8 @@
         int timer_active;
         unsigned long timer_expires;
 
- dest = sp->daddr;
- src = sp->rcv_saddr;
+ dest = ntohl(sp->daddr);
+ src = ntohl(sp->rcv_saddr);
         destp = ntohs(sp->dport);
         srcp = ntohs(sp->sport);
         timer_active = timer_pending(&sp->timer) ? 2 : 0;
--- linux/net/ipv4/raw.c.old Mon Sep 11 13:54:23 2000
+++ linux/net/ipv4/raw.c Mon Sep 11 13:55:00 2000
@@ -617,8 +617,8 @@
         int timer_active;
         unsigned long timer_expires;
 
- dest = sp->daddr;
- src = sp->rcv_saddr;
+ dest = ntohl(sp->daddr);
+ src = ntohl(sp->rcv_saddr);
         destp = 0;
         srcp = sp->num;
         timer_active = (timer_pending(&sp->timer)) ? 2 : 0;

-- 
Places change, faces change. Life is so very strange.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Sep 15 2000 - 21:00:14 EST