Bug 2560148

Summary: dnf automatic creates warning "No network connection detected'
Product: [Fedora] Fedora Reporter: Villy Kruse <ppywlkiqletw>
Component: dnf5Assignee: Marek Blaha <mblaha>
Status: POST --- QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: 44CC: jonathan, lzqhwo, mblaha, pkratoch, ppisar, rpm-software-management
Target Milestone: ---Keywords: Triaged
Target Release: ---Flags: fedora-admin-xmlrpc: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Villy Kruse 2026-10-23 18:00:21 UTC
The problem code is

static bool server_available(std::string_view host, std::string_view service) {
    // Resolve host name/service to IP address/port
    struct addrinfo * server_info;
    if (getaddrinfo(host.data(), service.data(), nullptr, &server_info) != 0) {
        return false;
    }
    
    // Create a socket
    int sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0) {
        freeaddrinfo(server_info);
        return false;
    }
    
    // Attempt to connect to the server
    bool retval = true;
    struct timeval timeout;
    timeout.tv_sec = 1;
    timeout.tv_usec = 0;
    setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
    if (connect(sockfd, server_info->ai_addr, server_info->ai_addrlen) < 0) {
        retval = false;
    }

    close(sockfd);
    freeaddrinfo(server_info);
    return retval;
}

The problem is that when you test an IPv6 address you also need to create an IPv6 socket.  On systems where IPv6 is preferred, you almost always get an IPv6 address to test.

The AutomaticCommand::wait_for_network() seems pointless as you wouldn't get any addresses to test with if the network is down.  At least not when you get the addresses from DNS over the network.

Reproducible: Always

Comment 2 Dominic 2026-10-24 11:25:26 UTC
I should add that I'm not sure the bug I reported in my forum post is the same as being reported here. I get a dnf5 automatic timeout even when the network is functioning correctly so I believe it always uses cached package lists as a result.

I'll open a new bug if required.

Comment 3 Marek Blaha 2026-10-26 08:21:42 UTC
@lzqhwo the discussion very likely represents the same root cause, thanks!

Comment 4 Marek Blaha 2026-10-26 08:52:14 UTC
I created https://github.com/rpm-software-management/dnf5/pull/3006 PR with a fix for IPv6 environments.