summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-05-20 10:41:20 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-05-20 10:41:20 +0200
commit46e337a1fd34a3c0555f286b6bc46b9ba058c17c (patch)
tree01a31d9dcd9332cb99ddc6de826e73d82d6da366 /src/fastd.c
parent3c8abc1921c51b654dace98002bdf7ed49f7489c (diff)
downloadfastd-46e337a1fd34a3c0555f286b6bc46b9ba058c17c.tar
fastd-46e337a1fd34a3c0555f286b6bc46b9ba058c17c.zip
Optimize send_all() to allow zero-copy TUN mode
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/fastd.c b/src/fastd.c
index bbf1e03..63c5750 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -611,6 +611,12 @@ static inline void send_all(fastd_context_t *ctx, fastd_peer_t *source_peer, fas
if (dest_peer == source_peer || !fastd_peer_is_established(dest_peer))
continue;
+ /* optimization, primarily for TUN mode: don't duplicate the buffer for the last (or only) peer */
+ if (!dest_peer->next) {
+ ctx->conf->protocol->send(ctx, dest_peer, buffer);
+ return;
+ }
+
ctx->conf->protocol->send(ctx, dest_peer, fastd_buffer_dup(ctx, buffer, methods_min_encrypt_head_space(ctx), methods_min_encrypt_tail_space(ctx)));
}