From 9c1fb4c04bd26f8be9b3d0a8edb7ad453964ef8b Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Tue, 18 May 2021 21:10:03 +0800 Subject: [PATCH] net/icmp: consume the data length to avoid duplicate packet Signed-off-by: chao.an --- net/icmp/icmp_recvmsg.c | 3 ++- net/icmpv6/icmpv6_recvmsg.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/icmp/icmp_recvmsg.c b/net/icmp/icmp_recvmsg.c index 80c1ab88d3..4f2577d97e 100644 --- a/net/icmp/icmp_recvmsg.c +++ b/net/icmp/icmp_recvmsg.c @@ -181,7 +181,8 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev, /* Indicate that the data has been consumed */ - flags &= ~ICMP_NEWDATA; + flags &= ~ICMP_NEWDATA; + dev->d_len = 0; goto end_wait; } diff --git a/net/icmpv6/icmpv6_recvmsg.c b/net/icmpv6/icmpv6_recvmsg.c index b4fb7c80d2..a4678e8f69 100644 --- a/net/icmpv6/icmpv6_recvmsg.c +++ b/net/icmpv6/icmpv6_recvmsg.c @@ -188,7 +188,8 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev, /* Indicate that the data has been consumed */ - flags &= ~ICMPv6_NEWDATA; + flags &= ~ICMPv6_NEWDATA; + dev->d_len = 0; goto end_wait; }