[PATCH] net/af_packet: fix drop count error check
Stefan Lässer
stefan.laesser at omicronenergy.com
Wed Nov 25 13:49:32 CET 2026
Yes, you are right with the return code of the getsockopt() function.
Your changes fix the error case handling.
> -----Original Message-----
> From: Changwoo Kang <changwoo.kang at ericsson.com>
> Sent: Tuesday, November 24, 2026 4:24 PM
> To: dev at dpdk.org
> Cc: Thomas Monjalon <thomas at monjalon.net>; Stephen Hemminger
> <stephen at networkplumber.org>; Changwoo Kang
> <changwoo.kang at ericsson.com>; stable at dpdk.org; Stefan Lässer
> <stefan.laesser at omicronenergy.com>
> Subject: [PATCH] net/af_packet: fix drop count error check
>
> [You don't often get email from changwoo.kang at ericsson.com. Learn why
> this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> getsockopt() returns 0 on success and -1 on error, so the check "< -1" is never
> true. On failure the function returned an uninitialized value. Check for "< 0"
> instead.
>
> Fixes: 6b3246245507 ("net/af_packet: provide packet drop stats")
> Cc: stable at dpdk.org
> Cc: Stefan Laesser <stefan.laesser at omicronenergy.com>
>
> Signed-off-by: Changwoo Kang <changwoo.kang at ericsson.com>
> ---
> .mailmap | 1 +
> drivers/net/af_packet/rte_eth_af_packet.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/.mailmap b/.mailmap
> index a0096fb97a..ed6e68cc1b 100644
> --- a/.mailmap
> +++ b/.mailmap
> @@ -264,6 +264,7 @@ Changchun Ouyang <changchun.ouyang at intel.com>
> Changpeng Liu <changpeng.liu at intel.com> Changqi Dingluo
> <dingluochangqi.ck at bytedance.com> Changqing Wu
> <changqingx.wu at intel.com>
> +Changwoo Kang <changwoo.kang at ericsson.com>
> Chao Zhu <chaozhu at linux.vnet.ibm.com> <bjzhuc at cn.ibm.com> Chaoyong
> He <chaoyong.he at corigine.com> Charles Brett <cfb at hpe.com> diff --git
> a/drivers/net/af_packet/rte_eth_af_packet.c
> b/drivers/net/af_packet/rte_eth_af_packet.c
> index fbaea57615..ad71582aea 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -518,7 +518,7 @@ packet_drop_count(int sockfd)
> return 0;
>
> if (getsockopt(sockfd, SOL_PACKET, PACKET_STATISTICS, &pkt_stats,
> - &pkt_stats_len) < -1)
> + &pkt_stats_len) < 0)
> return 0;
>
> return pkt_stats.tp_drops;
> --
> 2.36.0
More information about the stable
mailing list