summaryrefslogtreecommitdiff
path: root/src/nspawn/nspawn.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-03-26 19:25:01 +0100
committerTom Gundersen <teg@jklm.no>2014-03-28 19:11:59 +0100
commitd8e538ecd9e62f841242f07e3df5c835c1ba6313 (patch)
tree0fba56485f73d01a985ed4afaff83cffa19068d2 /src/nspawn/nspawn.c
parent9f5bbfe354c52cd9e28cca32c35596b73e8d738b (diff)
sd-rtnl: rework rtnl type system
Use a static table with all the typing information, rather than repeated switch statements. This should make it a lot simpler to add new types. We need to keep all the type info to be able to create containers without exposing their implementation details to the users of the library. As a freebee we verify the types of appended/read attributes. The API is extended to nicely deal with unions of container types.
Diffstat (limited to 'src/nspawn/nspawn.c')
-rw-r--r--src/nspawn/nspawn.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 9a9ed9dc6..84724d59c 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1486,13 +1486,7 @@ static int setup_veth(pid_t pid, char iface_name[IFNAMSIZ]) {
return r;
}
- r = sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "veth");
- if (r < 0) {
- log_error("Failed to append netlink kind: %s", strerror(-r));
- return r;
- }
-
- r = sd_rtnl_message_open_container(m, IFLA_INFO_DATA);
+ r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "veth");
if (r < 0) {
log_error("Failed to open netlink container: %s", strerror(-r));
return r;
@@ -1757,13 +1751,7 @@ static int setup_macvlan(pid_t pid) {
return r;
}
- r = sd_rtnl_message_append_string(m, IFLA_INFO_KIND, "macvlan");
- if (r < 0) {
- log_error("Failed to append netlink kind: %s", strerror(-r));
- return r;
- }
-
- r = sd_rtnl_message_open_container(m, IFLA_INFO_DATA);
+ r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "macvlan");
if (r < 0) {
log_error("Failed to open netlink container: %s", strerror(-r));
return r;