|SUCCESS| net/ark: validate IPv4 octets in address parser
dpdklab at iol.unh.edu
dpdklab at iol.unh.edu
Wed Jun 3 18:46:35 CEST 2026
Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/164875
_AI Code Review_
=== Patch Review: series.patch (via Claude) ===
Review date: 2026-06-03
Commit: <git sha from patch header>
Author: Denis Sergeev <denserg.edu at gmail.com>
Subject: [PATCH] net/ark: validate IPv4 octets in address parser
The patch adds validation to reject IPv4 octets exceeding 255 in the
parse_ipv4_string() helper function used by ark pktgen and pktchkr
modules.
> diff --git a/drivers/net/ark/ark_pktchkr.c b/drivers/net/ark/ark_pktchkr.c
> index e1f336c73c..76e6f42659 100644
> --- a/drivers/net/ark/ark_pktchkr.c
> +++ b/drivers/net/ark/ark_pktchkr.c
> @@ -379,6 +379,8 @@ parse_ipv4_string(char const *ip_address)
> if (sscanf(ip_address, "%u.%u.%u.%u",
> &ip[0], &ip[1], &ip[2], &ip[3]) != 4)
> return 0;
> + if (ip[0] > 255 || ip[1] > 255 || ip[2] > 255 || ip[3] > 255)
> + return 0;
Does this check need a diagnostic message? The function returns 0 on
error, but callers might benefit from knowing why parsing failed,
especially since this is a new rejection case. Consider using ARK_PMD_LOG
to report the invalid octet values before returning 0.
Also, per the coding style guide section on comparisons, explicit
comparisons with 0 can be clearer as "!= 0" when testing for non-zero
values. However, the existing code already uses implicit zero comparison
in the return statement pattern, so this is consistent.
> return ip[3] + ip[2] * 0x100 + ip[1] * 0x10000ul + ip[0] * 0x1000000ul;
> }
>
> diff --git a/drivers/net/ark/ark_pktgen.c b/drivers/net/ark/ark_pktgen.c
> index 69ff7072b2..0b7246c374 100644
> --- a/drivers/net/ark/ark_pktgen.c
> +++ b/drivers/net/ark/ark_pktgen.c
> @@ -360,6 +360,8 @@ parse_ipv4_string(char const *ip_address)
> if (sscanf(ip_address, "%u.%u.%u.%u",
> &ip[0], &ip[1], &ip[2], &ip[3]) != 4)
> return 0;
> + if (ip[0] > 255 || ip[1] > 255 || ip[2] > 255 || ip[3] > 255)
> + return 0;
> return ip[3] + ip[2] * 0x100 + ip[1] * 0x10000ul + ip[0] * 0x1000000ul;
> }
Same question about diagnostic logging applies here in ark_pktgen.c.
Would a log message help administrators diagnose configuration file
errors when invalid IP addresses are rejected?
More information about the test-report
mailing list