summaryrefslogtreecommitdiff
path: root/src/network/networkd-manager.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2013-11-24 23:37:56 +0100
committerTom Gundersen <teg@jklm.no>2013-11-26 01:32:25 +0100
commit02b59d57e0c08231645120077f651151f5bb2bab (patch)
tree10549c36b26f6fda4daf7b9d11c994adfc6a88ff /src/network/networkd-manager.c
parentc166a070553511e402de5ad216d3fb62b49bdacb (diff)
networkd: add bridge support
A bridge is specified in a .netdev file with a section [Bridge] and at least the entry Name=. A link may be joined to a bridge if the .network applied to it has a Bridge= entry giving the name of the bridge in its [Network] section. We eagerly create all bridges on startup, and links are added to bridges as soon as they both appear.
Diffstat (limited to 'src/network/networkd-manager.c')
-rw-r--r--src/network/networkd-manager.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index c28f3d9813..1dc7e88dfd 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -51,6 +51,10 @@ int manager_new(Manager **ret) {
if (!m->links)
return -ENOMEM;
+ m->bridges = hashmap_new(string_hash_func, string_compare_func);
+ if (!m->bridges)
+ return -ENOMEM;
+
LIST_HEAD_INIT(m->networks);
m->network_dirs = strv_new("/etc/systemd/network/",
@@ -74,6 +78,7 @@ int manager_new(Manager **ret) {
void manager_free(Manager *m) {
Network *network;
+ Bridge *bridge;
Link *link;
udev_monitor_unref(m->udev_monitor);
@@ -88,12 +93,37 @@ void manager_free(Manager *m) {
link_free(link);
hashmap_free(m->links);
+ while ((bridge = hashmap_first(m->bridges)))
+ bridge_free(bridge);
+ 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 */
+ paths_check_timestamp(m->network_dirs, &m->network_dirs_ts_usec, true);
+
+ 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) {
+ return paths_check_timestamp(m->network_dirs, &m->network_dirs_ts_usec, false);
+}
+
static int manager_process_link(Manager *m, struct udev_device *device) {
Link *link;
int r;