Compare commits

..

10 Commits

Author SHA1 Message Date
Adrien Gallouët
c113724eb0 Update mud
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 20:47:47 +00:00
Adrien Gallouët
b184ddedaa Code cleanup
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 10:33:47 +00:00
Adrien Gallouët
28a978f276 Fix the last fix :)
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-25 07:32:34 +00:00
Adrien Gallouët
e0546ec46a Fix build on OpenBSD
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-24 17:41:58 +00:00
Adrien Gallouët
50f002b7f8 Add variable X to cross build a static binary
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-24 09:27:36 +00:00
Adrien Gallouët
42faaf816f Update mud: losslimit per path
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-03-07 16:19:06 +00:00
Adrien Gallouët
eee6a22ccd Use strip -x
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-29 10:06:50 +00:00
Adrien Gallouët
ee2d7a2e07 Update mud
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-29 09:57:46 +00:00
Adrien Gallouët
e5949b409f Handle cross stripped binary
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-29 09:34:58 +00:00
Adrien Gallouët
13703fb15f Allow to setup beat without [back]up
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
2020-02-21 16:40:22 +00:00
8 changed files with 44 additions and 18 deletions

View File

@@ -2,31 +2,37 @@ NAME := glorytun
VERSION := $(shell ./version.sh) VERSION := $(shell ./version.sh)
DIST := $(NAME)-$(VERSION) DIST := $(NAME)-$(VERSION)
CFLAGS ?= -std=c11 -O2 -Wall -fstack-protector-strong
FLAGS := $(CFLAGS) $(LDFLAGS) $(CPPFLAGS)
CC ?= cc CC ?= cc
DESTDIR ?=
prefix ?= /usr prefix ?= /usr
Q := @ Q := @
CFLAGS := -std=c11 -O2 -Wall -fstack-protector-strong ifneq ($(X),)
H = $(X)-
FLAGS += -static
endif
FLAGS := $(CFLAGS) $(LDFLAGS) $(CPPFLAGS)
FLAGS += -DPACKAGE_NAME=\"$(NAME)\" -DPACKAGE_VERSION=\"$(VERSION)\" FLAGS += -DPACKAGE_NAME=\"$(NAME)\" -DPACKAGE_VERSION=\"$(VERSION)\"
FLAGS += -I.static/$(X)/libsodium-stable/src/libsodium/include
FLAGS += -I.static/$(CROSS)/libsodium-stable/src/libsodium/include FLAGS += -L.static/$(X)/libsodium-stable/src/libsodium/.libs
FLAGS += -L.static/$(CROSS)/libsodium-stable/src/libsodium/.libs
SRC := argz/argz.c mud/mud.c mud/aegis256/aegis256.c $(wildcard src/*.c) SRC := argz/argz.c mud/mud.c mud/aegis256/aegis256.c $(wildcard src/*.c)
HDR := argz/argz.h mud/mud.h mud/aegis256/aegis256.h $(wildcard src/*.h) HDR := argz/argz.h mud/mud.h mud/aegis256/aegis256.h $(wildcard src/*.h)
$(NAME): $(SRC) $(HDR) $(NAME): $(SRC) $(HDR)
@echo "$(NAME)" $(Q)$(H)$(CC) $(FLAGS) -o $(NAME) $(SRC) -lsodium
$(Q)$(CC) $(FLAGS) -o $(NAME) $(SRC) -lsodium
$(NAME)-strip: $(NAME)
$(Q)cp $< $@
$(Q)$(H)strip -x $@
.PHONY: install .PHONY: install
install: $(NAME) install: $(NAME)-strip
@echo "$(DESTDIR)$(prefix)/bin/$(NAME)" @echo "$(DESTDIR)$(prefix)/bin/$(NAME)"
$(Q)install -m 755 -d $(DESTDIR)$(prefix)/bin $(Q)install -m 755 -d $(DESTDIR)$(prefix)/bin
$(Q)install -m 755 -s $(NAME) $(DESTDIR)$(prefix)/bin $(Q)install -m 755 $(NAME)-strip $(DESTDIR)$(prefix)/bin/$(NAME)
.PHONY: clean .PHONY: clean
clean: clean:

2
mud

Submodule mud updated: 5be4096452...c426cef08b

View File

@@ -305,7 +305,8 @@ gt_bind(int argc, char **argv)
req.path.rate_tx, req.path.rate_tx,
req.path.rate_rx, req.path.rate_rx,
req.path.beat, req.path.beat,
req.path.fixed_rate)) req.path.fixed_rate,
req.path.loss_limit))
res.ret = errno; res.ret = errno;
break; break;
case CTL_CONF: case CTL_CONF:

View File

@@ -12,6 +12,8 @@
#include <errno.h> #include <errno.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#ifndef PACKAGE_NAME #ifndef PACKAGE_NAME
#define PACKAGE_NAME "glorytun" #define PACKAGE_NAME "glorytun"

View File

@@ -27,6 +27,7 @@ struct ctl_msg {
unsigned long rate_rx; unsigned long rate_rx;
unsigned long beat; unsigned long beat;
unsigned char fixed_rate; unsigned char fixed_rate;
unsigned char loss_limit;
} path; } path;
struct { struct {
char tun_name[64]; char tun_name[64];

View File

@@ -40,6 +40,7 @@ gt_path_print_status(struct mud_path *path, int term)
" rtt: %.3f ms\n" " rtt: %.3f ms\n"
" rttvar: %.3f ms\n" " rttvar: %.3f ms\n"
" rate: %s\n" " rate: %s\n"
" losslim: %u\n"
" beat: %"PRIu64" ms\n" " beat: %"PRIu64" ms\n"
" tx:\n" " tx:\n"
" rate: %"PRIu64" bytes/sec\n" " rate: %"PRIu64" bytes/sec\n"
@@ -52,7 +53,7 @@ gt_path_print_status(struct mud_path *path, int term)
: "path %s %s" : "path %s %s"
" %s %"PRIu16" %s %"PRIu16" %s %"PRIu16 " %s %"PRIu16" %s %"PRIu16" %s %"PRIu16
" %zu %.3f %.3f" " %zu %.3f %.3f"
" %s" " %s %u"
" %"PRIu64 " %"PRIu64
" %"PRIu64" %"PRIu64" %"PRIu64 " %"PRIu64" %"PRIu64" %"PRIu64
" %"PRIu64" %"PRIu64" %"PRIu64 " %"PRIu64" %"PRIu64" %"PRIu64
@@ -69,6 +70,7 @@ gt_path_print_status(struct mud_path *path, int term)
(double)path->rtt.val / 1e3, (double)path->rtt.val / 1e3,
(double)path->rtt.var / 1e3, (double)path->rtt.var / 1e3,
path->conf.fixed_rate ? "fixed" : "auto", path->conf.fixed_rate ? "fixed" : "auto",
path->conf.loss_limit * 100 / 255,
path->conf.beat / 1000, path->conf.beat / 1000,
path->tx.rate, path->tx.rate,
path->tx.loss * 100 / 255, path->tx.loss * 100 / 255,
@@ -145,6 +147,7 @@ int
gt_path(int argc, char **argv) gt_path(int argc, char **argv)
{ {
const char *dev = NULL; const char *dev = NULL;
unsigned int loss_limit = 0;
struct ctl_msg req = { struct ctl_msg req = {
.type = CTL_STATE, .type = CTL_STATE,
@@ -165,6 +168,7 @@ gt_path(int argc, char **argv)
{"up|backup|down", NULL, NULL, argz_option}, {"up|backup|down", NULL, NULL, argz_option},
{"rate", NULL, &ratez, argz_option}, {"rate", NULL, &ratez, argz_option},
{"beat", "SECONDS", &req.path.beat, argz_time}, {"beat", "SECONDS", &req.path.beat, argz_time},
{"losslimit", "PERCENT", &loss_limit, argz_percent},
{NULL}}; {NULL}};
if (argz(pathz, argc, argv)) if (argz(pathz, argc, argv))
@@ -189,9 +193,11 @@ gt_path(int argc, char **argv)
return 1; return 1;
} }
int set_rate = argz_is_set(pathz, "rate"); int set = argz_is_set(pathz, "rate")
|| argz_is_set(pathz, "beat")
|| argz_is_set(pathz, "losslimit");
if (set_rate && !req.path.addr.ss_family) { if (set && !req.path.addr.ss_family) {
gt_log("please specify a path\n"); gt_log("please specify a path\n");
return 1; return 1;
} }
@@ -204,6 +210,9 @@ gt_path(int argc, char **argv)
req.path.state = MUD_DOWN; req.path.state = MUD_DOWN;
} }
if (loss_limit)
req.path.loss_limit = loss_limit * 255 / 100;
if (argz_is_set(ratez, "fixed")) { if (argz_is_set(ratez, "fixed")) {
req.path.fixed_rate = 3; req.path.fixed_rate = 3;
} else if (argz_is_set(ratez, "auto")) { } else if (argz_is_set(ratez, "auto")) {
@@ -213,7 +222,7 @@ gt_path(int argc, char **argv)
int ret; int ret;
if (!req.path.addr.ss_family || if (!req.path.addr.ss_family ||
(req.path.state == MUD_EMPTY && !set_rate)) { (req.path.state == MUD_EMPTY && !set)) {
ret = gt_path_status(fd, req.path.state, &req.path.addr); ret = gt_path_status(fd, req.path.state, &req.path.addr);
} else { } else {
ret = ctl_reply(fd, &res, &req); ret = ctl_reply(fd, &res, &req);

View File

@@ -47,7 +47,6 @@ gt_set(int argc, char **argv)
{"tc", "CS|AF|EF", &req.conf.tc, gt_argz_tc}, {"tc", "CS|AF|EF", &req.conf.tc, gt_argz_tc},
{"kxtimeout", "SECONDS", &req.conf.kxtimeout, argz_time}, {"kxtimeout", "SECONDS", &req.conf.kxtimeout, argz_time},
{"timetolerance", "SECONDS", &req.conf.timetolerance, argz_time}, {"timetolerance", "SECONDS", &req.conf.timetolerance, argz_time},
{"losslimit", "PERCENT", &req.conf.losslimit, argz_percent},
{"keepalive", "SECONDS", &req.conf.keepalive, argz_time}, {"keepalive", "SECONDS", &req.conf.keepalive, argz_time},
{NULL}}; {NULL}};

View File

@@ -131,13 +131,21 @@ tun_create_by_name(char *name, size_t len, const char *dev_name)
static int static int
tun_create_by_name(char *name, size_t len, const char *dev_name) tun_create_by_name(char *name, size_t len, const char *dev_name)
{ {
int ret = snprintf(name, len, "/dev/%s", dev_name); int ret = snprintf(name, len, "%s", dev_name);
if (ret <= 0 || (size_t)ret >= len) { if (ret <= 0 || (size_t)ret >= len) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
char tmp[64];
ret = snprintf(tmp, sizeof(tmp), "/dev/%s", dev_name);
if (ret <= 0 || (size_t)ret >= sizeof(tmp)) {
errno = EINVAL;
return -1;
}
return open(tmp, O_RDWR); return open(tmp, O_RDWR);
} }