netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipvs -- format /proc/net/ip_vs_conn entries in dotted notation.
@ 2003-09-15 21:43 Stephen Hemminger
  2003-09-15 23:17 ` Roberto Nibali
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2003-09-15 21:43 UTC (permalink / raw)
  To: David S. Miller, lvs-users; +Cc: netdev

Easier for human's to read dotted notation IP addresses.

Assumes earlier seq_file patch.

diff -Nru a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
--- a/net/ipv4/ipvs/ip_vs_conn.c	Mon Sep 15 14:31:28 2003
+++ b/net/ipv4/ipvs/ip_vs_conn.c	Mon Sep 15 14:31:28 2003
@@ -682,23 +682,33 @@
 		ct_read_unlock(l - ip_vs_conn_tab);
 }
 
+static inline void addr_format(char * tmp,__u32 addr, __u16 port)
+{
+	sprintf(tmp, "%u.%u.%u.%u:%u",
+		NIPQUAD(addr), ntohs(port));
+}
+
+
 static int ip_vs_conn_seq_show(struct seq_file *seq, void *v)
 {
 
 	if (v == SEQ_START_TOKEN)
-		seq_puts(seq,
-   "Pro FromIP   FPrt ToIP     TPrt DestIP   DPrt State       Expires\n");
+		seq_printf(seq, "%-3s %-18s %-18s %-18s %-11s %-6s\n",
+			   "Pro", "From", "To", "Destination", 
+			   "State", "Expire");
 	else {
 		const struct ip_vs_conn *cp = v;
+		char from[20], to[20], dest[20];
+
+		addr_format(from, cp->caddr, ntohs(cp->cport));
+		addr_format(to, cp->vaddr, ntohs(cp->vport));
+		addr_format(dest, cp->daddr, ntohs(cp->dport));
 
-		seq_printf(seq,
-			"%-3s %08X %04X %08X %04X %08X %04X %-11s %7lu\n",
-				ip_vs_proto_name(cp->protocol),
-				ntohl(cp->caddr), ntohs(cp->cport),
-				ntohl(cp->vaddr), ntohs(cp->vport),
-				ntohl(cp->daddr), ntohs(cp->dport),
-				ip_vs_state_name(cp->protocol, cp->state),
-				(cp->timer.expires-jiffies)/HZ);
+		seq_printf(seq,	"%-3s %-18s %-18s %-18s %-11s %7lu\n",
+			   ip_vs_proto_name(cp->protocol),
+			   from, to, dest,
+			   ip_vs_state_name(cp->protocol, cp->state),
+			   (cp->timer.expires-jiffies)/HZ);
 	}
 	return 0;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-09-15 23:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-15 21:43 [PATCH] ipvs -- format /proc/net/ip_vs_conn entries in dotted notation Stephen Hemminger
2003-09-15 23:17 ` Roberto Nibali

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).