All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Hangbin Liu <liuhangbin@gmail.com>
Cc: netdev@vger.kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH iproute2 net-next] nstat: add sctp snmp support
Date: Fri, 2 Sep 2016 12:09:12 +0200	[thread overview]
Message-ID: <20160902100912.GC5252@orbyte.nwl.cc> (raw)
In-Reply-To: <1472800358-31881-1-git-send-email-liuhangbin@gmail.com>

On Fri, Sep 02, 2016 at 03:12:38PM +0800, Hangbin Liu wrote:
> SCTP module was not load by default. But this should be OK since we will not
> load table if fdopen() failed.
> 
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  misc/nstat.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/misc/nstat.c b/misc/nstat.c
> index 6143719..8035be4 100644
> --- a/misc/nstat.c
> +++ b/misc/nstat.c
> @@ -76,6 +76,11 @@ static int net_snmp6_open(void)
>  	return generic_proc_open("PROC_NET_SNMP6", "net/snmp6");
>  }
>  
> +static int net_sctp_snmp_open(void)
> +{
> +	return generic_proc_open("PROC_NET_SCTP_SNMP", "net/sctp/snmp");
> +}
> +
>  struct nstat_ent {
>  	struct nstat_ent *next;
>  	char		 *id;
> @@ -247,6 +252,16 @@ static void load_ugly_table(FILE *fp)
>  	}
>  }
>  
> +static void load_sctp_snmp(void)
> +{
> +	FILE *fp = fdopen(net_sctp_snmp_open(), "r");
> +
> +	if (fp) {
> +		load_good_table(fp);
> +		fclose(fp);
> +	}
> +}
> +
>  static void load_snmp(void)
>  {
>  	FILE *fp = fdopen(net_snmp_open(), "r");
> @@ -450,6 +465,7 @@ static void server_loop(int fd)
>  	load_netstat();
>  	load_snmp6();
>  	load_snmp();
> +	load_sctp_snmp();
>  
>  	for (;;) {
>  		int status;
> @@ -706,6 +722,7 @@ int main(int argc, char *argv[])
>  		load_netstat();
>  		load_snmp6();
>  		load_snmp();
> +		load_sctp_snmp();
>  		if (info_source[0] == 0)
>  			strcpy(info_source, "kernel");
>  	}

Did you forget to add the load call to update_db(), or am I missing
something?

Apart from that, looks nice and clean.

Cheers, Phil

  reply	other threads:[~2016-09-02 10:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02  7:12 [PATCH iproute2 net-next] nstat: add sctp snmp support Hangbin Liu
2016-09-02 10:09 ` Phil Sutter [this message]
2016-09-05  3:31   ` Hangbin Liu
2016-09-02 19:46 ` Stephen Hemminger
2016-09-02 19:48   ` Stephen Hemminger

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=20160902100912.GC5252@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=liuhangbin@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.