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. MFC after: 3 days
This commit is contained in:
parent
da761f3b1f
commit
6aee0bfa85
@ -2705,18 +2705,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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user