]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
etherdev: Avoid unnecessary byte swap in check for Ethertype
authorAlexander Duyck <alexander.h.duyck@redhat.com>
Thu, 30 Apr 2015 21:53:48 +0000 (14:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 May 2015 02:30:36 +0000 (22:30 -0400)
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>
net/ethernet/eth.c

index f3bad41d725f449f91d0b1b4f7119a9c9660e976..60069318d5d1f2103bea22d96254fefd1538cc70 100644 (file)
@@ -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;
 
        /*