networkd-manager.c revision bf5332d2bf2a1acbba9daacf40570a4addbd3411
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Tom Gundersen <teg@jklm.no>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "path-util.h"
#include "networkd.h"
#include "libudev-private.h"
#include "udev-util.h"
int r;
if (!m)
return -ENOMEM;
r = sd_event_default(&m->event);
if (r < 0)
return r;
sd_event_set_watchdog(m->event, true);
if (r < 0)
return r;
if (!m->udev)
return -ENOMEM;
if (!m->udev_monitor)
return -ENOMEM;
if (!m->links)
return -ENOMEM;
if (!m->bridges)
return -ENOMEM;
LIST_HEAD_INIT(m->networks);
#ifdef HAVE_SPLIT_USER
#endif
NULL);
if (!m->network_dirs)
return -ENOMEM;
if (!path_strv_canonicalize_uniq(m->network_dirs))
return -ENOMEM;
*ret = m;
m = NULL;
return 0;
}
void manager_free(Manager *m) {
udev_unref(m->udev);
sd_event_unref(m->event);
hashmap_free(m->links);
hashmap_free(m->bridges);
strv_free(m->network_dirs);
sd_rtnl_unref(m->rtnl);
free(m);
}
int manager_load_config(Manager *m) {
int r;
/* update timestamp */
r = bridge_load(m);
if (r < 0)
return r;
r = network_load(m);
if (r < 0)
return r;
return 0;
}
bool manager_should_reload(Manager *m) {
}
int r;
if (!link)
return 0;
} else {
if (r < 0) {
log_error("Could not handle link %s: %s",
strerror(-r));
}
}
return 0;
}
int manager_udev_enumerate_links(Manager *m) {
int r;
assert(m);
e = udev_enumerate_new(m->udev);
if (!e)
return -ENOMEM;
r = udev_enumerate_add_match_subsystem(e, "net");
if (r < 0)
return r;
r = udev_enumerate_scan_devices(e);
if (r < 0)
return r;
int k;
if (!d)
return -ENOMEM;
if (!udev_device_get_is_initialized(d))
continue;
k = manager_process_link(m, d);
if (k < 0)
r = k;
}
return r;
}
static int manager_dispatch_link_udev(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
if (!device)
return -ENOMEM;
return 0;
}
int manager_udev_listen(Manager *m) {
int r;
if (r < 0) {
return r;
}
if (r < 0) {
log_error("Could not enable udev monitor");
return r;
}
r = sd_event_add_io(m->event,
m, &m->udev_event_source);
if (r < 0)
return r;
return 0;
}
int r, ifindex;
if (r < 0)
return 0;
if (!link)
return 0;
if (r < 0)
return 0;
return 1;
}
int manager_rtnl_listen(Manager *m) {
int r;
if (r < 0)
return r;
if (r < 0)
return r;
return 0;
}