From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH iproute2-next v2 0/6] ip: Use netlink to walk through network device list Date: Wed, 7 Feb 2018 17:20:38 -0700 Message-ID: <359128a5-b8a1-a821-1497-5ec2fa4c4cdc@gmail.com> References: <1517985056-10043-1-git-send-email-serhe.popovych@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Serhey Popovych , netdev@vger.kernel.org Return-path: Received: from mail-pf0-f170.google.com ([209.85.192.170]:42534 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750729AbeBHAUl (ORCPT ); Wed, 7 Feb 2018 19:20:41 -0500 Received: by mail-pf0-f170.google.com with SMTP id b25so1060553pfd.9 for ; Wed, 07 Feb 2018 16:20:40 -0800 (PST) In-Reply-To: <1517985056-10043-1-git-send-email-serhe.popovych@gmail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 2/6/18 11:30 PM, Serhey Popovych wrote: > In this seris I replace /proc/net/dev and /sys/class/net usage for walk > through network device list in iptunnel/ip6tunnel and iptuntap with > netlink dump. > > Following changed since RFC was sent: > > 1) Treat @struct rtnl_link_stats and @struct rtnl_link_stats64 as > array with __u32 and __u64 elements respectively in > copy_rtnl_link_stats64() as suggested by Stephen Hemminger. > > 2) Remove @name and @size parameters from @struct tnl_print_nlmsg_info > since we can get them easily from other data. > > Testing. > ======== > > Following script is used to ensure I didn't broke things too much: > > \#!/bin/bash > > iproute2_dir="$1" > iface='gre1' > > pushd "$iproute2_dir" &>/dev/null > > for i in new old; do > DIR="/tmp/$i" > mkdir -p "$DIR" > > ln -snf ip.$i ip/ip > > for o in '' -s -d; do > ip/ip $o tunnel show >"$DIR/ip${o}-tunnel-show" > ip/ip -4 $o tunnel show >"$DIR/ip-4${o}-tunnel-show" > ip/ip -6 $o tunnel show >"$DIR/ip-6${o}-tunnel-show" > ip/ip $o tunnel show dev "$iface" \ > >"$DIR/ip${o}-tunnel-show-$iface" > ip/ip $o tuntap show >"$DIR/ip${o}-tuntap-show" > done > done > rm -f ip/ip > > diff -urN /tmp/{old,new} |sed -n -Ee'/^(-{3}|\+{3})[[:space:]]+/!p' > rc=$? > > popd &>/dev/null > exit $rc > > Results: > ======== > > ... > fopen /sys/class/net/ipip1/tun_flags: No such file or directory > fopen /sys/class/net/ipip2/tun_flags: No such file or directory > fopen /sys/class/net/gre10/tun_flags: No such file or directory > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > note that this comes from ip.old > ... > diff -urN /tmp/old/ip-d-tuntap-show /tmp/new/ip-d-tuntap-show > @@ -1,4 +1,4 @@ > -tun1: tap user 1004 group 27 > - Attached to processes: > tun0: tun user 1000 group 27 > Attached to processes: > +tun1: tap user 1004 group 27 > + Attached to processes: > diff -urN /tmp/old/ip-s-tuntap-show /tmp/new/ip-s-tuntap-show > @@ -1,2 +1,2 @@ > -tun1: tap user 1004 group 27 > tun0: tun user 1000 group 27 > +tun1: tap user 1004 group 27 > diff -urN /tmp/old/ip-tuntap-show /tmp/new/ip-tuntap-show > @@ -1,2 +1,2 @@ > -tun1: tap user 1004 group 27 > tun0: tun user 1000 group 27 > +tun1: tap user 1004 group 27 > > So basically only print order for ip tuntap get changes. Rest is intact. > > v2 > Fix build failure in 0/4 patch ("iptunnel/ip6tunnel: Code cleanups") > and update it's description showing why this cleanup is necessary. > > Update cover letter to explain origins of fopen /sys/class/net/... > error message sources. > > Thanks, > Serhii > > Serhey Popovych (6): > ipaddress: Unify print_link_stats() and print_link_stats64() > ip: Introduce get_rtnl_link_stats_rta() to get link statistics > tunnel: Split statistic getting and printing > iptunnel/ip6tunnel: Code cleanups > iptunnel/ip6tunnel: Use netlink to walk through tunnels list > tuntap: Use netlink to walk through tuntap list > > include/utils.h | 3 + > ip/ip6tunnel.c | 115 +++++++++++---------------------- > ip/ipaddress.c | 189 ++++--------------------------------------------------- > ip/iptunnel.c | 93 +++++++++------------------ > ip/iptuntap.c | 121 ++++++++++++++++++++++++++--------- > ip/tunnel.c | 114 ++++++++++++++++++++++++++------- > ip/tunnel.h | 17 ++++- > lib/utils.c | 45 +++++++++++++ > 8 files changed, 324 insertions(+), 373 deletions(-) > series applied to iproute2-next