From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovych Subject: [PATCH iproute2-next 0/4] ip: Introduce and use helper to read /proc/net/dev Date: Wed, 31 Jan 2018 21:49:45 +0200 Message-ID: <1517428189-29279-1-git-send-email-serhe.popovych@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-lf0-f65.google.com ([209.85.215.65]:34661 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750829AbeAaTuP (ORCPT ); Wed, 31 Jan 2018 14:50:15 -0500 Received: by mail-lf0-f65.google.com with SMTP id k19so22593608lfj.1 for ; Wed, 31 Jan 2018 11:50:15 -0800 (PST) Received: from tuxracer.localdomain ([2a01:6d80::195:20:96:53]) by smtp.gmail.com with ESMTPSA id q77sm4040318lfd.17.2018.01.31.11.50.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jan 2018 11:50:13 -0800 (PST) Sender: netdev-owner@vger.kernel.org List-ID: 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(-) -- 1.7.10.4