* [IPV6]: ROUTE:read ifname in rt6_info_route()
@ 2009-04-16 11:05 Yuta sugiura
2009-04-16 11:38 ` David Miller
0 siblings, 1 reply; 8+ messages in thread
From: Yuta sugiura @ 2009-04-16 11:05 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 271 bytes --]
Hi,
I have a suggestion about /proc/net/IPv6_route format.
In rt6_info_route(), interface name is treated as a maximum 8 characters.
But the type of (struct rt6_inf *)->u.dst.dev->name is char[IFNAMESIZ= 16]
so, I think that it should change "%8s" to "%16s".
Thanks,
[-- Attachment #2: ipv6_route_ifnamesiz.patch --]
[-- Type: text/plain, Size: 762 bytes --]
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1394ddb..9ad58e7 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2434,7 +2434,7 @@ static int ip6_route_dev_notify(struct notifier_block *this,
#ifdef CONFIG_PROC_FS
-#define RT6_INFO_LEN (32 + 4 + 32 + 4 + 32 + 40 + 5 + 1)
+#define RT6_INFO_LEN (32 + 4 + 32 + 4 + 32 + 48 + 5 + 1)
struct rt6_proc_arg
{
@@ -2462,7 +2462,7 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
} else {
seq_puts(m, "00000000000000000000000000000000");
}
- seq_printf(m, " %08x %08x %08x %08x %8s\n",
+ seq_printf(m, " %08x %08x %08x %08x %16s\n",
rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
rt->u.dst.__use, rt->rt6i_flags,
rt->rt6i_dev ? rt->rt6i_dev->name : "");
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [IPV6]: ROUTE:read ifname in rt6_info_route()
2009-04-16 11:05 [IPV6]: ROUTE:read ifname in rt6_info_route() Yuta sugiura
@ 2009-04-16 11:38 ` David Miller
2009-04-16 15:30 ` Stephen Hemminger
0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2009-04-16 11:38 UTC (permalink / raw)
To: ysugiura; +Cc: netdev
From: Yuta sugiura <ysugiura@miraclelinux.com>
Date: Thu, 16 Apr 2009 20:05:05 +0900
> Hi,
> I have a suggestion about /proc/net/IPv6_route format.
> In rt6_info_route(), interface name is treated as a maximum 8
> characters.
> But the type of (struct rt6_inf *)->u.dst.dev->name is char[IFNAMESIZ=
> 16]
> so, I think that it should change "%8s" to "%16s".
Isn't there a way to pass the field length as a paramenter
to formatting functions? Then we can just pass in
IFNAMESIZE as that parameter.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [IPV6]: ROUTE:read ifname in rt6_info_route()
2009-04-16 11:38 ` David Miller
@ 2009-04-16 15:30 ` Stephen Hemminger
2009-04-16 16:17 ` Brian Haley
2009-04-16 16:47 ` Andreas Schwab
0 siblings, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2009-04-16 15:30 UTC (permalink / raw)
To: David Miller; +Cc: ysugiura, netdev
On Thu, 16 Apr 2009 04:38:00 -0700 (PDT)
David Miller <davem@davemloft.net> wrote:
> From: Yuta sugiura <ysugiura@miraclelinux.com>
> Date: Thu, 16 Apr 2009 20:05:05 +0900
>
> > Hi,
> > I have a suggestion about /proc/net/IPv6_route format.
> > In rt6_info_route(), interface name is treated as a maximum 8
> > characters.
> > But the type of (struct rt6_inf *)->u.dst.dev->name is char[IFNAMESIZ=
> > 16]
> > so, I think that it should change "%8s" to "%16s".
>
> Isn't there a way to pass the field length as a paramenter
> to formatting functions? Then we can just pass in
> IFNAMESIZE as that parameter.
seq_printf(m, " %08x %08x %08x %08x %*s\n"
rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
rt->u.dst.__use, rt->rt6i_flags,
IFNAMESIZE,
rt->rt6i_dev ? rt->rt6i_dev->name : "")
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [IPV6]: ROUTE:read ifname in rt6_info_route()
2009-04-16 15:30 ` Stephen Hemminger
@ 2009-04-16 16:17 ` Brian Haley
2009-04-16 16:47 ` Andreas Schwab
1 sibling, 0 replies; 8+ messages in thread
From: Brian Haley @ 2009-04-16 16:17 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, ysugiura, netdev
Stephen Hemminger wrote:
> On Thu, 16 Apr 2009 04:38:00 -0700 (PDT)
> David Miller <davem@davemloft.net> wrote:
>
>> From: Yuta sugiura <ysugiura@miraclelinux.com>
>> Date: Thu, 16 Apr 2009 20:05:05 +0900
>>
>>> Hi,
>>> I have a suggestion about /proc/net/IPv6_route format.
>>> In rt6_info_route(), interface name is treated as a maximum 8
>>> characters.
>>> But the type of (struct rt6_inf *)->u.dst.dev->name is char[IFNAMESIZ=
>>> 16]
>>> so, I think that it should change "%8s" to "%16s".
>> Isn't there a way to pass the field length as a paramenter
>> to formatting functions? Then we can just pass in
>> IFNAMESIZE as that parameter.
>
> seq_printf(m, " %08x %08x %08x %08x %*s\n"
> rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
> rt->u.dst.__use, rt->rt6i_flags,
> IFNAMESIZE,
> rt->rt6i_dev ? rt->rt6i_dev->name : "")
Does the kernel actually truncate an interface name more than 8 chars long in
the original version? I did a quick test in userspace and found that
printf("%*s\n", 1, "foo");
prints:
foo
I think the width specifier is used for *minimum* width, not maximum.
-Brian
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [IPV6]: ROUTE:read ifname in rt6_info_route()
2009-04-16 15:30 ` Stephen Hemminger
2009-04-16 16:17 ` Brian Haley
@ 2009-04-16 16:47 ` Andreas Schwab
2009-04-16 17:27 ` Stephen Hemminger
1 sibling, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2009-04-16 16:47 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, ysugiura, netdev
Stephen Hemminger <shemminger@vyatta.com> writes:
> On Thu, 16 Apr 2009 04:38:00 -0700 (PDT)
> David Miller <davem@davemloft.net> wrote:
>
>> From: Yuta sugiura <ysugiura@miraclelinux.com>
>> Date: Thu, 16 Apr 2009 20:05:05 +0900
>>
>> > Hi,
>> > I have a suggestion about /proc/net/IPv6_route format.
>> > In rt6_info_route(), interface name is treated as a maximum 8
>> > characters.
>> > But the type of (struct rt6_inf *)->u.dst.dev->name is char[IFNAMESIZ=
>> > 16]
>> > so, I think that it should change "%8s" to "%16s".
>>
>> Isn't there a way to pass the field length as a paramenter
>> to formatting functions? Then we can just pass in
>> IFNAMESIZE as that parameter.
>
> seq_printf(m, " %08x %08x %08x %08x %*s\n"
> rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
> rt->u.dst.__use, rt->rt6i_flags,
> IFNAMESIZE,
> rt->rt6i_dev ? rt->rt6i_dev->name : "")
Actually since it is the last item on the line a field width does not
make much sense, and omitting it would print the name left justified.
(And RT6_INFO_LEN is not used any more.)
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [IPV6]: ROUTE:read ifname in rt6_info_route()
2009-04-16 16:47 ` Andreas Schwab
@ 2009-04-16 17:27 ` Stephen Hemminger
2009-04-17 3:44 ` Yuta sugiura
2009-04-17 10:24 ` Andreas Schwab
0 siblings, 2 replies; 8+ messages in thread
From: Stephen Hemminger @ 2009-04-16 17:27 UTC (permalink / raw)
To: Andreas Schwab; +Cc: David Miller, ysugiura, netdev
On Thu, 16 Apr 2009 18:47:04 +0200
Andreas Schwab <schwab@linux-m68k.org> wrote:
> Stephen Hemminger <shemminger@vyatta.com> writes:
>
> > On Thu, 16 Apr 2009 04:38:00 -0700 (PDT)
> > David Miller <davem@davemloft.net> wrote:
> >
> >> From: Yuta sugiura <ysugiura@miraclelinux.com>
> >> Date: Thu, 16 Apr 2009 20:05:05 +0900
> >>
> >> > Hi,
> >> > I have a suggestion about /proc/net/IPv6_route format.
> >> > In rt6_info_route(), interface name is treated as a maximum 8
> >> > characters.
> >> > But the type of (struct rt6_inf *)->u.dst.dev->name is char[IFNAMESIZ=
> >> > 16]
> >> > so, I think that it should change "%8s" to "%16s".
> >>
> >> Isn't there a way to pass the field length as a paramenter
> >> to formatting functions? Then we can just pass in
> >> IFNAMESIZE as that parameter.
> >
> > seq_printf(m, " %08x %08x %08x %08x %*s\n"
> > rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
> > rt->u.dst.__use, rt->rt6i_flags,
> > IFNAMESIZE,
> > rt->rt6i_dev ? rt->rt6i_dev->name : "")
>
> Actually since it is the last item on the line a field width does not
> make much sense, and omitting it would print the name left justified.
>
> (And RT6_INFO_LEN is not used any more.)
>
> Andreas.
>
The issue is what happens if name is not null terminated. in this case
I bet the kernel already handles that.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [IPV6]: ROUTE:read ifname in rt6_info_route()
2009-04-16 17:27 ` Stephen Hemminger
@ 2009-04-17 3:44 ` Yuta sugiura
2009-04-17 10:24 ` Andreas Schwab
1 sibling, 0 replies; 8+ messages in thread
From: Yuta sugiura @ 2009-04-17 3:44 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Andreas Schwab, David Miller, brian.haley
[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]
Thank you for respons to my e-mail.
I read net-snmp's patch as reference.
How about this method?
Stephen Hemminger wrote:
> On Thu, 16 Apr 2009 18:47:04 +0200
> Andreas Schwab <schwab@linux-m68k.org> wrote:
>
>
>> Stephen Hemminger <shemminger@vyatta.com> writes:
>>
>>
>>> On Thu, 16 Apr 2009 04:38:00 -0700 (PDT)
>>> David Miller <davem@davemloft.net> wrote:
>>>
>>>
>>>> From: Yuta sugiura <ysugiura@miraclelinux.com>
>>>> Date: Thu, 16 Apr 2009 20:05:05 +0900
>>>>
>>>>
>>>>> Hi,
>>>>> I have a suggestion about /proc/net/IPv6_route format.
>>>>> In rt6_info_route(), interface name is treated as a maximum 8
>>>>> characters.
>>>>> But the type of (struct rt6_inf *)->u.dst.dev->name is char[IFNAMESIZ=
>>>>> 16]
>>>>> so, I think that it should change "%8s" to "%16s".
>>>>>
>>>> Isn't there a way to pass the field length as a paramenter
>>>> to formatting functions? Then we can just pass in
>>>> IFNAMESIZE as that parameter.
>>>>
>>> seq_printf(m, " %08x %08x %08x %08x %*s\n"
>>> rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
>>> rt->u.dst.__use, rt->rt6i_flags,
>>> IFNAMESIZE,
>>> rt->rt6i_dev ? rt->rt6i_dev->name : "")
>>>
>> Actually since it is the last item on the line a field width does not
>> make much sense, and omitting it would print the name left justified.
>>
>> (And RT6_INFO_LEN is not used any more.)
>>
>> Andreas.
>>
>>
>
> The issue is what happens if name is not null terminated. in this case
> I bet the kernel already handles that.
>
>
[-- Attachment #2: ipv6_route_ifnamesiz2.patch --]
[-- Type: text/plain, Size: 824 bytes --]
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1394ddb..a532dda 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -2434,7 +2434,8 @@ static int ip6_route_dev_notify(struct notifier_block *this,
#ifdef CONFIG_PROC_FS
-#define RT6_INFO_LEN (32 + 4 + 32 + 4 + 32 + 40 + 5 + 1)
+#define RT6_INFO_LEN (32 + 4 + 32 + 4 + 32 + 48 + 5 + 1)
+#define RT6_VAL_TO_STR(s) #s
struct rt6_proc_arg
{
@@ -2462,7 +2463,8 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
} else {
seq_puts(m, "00000000000000000000000000000000");
}
- seq_printf(m, " %08x %08x %08x %08x %8s\n",
+ seq_printf(m, " %08x %08x %08x %08x %"
+ RT6_VAL_TO_STR(IFNAMSIZ) "s\n",
rt->rt6i_metric, atomic_read(&rt->u.dst.__refcnt),
rt->u.dst.__use, rt->rt6i_flags,
rt->rt6i_dev ? rt->rt6i_dev->name : "");
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [IPV6]: ROUTE:read ifname in rt6_info_route()
2009-04-16 17:27 ` Stephen Hemminger
2009-04-17 3:44 ` Yuta sugiura
@ 2009-04-17 10:24 ` Andreas Schwab
1 sibling, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2009-04-17 10:24 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, ysugiura, netdev
Stephen Hemminger <shemminger@vyatta.com> writes:
> The issue is what happens if name is not null terminated.
That cannot happen. And a field width would not help anyway.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-04-17 10:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-16 11:05 [IPV6]: ROUTE:read ifname in rt6_info_route() Yuta sugiura
2009-04-16 11:38 ` David Miller
2009-04-16 15:30 ` Stephen Hemminger
2009-04-16 16:17 ` Brian Haley
2009-04-16 16:47 ` Andreas Schwab
2009-04-16 17:27 ` Stephen Hemminger
2009-04-17 3:44 ` Yuta sugiura
2009-04-17 10:24 ` Andreas Schwab
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).