All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 iproute2 net-next] nstat: add sctp snmp support
@ 2016-09-05  3:35 Hangbin Liu
  2016-09-08 21:30 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Hangbin Liu @ 2016-09-05  3:35 UTC (permalink / raw)
  To: netdev; +Cc: Hangbin Liu

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCHv2 iproute2 net-next] nstat: add sctp snmp support
  2016-09-05  3:35 [PATCHv2 iproute2 net-next] nstat: add sctp snmp support Hangbin Liu
@ 2016-09-08 21:30 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2016-09-08 21:30 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev

On Mon,  5 Sep 2016 11:35:02 +0800
Hangbin Liu <liuhangbin@gmail.com> wrote:

> 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>

Applied thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-08 21:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-05  3:35 [PATCHv2 iproute2 net-next] nstat: add sctp snmp support Hangbin Liu
2016-09-08 21:30 ` Stephen Hemminger

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.