netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: Roopa Prabhu <roopa@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com, davem@davemloft.net
Subject: Re: [PATCH net-next v3 RFC 2/2] ipv6: add support for stats via RTM_GETSTATS
Date: Sat, 16 Apr 2016 09:55:12 +0200	[thread overview]
Message-ID: <20160416075512.GB2486@pox.localdomain> (raw)
In-Reply-To: <1460777293-39474-3-git-send-email-roopa@cumulusnetworks.com>

On 04/15/16 at 08:28pm, Roopa Prabhu wrote:
> +static size_t inet6_get_link_af_stats_size(const struct net_device *dev,
> +					   u32 filter_mask)
> +{
> +	if (!(filter_mask & IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_INET6)))
> +		return 0;
> +
> +	if (!__in6_dev_get(dev))
> +		return 0;
> +
> +	return nla_total_size(sizeof(struct nlattr)) /* IFLA_STATS_LINK_INET6 */
> +		+ nla_total_size(IPSTATS_MIB_MAX * 8) /* IFLA_INET6_STATS */
> +		+ nla_total_size(ICMP6_MIB_MAX * sizeof(u64));/* IFLA_INET6_ICMP6STATS */
> +}

I think this is a good example. The above is an expensive way to
figure out whether you have at least one interface with IPv6
statistics. I'd suggest to turn this into:

if (filter_mask & IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_INET6)) {
        size += nla_total_size(sizeof(struct nlattr)) /* IFLA_STATS_LINK_INET6 */
                + nla_total_size(IPSTATS_MIB_MAX * 8) /* IFLA_INET6_STATS */
                + nla_total_size(ICMP6_MIB_MAX * sizeof(u64));/* IFLA_INET6_ICMP6STATS */
}

... and put it into the main calcit function. The user has explicitly opted into
IPv6 statistics so I think it's not a waste to allocate resources for it in the
message. You could also make it depend on "disable_ipv6" to be more accurate but
I think even the above is good enough.

      reply	other threads:[~2016-04-16  7:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-16  3:28 [PATCH net-next v3 RFC 2/2] ipv6: add support for stats via RTM_GETSTATS Roopa Prabhu
2016-04-16  7:55 ` Thomas Graf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160416075512.GB2486@pox.localdomain \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).