From: Pasi Sjöholm <[email protected]>
If service is ever being configured with manual ip-address, netmask
and gateway and later changed to dhcp, the related settings must
not be read if configuration method is not manual or fixed.
Otherwise they can possible collide with the settings got from
dhcp-server if they are exactly the same
(eg. dhcp.c: lease_available_cb()). This could lead network
interface not being configured correctly.
---
src/ipconfig.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 5c34e98..803b7d1 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -2249,6 +2249,25 @@ int __connman_ipconfig_load(struct connman_ipconfig
*ipconfig,
g_free(method);
g_free(key);
+ switch (ipconfig->method) {
+ case CONNMAN_IPCONFIG_METHOD_FIXED:
+ case CONNMAN_IPCONFIG_METHOD_MANUAL:
+ break;
+ case CONNMAN_IPCONFIG_METHOD_DHCP:
+ key = g_strdup_printf("%sDHCP.LastAddress", prefix);
+ str = g_key_file_get_string(keyfile, identifier, key, NULL);
+ if (str) {
+ g_free(ipconfig->last_dhcp_address);
+ ipconfig->last_dhcp_address = str;
+ }
+ g_free(key);
+ /* fall through */
+ case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
+ case CONNMAN_IPCONFIG_METHOD_OFF:
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
+ return 0;
+ }
+
key = g_strdup_printf("%snetmask_prefixlen", prefix);
ipconfig->address->prefixlen = g_key_file_get_integer(
keyfile, identifier, key, NULL);
@@ -2278,14 +2297,6 @@ int __connman_ipconfig_load(struct connman_ipconfig
*ipconfig,
keyfile, identifier, key, NULL);
g_free(key);
- key = g_strdup_printf("%sDHCP.LastAddress", prefix);
- str = g_key_file_get_string(keyfile, identifier, key, NULL);
- if (str) {
- g_free(ipconfig->last_dhcp_address);
- ipconfig->last_dhcp_address = str;
- }
- g_free(key);
-
return 0;
}
--
2.1.0
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman