From 896ccd678d1837f7c39b4c0a617a081f2c168443 Mon Sep 17 00:00:00 2001 From: Marko Zec Date: Wed, 19 Jun 2019 08:39:19 +0000 Subject: [PATCH] Evaluating htons() at compile time is more efficient than doing ntohs() at runtime. This change removes a dependency on a barrel shifter pass before branch resolution, while reducing the instruction stream size by 9 bytes on amd64. (cherry picked from commit 6aee0bfa85685017dbc5050ce36793f7dcd80f82) --- sys/net/iflib.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 24f23a33841..4b5e73ce08e 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -2784,18 +2784,16 @@ static bool iflib_check_lro_possible(struct mbuf *m, bool v4_forwarding, bool v6_forwarding) { struct ether_header *eh; - uint16_t eh_type; eh = mtod(m, struct ether_header *); - eh_type = ntohs(eh->ether_type); - switch (eh_type) { + switch (eh->ether_type) { #if defined(INET6) - case ETHERTYPE_IPV6: - return !v6_forwarding; + case htons(ETHERTYPE_IPV6): + return (!v6_forwarding); #endif #if defined (INET) - case ETHERTYPE_IP: - return !v4_forwarding; + case htons(ETHERTYPE_IP): + return (!v4_forwarding); #endif } -- 2.45.0