aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-23 18:12:43 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-23 18:50:45 +0200
commit193c75255729b0a9b0ef91b9c86de3823b4352e2 (patch)
tree8e3f47400ee9bdc6119d23724af0bf7f442492d8
parentchacha20-arm: switch to entirely Andy Polyakov's implementation (diff)
downloadWireGuard-jd/andy-is-best-maybe.tar.xz
WireGuard-jd/andy-is-best-maybe.zip
Real life sort of benchmarkjd/andy-is-best-maybe
-rw-r--r--src/messages.h2
-rw-r--r--src/receive.c2
-rw-r--r--src/send.c22
-rwxr-xr-xsrc/tests/netns.sh7
-rw-r--r--src/tests/qemu/Makefile2
5 files changed, 28 insertions, 7 deletions
diff --git a/src/messages.h b/src/messages.h
index 131e1c4..80b8f3c 100644
--- a/src/messages.h
+++ b/src/messages.h
@@ -50,7 +50,7 @@ enum limits {
MAX_TIMER_HANDSHAKES = 90 / REKEY_TIMEOUT,
MAX_QUEUED_INCOMING_HANDSHAKES = 4096, /* TODO: replace this with DQL */
MAX_STAGED_PACKETS = 128,
- MAX_QUEUED_PACKETS = 1024 /* TODO: replace this with DQL */
+ MAX_QUEUED_PACKETS = 102400 /* TODO: replace this with DQL */
};
enum message_type {
diff --git a/src/receive.c b/src/receive.c
index 6a27bdd..085cda0 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -580,6 +580,8 @@ void packet_receive(struct wireguard_device *wg, struct sk_buff *skb)
break;
}
case cpu_to_le32(MESSAGE_DATA):
+ if (skb->len > MESSAGE_MINIMUM_LENGTH)
+ goto err;
PACKET_CB(skb)->ds = ip_tunnel_get_dsfield(ip_hdr(skb), skb);
packet_consume_data(wg, skb);
break;
diff --git a/src/send.c b/src/send.c
index 5dde5a3..3fee01e 100644
--- a/src/send.c
+++ b/src/send.c
@@ -291,6 +291,12 @@ void packet_tx_worker(struct work_struct *work)
}
}
+static inline void report_bench(unsigned int bytes, cycles_t duration)
+{
+ cycles_t cCPB = duration * 100;
+ pr_err("%u bytes in %u cycles (%u cCPB)\n", bytes, duration, cCPB / bytes);
+}
+
void packet_encrypt_worker(struct work_struct *work)
{
struct crypt_queue *queue =
@@ -298,11 +304,16 @@ void packet_encrypt_worker(struct work_struct *work)
struct sk_buff *first, *skb, *next;
simd_context_t simd_context;
+ unsigned int bytes = 0;
+ cycles_t start;
+
simd_get(&simd_context);
+ start = get_cycles();
while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state = PACKET_STATE_CRYPTED;
skb_walk_null_queue_safe (first, skb, next) {
+ bytes += skb->len;
if (likely(skb_encrypt(skb, PACKET_CB(first)->keypair,
&simd_context)))
skb_reset(skb);
@@ -311,11 +322,18 @@ void packet_encrypt_worker(struct work_struct *work)
break;
}
}
+ if (bytes >= 1024 * 1024 * 5) {
+ report_bench(bytes, get_cycles() - start);
+ bytes = 0;
+ start = get_cycles();
+ }
+
queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first,
state);
-
- simd_relax(&simd_context);
}
+
+ if (bytes > 1024 * 10)
+ report_bench(bytes, get_cycles() - start);
simd_put(&simd_context);
}
diff --git a/src/tests/netns.sh b/src/tests/netns.sh
index 568612c..7ba498b 100755
--- a/src/tests/netns.sh
+++ b/src/tests/netns.sh
@@ -140,10 +140,11 @@ tests() {
big_mtu=$(( 34816 - 1500 + $orig_mtu ))
# Test using IPv4 as outer transport
-n1 wg set wg0 peer "$pub2" endpoint 127.0.0.1:2
+n1 wg set wg0 peer "$pub2" endpoint 127.0.0.1:2 persistent-keepalive 5
n2 wg set wg0 peer "$pub1" endpoint 127.0.0.1:1
-# Before calling tests, we first make sure that the stats counters are working
-n2 ping -c 10 -f -W 1 192.168.241.1
+n2 ncat -u 192.168.241.1 1234 < /dev/zero
+
+
{ read _; read _; read _; read rx_bytes _; read _; read tx_bytes _; } < <(ip2 -stats link show dev wg0)
(( rx_bytes == 1372 && (tx_bytes == 1428 || tx_bytes == 1460) ))
{ read _; read _; read _; read rx_bytes _; read _; read tx_bytes _; } < <(ip1 -stats link show dev wg0)
diff --git a/src/tests/qemu/Makefile b/src/tests/qemu/Makefile
index 8d76394..bef99a0 100644
--- a/src/tests/qemu/Makefile
+++ b/src/tests/qemu/Makefile
@@ -187,7 +187,7 @@ qemu: $(KERNEL_BZIMAGE)
-nographic \
-smp $(NR_CPUS) \
$(QEMU_MACHINE) \
- -m $$(grep -q CONFIG_DEBUG_KMEMLEAK=y $(KERNEL_PATH)/.config && echo 1G || echo 192M) \
+ -m 1G \
-serial stdio \
-serial file:$(BUILD_PATH)/result \
-no-reboot \