Project

General

Profile

Bug #20258

Updated by marek22k (Marek Küthe) 6 months ago

Hello, 

 I am currently trying to receive ICMP error messages in Ruby. For IPv4 there is the `Socket::IP_RECVERR` flag, which can be set, but not for IPv6 (not found unter https://docs.ruby-lang.org/en/3.2/Socket/Constants.html for example), although this is provided for in POSIX (see https://manned.org/ipv6.7 under IPV6_RECVERR). 
 The following can therefore be done for IPv4: 
 ```rb 
 sock.setsockopt Socket::IPPROTO_IP, Socket::IP_RECVERR, 1 
 ``` 
 But not for IPv6: 
 ``` 
 sock.setsockopt Socket::IPPROTO_IPV6, Socket::IPV6_RECVERR, 1 
 ``` 

 Could IPV6_RECVERR be included? 

 Background: 

 I want to try to build a traceroute implementation in Ruby. So far I have the following code: 
 ```rb 
 # frozen_string_literal: true 
 # sharable_constant_value: literal 

 require 'socket' 

 sock = Socket.open(Socket::AF_INET6, Socket::SOCK_DGRAM, Socket::IPPROTO_UDP) 
 sock.setsockopt Socket::IPPROTO_IPV6, Socket::IPV6_UNICAST_HOPS, 1 
 # sock.setsockopt Socket::IPPROTO_IPV6, Socket::IPV6_RECVERR, 1 
 dest = Socket.sockaddr_in 33435, '2a00:1450:4001:806::2003' 
 pp sock.send "Test", 0, dest 
 pp sock.recvmsg 1000, Socket::MSG_ERRQUEUE, 1000 nil, Socket::MSG_ERRQUEUE 
 ``` 
 However, the `recvmsg` function is blocking (still receiving the ICMP error message) forever. I could imagine that this is due to the missing flag. Hence this request.

Back