From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCHv2 iproute2 net-next] nstat: add sctp snmp support
Date: Mon, 5 Sep 2016 11:35:02 +0800 [thread overview]
Message-ID: <1473046502-5395-1-git-send-email-liuhangbin@gmail.com> (raw)
SCTP module was not load by default. But this should be OK since we will not
load table if fdopen() failed, also opening the proc file won't load SCTP
kernel module.
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
misc/nstat.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/misc/nstat.c b/misc/nstat.c
index 6143719..1cb6c7e 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");
@@ -391,6 +406,7 @@ static void update_db(int interval)
load_netstat();
load_snmp6();
load_snmp();
+ load_sctp_snmp();
h = kern_db;
kern_db = n;
@@ -450,6 +466,7 @@ static void server_loop(int fd)
load_netstat();
load_snmp6();
load_snmp();
+ load_sctp_snmp();
for (;;) {
int status;
@@ -706,6 +723,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");
}
--
2.5.5
next reply other threads:[~2016-09-05 3:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-05 3:35 Hangbin Liu [this message]
2016-09-08 21:30 ` [PATCHv2 iproute2 net-next] nstat: add sctp snmp support 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=1473046502-5395-1-git-send-email-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.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 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).