Date: Thu, 12 Jan 2012 12:11:04 +0100 From: Michael Tuexen <Michael.Tuexen@lurchi.franken.de> To: smahood@engmail.uwaterloo.ca Cc: freebsd-net@freebsd.org Subject: Re: [PATCH] Have netstat test for sctp kernel support Message-ID: <940650A6-785B-435B-B7C5-7C68925DEC8D@lurchi.franken.de> In-Reply-To: <20111025141741.26891k8ib38ekmkg@www.nexusmail.uwaterloo.ca> References: <20111025141741.26891k8ib38ekmkg@www.nexusmail.uwaterloo.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On Oct 25, 2011, at 8:17 PM, Sean Mahood wrote:
> Hello,
>
> I noticed that when doing a netstat -s (running on a kernel without SCTP support compiled in), I get the following message output to stderr:
>
> netstat: sysctl: net.inet.sctp.stats: No such file or directory
>
> Wondering why it would attempt to fetch SCTP stats when it was compiled out of the kernel, I noted that netstat could be compiled without SCTP support as well, but that there is no good way to link the two compilation conditions, or to have a generic binary that can run without error regardless of compiled kernel options.
>
> To that end, I added a method to check for environment compatibility in netstat. For SCTP specifically, I used the FEATURE macros and added SCTP as a FEATURE.
>
> Other protocols could also be configured to be checked at runtime if desired, though I haven't implemented any others at this time.
Hi Sean,
I agree, the error message should be avoided. There is a similar situation for IPv6. When not compiled
into the kernel, netstat should not report an error, even if it is not recompiled. The way it is
handled for INET6 is to pay attention to the errno in case sysctlbyname() fails. we also have already
one place in the sctp.c code where we do the correct check. I guess it was missed in the code
responsable for the above error message.
So what do you think about the attached patch, which resolves the issue you reported in a way already
used in netstat and which is portable to other BSD based platform (like Mac OS X)?
Thank you very much for reporting the issue.
Best regards
Michael
Index: sctp.c
===================================================================
--- sctp.c (revision 230008)
+++ sctp.c (working copy)
@@ -611,7 +611,8 @@
memset(&zerostat, 0, len);
if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
- warn("sysctl: net.inet.sctp.stats");
+ if (errno != ENOENT)
+ warn("sysctl: net.inet.sctp.stats");
return;
}
} else
>
> -- Sean
>
>
>
> <main.c.diff><netstat.h.diff><sctp.c.diff><sctp_sysctl.c.diff>_______________________________________________
> freebsd-net@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?940650A6-785B-435B-B7C5-7C68925DEC8D>
