e1000e: use ip_hdrlen() instead of bit shift
Subsystems (3)
PATCH 1/1 e1000e: use ip_hdrlen() instead of bit shift
There's no reason to use bit shift to find the UDP header. It's not intuitive and it reinvents well-defined functions.
--- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000e/netdev.c +1 -1
@@ -5731,7 +5731,7 @@ static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,if (ip->protocol !=IPPROTO_UDP )return 0 ; - udp = (struct udphdr *)((u8 *)ip + (ip->ihl <<2 )); + udp = (struct udphdr *)((u8 *)ip +ip_hdrlen (skb));if (ntohs (udp->dest) !=67 )return 0 ;
Signature · 1 line
2.45.2
Quoted 13 lines · Moon Yeounsu
There's no reason to use bit shift to find the UDP header. It's not intuitive and it reinvents well-defined functions.
Signed-off-by Moon Yeounsu <[email protected]>--- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/e1000e/netdev.c +0
-0
drivers/net/ethernet/intel/e1000e/netdev.c static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter, · line 5734
Quoted 5 lines
drivers/net/ethernet/intel/e1000e/netdev.c +1
-1@@ -5731,7 +5731,7 @@ static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,if (ip->protocol !=IPPROTO_UDP )return 0 ; - udp = (struct udphdr *)((u8 *)ip + (ip->ihl <<2 )); + udp = (struct udphdr *)((u8 *)ip +ip_hdrlen (skb));
This helper needs skb_network_header being set up correctly, are you sure thats the case here? ip pointer is fetched via data + 14 right above, so it doesn't look like this would work.
Quoted 3 lines · Florian Westphal
This helper needs
skb_network_headerbeing set up correctly, are you sure thats the case here? ip pointer is fetched via data + 14 right above, so it doesn't look like this would work.
I read it once more carefully, and yes, you are right. Sorry for wasting your time...
It is my first patch to the netdev subsystem. So... I was too excited. It's all my fault. Next time, I'll be careful and deliberate.
Thank you for reviewing.