diff options
author | Alexander Duyck <alexander.h.duyck@redhat.com> | 2015-04-30 14:53:48 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-03 22:30:36 -0400 |
commit | 849b920e17a2b1e9a3c912ca960dc667d27985e8 (patch) | |
tree | 022462df37208a5eba25b4ad59a2c18b846aa5c3 /net/ethernet | |
parent | 82a584b7cd366511a22e37675b029cf2fb58e291 (diff) | |
download | linux-riscv-849b920e17a2b1e9a3c912ca960dc667d27985e8.tar.gz linux-riscv-849b920e17a2b1e9a3c912ca960dc667d27985e8.tar.bz2 linux-riscv-849b920e17a2b1e9a3c912ca960dc667d27985e8.zip |
etherdev: Avoid unnecessary byte swap in check for Ethertype
This change takes advantage of the fact that ETH_P_802_3_MIN is aligned to
512 so as a result we can actually ignore the lower 8b when comparing the
Ethertype to ETH_P_802_3_MIN. This allows us to avoid a byte swap by simply
masking the value and comparing it to the byte swapped value for
ETH_P_802_3_MIN.
Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethernet')
-rw-r--r-- | net/ethernet/eth.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index f3bad41d725f..60069318d5d1 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -178,7 +178,7 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) if (unlikely(netdev_uses_dsa(dev))) return htons(ETH_P_XDSA); - if (likely(ntohs(eth->h_proto) >= ETH_P_802_3_MIN)) + if (likely((eth->h_proto & htons(0xFF00)) >= htons(ETH_P_802_3_MIN))) return eth->h_proto; /* |