lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 17 Jan 2018 16:28:49 -0800
From:   David Ahern <dsahern@...il.com>
To:     Florian Fainelli <f.fainelli@...il.com>, netdev@...r.kernel.org
Cc:     edumazet@...gle.com, andrew@...n.ch, cphealy@...il.com,
        David Decotigny <decot@...glers.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jamal Hadi Salim <jhs@...atatu.com>,
        Cong Wang <xiyou.wangcong@...il.com>,
        Jiri Pirko <jiri@...nulli.us>,
        Daniel Borkmann <daniel@...earbox.net>,
        Nikolay Aleksandrov <nikolay@...ulusnetworks.com>,
        Alexei Starovoitov <ast@...com>,
        Roopa Prabhu <roopa@...ulusnetworks.com>,
        Mahesh Bandewar <maheshb@...gle.com>,
        Vlad Yasevich <vyasevich@...il.com>,
        Jakub Kicinski <jakub.kicinski@...ronome.com>,
        Jonas Bonn <jonas@...thpole.se>,
        stephen hemminger <stephen@...workplumber.org>,
        Hans Liljestrand <ishkamiel@...il.com>,
        "Reshetova, Elena" <elena.reshetova@...el.com>,
        Kirill Tkhai <ktkhai@...tuozzo.com>,
        Andrey Vagin <avagin@...nvz.org>,
        Florian Westphal <fw@...len.de>,
        Xin Long <lucien.xin@...il.com>,
        Matthias Schiffer <mschiffer@...verse-factory.net>,
        Jiri Benc <jbenc@...hat.com>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next] net: core: Expose number of link up/down
 transitions

On 1/17/18 3:06 PM, Florian Fainelli wrote:
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 7bf8b85ade16..9f732c3dc2ce 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -295,10 +295,29 @@ static ssize_t carrier_changes_show(struct device *dev,
>  	struct net_device *netdev = to_net_dev(dev);
>  
>  	return sprintf(buf, fmt_dec,
> -		       atomic_read(&netdev->carrier_changes));
> +		       atomic_read(&netdev->count_link_up) +
> +		       atomic_read(&netdev->count_link_down));
>  }
>  static DEVICE_ATTR_RO(carrier_changes);
>  
> +static ssize_t count_link_up_show(struct device *dev,
> +				  struct device_attribute *attr, char *buf)
> +{
> +	struct net_device *netdev = to_net_dev(dev);
> +
> +	return sprintf(buf, fmt_dec, atomic_read(&netdev->count_link_up));
> +}
> +static DEVICE_ATTR_RO(count_link_up);
> +
> +static ssize_t count_link_down_show(struct device *dev,
> +				    struct device_attribute *attr, char *buf)
> +{
> +	struct net_device *netdev = to_net_dev(dev);
> +
> +	return sprintf(buf, fmt_dec, atomic_read(&netdev->count_link_down));
> +}
> +static DEVICE_ATTR_RO(count_link_down);
> +
>  /* read-write attributes */
>  
>  static int change_mtu(struct net_device *dev, unsigned long new_mtu)
> @@ -547,6 +566,8 @@ static struct attribute *net_class_attrs[] __ro_after_init = {
>  	&dev_attr_phys_port_name.attr,
>  	&dev_attr_phys_switch_id.attr,
>  	&dev_attr_proto_down.attr,
> +	&dev_attr_count_link_up.attr,
> +	&dev_attr_count_link_down.attr,
>  	NULL,
>  };
>  ATTRIBUTE_GROUPS(net_class);

Personally, I do not like adding any more sysfs files. As discussed in
the past sysfs is a huge contributor to the overhead of netdevs.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ