* [PATCH] Cleanup the IPv6 addresses printing in /proc files
@ 2007-10-23 16:37 Pavel Emelyanov
2007-10-24 3:43 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Pavel Emelyanov @ 2007-10-23 16:37 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List, devel
The /proc/net udp6, tcp6 and raw6 files print the IPs of
the connection ends. Make a NIP6Lxxx macros (L stands for
"long") for making the printing code look nicer.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 94bc996..5d199ae 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -307,6 +307,13 @@ static inline int __attribute__ ((format (printf, 1, 2))) pr_debug(const char *
#define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
#define NIP6_SEQFMT "%04x%04x%04x%04x%04x%04x%04x%04x"
+#define NIP6L(addr) \
+ ((addr).s6_addr32[0]), \
+ ((addr).s6_addr32[1]), \
+ ((addr).s6_addr32[2]), \
+ ((addr).s6_addr32[3])
+#define NIP6L_FMT "%08X%08X%08X%08X"
+
#if defined(__LITTLE_ENDIAN)
#define HIPQUAD(addr) \
((unsigned char *)&addr)[3], \
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index ca24ef1..c3a1939 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -1250,13 +1250,9 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
destp = 0;
srcp = inet_sk(sp)->num;
seq_printf(seq,
- "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
+ "%4d: " NIP6L_FMT ":%04X " NIP6L_FMT ":%04X "
"%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p\n",
- i,
- src->s6_addr32[0], src->s6_addr32[1],
- src->s6_addr32[2], src->s6_addr32[3], srcp,
- dest->s6_addr32[0], dest->s6_addr32[1],
- dest->s6_addr32[2], dest->s6_addr32[3], destp,
+ i, NIP6L(*src), srcp, NIP6L(*dest), destp,
sp->sk_state,
atomic_read(&sp->sk_wmem_alloc),
atomic_read(&sp->sk_rmem_alloc),
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 737b755..0041be3 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1945,15 +1945,10 @@ static void get_openreq6(struct seq_file *seq,
ttd = 0;
seq_printf(seq,
- "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
+ "%4d: " NIP6L_FMT ":%04X " NIP6L_FMT ":%04X "
"%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n",
- i,
- src->s6_addr32[0], src->s6_addr32[1],
- src->s6_addr32[2], src->s6_addr32[3],
- ntohs(inet_sk(sk)->sport),
- dest->s6_addr32[0], dest->s6_addr32[1],
- dest->s6_addr32[2], dest->s6_addr32[3],
- ntohs(inet_rsk(req)->rmt_port),
+ i, NIP6L(*src), ntohs(inet_sk(sk)->sport),
+ NIP6L(*dest), ntohs(inet_rsk(req)->rmt_port),
TCP_SYN_RECV,
0,0, /* could print option size, but that is af dependent. */
1, /* timers active (only the expire timer) */
@@ -1996,13 +1991,9 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
}
seq_printf(seq,
- "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
+ "%4d: " NIP6L_FMT ":%04X " NIP6L_FMT ":%04X "
"%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p %u %u %u %u %d\n",
- i,
- src->s6_addr32[0], src->s6_addr32[1],
- src->s6_addr32[2], src->s6_addr32[3], srcp,
- dest->s6_addr32[0], dest->s6_addr32[1],
- dest->s6_addr32[2], dest->s6_addr32[3], destp,
+ i, NIP6L(*src), srcp, NIP6L(*dest), destp,
sp->sk_state,
tp->write_seq-tp->snd_una,
(sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq),
@@ -2037,13 +2028,9 @@ static void get_timewait6_sock(struct seq_file *seq,
srcp = ntohs(tw->tw_sport);
seq_printf(seq,
- "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
+ "%4d: " NIP6L_FMT ":%04X " NIP6L_FMT ":%04X "
"%02X %08X:%08X %02X:%08lX %08X %5d %8d %d %d %p\n",
- i,
- src->s6_addr32[0], src->s6_addr32[1],
- src->s6_addr32[2], src->s6_addr32[3], srcp,
- dest->s6_addr32[0], dest->s6_addr32[1],
- dest->s6_addr32[2], dest->s6_addr32[3], destp,
+ i, NIP6L(*src), srcp, NIP6L(*dest), destp,
tw->tw_substate, 0, 0,
3, jiffies_to_clock_t(ttd), 0, 0, 0, 0,
atomic_read(&tw->tw_refcnt), tw);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index caebad6..bcc5f8e 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -919,13 +919,9 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
destp = ntohs(inet->dport);
srcp = ntohs(inet->sport);
seq_printf(seq,
- "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
+ "%4d: " NIP6L_FMT ":%04X " NIP6L_FMT ":%04X "
"%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p\n",
- bucket,
- src->s6_addr32[0], src->s6_addr32[1],
- src->s6_addr32[2], src->s6_addr32[3], srcp,
- dest->s6_addr32[0], dest->s6_addr32[1],
- dest->s6_addr32[2], dest->s6_addr32[3], destp,
+ bucket, NIP6L(*src), srcp, NIP6L(*dest), destp,
sp->sk_state,
atomic_read(&sp->sk_wmem_alloc),
atomic_read(&sp->sk_rmem_alloc),
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Cleanup the IPv6 addresses printing in /proc files
2007-10-23 16:37 [PATCH] Cleanup the IPv6 addresses printing in /proc files Pavel Emelyanov
@ 2007-10-24 3:43 ` David Miller
2007-10-24 4:04 ` Joe Perches
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2007-10-24 3:43 UTC (permalink / raw)
To: xemul; +Cc: netdev, devel
From: Pavel Emelyanov <xemul@openvz.org>
Date: Tue, 23 Oct 2007 20:37:22 +0400
> The /proc/net udp6, tcp6 and raw6 files print the IPs of
> the connection ends. Make a NIP6Lxxx macros (L stands for
> "long") for making the printing code look nicer.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Cleanup the IPv6 addresses printing in /proc files
2007-10-24 3:43 ` David Miller
@ 2007-10-24 4:04 ` Joe Perches
2007-10-24 4:10 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2007-10-24 4:04 UTC (permalink / raw)
To: David Miller; +Cc: xemul, netdev, devel
On Tue, 2007-10-23 at 20:43 -0700, David Miller wrote:
> From: Pavel Emelyanov <xemul@openvz.org>
> Date: Tue, 23 Oct 2007 20:37:22 +0400
> > The /proc/net udp6, tcp6 and raw6 files print the IPs of
> > the connection ends. Make a NIP6Lxxx macros (L stands for
> > "long") for making the printing code look nicer.
> > Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
> Applied, thanks.
Why aren't these addresses converted with ntohl?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Cleanup the IPv6 addresses printing in /proc files
2007-10-24 4:04 ` Joe Perches
@ 2007-10-24 4:10 ` David Miller
2007-10-24 4:15 ` Joe Perches
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2007-10-24 4:10 UTC (permalink / raw)
To: joe; +Cc: xemul, netdev, devel
From: Joe Perches <joe@perches.com>
Date: Tue, 23 Oct 2007 21:04:01 -0700
> On Tue, 2007-10-23 at 20:43 -0700, David Miller wrote:
> > From: Pavel Emelyanov <xemul@openvz.org>
> > Date: Tue, 23 Oct 2007 20:37:22 +0400
> > > The /proc/net udp6, tcp6 and raw6 files print the IPs of
> > > the connection ends. Make a NIP6Lxxx macros (L stands for
> > > "long") for making the printing code look nicer.
> > > Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
> > Applied, thanks.
>
> Why aren't these addresses converted with ntohl?
The reason is immaterial because whatever the kernel is doing
now we have to keep doing because applications parsing these
/proc files expect things to be how they are.
We'll break things if we change it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Cleanup the IPv6 addresses printing in /proc files
2007-10-24 4:10 ` David Miller
@ 2007-10-24 4:15 ` Joe Perches
2007-10-24 4:18 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Joe Perches @ 2007-10-24 4:15 UTC (permalink / raw)
To: David Miller; +Cc: xemul, netdev, devel
On Tue, 2007-10-23 at 21:10 -0700, David Miller wrote:
> We'll break things if we change it.
Maybe, but definitely the macro names should
reflect this brokenness.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Cleanup the IPv6 addresses printing in /proc files
2007-10-24 4:15 ` Joe Perches
@ 2007-10-24 4:18 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2007-10-24 4:18 UTC (permalink / raw)
To: joe; +Cc: xemul, netdev, devel
From: Joe Perches <joe@perches.com>
Date: Tue, 23 Oct 2007 21:15:36 -0700
> On Tue, 2007-10-23 at 21:10 -0700, David Miller wrote:
> > We'll break things if we change it.
>
> Maybe, but definitely the macro names should
> reflect this brokenness.
That's a good point, we don't want to encourage further
use of these things.
Pavel, I'm going to revert this patch for now. It may
save some code lines, but it does so at the expense of
creating an interface we actually don't want more users
of.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-10-24 4:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-23 16:37 [PATCH] Cleanup the IPv6 addresses printing in /proc files Pavel Emelyanov
2007-10-24 3:43 ` David Miller
2007-10-24 4:04 ` Joe Perches
2007-10-24 4:10 ` David Miller
2007-10-24 4:15 ` Joe Perches
2007-10-24 4:18 ` David Miller
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).