[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a59017f9-53f4-dfe3-fc04-e6a83775ec7c@gmail.com>
Date: Mon, 5 Feb 2018 17:34:51 +0200
From: Serhey Popovych <serhe.popovych@...il.com>
To: David Ahern <dsahern@...il.com>
Cc: netdev <netdev@...r.kernel.org>,
Maciej Żenczykowski <maze@...gle.com>
Subject: Re: [BUG iproute2] ip tuntap show
David Ahern wrote:
> On 1/31/18 10:21 AM, Serhey Popovych wrote:
>> Eric Dumazet wrote:
>>> ip tuntap enumerates devices using /sys/class/net which is unusual.
>>>
>>> Should we replace this enumeration using /proc/net/dev like "ip tunnel" ?
>>>
>>> After "unshare -n" maybe mounting /sys should not be required for
>>> proper iproute2 behavior.
>>>
>>> At least ip command should adopt a common enumeration method.
>>>
>>> What do you think ?
>>
>> It seems main reason for using /sys/class/net is to get additional
>> information for netdev like "owner", "group" and "tun_flags".
>>
>> On the other hand at least iptunnel and ip6tunnel uses nearly identical
>> code to parse /proc/net/dev.
>>
>> Having single routine that reads /proc/net/dev and calls implementation
>> specific callback function with given network device name is good idea.
>>
>> I can try to prepare v1 for this, if no one objects this.
>>
>
> pid_name function needs help too. comm is allocated via sprintf, freed,
> and used again and then returned to caller.
>
Sorry David, but I do no see problem with this function right now:
1. It allocates string using malloc() in asprintf()
2. free() it *after* fopen() to prevent memory leak if fopen() fails
3. or if fopen() succeeded and we fscanf() with %ms that will allcate
buffer we return.
I agree this is GNU extensions, but it does not look as user after free
to me. Should I get rid of these extensions? They are not last as I can
find.
Correct if I miss something.
Download attachment "signature.asc" of type "application/pgp-signature" (491 bytes)
Powered by blists - more mailing lists