diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index a3b03efe31..8dd90684e6 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -5645,6 +5645,7 @@ connection_warnings(NmCli *nmc, NMConnection *connection) guint i, found; const char *id; const char *deprecated; + gs_free char *gw_warning = NULL; deprecated = nmc_connection_check_deprecated(NM_CONNECTION(connection)); if (deprecated) @@ -5673,6 +5674,10 @@ connection_warnings(NmCli *nmc, NMConnection *connection) nm_connection_get_uuid(NM_CONNECTION(connection)), found); } + + gw_warning = nm_connection_get_unreachable_gateways_warning(connection, TRUE); + if (gw_warning) + nmc_printerr("Warning: %s.\n", gw_warning); } static void diff --git a/src/tests/client/test-client.check-on-disk/test_005.expected b/src/tests/client/test-client.check-on-disk/test_005.expected new file mode 100644 index 0000000000..04f2f8adde --- /dev/null +++ b/src/tests/client/test-client.check-on-disk/test_005.expected @@ -0,0 +1,15 @@ +size: 683 +location: src/tests/client/test-client.py:test_005()/1 +cmd: $NMCLI c add type ethernet ifname eth0 con-name con-xx1 ipv4.method manual ipv4.addresses 192.168.1.1/24 ipv4.gateway 192.168.2.1 ipv4.routes '192.168.4.4 192.168.4.1' +lang: C +returncode: 0 +stdout: 80 bytes +>>> +Connection 'con-xx1' (UUID-con-xx1-REPLACED-REPLACED-REPLA) successfully added. + +<<< +stderr: 300 bytes +>>> +Warning: the following gateways are not directly reachable from any configured address or route: 192.168.2.1, 192.168.4.1. NetworkManager currently adds on-link routes for them automatically, but this will change in the future. Consider adding addresses or routes whose subnets cover these gateways. + +<<< diff --git a/src/tests/client/test-client.py b/src/tests/client/test-client.py index 37149d0530..3d618e35d5 100755 --- a/src/tests/client/test-client.py +++ b/src/tests/client/test-client.py @@ -2222,6 +2222,41 @@ class TestNmcli(unittest.TestCase): replace_stdout=replace_uuids, ) + @nm_test + def test_005(self): + self.init_001() + + replace_uuids = [] + + replace_uuids.append( + self.ctx.srv.ReplaceTextConUuid( + "con-xx1", "UUID-con-xx1-REPLACED-REPLACED-REPLA" + ) + ) + + # Check the warning about unreachable gateways + self.call_nmcli( + [ + "c", + "add", + "type", + "ethernet", + "ifname", + "eth0", + "con-name", + "con-xx1", + "ipv4.method", + "manual", + "ipv4.addresses", + "192.168.1.1/24", + "ipv4.gateway", + "192.168.2.1", + "ipv4.routes", + "192.168.4.4 192.168.4.1", + ], + replace_stdout=replace_uuids, + ) + @nm_test_no_dbus def test_offline(self): # Make sure we're not using D-Bus