nat46: Delete 464xlat device when pause is interrupted by SIGTERM 88/head
authorHans Dedecker <hans.dedecker@technicolor.com>
Thu, 16 Apr 2015 13:08:18 +0000 (15:08 +0200)
committerHans Dedecker <hans.dedecker@technicolor.com>
Thu, 16 Apr 2015 13:08:18 +0000 (15:08 +0200)
nat46/src/464xlatcfg.c

index dfce9d7..1d9466e 100644 (file)
 #include <stdio.h>
 #include <netdb.h>
 
+static void sighandler(__attribute__((unused)) int signal)
+{
+}
+
 int main(int argc, const char *argv[])
 {
        char buf[INET6_ADDRSTRLEN], prefix[INET6_ADDRSTRLEN + 4];
@@ -48,6 +52,8 @@ int main(int argc, const char *argv[])
        if (!argv[3] || !argv[4] || !(fp = fopen(buf, "wx")))
                return 1;
 
+       signal(SIGTERM, sighandler);
+
        prefix[sizeof(prefix) - 1] = 0;
        strncpy(prefix, argv[3], sizeof(prefix) - 1);
 
@@ -108,6 +114,12 @@ int main(int argc, const char *argv[])
                chdir("/");
                setsid();
                pause();
+
+               nat46 = fopen("/proc/net/nat46/control", "w");
+               if (nat46) {
+                       fprintf(nat46, "del %s\n", argv[1]);
+                       fclose(nat46);
+               }
        } else {
                fprintf(fp, "%d\n", pid);
        }