From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH iproute2-next 0/4] ip: Introduce and use helper to read /proc/net/dev Date: Wed, 31 Jan 2018 15:04:44 -0800 Message-ID: <20180131150444.439b9d20@xeon-e3> References: <1517428189-29279-1-git-send-email-serhe.popovych@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Serhey Popovych Return-path: Received: from mail-pf0-f194.google.com ([209.85.192.194]:35166 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754341AbeAaXEs (ORCPT ); Wed, 31 Jan 2018 18:04:48 -0500 Received: by mail-pf0-f194.google.com with SMTP id t12so14217875pfg.2 for ; Wed, 31 Jan 2018 15:04:47 -0800 (PST) In-Reply-To: <1517428189-29279-1-git-send-email-serhe.popovych@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, 31 Jan 2018 21:49:45 +0200 Serhey Popovych wrote: > Currently there is two places in ip(8) where /proc/net/dev is read line > by line with nearly identical steps: iptunnel.c and ip6tunnel.c > > On the other hand we have iptuntap.c that uses /sys/class/net that could > be problematic in case of unshare(1)d network namespace without sysfs > being mounted. > > Introduce and use do_each_proc_net_dev() helper to read data from > /proc/net/dev line by line and pass this information to implementation > specific callback function. > > See individual patch description message for more details. > > Series is open for reviews and comments. > > Tested only by compiling and executing ip [-46] [-s] [-d] tunnel in > various combinations: no problem so far. More can be done by request. > > Thanks, > Serhii > > Serhey Popovych (4): > utils: Introduce do_each_proc_net_dev() helper > iptunnel: Use do_each_proc_net_dev() > ip6tunnel: Use do_each_proc_net_dev() > tuntap: Use do_each_proc_net_dev() > > include/utils.h | 10 ++++++ > ip/ip6tunnel.c | 94 ++++++++++++++++++++------------------------------ > ip/iptunnel.c | 102 +++++++++++++++++++++++++------------------------------ > ip/iptuntap.c | 59 ++++++++++++++------------------ > lib/utils.c | 51 ++++++++++++++++++++++++++++ > 5 files changed, 170 insertions(+), 146 deletions(-) > /proc/net/dev is legacy and unextensible. I would rather see netlink used everywhere and not /proc/net/dev or sysfs!