Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet: use ip_hdrlen() instead of bit shift

`ip_hdr(skb)->ihl << 2` is the same as `ip_hdrlen(skb)`
Therefore, we should use a well-defined function not a bit shift
to find the header length.

It also compresses two lines to a single line.

Signed-off-by: Moon Yeounsu <yyyynoom@gmail.com>
Reviewed-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Moon Yeounsu and committed by
David S. Miller
9a039eeb eb755a95

+4 -6
+4 -6
drivers/net/ethernet/jme.c
··· 946 946 if (skb->protocol != htons(ETH_P_IP)) 947 947 return csum; 948 948 skb_set_network_header(skb, ETH_HLEN); 949 - if ((ip_hdr(skb)->protocol != IPPROTO_UDP) || 950 - (skb->len < (ETH_HLEN + 951 - (ip_hdr(skb)->ihl << 2) + 952 - sizeof(struct udphdr)))) { 949 + 950 + if (ip_hdr(skb)->protocol != IPPROTO_UDP || 951 + skb->len < (ETH_HLEN + ip_hdrlen(skb) + sizeof(struct udphdr))) { 953 952 skb_reset_network_header(skb); 954 953 return csum; 955 954 } 956 - skb_set_transport_header(skb, 957 - ETH_HLEN + (ip_hdr(skb)->ihl << 2)); 955 + skb_set_transport_header(skb, ETH_HLEN + ip_hdrlen(skb)); 958 956 csum = udp_hdr(skb)->check; 959 957 skb_reset_transport_header(skb); 960 958 skb_reset_network_header(skb);