added 'default' and 'secure' pseudo flags; they are open for enhancements
[util-vserver.git] / util-vserver / vserver-start / interface.c
index 6afbbe4..c3f3bb3 100644 (file)
 
 #include "vserver-start.h"
 #include "configuration.h"
+#include "undo.h"
 
 #include <lib_internal/util.h>
 
+static void
+Iface_removeWrapper(void const *iface)
+{
+  (void)Iface_remove(iface);
+}
+
 void
-activateInterfaces()
+activateInterfaces(InterfaceList const *interfaces)
 {
   struct Interface const *     iface;
 
-  for (iface=Vector_begin(&cfg.interfaces);
-       iface!=Vector_end(&cfg.interfaces);
-       ++iface)
-    Iface_add(iface);
+  for (iface=Vector_begin_const(interfaces);
+       iface!=Vector_end_const(interfaces);
+       ++iface) {
+    if (!Iface_add(iface)) {
+      WRITE_MSG(2, "Failed to add interface ");
+      Iface_print(iface, 2);
+      WRITE_MSG(2, "\n");
+      
+      exit(1);
+    }
+    Undo_addTask(Iface_removeWrapper, iface);
+  }
 }