]> xenbits.xensource.com Git - rumpuser-xen.git/commitdiff
rumpconfig: Enable deconfig for network interfaces
authorMartin Lucina <martin@lucina.net>
Tue, 13 Jan 2015 18:05:09 +0000 (19:05 +0100)
committerMartin Lucina <martin@lucina.net>
Tue, 13 Jan 2015 18:05:09 +0000 (19:05 +0100)
Enable deconfig of network interaces, including dhcp. Current tests show
that issue #14 appears to be fixed, so this should be good to go.

Signed-off-by: Martin Lucina <martin@lucina.net>
rumpconfig.c

index 6c60a719898d83c41517b0db0835ce1ae6e101bb..cec6a5def25013f257e906ab190fb94cdc732064 100644 (file)
@@ -198,10 +198,6 @@ out:
 static void
 rumprun_deconfig_net(const char *if_index)
 {
-#if 1
-       /* TODO According to pwwka this is not fully implemented yet */
-       printf("rumprun_deconfig: (not yet) deconfiguring xenif%s\n", if_index);
-#else
        char *if_type = NULL;
        char *if_method = NULL;
        char *if_addr = NULL;
@@ -217,10 +213,19 @@ rumprun_deconfig_net(const char *if_index)
 
        if (strcmp(if_type, "inet") == 0 &&
            strcmp(if_method, "dhcp") == 0) {
-               /* TODO: need an interface into brlib dhcp to allow us to
-                * destroy the interface. */
-               printf("rumprun_deconfig: not deconfiguring xenif%s (uses dhcp)\n",
-                       if_index);
+               /* TODO: need an interface to send DHCPRELEASE here */
+               snprintf(buf, sizeof buf, "xenif%s", if_index);
+               if ((rv = rump_pub_netconfig_ifdown(buf)) != 0) {
+                       warnx("rumprun_deconfig: %s: ifdown failed: %s\n", buf,
+                               strerror(rv));
+                       goto out;
+               }
+               if ((rv = rump_pub_netconfig_ifdestroy(buf)) != 0) {
+                       printf("rumprun_deconfig: %s: ifdestroy failed: %s\n",
+                               buf, strerror(rv));
+                       goto out;
+               }
+
        }
        else if (strcmp(if_type, "inet") == 0 &&
                 strcmp(if_method, "static") == 0) {
@@ -250,7 +255,6 @@ out:
                free(if_mask);
        if (if_gw)
                free(if_gw);
-#endif
 }
 
 static int