From: marek22k via ruby-core <ruby-core@...>
Date: 2024-02-20T17:17:29+00:00
Subject: [ruby-core:116884] [Ruby master Bug#20258] Socket::IPV6_RECVERR for IPv6

Issue #20258 has been updated by marek22k (Marek K�the).





`Socket::IPV6_MTU_DISCOVER` is also missing in the current Ruby version.



----------------------------------------

Bug #20258: Socket::IPV6_RECVERR for IPv6

https://bugs.ruby-lang.org/issues/20258#change-106920



* Author: marek22k (Marek K�the)

* Status: Open

* Priority: Normal

* ruby -v: ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]

* Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN

----------------------------------------

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

```

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.







-- 

https://bugs.ruby-lang.org/

 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/