diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-05-09 15:32:09 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-05-09 15:48:10 +0200 |
commit | b784360eff27aa71e1cd1180d9699cd295788a3d (patch) | |
tree | 5bd442f6ce838333b0675b5a4063d1ddc5e3da72 /src/dhcp/nm-dhcp-utils.c | |
parent | c8dbe90f428fbc58b22f1d86b29d63e565d2ed91 (diff) | |
download | NetworkManager-b784360eff27aa71e1cd1180d9699cd295788a3d.tar.gz |
Diffstat (limited to 'src/dhcp/nm-dhcp-utils.c')
-rw-r--r-- | src/dhcp/nm-dhcp-utils.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/dhcp/nm-dhcp-utils.c b/src/dhcp/nm-dhcp-utils.c index 9d644f6d2e..8807fbbd7c 100644 --- a/src/dhcp/nm-dhcp-utils.c +++ b/src/dhcp/nm-dhcp-utils.c @@ -386,6 +386,7 @@ NMIP4Config * nm_dhcp_utils_ip4_config_from_options (int ifindex, const char *iface, GHashTable *options, + gboolean never_default, guint32 priority) { NMIP4Config *ip4_config = NULL; @@ -465,11 +466,29 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex, str = g_hash_table_lookup (options, "dhcp_server_identifier"); if (str) { if (inet_pton (AF_INET, str, &tmp_addr) > 0) { + gboolean add_route = FALSE; _LOG2I (LOGD_DHCP4, iface, " server identifier %s", str); - if ( nm_utils_ip4_address_clear_host_address(tmp_addr, address.plen) != nm_utils_ip4_address_clear_host_address(address.address, address.plen) - && !nm_ip4_config_get_route_for_host (ip4_config, tmp_addr, TRUE)) { - /* DHCP server not on assigned subnet and the no direct route was returned. Add route */ + + if (nm_utils_ip4_address_clear_host_address (tmp_addr, address.plen) == + nm_utils_ip4_address_clear_host_address (address.address, address.plen)) { + /* directly reachable, nothing to do */ + } else if (gwaddr) { + if (never_default) { + /* we reach the server through a default route, but + * never-default is set and thus the route won't be + * installed + */ + add_route = TRUE; + } + } else if (nm_ip4_config_get_route_for_host (ip4_config, tmp_addr, FALSE)) { + /* indirectly reachable, nothing to do */ + } else { + /* no route to server, add a direct one */ + add_route = TRUE; + } + + if (add_route) { NMPlatformIP4Route route = { 0 }; route.network = tmp_addr; |