You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/24 15:19:17 UTC
[incubator-nuttx] 02/03: net/icmpv6: Fix `datalen` in icmpv6_reply
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit a26ea96f3bca2e9b5a221bdab26820474c22be1f
Author: Zhe Weng <we...@xiaomi.com>
AuthorDate: Thu Nov 24 16:59:31 2022 +0800
net/icmpv6: Fix `datalen` in icmpv6_reply
The `datalen` indicates the whole len of original packet, which will become the payload inside icmpv6 packet.
Using `datalen = (ipv4->len[0] << 8) + ipv4->len[1]` in icmp_reply is correct, because it includes IPv4 header, but when coming to IPv6, the `len` does not include the header, so we need to add it back.
Signed-off-by: Zhe Weng <we...@xiaomi.com>
---
net/icmpv6/icmpv6_reply.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/icmpv6/icmpv6_reply.c b/net/icmpv6/icmpv6_reply.c
index 3bd4192d52..b6be31624e 100644
--- a/net/icmpv6/icmpv6_reply.c
+++ b/net/icmpv6/icmpv6_reply.c
@@ -99,9 +99,9 @@ void icmpv6_reply(FAR struct net_driver_s *dev, int type, int code, int data)
return;
}
- /* Get the data size of the packet. */
+ /* Get the data (whole original packet) size of the packet. */
- datalen = (ipv6->len[0] << 8) + ipv6->len[1];
+ datalen = (ipv6->len[0] << 8) + ipv6->len[1] + IPv6_HDRLEN;
/* RFC says return as much as we can without exceeding 1280 bytes. */