summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-07 21:57:09 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-07 21:57:09 +0200
commit6cf76ca46dc1620431d536839472709895a60a9a (patch)
tree78e285745a0d8095c15a30d39973731427538535 /src/fastd.c
parentdfac85a4ced46f83738c84b52719ded503e349e7 (diff)
downloadfastd-6cf76ca46dc1620431d536839472709895a60a9a.tar
fastd-6cf76ca46dc1620431d536839472709895a60a9a.zip
Use multi-af tun mode on FreeBSD to make IPv6 work on tun
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 2c70007..aa22cc0 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -246,8 +246,7 @@ void fastd_handle_receive(fastd_context_t *ctx, fastd_peer_t *peer, fastd_buffer
fastd_peer_eth_addr_add(ctx, peer, src_addr);
}
- if (write(ctx->tunfd, buffer.data, buffer.len) < 0)
- pr_warn_errno(ctx, "write");
+ fastd_tuntap_write(ctx, buffer);
if (ctx->conf->mode == MODE_TAP && ctx->conf->forward) {
handle_forward(ctx, peer, buffer);
@@ -477,20 +476,9 @@ static inline bool handle_tun_tap(fastd_context_t *ctx, fastd_buffer_t buffer) {
}
static void handle_tun(fastd_context_t *ctx) {
- size_t max_len = fastd_max_packet_size(ctx);
- fastd_buffer_t buffer = fastd_buffer_alloc(ctx, max_len, ctx->conf->min_encrypt_head_space, ctx->conf->min_encrypt_tail_space);
-
- ssize_t len = read(ctx->tunfd, buffer.data, max_len);
- if (len < 0) {
- if (errno == EINTR) {
- fastd_buffer_free(buffer);
- return;
- }
-
- exit_errno(ctx, "read");
- }
-
- buffer.len = len;
+ fastd_buffer_t buffer = fastd_tuntap_read(ctx);
+ if (!buffer.len)
+ return;
if (handle_tun_tap(ctx, buffer))
return;