From: David Ahern Subject: Re: [BUG iproute2] ip tuntap show Date: Wed, 31 Jan 2018 10:40:35 -0700 Message-ID: References: <1517417908.3715.102.camel@gmail.com> <84e6cb8a-f140-4ced-4f6a-c508eaf06f6c@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: netdev , =?UTF-8?Q?Maciej_=c5=bbenczykowski?= To: Serhey Popovych , Eric Dumazet , Stephen Hemminger Return-path: Received: from mail-pf0-f180.google.com ([209.85.192.180]:35928 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753031AbeAaRkS (ORCPT ); Wed, 31 Jan 2018 12:40:18 -0500 Received: by mail-pf0-f180.google.com with SMTP id 23so13375332pfp.3 for ; Wed, 31 Jan 2018 09:40:18 -0800 (PST) In-Reply-To: <84e6cb8a-f140-4ced-4f6a-c508eaf06f6c@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: 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.