From owner-freebsd-net@FreeBSD.ORG Thu Jan 12 11:11:06 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7FC8106564A for ; Thu, 12 Jan 2012 11:11:06 +0000 (UTC) (envelope-from Michael.Tuexen@lurchi.franken.de) Received: from mail-n.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) by mx1.freebsd.org (Postfix) with ESMTP id 5BE088FC19 for ; Thu, 12 Jan 2012 11:11:06 +0000 (UTC) Received: from [192.168.1.103] (p508FAE66.dip.t-dialin.net [80.143.174.102]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTP id 696F21C0B4603; Thu, 12 Jan 2012 12:11:04 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Michael Tuexen In-Reply-To: <20111025141741.26891k8ib38ekmkg@www.nexusmail.uwaterloo.ca> Date: Thu, 12 Jan 2012 12:11:04 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <940650A6-785B-435B-B7C5-7C68925DEC8D@lurchi.franken.de> References: <20111025141741.26891k8ib38ekmkg@www.nexusmail.uwaterloo.ca> To: smahood@engmail.uwaterloo.ca X-Mailer: Apple Mail (2.1251.1) Cc: freebsd-net@freebsd.org Subject: Re: [PATCH] Have netstat test for sctp kernel support X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jan 2012 11:11:07 -0000 On Oct 25, 2011, at 8:17 PM, Sean Mahood wrote: > Hello, >=20 > 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: >=20 > netstat: sysctl: net.inet.sctp.stats: No such file or directory >=20 > 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. >=20 > 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. >=20 > 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 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 !=3D ENOENT) + warn("sysctl: net.inet.sctp.stats"); return; } } else >=20 > -- Sean >=20 >=20 >=20 > = ____________= ___________________________________ > 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"