summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn-settings.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-12 21:54:28 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-12 22:04:49 +0100
commitf6d6bad1461a8f545a80955fadd7ee0c10db15bb (patch)
tree564da70bc2b76fcfeadf67cf515439a76ad482df /src/nspawn/nspawn-settings.c
parent76e0779b5c7e85c7b69b2fffe5acaa7e9f12adbc (diff)
nspawn: add new --network-veth-extra= switch for defining additional veth links
The new switch operates like --network-veth, but may be specified multiple times (to define multiple link pairs) and allows flexible definition of the interface names. This is an independent reimplementation of #1678, but defines different semantics, keeping the behaviour completely independent of --network-veth. It also comes will full hook-up for .nspawn files, and the matching documentation.
Diffstat (limited to 'src/nspawn/nspawn-settings.c')
-rw-r--r--src/nspawn/nspawn-settings.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c
index 6885d0641e..d6b64d8d5a 100644
--- a/src/nspawn/nspawn-settings.c
+++ b/src/nspawn/nspawn-settings.c
@@ -22,6 +22,7 @@
#include "alloc-util.h"
#include "cap-list.h"
#include "conf-parser.h"
+#include "nspawn-network.h"
#include "nspawn-settings.h"
#include "process-util.h"
#include "strv.h"
@@ -77,6 +78,7 @@ Settings* settings_free(Settings *s) {
strv_free(s->network_interfaces);
strv_free(s->network_macvlan);
strv_free(s->network_ipvlan);
+ strv_free(s->network_veth_extra);
free(s->network_bridge);
expose_port_free_all(s->expose_ports);
@@ -95,7 +97,8 @@ bool settings_private_network(Settings *s) {
s->network_bridge ||
s->network_interfaces ||
s->network_macvlan ||
- s->network_ipvlan;
+ s->network_ipvlan ||
+ s->network_veth_extra;
}
bool settings_network_veth(Settings *s) {
@@ -269,15 +272,33 @@ int config_parse_tmpfs(
return 0;
}
- if (settings->network_bridge)
- settings->network_veth = true;
+ return 0;
+}
- if (settings->network_interfaces ||
- settings->network_macvlan ||
- settings->network_ipvlan ||
- settings->network_bridge ||
- settings->network_veth)
- settings->private_network = true;
+int config_parse_veth_extra(
+ 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) {
+
+ Settings *settings = data;
+ int r;
+
+ assert(filename);
+ assert(lvalue);
+ assert(rvalue);
+
+ r = veth_extra_parse(&settings->network_veth_extra, rvalue);
+ if (r < 0) {
+ log_syntax(unit, LOG_ERR, filename, line, r, "Invalid extra virtual Ethernet link specification %s: %m", rvalue);
+ return 0;
+ }
return 0;
}