[PATCH] config: Use g_try_malloc0 instead of g_malloc0
by Niraj Kumar Goit
---
src/config.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/config.c b/src/config.c
index 344b8ce..3e30847 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1328,7 +1328,10 @@ static int try_provision_service(struct connman_config_service *config,
if (config->virtual) {
struct connect_virtual *virtual;
- virtual = g_malloc0(sizeof(struct connect_virtual));
+ virtual = g_try_malloc0(sizeof(struct connect_virtual));
+ if(!virtual)
+ return -ENOMEM;
+
virtual->service = service;
virtual->vfile = config->virtual_file;
--
1.7.9.5
5 years
[PATCH] peer: Use g_try_malloc instead of g_malloc
by Niraj Kumar Goit
---
src/peer.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/peer.c b/src/peer.c
index 8a380c9..cad1071 100644
--- a/src/peer.c
+++ b/src/peer.c
@@ -706,7 +706,10 @@ struct connman_peer *connman_peer_create(const char *identifier)
{
struct connman_peer *peer;
- peer = g_malloc0(sizeof(struct connman_peer));
+ peer = g_try_malloc0(sizeof(struct connman_peer));
+ if(!peer)
+ return NULL;
+
peer->identifier = g_strdup(identifier);
peer->state = CONNMAN_PEER_STATE_IDLE;
--
1.7.9.5
5 years
[PATCH 2/2] gsupplicant:Use g_try_malloc0 instead of g_malloc0
by Niraj Kumar Goit
As per the connman coding style (doc/coding-style.txt), g_try_malloc0 should
be used instead of g_malloc0.
---
gsupplicant/supplicant.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 4960ab7..246bef2 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2637,7 +2637,10 @@ static void create_peer_identifier(GSupplicantPeer *peer)
return;
}
- peer->identifier = g_malloc0(19);
+ peer->identifier = g_try_malloc0(19);
+ if (!peer->identifier)
+ return;
+
snprintf(peer->identifier, 19, "%02x%02x%02x%02x%02x%02x",
peer->device_address[0],
peer->device_address[1],
--
1.7.9.5
5 years
[PATCH 1/2] gdhcp: Use g_try_malloc instead of g_malloc
by Niraj Kumar Goit
As per the connman coding style, g_try_malloc should be used
instead of g_malloc.
---
gdhcp/client.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdhcp/client.c b/gdhcp/client.c
index f9cba89..0a721cb 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -1840,7 +1840,7 @@ static char *malloc_option_value_string(uint8_t *option, GDHCPOptionType type)
return NULL;
upper_length = len_of_option_as_string[type] *
((unsigned)len / (unsigned)optlen);
- dest = ret = g_malloc(upper_length + 1);
+ dest = ret = g_try_malloc(upper_length + 1);
if (!ret)
return NULL;
--
1.7.9.5
5 years
[PATCH 1/2] gsupplicant:Use g_try_malloc0 instead of g_malloc0
by Niraj Kumar Goit
As per the connman coding style (doc/coding-style.txt), g_try_malloc0 should
be used instead of g_malloc0.
---
gsupplicant/supplicant.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 5a0a5e4..4960ab7 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2765,11 +2765,12 @@ static void peer_property(const char *key, DBusMessageIter *iter,
peer->widi_ies_length = 0;
}
- peer->widi_ies = g_malloc0(ie_len * sizeof(unsigned char));
-
- memcpy(peer->widi_ies, ie, ie_len);
- peer->widi_ies_length = ie_len;
- data->services_changed = true;
+ peer->widi_ies = g_try_malloc0(ie_len * sizeof(unsigned char));
+ if (peer->widi_ies) {
+ memcpy(peer->widi_ies, ie, ie_len);
+ peer->widi_ies_length = ie_len;
+ data->services_changed = true;
+ }
}
}
--
1.7.9.5
5 years
[PATCH] service: Fix auto_connect service if state is not failure and ClearProperty is called
by Saurav Babu
If ClearProperty method is called with property Error and service state
other than failure then connman tries to auto_connect service if
connect_reason was not CONNMAN_SERVICE_CONNECT_REASON_USER. This patch
tries to run auto_connect only when service state was changed to idle
from failure.
---
src/service.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/service.c b/src/service.c
index abf0899..65439d1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3566,10 +3566,17 @@ static DBusMessage *clear_property(DBusConnection *conn,
DBUS_TYPE_INVALID);
if (g_str_equal(name, "Error")) {
+ int err;
+
set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
- __connman_service_clear_error(service);
- service_complete(service);
+ err = __connman_service_clear_error(service);
+
+ if (err < 0) {
+ g_get_current_time(&service->modified);
+ service_save(service);
+ } else
+ service_complete(service);
} else
return __connman_error_invalid_property(msg);
--
1.9.1
5 years
[PATCH] client: Add support for ClearProperty Service API
by Saurav Babu
ClearProperty API used by connman to clear the value of readonly Error property
of a service. This patch adds a new config_option "clear" in the Service
Configuration option to clear the readonly Error property.
---
client/commands.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/client/commands.c b/client/commands.c
index db24d16..70e5b62 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -1193,6 +1193,14 @@ static int cmd_config(char *args[], int num, struct connman_option *options)
config_return, g_strdup(service_name),
NULL, NULL);
break;
+ case 'c':
+ res = __connmanctl_dbus_method_call(connection,
+ CONNMAN_SERVICE, path,
+ "net.connman.Service", "ClearProperty",
+ config_return, g_strdup(service_name),
+ config_append_str, &append);
+ index += append.values;
+ break;
default:
res = -EINVAL;
break;
@@ -2183,6 +2191,7 @@ static struct connman_option config_options[] = {
{"autoconnect", 'a', "yes|no"},
{"ipv4", 'i', "off|dhcp|manual <address> <netmask> <gateway>"},
{"remove", 'r', " Remove service"},
+ {"clear", 'c', "Error Clear readonly Error property"},
{ NULL, }
};
--
1.9.1
5 years
[PATCH v2 0/7] Clean up gateway selection
by Patrik Flykt
Hi,
Patch 4/7 was added to this set, it keeps service order in sync with VPN
split routing, something that was being implicitly updated when calling
update_order() in connection.c. The code currently already sorts the
service list after the new calls to set_split_routing(), that's why there
is no explicit service sorting added by patch 4/7.
The rest of the patches are as before.
Cheers,
Patrik
In order to clean up gateway selection, the gateway code should use the
sorted list of services instead of sorting the gateways by itself.
The 'order' value in the gateway_data structure follows the service list,
i.e. the default service gets an 'order' value of 1, a VPN without split
routing a value of 10 and the rest a value of 0. This means the gateway
'order' variable gets its values so that the sorting order is the same
between gateways and services in the service list. With that, there are
now two entities that are being sorted, which in turn has caused code
duplication and a non-trivial implementation to decipher for the gateway
selection.
To change the current behavior, a function comparing the ordering between
two services is introduced in patch 1/7. This function is then used in
patch 3/7, throwing out the old code as a result. Patch 3/7 also combines
consecutive if statements.
Patch 2/7 gets the default service and uses that to look up the corresponding
gateway_data structure instead of iterating over the hash table.
With the previous ones applied, the 'order' variable is removed in patch 5/7,
the now unused function __connman_service_update_ordering() in patch 6/7 and
the TODO is updated in patch 7/7.
Patrik Flykt (7):
service: Add function to compare the order between two services
connection: Use the sorted service list to find the default gateway
connection: Use services to compare gateway ordering
service: Create helper function for setting split routing
connection: Remove 'order' variable
service: Remove obsolete __connman_service_update_ordering() function
TODO: Mark gateway selection simplification done
TODO | 11 ---------
src/connection.c | 75 ++++++++++++++------------------------------------------
src/connman.h | 4 ++-
src/service.c | 43 ++++++++++++++++++++++----------
4 files changed, 52 insertions(+), 81 deletions(-)
--
2.1.4
5 years
[PATCH] network: Remove explicit gateway activation
by Patrik Flykt
Remove explicit gateway activation for IPv6 static addresses. The gateway
activation will take place in __connman_ipconfig_gateway_add(), which is
called immediately before.
Remove the now unused __connman_connection_gateway_activate() function.
---
src/connection.c | 18 ------------------
src/connman.h | 2 --
src/network.c | 3 ---
3 files changed, 23 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index aa4e1c0..bbc5d83 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -771,24 +771,6 @@ static void update_order(void)
}
}
-void __connman_connection_gateway_activate(struct connman_service *service,
- enum connman_ipconfig_type type)
-{
- struct gateway_data *data = NULL;
-
- data = g_hash_table_lookup(gateway_hash, service);
- if (!data)
- return;
-
- DBG("gateway %p/%p type %d", data->ipv4_gateway,
- data->ipv6_gateway, type);
-
- if (type == CONNMAN_IPCONFIG_TYPE_IPV4)
- data->ipv4_gateway->active = true;
- else if (type == CONNMAN_IPCONFIG_TYPE_IPV6)
- data->ipv6_gateway->active = true;
-}
-
static void add_host_route(int family, int index, const char *gateway,
enum connman_service_type service_type)
{
diff --git a/src/connman.h b/src/connman.h
index 3049f08..ad789c3 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -493,8 +493,6 @@ void __connman_connection_gateway_remove(struct connman_service *service,
int __connman_connection_get_vpn_index(int phy_index);
bool __connman_connection_update_gateway(void);
-void __connman_connection_gateway_activate(struct connman_service *service,
- enum connman_ipconfig_type type);
int __connman_ntp_start(char *server);
void __connman_ntp_stop();
diff --git a/src/network.c b/src/network.c
index 08cf407..db3d2f3 100644
--- a/src/network.c
+++ b/src/network.c
@@ -285,9 +285,6 @@ static int manual_ipv6_set(struct connman_network *network,
if (err < 0)
return err;
- __connman_connection_gateway_activate(service,
- CONNMAN_IPCONFIG_TYPE_IPV6);
-
__connman_device_set_network(network->device, network);
connman_network_set_associating(network, false);
--
2.1.4
5 years
[PATCH] doc: Typo fix in overview-api.txt
by Saurav Babu
---
doc/overview-api.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/overview-api.txt b/doc/overview-api.txt
index 0a5996e..fd51d70 100644
--- a/doc/overview-api.txt
+++ b/doc/overview-api.txt
@@ -302,7 +302,7 @@ the "idle" state since the service is not connected.
| |
+------------------------------------------+
-The different states should no be used by the user interface to trigger
+The different states should not be used by the user interface to trigger
advanced actions. The state transitions are provided for the sole purpose
to give the user feedback on what is currently going on. Especially in
cases where networks are flaky or DHCP servers take a long time these
--
1.9.1
5 years