Page MenuHomeFreeBSD

syslogd: Detect INET/INET6 support using kern.features
AcceptedPublic

Authored by jfree on Sun, Nov 17, 7:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 3:17 AM
Unknown Object (File)
Wed, Nov 20, 12:04 AM
Unknown Object (File)
Tue, Nov 19, 3:18 PM
Unknown Object (File)
Tue, Nov 19, 12:22 PM
Unknown Object (File)
Tue, Nov 19, 8:48 AM
Unknown Object (File)
Tue, Nov 19, 8:20 AM
Unknown Object (File)
Tue, Nov 19, 8:17 AM
Unknown Object (File)
Tue, Nov 19, 8:00 AM
Subscribers

Details

Reviewers
markj
zlei
Summary

Previously, INET and INET6 support was determined by fetching the kernel
configuration (kern.conftxt) and grep'ing through it. This approach fails
if the kernel was compiled without an embedded conftxt.

Use the kern.features.inet and kern.features.inet6 sysctls instead to
determine INET and INET6 support. These knobs return non-zero if the
feature is supported.

This lets us call one less command (since grep is no longer needed) and
works on systems without conftxt.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 60648
Build 57532: arc lint + arc unit

Event Timeline

jfree requested review of this revision.Sun, Nov 17, 7:57 PM
usr.sbin/syslogd/tests/syslogd_test.sh
122
131
138

I would suggest calling atf_skip if both inet and inet6 are not set.

zlei added inline comments.
usr.sbin/syslogd/tests/syslogd_test.sh
138

I would suggest calling atf_skip if both inet and inet6 are not set.

Or maybe it is better to have separate test cases, aka test_unix, test_inet and test_inet6 ?

jfree marked 3 inline comments as done.
jfree removed a subscriber: zlei.
  • Use sysctl's -n flag to print value without variable name. Silly mistake on my part.
  • Skip test if INET and INET6 are unsupported by kernel.
jfree marked an inline comment as not done.
jfree added a subscriber: zlei.

Separate the "basic" test into three separate tests:

  • unix
  • inet
  • inet6

Thanks to @zlei for the suggestion.

This revision is now accepted and ready to land.Mon, Nov 18, 3:18 AM
usr.sbin/syslogd/tests/syslogd_test.sh
132

Unfortunately, the way this works is that the sysctl simply doesn't exist if the feature isn't there. So you have to write something like:

if [ "$(sysctl -n kern.features.inet)" -ne 1 ]; then
    atf_skip
fi

You might also want to make sure that atf_skip can be used in the test case head. It might be fine, but it should be double-checked if you haven't already.