libhv icon indicating copy to clipboard operation
libhv copied to clipboard

protocol/icmp在IPv6下recvfrom返回错误

Open bamlan opened this issue 1 year ago • 6 comments

protocol/icmp在IPv6下无法使用, sendto调用正常返回,windows下recvfrom时错误代码10060, linux下错误代码 11

bamlan avatar Aug 27 '24 01:08 bamlan

通过so_rcvtimeo设置了接收超时的,windows 10060和linux 11错误码都是超时未收到响应导致的,这个是正常现象

ithewei avatar Aug 27 '24 03:08 ithewei

通过so_rcvtimeo设置了接收超时的,windows 10060和linux 11错误码都是超时未收到响应导致的,这个是正常现象

但我把超时时间设置为30秒都显示超时状态,ping ipv4地址就正常返回,地址使用系统ping程序都是正常能ping通的。

bamlan avatar Aug 27 '24 03:08 bamlan

我发现有个socket选项可能没用适配ipv6,把IPPROTO_ICMP改成IPPROTO_ICMPV6试试呢

ithewei avatar Aug 27 '24 13:08 ithewei

我发现有个socket选项可能没用适配ipv6,把IPPROTO_ICMP改成IPPROTO_ICMPV6试试呢

修改成:int sockfd = socket(peeraddr.sa.sa_family, SOCK_RAW, peeraddr.sa.sa_family == AF_INET6 ? IPPROTO_ICMPV6 : IPPROTO_ICMP); 还是一样的运行结果

bamlan avatar Aug 28 '24 05:08 bamlan

应该是ICMPV6和ICMP的报文内容也不同,需要详细研究下

ithewei avatar Sep 02 '24 08:09 ithewei

#709 提交了一个PR,修复了这个问题

bamlan avatar Apr 07 '25 08:04 bamlan