Bug 174595

Summary: /etc/rc.d/sysctl : unknown oid 'XXX' [regression]
Product: Base System Reporter: Olivier <olivier>
Component: confAssignee: Jilles Tjoelker <jilles>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch.txt none

Description Olivier 2012-12-20 16:40:00 UTC
Since the last commit (r244198) to /usr/src/etc/rc.d/sysctl, I've got this error at startup just after root is mounted :

sysctl: unknown oid 'compat.linux.osrelease' at line 22: No such file or directory

This is somewhat expected, because the linux compat kmod is only loaded after that by /etc/rc.d/abi (because of linux_enable="YES" in /etc/rc.conf, which is a common use case).

The problem is that... there was no error before. I think the problem comes from the rewritten /usr/src/etc/rc.d/sysctl, which used ">/dev/null 2>&1" to avoid startup errors from being displayed.

Fix: 

Add "2>&1" after "> /dev/null" in /usr/src/etc/rc.d/sysctl
How-To-Repeat: # echo 'compat.linux.osrelease=2.6.32' >> /etc/sysctl.conf
# echo 'linux_enable="YES"' >> /etc/rc.conf
# sed -i '' 's/^linux_load=/#linux_load=/' /boot/loader.conf
# shutdown -r now
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-12-24 08:58:08 UTC
Responsible Changed
From-To: freebsd-amd64->freebsd-rc

reclassify.
Comment 2 Xin LI 2012-12-24 22:17:27 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

It seems that the old behavior is actually wrong...  How are we
benefited by not being told about fatal errors?

Cheers,
- -- 
Xin LI <delphij@delphij.net>    https://www.delphij.net/
FreeBSD - The Power to Serve!           Live free or die
-----BEGIN PGP SIGNATURE-----

iQEcBAEBCAAGBQJQ2NR3AAoJEG80Jeu8UPuzniUH/0WqlPNwNRhyk1EosRKsVQyU
0x3O9AKRHh1k7qlvCkqSr3tFjMnJ+DVLKL9AfkgPweZj7mQ2q8G3BPZTzYlNWFts
aqiZ0o+Ua5F6FVx992yaCPS8Lbwkfmab/ia2HlrowJJmiLdjwu6rOisTnCTPbbvw
NbLKzja72nrYFQ5ibub5zFoCP0lwJwSV2m6mhOyG+G07LXY4OZTdPuaBrJ3zCqt2
Pd8AV9jmxsTn5e5jj1w3hJRhShQ1mgSeknYNBvbOFwQE2q4I+UVUr6ulmD624y57
9ID1RHXB8SBbGGyLwaTShSMsSOE1e1wSPNBO2pJzwHSeYw6rMNjo5izrL4GCDhM=
=gVdi
-----END PGP SIGNATURE-----
Comment 3 Olivier 2013-01-15 11:16:12 UTC
In the compat.linux.osrelease case it's not a fatal error, it seems
that sysctl manages to set the correct value after the linux kld is
loaded by linux_enable="YES", even if it failed the first time.

% sysctl compat.linux.osrelease
compat.linux.osrelease: 2.6.32

I don't really know why and which mechanism is responsible of this but
it behaves like "late" mounts.


2012/12/24 Xin Li <delphij@delphij.net>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> It seems that the old behavior is actually wrong...  How are we
> benefited by not being told about fatal errors?
>
> Cheers,
> - --
> Xin LI <delphij@delphij.net>    https://www.delphij.net/
> FreeBSD - The Power to Serve!           Live free or die
> -----BEGIN PGP SIGNATURE-----
>
> iQEcBAEBCAAGBQJQ2NR3AAoJEG80Jeu8UPuzniUH/0WqlPNwNRhyk1EosRKsVQyU
> 0x3O9AKRHh1k7qlvCkqSr3tFjMnJ+DVLKL9AfkgPweZj7mQ2q8G3BPZTzYlNWFts
> aqiZ0o+Ua5F6FVx992yaCPS8Lbwkfmab/ia2HlrowJJmiLdjwu6rOisTnCTPbbvw
> NbLKzja72nrYFQ5ibub5zFoCP0lwJwSV2m6mhOyG+G07LXY4OZTdPuaBrJ3zCqt2
> Pd8AV9jmxsTn5e5jj1w3hJRhShQ1mgSeknYNBvbOFwQE2q4I+UVUr6ulmD624y57
> 9ID1RHXB8SBbGGyLwaTShSMsSOE1e1wSPNBO2pJzwHSeYw6rMNjo5izrL4GCDhM=
> =gVdi
> -----END PGP SIGNATURE-----



-- 
Olivier Smedts                                                 _
                                        ASCII ribbon campaign ( )
e-mail: olivier@gid0.org        - against HTML email & vCards  X
www: http://www.gid0.org    - against proprietary attachments / \

  "Il y a seulement 10 sortes de gens dans le monde :
  ceux qui comprennent le binaire,
  et ceux qui ne le comprennent pas."
Comment 4 Olivier 2013-03-13 09:11:08 UTC
Hi,

Isn't the logic inverted between the start/reload case and the lastload case ?

The attached patch seems logical :
- tell sysctl to ignore unknown OIDs during the "start" case (corrects
the regression)
rationale : some klds still aren't loaded at start, my example with
linux_enable="YES" in rc.conf and compat.linux.osrelease=2.6.32 in
sysctl.conf is a common use case, and it's not meaningful / it's
confusing to show a startup error about a sysctl which couldn't be set
while it actually has been set in lastload stage
- tell sysctl to not ignore unknown OIDs during the "lastload" case
(preserve added value of r244198)
rationale : if an OID is really unknown and couldn't be set neither in
the start nor in the lastload cases, it's useful to be told about the
fatal error
- behave in the "reload" case like in the "lastload" stage
rationale : reloads usually happen after system startup so they're
really a "lastlastload", and it's useful to spit out errors about
unknown OIDs to the operator who asked for a reload

Hoping the attachment won't be stripped,
Olivier

-- 
Olivier Smedts                                                 _
                                        ASCII ribbon campaign ( )
e-mail: olivier@gid0.org        - against HTML email & vCards  X
www: http://www.gid0.org    - against proprietary attachments / \

  "Il y a seulement 10 sortes de gens dans le monde :
  ceux qui comprennent le binaire,
  et ceux qui ne le comprennent pas."
Comment 5 dfilter service freebsd_committer freebsd_triage 2013-03-22 20:12:33 UTC
Author: jilles
Date: Fri Mar 22 20:12:25 2013
New Revision: 248620
URL: http://svnweb.freebsd.org/changeset/base/248620

Log:
  rc.d/sysctl: Fix error messages about unknown OIDs.
  
  There are three situations where the sysctl script is called:
  1. "start", very early
  2. "lastload", near the end of rc
  3. "reload", at admin request while the system is booted
  
  Ignore unknown OIDs in situation 1 because kernel modules may not be loaded
  yet and complain about them in situations 2 and 3.
  
  PR:		conf/174595
  Submitted by:	Olivier Smedts

Modified:
  head/etc/rc.d/sysctl

Modified: head/etc/rc.d/sysctl
==============================================================================
--- head/etc/rc.d/sysctl	Fri Mar 22 17:55:38 2013	(r248619)
+++ head/etc/rc.d/sysctl	Fri Mar 22 20:12:25 2013	(r248620)
@@ -11,7 +11,7 @@ name="sysctl"
 command="/sbin/sysctl"
 stop_cmd=":"
 start_cmd="sysctl_start"
-reload_cmd="sysctl_start"
+reload_cmd="sysctl_start last"
 lastload_cmd="sysctl_start last"
 extra_commands="reload lastload"
 
@@ -19,10 +19,10 @@ sysctl_start()
 {
 	case $1 in
 	last)
-		command_args="-i -f"
+		command_args="-f"
 	;;
 	*)
-		command_args="-f"
+		command_args="-i -f"
 	;;
 	esac
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 Jilles Tjoelker freebsd_committer freebsd_triage 2013-03-22 20:12:46 UTC
State Changed
From-To: open->closed

Fixed in head in r248620, thanks. 
This bug does not exist in older branches. 


Comment 7 Jilles Tjoelker freebsd_committer freebsd_triage 2013-03-22 20:12:46 UTC
Responsible Changed
From-To: freebsd-rc->jilles

Track followups.