diff options
author | 2013-06-03 12:32:06 +0000 | |
---|---|---|
committer | 2013-06-03 12:32:06 +0000 | |
commit | 0cc8009b439a6446b9fc18e91e78c9d24c948ab5 (patch) | |
tree | 81e3208b1ae8643306b6ffa399b5727d969eb408 | |
parent | sprinkle $OpenBSD$, pointed out by pedro (diff) | |
download | wireguard-openbsd-0cc8009b439a6446b9fc18e91e78c9d24c948ab5.tar.xz wireguard-openbsd-0cc8009b439a6446b9fc18e91e78c9d24c948ab5.zip |
Replace "hot" bcopy() calls in ether_output() with memcpy(). This tells the
compiler that source and destination are not overlapping, allowing for more
aggressive optimization, leading to a significant performance improvement
on busy firewalls. Reworking of a diff by dlg@, who did the hard work of
benchmarking this.
ok deraadt@, mikeb@, henning@, mcbride@, tedu@, matthew@
-rw-r--r-- | sys/net/if_ethersubr.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index b1ea66c4ad2..5b97404d327 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.155 2013/03/28 16:55:27 deraadt Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.156 2013/06/03 12:32:06 kettenis Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -363,14 +363,13 @@ ether_output(ifp0, m0, dst, rt0) if (m == 0) senderr(ENOBUFS); eh = mtod(m, struct ether_header *); - bcopy((caddr_t)&etype,(caddr_t)&eh->ether_type, - sizeof(eh->ether_type)); - bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof(edst)); + eh->ether_type = etype; + memcpy(eh->ether_dhost, edst, sizeof(edst)); if (hdrcmplt) - bcopy((caddr_t)esrc, (caddr_t)eh->ether_shost, + memcpy(eh->ether_shost, esrc, sizeof(eh->ether_shost)); else - bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost, + memcpy(eh->ether_shost, ac->ac_enaddr, sizeof(eh->ether_shost)); #if NCARP > 0 |