Project

General

Profile

Actions

Bug #20258

closed

Socket::IPV6_RECVERR for IPv6

Added by marek22k (Marek Küthe) 4 months ago. Updated 4 months ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
[ruby-core:116676]

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 #1

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

  • Description updated (diff)

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

I have created a PR to fix the error: https://github.com/ruby/ruby/pull/9930

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

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

Actions #4

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

  • Status changed from Open to Closed

Applied in changeset git|4bb432722832b6451a289d906b08db322de6bad7.


Fixes [Bug #20258]

Signed-off-by: Marek Küthe

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0