summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2021-02-26 08:31:23 +0000
committerdlg <dlg@openbsd.org>2021-02-26 08:31:23 +0000
commit2c44fd7e189600dc56a75c5f4dd861d51e12ef5d (patch)
tree5b344bbb4ebe654ab53d87308697b658a99e3ff2
parentAdd a couple of format variables for active and last window index. (diff)
downloadwireguard-openbsd-2c44fd7e189600dc56a75c5f4dd861d51e12ef5d.tar.xz
wireguard-openbsd-2c44fd7e189600dc56a75c5f4dd861d51e12ef5d.zip
only store the current time on address table entries if it changes.
this avoids unecessary writes to memory. it helps a little bit with a single nettq, but we get a lot more of a boost in pps when running concurrently. thanks to hrvoje for testing.
-rw-r--r--sys/net/if_etherbridge.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/if_etherbridge.c b/sys/net/if_etherbridge.c
index 451781a9908..d3488029d36 100644
--- a/sys/net/if_etherbridge.c
+++ b/sys/net/if_etherbridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_etherbridge.c,v 1.4 2021/02/26 01:28:51 dlg Exp $ */
+/* $OpenBSD: if_etherbridge.c,v 1.5 2021/02/26 08:31:23 dlg Exp $ */
/*
* Copyright (c) 2018, 2021 David Gwynne <dlg@openbsd.org>
@@ -299,10 +299,12 @@ etherbridge_map(struct etherbridge *eb, void *port, uint64_t eba)
unsigned int num;
void *nport;
int new = 0;
+ time_t now;
if (ETH64_IS_MULTICAST(eba) || ETH64_IS_ANYADDR(eba))
return;
+ now = getuptime();
ebl = etherbridge_list(eb, eba);
smr_read_enter();
@@ -310,7 +312,8 @@ etherbridge_map(struct etherbridge *eb, void *port, uint64_t eba)
if (oebe == NULL)
new = 1;
else {
- oebe->ebe_age = getuptime();
+ if (oebe->ebe_age != now)
+ oebe->ebe_age = now;
/* does this entry need to be replaced? */
if (oebe->ebe_type == EBE_DYNAMIC &&
@@ -345,7 +348,7 @@ etherbridge_map(struct etherbridge *eb, void *port, uint64_t eba)
nebe->ebe_addr = eba;
nebe->ebe_port = nport;
nebe->ebe_type = EBE_DYNAMIC;
- nebe->ebe_age = getuptime();
+ nebe->ebe_age = now;
mtx_enter(&eb->eb_lock);
num = eb->eb_num + (oebe == NULL);