Skip to content

[servers.udp] UDP server initialization fails when IPv6 is disabled in kernel #1064

Closed

Description

@conallob

Describe the bug

I was trying to use cloudprober to help chase down an intermittent issue and I ran into this error:

level=ERROR+4 source=cmd/cloudprober/main.go:151 msg="Error initializing cloudprober. Err: SetControlMessage(ipv6.FlagDst, true) failed: setsockopt: protocol not available" system=cloudprober component=global

When debugging certain networks, I may want to explicitly prefer IPv4 or IPv6 depending on what I am debugging. When I do this, my toolset typically supports -4 and -6 CLI flags to force what family of socket I wish to make.

As per https://cloudprober.org/docs/config/latest/overview/ , each probeset can be configured with an ip_version configuration option, however that should be for steady state configuration. Sometimes you may want to override the configuration with a CLI flag for some period of time.

Cloudprober Version

v0.13.9

To Reproduce

  1. Boot Linux with ipv6.disable=1
  2. go run github.com/cloudprober/cloudprober --config_file=example_probes.cfg
  3. See if cloudprober continues to run or not

Additional context

I'm happy to implement this feature, so feel free to assign this bug to me.

Activity

  1. added
    bug
    on Apr 15, 2025
  2. added
    bug
    and removed
    bug
    on Apr 15, 2025
  3. manugarg commented on Apr 15, 2025

    @manugarg
    Contributor

    Describe the bug

    I was trying to use cloudprober to help chase down an intermittent issue and I ran into this error:

    level=ERROR+4 source=cmd/cloudprober/main.go:151 msg="Error initializing cloudprober. Err: SetControlMessage(ipv6.FlagDst, true) failed: setsockopt: protocol not available" system=cloudprober component=global
    

    I think CLI flag itself is an enhancement, but this log message seems to be a bug, where IPv6 connection wrapper for UDP conn is not working:

    if err := s.p6.SetControlMessage(ipv6.FlagDst, true); err != nil {

    Is that correct? Did you get this message while running on an ipv6 disabled machine?

    Also, can you please confirm if you encountered it for UDP probes?

  4. conallob commented on Apr 15, 2025

    @conallob
    ContributorAuthor

    The machine I was reproducing the error on had IPv6 dissbled.

    It does not have any UDP probes configured though, just some HTTPS proves to test internet egress and a TCP/22 probe to the machines I am chasing intermittent issues with

  5. manugarg commented on Apr 15, 2025

    @manugarg
    Contributor

    Sorry, I said UDP probe, but the snippet I shared is only in the UDP server code. Did you have UDP server configured by any chance? We don't call SetControlMessage(ipv6.FlagDst, true) anywhere else.

  6. conallob commented on Apr 15, 2025

    @conallob
    ContributorAuthor

    I'm wondering if it's actually net.Dialer() being called with the default value for DualStack

  7. manugarg commented on Apr 15, 2025

    @manugarg
    Contributor

    No, this error message is 100% coming from UDP server initialization code:

    return nil, fmt.Errorf("SetControlMessage(ipv6.FlagDst, true) failed: %v", err)

    The whole error message corresponds to that.

  8. conallob commented on Apr 15, 2025

    @conallob
    ContributorAuthor

    Apologies, you're right. I'm juggling too many things

    In addition to the configured probesets, my cloudprober config includes a cloudprober_common.cfg, which has the per protocol server configuration and other common settings. Although they're not being used, the UDP server is in fact getting initialised.

  9. manugarg commented on Apr 16, 2025

    @manugarg
    Contributor

    No worries. I'll change the title to reflect the actual issue.

    This is happening in the UDP server code because there we are using IPv6 connection wrapper to set the control message, regardless of the IP version that user configures, or system detects. But when IPv6 is disabled at the kernel level like what you were trying (not that IPv6 address is not available), kernel doesn't have data structures to support our system call.

    Change that introduced this behavior: 8ff8366, earlier we were using appropriate connection based on the destination's IP address, which would have worked correctly.

  10. changed the title [-]Provide CLI flags to explicitly select IPv4 or IPv6 Sockets[/-] [+][servers.udp] UDP server initialization fails when IPv6 is disabled in kernel[/+] on Apr 16, 2025
  11. self-assigned this
    on Apr 16, 2025
  12. manugarg commented on Apr 16, 2025

    @manugarg
    Contributor

    Also, I want to call out that with the new image this error message would have been much more clear:
    cccd9cd#diff-4dfce68395d663d108da2c51422411841382848ea551bf8b2f0eae7b8da1a52b

  13. conallob commented on Apr 16, 2025

    @conallob
    ContributorAuthor

    Thank you for the quick fix. I've filed #1068 to track the CLI flag feature

    Pity #1067 didn't make it into v0.14.0 though. :-/

  14. added this to the v0.14.1 milestone on Apr 16, 2025
  15. manugarg commented on Apr 16, 2025

    @manugarg
    Contributor

    Yeah, since this bug has a work around and disabling ipv6 at kernel level is a less likely scenario, I'll prefer waiting for the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions