From 8438bd3f314cf0ea5eeb9200ba815c0e031e3c0a Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 9 Dec 2015 12:30:32 +0530 Subject: [PATCH] networks: Fix issue with setting default netmask - Minor refactoring of DNS server setting code. --- plinth/network.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/plinth/network.py b/plinth/network.py index 2df9edbf7..b9dd9ee8a 100644 --- a/plinth/network.py +++ b/plinth/network.py @@ -312,21 +312,18 @@ def _update_ipv4_settings(connection, ipv4_method, ipv4_address, ipv4_netmask, settings.set_property(nm.SETTING_IP_CONFIG_METHOD, ipv4_method) if ipv4_method == nm.SETTING_IP4_CONFIG_METHOD_MANUAL and ipv4_address: ipv4_address_int = ipv4_string_to_int(ipv4_address) + if not ipv4_netmask: ipv4_netmask_int = nm.utils_ip4_get_default_prefix( - ipv4_address_int) + ipv4_address_int) + else: + ipv4_netmask_int = nm.utils_ip4_netmask_to_prefix( + ipv4_string_to_int(ipv4_netmask)) - ipv4_netmask_int = nm.utils_ip4_netmask_to_prefix( - ipv4_string_to_int(ipv4_netmask)) address = nm.IPAddress.new(socket.AF_INET, ipv4_address, ipv4_netmask_int) settings.add_address(address) - if ipv4_dns: - settings.add_dns(ipv4_dns) - if ipv4_second_dns: - settings.add_dns(ipv4_second_dns) - if not ipv4_gateway: settings.set_property(nm.SETTING_IP_CONFIG_GATEWAY, '0.0.0.0') else: @@ -335,10 +332,11 @@ def _update_ipv4_settings(connection, ipv4_method, ipv4_address, ipv4_netmask, if ipv4_dns or ipv4_second_dns: settings.set_property(nm.SETTING_IP_CONFIG_IGNORE_AUTO_DNS, True) - if ipv4_dns: - settings.add_dns(ipv4_dns) - if ipv4_second_dns: - settings.add_dns(ipv4_second_dns) + if ipv4_dns: + settings.add_dns(ipv4_dns) + + if ipv4_second_dns: + settings.add_dns(ipv4_second_dns) def _update_ethernet_settings(connection, connection_uuid, name, interface,