diff options
author | Tom Gundersen <teg@jklm.no> | 2013-11-24 23:37:56 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2013-11-26 01:32:25 +0100 |
commit | 02b59d57e0c08231645120077f651151f5bb2bab (patch) | |
tree | 10549c36b26f6fda4daf7b9d11c994adfc6a88ff /src/network/networkd-network.c | |
parent | c166a070553511e402de5ad216d3fb62b49bdacb (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-network.c')
-rw-r--r-- | src/network/networkd-network.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index eb3ff2316d..ae8d4d160d 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -83,9 +83,6 @@ int network_load(Manager *manager) { while ((network = manager->networks)) network_free(network); - /* update timestamp */ - paths_check_timestamp(manager->network_dirs, &manager->network_dirs_ts_usec, true); - r = conf_files_list_strv(&files, ".network", NULL, (const char **)manager->network_dirs); if (r < 0) { log_error("failed to enumerate network files: %s", strerror(-r)); @@ -103,10 +100,6 @@ int network_load(Manager *manager) { return 0; } -bool network_should_reload(Manager *manager) { - return paths_check_timestamp(manager->network_dirs, &manager->network_dirs_ts_usec, false); -} - void network_free(Network *network) { Route *route; Address *address; @@ -145,8 +138,8 @@ int network_get(Manager *manager, struct udev_device *device, Network **ret) { assert(device); assert(ret); - if (network_should_reload(manager)) - network_load(manager); + if (manager_should_reload(manager)) + manager_load_config(manager); LIST_FOREACH(networks, network, manager->networks) { if (net_match_config(network->match_mac, network->match_path, @@ -173,8 +166,8 @@ int network_get(Manager *manager, struct udev_device *device, Network **ret) { int network_apply(Manager *manager, Network *network, Link *link) { int r; - log_info("Network '%s' being applied to link '%ju'", - network->description, link->ifindex); + log_info("Network '%s' being applied to link '%s'", + network->description, link->ifname); link->network = network; @@ -184,3 +177,34 @@ int network_apply(Manager *manager, Network *network, Link *link) { return 0; } + +int config_parse_bridge(const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + Network *network = userdata; + Bridge *bridge; + int r; + + assert(filename); + assert(lvalue); + assert(rvalue); + assert(data); + + r = bridge_get(network->manager, rvalue, &bridge); + if (r < 0) { + log_syntax(unit, LOG_ERR, filename, line, EINVAL, + "Bridge is invalid, ignoring assignment: %s", rvalue); + return 0; + } + + network->bridge = bridge; + + return 0; +} |