diff mbox series

e1000e: use ip_hdrlen() instead of bit shift

Message ID 20240801134709.1737190-2-yyyynoom@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series e1000e: use ip_hdrlen() instead of bit shift | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 42 this patch: 42
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: przemyslaw.kitszel@intel.com anthony.l.nguyen@intel.com
netdev/build_clang success Errors and warnings before: 43 this patch: 43
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 43 this patch: 43
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 35 this patch: 35
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-08-01--21-00 (tests: 346)

Commit Message

Moon Yeounsu Aug. 1, 2024, 1:47 p.m. UTC
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 <yyyynoom@gmail.com>
---
 drivers/net/ethernet/intel/e1000e/netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Florian Westphal Aug. 1, 2024, 2:06 p.m. UTC | #1
Moon Yeounsu <yyyynoom@gmail.com> wrote:
> 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 <yyyynoom@gmail.com>
> ---
>  drivers/net/ethernet/intel/e1000e/netdev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
> index 360ee26557f7..07c4cf84bdf3 100644
> --- a/drivers/net/ethernet/intel/e1000e/netdev.c
> +++ b/drivers/net/ethernet/intel/e1000e/netdev.c
> @@ -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.
Moon Yeounsu Aug. 2, 2024, 2:25 a.m. UTC | #2
On Thu, Aug 1, 2024 at 11:06 PM Florian Westphal <fw@strlen.de> wrote:
> 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.
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.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 360ee26557f7..07c4cf84bdf3 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -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;