Thread (7 messages) 7 messages, 3 authors, 2018-02-05

Re: [BUG iproute2] ip tuntap show

From: Serhey Popovych <hidden>
Date: 2018-02-05 15:35:06

David Ahern wrote:
On 1/31/18 10:21 AM, Serhey Popovych wrote:
quoted
Eric Dumazet wrote:
quoted
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.

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help