mirror of
https://github.com/troglobit/finit.git
synced 2026-11-13 17:00:16 +00:00
Merge pull request #468 from aanderse/master
netlink: enumerate existing interfaces at startup
This commit is contained in:
1 file changed
+21
-1
+21
-1
@@ -406,9 +406,29 @@ static void nl_reconf(void *arg)
|
|||||||
cond_reassert("net/");
|
cond_reassert("net/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initial enumeration of existing interfaces and routes. Called from
|
||||||
|
* HOOK_SVC_PLUGIN which runs after the condition system is initialized.
|
||||||
|
* Interfaces that exist before finit starts (e.g., virtio-net in QEMU)
|
||||||
|
* won't generate RTM_NEWLINK events, so we must query for them.
|
||||||
|
*/
|
||||||
|
static void nl_enumerate(void *arg)
|
||||||
|
{
|
||||||
|
int sd;
|
||||||
|
|
||||||
|
sd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
|
||||||
|
if (sd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
nl_resync_ifaces(sd, 0);
|
||||||
|
nl_resync_routes(sd, 1);
|
||||||
|
close(sd);
|
||||||
|
}
|
||||||
|
|
||||||
static plugin_t plugin = {
|
static plugin_t plugin = {
|
||||||
.name = __FILE__,
|
.name = __FILE__,
|
||||||
.hook[HOOK_SVC_RECONF] = { .cb = nl_reconf },
|
.hook[HOOK_SVC_RECONF] = { .cb = nl_reconf },
|
||||||
|
.hook[HOOK_SVC_PLUGIN] = { .cb = nl_enumerate },
|
||||||
.io = {
|
.io = {
|
||||||
.cb = nl_callback,
|
.cb = nl_callback,
|
||||||
.flags = PLUGIN_IO_READ,
|
.flags = PLUGIN_IO_READ,
|
||||||
|
|||||||
Reference in new issue
Block a user