
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
89 lines
3.0 KiB
C
89 lines
3.0 KiB
C
/* MIB service - minix.c - implementation of the CTL_MINIX subtree */
|
|
|
|
#include "mib.h"
|
|
|
|
#if MINIX_TEST_SUBTREE
|
|
|
|
static char test_string[16], test_struct[12];
|
|
|
|
static struct mib_node mib_minix_test_secret_table[] = {
|
|
/* 0*/ [SECRET_VALUE] = MIB_INT(_RO, 12345, "value",
|
|
"The combination to my luggage"),
|
|
};
|
|
|
|
/*
|
|
* Note that even the descriptions here have been chosen such that returned
|
|
* description array alignment is tested. Do not change existing fields
|
|
* lightly, although adding new fields is always fine.
|
|
*/
|
|
static struct mib_node mib_minix_test_table[] = {
|
|
/* 0*/ [TEST_INT] = MIB_INT(_RO | CTLFLAG_HEX, 0x01020304, "int",
|
|
"Value test field"),
|
|
/* 1*/ [TEST_BOOL] = MIB_BOOL(_RW, 0, "bool",
|
|
"Boolean test field"),
|
|
/* 2*/ [TEST_QUAD] = MIB_QUAD(_RW, 0, "quad", "Quad test field"),
|
|
/* 3*/ [TEST_STRING] = MIB_STRING(_RW, test_string, "string",
|
|
"String test field"),
|
|
/* 4*/ [TEST_STRUCT] = MIB_STRUCT(_RW, sizeof(test_struct),
|
|
test_struct, "struct",
|
|
"Structure test field"),
|
|
/* 5*/ [TEST_PRIVATE] = MIB_INT(_RW | CTLFLAG_PRIVATE, -5375,
|
|
"private", "Private test field"),
|
|
/* 6*/ [TEST_ANYWRITE] = MIB_INT(_RW | CTLFLAG_ANYWRITE, 0,
|
|
"anywrite", "AnyWrite test field"),
|
|
/* 7*/ [TEST_DYNAMIC] = MIB_INT(_RO, 0, "deleteme",
|
|
"This node will be destroyed"),
|
|
/* 8*/ [TEST_SECRET] = MIB_NODE(_RO | CTLFLAG_PRIVATE,
|
|
mib_minix_test_secret_table, "secret",
|
|
"Private subtree"),
|
|
/* 9*/ [TEST_PERM] = MIB_INT(_P | _RO, 1, "permanent", NULL),
|
|
/*10*/ [TEST_DESTROY1] = MIB_INT(_RO, 123, "destroy1", NULL),
|
|
/*11*/ [TEST_DESTROY2] = MIB_INT(_RO, 456, "destroy2",
|
|
"This node will be destroyed"),
|
|
};
|
|
|
|
#endif /* MINIX_TEST_SUBTREE */
|
|
|
|
static struct mib_node mib_minix_mib_table[] = {
|
|
/* 1*/ [MIB_NODES] = MIB_INTPTR(_P | _RO | CTLFLAG_UNSIGNED,
|
|
&mib_nodes, "nodes",
|
|
"Number of nodes in the MIB tree"),
|
|
/* 2*/ [MIB_OBJECTS] = MIB_INTPTR(_P | _RO | CTLFLAG_UNSIGNED,
|
|
&mib_objects, "objects", "Number of "
|
|
"dynamically allocated MIB objects"),
|
|
/* 3*/ [MIB_REMOTES] = MIB_INTPTR(_P | _RO | CTLFLAG_UNSIGNED,
|
|
&mib_remotes, "remotes",
|
|
"Number of mounted remote MIB subtrees"),
|
|
};
|
|
|
|
static struct mib_node mib_minix_proc_table[] = {
|
|
/* 1*/ [PROC_LIST] = MIB_FUNC(_P | _RO | CTLTYPE_STRUCT, 0,
|
|
mib_minix_proc_list, "list",
|
|
"Process list"),
|
|
/* 2*/ [PROC_DATA] = MIB_FUNC(_P | _RO | CTLTYPE_NODE, 0,
|
|
mib_minix_proc_data, "data",
|
|
"Process data"),
|
|
};
|
|
|
|
static struct mib_node mib_minix_table[] = {
|
|
#if MINIX_TEST_SUBTREE
|
|
/* 0*/ [MINIX_TEST] = MIB_NODE(_P | _RW | CTLFLAG_HIDDEN,
|
|
mib_minix_test_table, "test",
|
|
"Test87 testing ground"),
|
|
#endif /* MINIX_TEST_SUBTREE */
|
|
/* 1*/ [MINIX_MIB] = MIB_NODE(_P | _RO, mib_minix_mib_table,
|
|
"mib", "MIB service information"),
|
|
/* 2*/ [MINIX_PROC] = MIB_NODE(_P | _RO, mib_minix_proc_table,
|
|
"proc", "Process information for ProcFS"),
|
|
};
|
|
|
|
/*
|
|
* Initialize the CTL_MINIX subtree.
|
|
*/
|
|
void
|
|
mib_minix_init(struct mib_node * node)
|
|
{
|
|
|
|
MIB_INIT_ENODE(node, mib_minix_table);
|
|
}
|