retitle -1 g_network_monitor_can_reach() returns unreachable on system with 
fully working network
reassign -1 glib2.0 2.84.3-1
thanks

On Mon, Jul 21, 2025 at 10:59:46AM -0500, Mario Limonciello wrote:
> A simple C app that uses just that symbol and prints the output is probably 
> the way to go.

While I do know basic C coding I have never used GLib before and didn't
really know where to start. I ended up asking an LLM, which produced the
attached example.

This example does indeed fail for me on the system in question while it
works on other systems.

I'll reassign this to glib2.0 and pursue it there.

Thanks!

Dear GLib maintainers,

On this install of Debian 13 g_network_monitor_can_reach() is returning
unreachable even though the machine;s network is as far as I am aware
fully working.

This system is now in test deployment and up until I tried to make fwupd
work, every other aspect of it was seen to be working correctly. It was
only when finding that fwupd wouldn't download its metadata database due
to believing that it had no network access that I have begun to look in
to this.

Are you able to help me find out why this function is deciding this?

This is a server system with network statically configured by ifupdown.
Its network configuration is slightly out of the ordinary however, in
that it has two network interfaces with only IPv6 link-local addresses
on them, and some global scope addresses on the loopback interface.

The system talks BGP over its main interfaces and learns default routes
from the BIRD BGP daemon.

This is a valid network configuration since even if BGP were not in the
picture, it could be talking to its default gateway router over one of
the link-local addresses and still be fully functional as an Internet
host. I recognise however that this kind of setup is probably rare so
this may be the area in which the problem lies.

$ ip a sh dev lo
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group 
default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 85.119.80.32/32 brd 85.119.80.32 scope global lo:0
       valid_lft forever preferred_lft forever
    inet6 2a0a:1100:f20::/128 scope global deprecated 
       valid_lft forever preferred_lft 0sec
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
$ ip a sh dev e-25g-0
4: e-25g-0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group 
default qlen 1000
    link/ether 40:a6:b7:2b:61:1c brd ff:ff:ff:ff:ff:ff
    inet6 fe80::2/64 scope link nodad 
       valid_lft forever preferred_lft forever
    inet6 fe80::42a6:b7ff:fe2b:611c/64 scope link proto kernel_ll 
       valid_lft forever preferred_lft forever
$ ip a sh dev e-25g-1
5: e-25g-1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group 
default qlen 1000
    link/ether 40:a6:b7:2b:61:1d brd ff:ff:ff:ff:ff:ff
    inet6 fe80::2/64 scope link nodad 
       valid_lft forever preferred_lft forever
    inet6 fe80::42a6:b7ff:fe2b:611d/64 scope link proto kernel_ll 
       valid_lft forever preferred_lft forever
$ ip ro sh default
default proto bird src 85.119.80.32 metric 500 
        nexthop via inet6 fe80::1 dev e-25g-0 weight 1 
        nexthop via inet6 fe80::1 dev e-25g-1 weight 1 
$ ip -6 ro sh default
default proto bird src 2a0a:1100:f20:: metric 500 pref medium
        nexthop via fe80::1 dev e-25g-0 weight 1 
        nexthop via fe80::1 dev e-25g-1 weight 1

The test program attached shows that g_network_monitor_can_reach()
thinks that this system can't reach 8.8.8.8, yet I can use other
applications to reach that IP with no issue.

$ ./can_reach 
Error checking network connectivity: Host unreachable

Thanks,
Andy
#include <glib.h>
#include <gio/gio.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
    GError *error = NULL;
    GNetworkMonitor *monitor;
    GSocketConnectable *connectable;
    gboolean can_reach;
    
    // Create a network monitor instance
    monitor = g_network_monitor_get_default();
    
    // Create a connectable for a test address (Google's DNS)
    connectable = g_network_address_new("8.8.8.8", 53);
    
    // Check if we can reach the address
    can_reach = g_network_monitor_can_reach(monitor, 
                                           connectable, 
                                           NULL,  // no cancellable
                                           &error);
    
    if (error != NULL) {
        printf("Error checking network connectivity: %s\n", error->message);
        g_error_free(error);
        g_object_unref(connectable);
        return 1;
    }
    
    printf("Can reach 8.8.8.8:53: %s\n", can_reach ? "YES" : "NO");
    
    // Cleanup
    g_object_unref(connectable);
    
    return 0;
}

Reply via email to