
Most of the nodes in the general sysctl tree will be managed directly by the MIB service, which obtains the necessary information as needed. However, in certain cases, it makes more sense to let another service manage a part of the sysctl tree itself, in order to avoid replicating part of that other service in the MIB service. This patch adds the basic support for such delegation: remote services may now register their own subtrees within the full sysctl tree with the MIB service, which will then forward any sysctl(2) requests on such subtrees to the remote services. The system works much like mounting a file system, but in addition to support for shadowing an existing node, the MIB service also supports creating temporary mount point nodes. Each have their own use cases. A remote "kern.ipc" would use the former, because even when such a subtree were not mounted, userland would still expect some of its children to exist and return default values. A remote "net.inet" would use the latter, as there is no reason to precreate nodes for all possible supported networking protocols in the MIB "net" subtree. A standard remote MIB (RMIB) implementation is provided for services that wish to make use of this functionality. It is essentially a simplified and somewhat more lightweight version of the MIB service's internals, and works more or less the same from a programmer's point of view. The most important difference is the "rmib" prefix instead of the "mib" prefix. Documentation will hopefully follow later. Overall, the RMIB functionality should not be used lightly, for several reasons. First, despite being more lightweight than the MIB service, the RMIB module still adds substantially to the code footprint of the containing service. Second, the RMIB protocol not only adds extra IPC for sysctl(2), but has also not been optimized for performance in other ways. Third, and most importantly, the RMIB implementation also several limitations. The main limitation is that remote MIB subtrees must be fully static. Not only may the user not create or destroy nodes, the service itself may not either, as this would clash with the simplified remote node versioning system and the cached subtree root node child counts. Other limitations exist, such as the fact that the root of a remote subtree may only be a node-type node, and a stricter limit on the highest node identifier of any child in this subtree root (currently 4095). The current implementation was born out of necessity, and therefore it leaves several improvements to future work. Most importantly, support for exit and crash notification is missing, primarily in the MIB service. This means that remote subtrees may not be cleaned up immediately, but instead only when the MIB service attempts to talk to the dead remote service. In addition, if the MIB service itself crashes, re-registration of remote subtrees is currently left up to the individual RMIB users. Finally, the MIB service uses synchronous (sendrec-based) calls to the remote services, which while convenient may cause cascading service hangs. The underlying protocol is ready for conversion to an asynchronous implementation already, though. A new test set, testrmib.sh, tests the basic RMIB functionality. To this end it uses a test service, rmibtest, and also reuses part of the existing test87 MIB service test. Change-Id: I3378fe04f2e090ab231705bde7e13d6289a9183e
75 lines
2.7 KiB
Bash
Executable File
75 lines
2.7 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Shell script used to test the Remote MIB (RMIB) functionality.
|
|
|
|
# We test a couple of things here, using the rmibtest service and test87:
|
|
# - some cases where remote MIB subtree registration should fail;
|
|
# - a new mount point (minix.rtest) with a small tree behind it, on which we
|
|
# test some basic reads and writes on an integer pointer and a function;
|
|
# - shadowing of an existing subtree (minix.test) with a similarly looking
|
|
# subtree, which we then subject to a subset of test87;
|
|
# - resource accounting, making sure everything is the same before and after.
|
|
|
|
bomb() {
|
|
echo $*
|
|
service down rmibtest 2>/dev/null
|
|
exit 1
|
|
}
|
|
|
|
PATH=/bin:/usr/bin:/sbin:/usr/sbin
|
|
export PATH
|
|
|
|
echo -n "Test RMIB "
|
|
|
|
cd rmibtest
|
|
|
|
sysctl -q minix.rtest && bomb "there should not be a minix.rtest"
|
|
|
|
old_nodes=`sysctl -n minix.mib.nodes 2>/dev/null` || bomb "no MIB stats?"
|
|
old_objects=`sysctl -n minix.mib.objects 2>/dev/null` || bomb "no MIB stats?"
|
|
old_remotes=`sysctl -n minix.mib.remotes 2>/dev/null` || bomb "no MIB stats?"
|
|
|
|
service up `pwd`/rmibtest -label rmibtest -config rmibtest.conf || \
|
|
bomb "unable to start test service"
|
|
|
|
cd ..
|
|
|
|
sleep 1
|
|
|
|
new_remotes=`sysctl -n minix.mib.remotes 2>/dev/null` || \
|
|
bomb "unable to get mount stats"
|
|
[ $(($old_remotes + 2)) -eq $new_remotes ] || bomb "mounting subtree failed"
|
|
|
|
# Test the temporary minix.rtest subtree with its two mirroring nodes
|
|
sysctl -q minix.rtest || bomb "there should be a minix.rtest"
|
|
|
|
[ $(sysctl -n minix.rtest.int) -eq 5375123 ] || bomb "unexpected int value"
|
|
[ $(sysctl -n minix.rtest.func) -eq 5375123 ] || bomb "unexpected func value"
|
|
sysctl -wq minix.rtest.int=456 || bomb "unable to set int value"
|
|
[ $(sysctl -n minix.rtest.int) -eq 456 ] || bomb "unexpected int value"
|
|
[ $(sysctl -n minix.rtest.func) -eq 456 ] || bomb "unexpected func value"
|
|
sysctl -wq minix.rtest.func=7895375 || bomb "unable to set func value"
|
|
[ $(sysctl -n minix.rtest.int) -eq 7895375 ] || bomb "unexpected int value"
|
|
[ $(sysctl -n minix.rtest.func) -eq 7895375 ] || bomb "unexpected func value"
|
|
|
|
# Test the minix.test shadowing subtree using a subset of the regular MIB test
|
|
./test87 19 >/dev/null || bomb "test87 reported failure"
|
|
|
|
service down rmibtest
|
|
|
|
sleep 1
|
|
|
|
# Is everything back to the old situation?
|
|
new_nodes=`sysctl -n minix.mib.nodes 2>/dev/null` || bomb "no MIB stats?"
|
|
new_objects=`sysctl -n minix.mib.objects 2>/dev/null` || bomb "no MIB stats?"
|
|
new_remotes=`sysctl -n minix.mib.remotes 2>/dev/null` || bomb "no MIB stats?"
|
|
|
|
[ $old_nodes -eq $new_nodes ] || bomb "stats not equal after unmount"
|
|
[ $old_objects -eq $new_objects ] || bomb "stats not equal after unmount"
|
|
[ $old_remotes -eq $new_remotes ] || bomb "stats not equal after unmount"
|
|
|
|
sysctl -q minix.rtest && bomb "there should not be a minix.rtest anymore"
|
|
|
|
echo "ok"
|
|
exit 0
|