summaryrefslogtreecommitdiff
path: root/src/network/networkd-network.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-21 21:58:08 +0100
committerTom Gundersen <teg@jklm.no>2014-01-22 17:56:49 +0100
commit52433f6b65eccd1c54606dde999610640f3458ac (patch)
tree73f12a1b4541829c00462592be6ad275cf01a032 /src/network/networkd-network.c
parent01b36069ccddbed35b82dd3b64af3e522ab305fe (diff)
networkd: add basic bonding support
Refactor bridging support to be generic netdev support and extend it to cover bonding as well.
Diffstat (limited to 'src/network/networkd-network.c')
-rw-r--r--src/network/networkd-network.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 40f6b23058..e703294731 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -223,7 +223,7 @@ int config_parse_bridge(const char *unit,
void *data,
void *userdata) {
Network *network = userdata;
- Bridge *bridge;
+ Netdev *netdev;
int r;
assert(filename);
@@ -231,14 +231,57 @@ int config_parse_bridge(const char *unit,
assert(rvalue);
assert(data);
- r = bridge_get(network->manager, rvalue, &bridge);
+ r = netdev_get(network->manager, rvalue, &netdev);
if (r < 0) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Bridge is invalid, ignoring assignment: %s", rvalue);
return 0;
}
- network->bridge = bridge;
+ if (netdev->kind != NETDEV_KIND_BRIDGE) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Netdev is not a bridge, ignoring assignment: %s", rvalue);
+ return 0;
+ }
+
+ network->bridge = netdev;
+
+ return 0;
+}
+
+int config_parse_bond(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;
+ Netdev *netdev;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+ assert(data);
+
+ r = netdev_get(network->manager, rvalue, &netdev);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Bond is invalid, ignoring assignment: %s", rvalue);
+ return 0;
+ }
+
+ if (netdev->kind != NETDEV_KIND_BOND) {
+ log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+ "Netdev is not a bond, ignoring assignment: %s", rvalue);
+ return 0;
+ }
+
+ network->bond = netdev;
return 0;
}