Actions
Bug #20258
closedSocket::IPV6_RECVERR for IPv6
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
Description
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:
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:
# 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
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.
Actions
Like0
Like0Like0Like0Like0