Compare commits

..

2 Commits

Author SHA1 Message Date
Adrien Gallouët
355040f576 Don't destroy tun on SIGHUP 2017-02-10 11:54:19 +00:00
Adrien Gallouët
bbf1c12f7a Update mud 2017-01-29 12:03:27 +00:00
4 changed files with 24 additions and 6 deletions

2
mud

Submodule mud updated: f67eae0a7f...dfcc08feed

View File

@@ -28,6 +28,7 @@
static struct {
volatile sig_atomic_t quit;
volatile sig_atomic_t reload;
char *dev;
char *keyfile;
char *host;
@@ -87,6 +88,7 @@ fd_set_nonblock(int fd)
static void
gt_quit_handler(int sig)
{
gt.reload = (sig == SIGHUP);
gt.quit = 1;
}
@@ -103,9 +105,9 @@ gt_set_signal(void)
sigaction(SIGINT, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGHUP, &sa, NULL);
sa.sa_handler = SIG_IGN;
sigaction(SIGHUP, &sa, NULL);
sigaction(SIGPIPE, &sa, NULL);
sigaction(SIGUSR1, &sa, NULL);
sigaction(SIGUSR2, &sa, NULL);
@@ -292,6 +294,9 @@ main(int argc, char **argv)
return 1;
}
if (tun_set_persist(tun_fd, 0) == -1)
perror("tun_set_persist");
struct mud *mud = mud_create(gt.bind.port, gt.ipv4, gt.ipv6,
!gt.chacha20, GT_MTU(gt.mtu));
@@ -482,5 +487,10 @@ main(int argc, char **argv)
}
}
if (gt.reload && tun_fd >= 0) {
if (tun_set_persist(tun_fd, 1) == -1)
perror("tun_set_persist");
}
return 0;
}

View File

@@ -17,6 +17,7 @@
#define IFF_TUN 0x0001
#define IFF_NO_PI 0x1000
#define TUNSETIFF _IOW('T', 202, int)
#define TUNSETPERSIST _IOW('T', 203, int)
#endif
#ifdef __APPLE__
@@ -260,3 +261,9 @@ tun_set_mtu(char *dev_name, int mtu)
return ret;
}
int
tun_set_persist(int fd, int on)
{
return ioctl(fd, TUNSETPERSIST, on);
}

View File

@@ -4,3 +4,4 @@ int tun_create (char *, char **);
int tun_read (int, void *, size_t);
int tun_write (int, const void *, size_t);
int tun_set_mtu (char *, int);
int tun_set_persist (int, int);