summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-02-01 17:52:52 +0100
committerThomas Haller <thaller@redhat.com>2019-02-06 12:16:37 +0100
commit5543f5f949df4606ddcb384dcc977ec0398ab28c (patch)
tree25a7417320ab693bc3fe93f9f529c68958daad71
parent708f81051589bd566cad37d564e07cfa5e594673 (diff)
downloadNetworkManager-th/nmcli-validate-default-route.tar.gz
cli: drop invalid validation for default-routes in nmclith/nmcli-validate-default-route
Currently, default-routes cannot be added like regular static-routes as ipv4.routes setting. Instead, one has to configure "ipv4.gateway" and "ipv4.never-default". That of course should be fixed, for example to configure a default-route in different routing tables. As it is, both nmcli's parse function and libnm's NMSettingIPConfig:verify() functions reject default-routes. But nmcli goes way beyond that, it also rejects all networks with "0.0.0.0"/"::" even if their prefix length is not zero. Such routes are not default-routes, and nmcli has no business rejecting them. The correct way for checking for a default-route is to check the prefix-length for zero. Drop the wrong validation in nmcli. Note, it may still not be the best idea to add catch-all routes like "0.0.0.0/1" and "128.0.0.0/1". It just defeats what counts as a default-route. NM has other means (like configuring the route-metric) to handle routing in face of multiple interfaces. But sure, whatever works for you.
-rw-r--r--clients/common/nm-meta-setting-desc.c13
1 files changed, 0 insertions, 13 deletions
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
index 118ffe7562..0cd9bf5164 100644
--- a/clients/common/nm-meta-setting-desc.c
+++ b/clients/common/nm-meta-setting-desc.c
@@ -117,7 +117,6 @@ _parse_ip_route (int family,
{
const int MAX_PREFIX = (family == AF_INET) ? 32 : 128;
const char *next_hop = NULL;
- const char *canon_dest;
int prefix;
NMIPRoute *route = NULL;
GError *local = NULL;
@@ -229,18 +228,6 @@ _parse_ip_route (int family,
return NULL;
}
- /* We don't accept default routes as NetworkManager handles it
- * itself. But we have to check this after @route has normalized the
- * dest string.
- */
- canon_dest = nm_ip_route_get_dest (route);
- if (!strcmp (canon_dest, "0.0.0.0") || !strcmp (canon_dest, "::")) {
- g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_INVALID_ARGUMENT,
- _("default route cannot be added (NetworkManager handles it by itself)"));
- g_clear_pointer (&route, nm_ip_route_unref);
- return NULL;
- }
-
if (attrs) {
GHashTableIter iter;
char *name;