[PATCH] service: Allow removing service in idle state
by Harish Jenny K N
Currently only if the service state is CONNMAN_SERVICE_STATE_FAILURE,
the service is allowed to be removed. This commit allows removing the
service when service state is CONNMAN_SERVICE_STATE_IDLE and
CONNMAN_SERVICE_STATE_DISCONNECT.
This is needed for the following usecase:
Connect to router with WEP encryption by issuing wrong passphrase
(exactly matching the length of WEP passphrase of 5 or 13.
Detected as wrong passphrase otherwise).
$ connmanctl> connect <service>
Passphrase = [ Type=wep, Requirement=mandatory ]
Passphrase? <Enter 5 digit passphrase>
$ connmanctl>
Agent ReportError <service>
connect-failed
Connection is unsuccessful as wrong key is entered(expected behaviour).
Again try to connect to the same router. But this time agent will not
ask for passphrase.
connman will never be able to connect to this router.
Try with config <service> --remove option to remove stored passphrase.
$ connmanctl> config <service> --remove
Error <service>: Not supported
In order to enter the right passphrase again while connecting we need
the option to remove the service during is_idle(service->state).
---
src/service.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/service.c b/src/service.c
index 0d08b5c..2289d54 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4242,8 +4242,7 @@ bool __connman_service_remove(struct connman_service *service)
__connman_provider_is_immutable(service->provider))
return false;
- if (!service->favorite && service->state !=
- CONNMAN_SERVICE_STATE_FAILURE)
+ if (!service->favorite && !is_idle(service->state))
return false;
__connman_service_disconnect(service);
--
1.9.1
5 years, 5 months
[PATCH v2] technology: Deny P2P finding if technology is disabled
by blanquicet@gmail.com
From: Jose Blanquicet <jose.blanquicet-melendez(a)magnetimarelli.com>
This check is added because P2P and WiFi scan end up at the same device and at
that level there is not differentiation between WiFi and P2P, they both are WiFi
devices. Therefore, when device's power is checked in device.c:device_scan(),
it is actually checking only if WiFi technology is enabled thus P2P scan will go
ahead even if P2P technology is not enabled.
---
src/technology.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/technology.c b/src/technology.c
index 4574f1e..d2f0ae2 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1077,6 +1077,10 @@ static DBusMessage *scan(DBusConnection *conn, DBusMessage *msg, void *data)
DBG("technology %p request from %s", technology,
dbus_message_get_sender(msg));
+ if (technology->type == CONNMAN_SERVICE_TYPE_P2P &&
+ !technology->enabled)
+ return __connman_error_permission_denied(msg);
+
dbus_message_ref(msg);
technology->scan_pending =
g_slist_prepend(technology->scan_pending, msg);
--
1.9.1
5 years, 5 months
How to set MTU?
by David Aldrich
Hi
I am working with Wind River Linux.
Is it possible to set the MTU of a network interface using connman?
Best regards
David
5 years, 5 months
[PATCH] wifi: Prevent scanning on tethering interface
by blanquicet@gmail.com
From: Jose Blanquicet <jose.blanquicet-melendez(a)magnetimarelli.com>
The first issue takes place when user asks for a Scan on P2P technology and
Tethering is enabled for WiFi technology, ConnMan will reply with a success to
the request even if the P2P find does not actually started. The second issue
occurs when user asks for a Scan on WiFi technology and WiFi tethering is
enabled, in such case, ConnMan will never emit the reply and client (e.g.
connmanctl) will go in D-Bus time-out.
This patch moves the tethering state check before calling P2PDevice.Find() in
order to solve first issue; in addition, return -EBUSY instead of zero
("success") if tethering is enabled to solve the second issue. Doing so, ConnMan
will save one useless D-Bus call toward wpa_supplicant (P2PDevice.Find) and will
be able to correctly reply "Error" to the scan requests while tethering.
---
plugins/wifi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index f8d88fa..a49031c 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1802,14 +1802,14 @@ static int wifi_scan(enum connman_service_type type,
if (wifi->p2p_device)
return 0;
+ if (wifi->tethering)
+ return -EBUSY;
+
if (type == CONNMAN_SERVICE_TYPE_P2P)
return p2p_find(device);
DBG("device %p wifi %p hidden ssid %s", device, wifi->interface, ssid);
- if (wifi->tethering)
- return 0;
-
scanning = connman_device_get_scanning(device);
if (!ssid || ssid_len == 0 || ssid_len > 32) {
--
1.9.1
5 years, 5 months
[PATCH v2] service: Add EnableOnlineCheck config option
by Lukasz Nowak
From: Lukasz Nowak <lnowak(a)tycoint.com>
Changes from v1:
- added info printouts reminding that the online check is disabled
at main.conf parse time, and every time a service would go ONLINE
but is kept in READY.
Lukasz Nowak (1):
service: Add EnableOnlineCheck config option
doc/connman.conf.5.in | 9 +++++++++
src/main.c | 17 +++++++++++++++++
src/main.conf | 9 +++++++++
src/service.c | 18 +++++++++++-------
4 files changed, 46 insertions(+), 7 deletions(-)
--
2.7.4
5 years, 5 months
[PATCH] gsupplicant: Add DBGs to trace errors from wpa_supplicant
by blanquicet@gmail.com
From: Jose Blanquicet <jose.blanquicet-melendez(a)magnetimarelli.com>
Errors comming from wpa_supplicant are mapped into standard errors. This patch
adds some DBGs to log those errors and ease debug in case one of these D-Bus
calls fails.
---
gsupplicant/supplicant.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index fcf5371..50e4aa6 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -3904,6 +3904,7 @@ static void interface_remove_result(const char *error,
if (error) {
err = -EIO;
+ SUPPLICANT_DBG("error: %s", error);
goto done;
}
@@ -4946,6 +4947,8 @@ static void network_remove_result(const char *error,
if (error) {
result = -EIO;
+ SUPPLICANT_DBG("error: %s", error);
+
if (g_strcmp0("org.freedesktop.DBus.Error.UnknownMethod",
error) == 0)
result = -ECONNABORTED;
@@ -5013,6 +5016,8 @@ static void interface_disconnect_result(const char *error,
if (error) {
result = -EIO;
+ SUPPLICANT_DBG("error: %s", error);
+
if (g_strcmp0("org.freedesktop.DBus.Error.UnknownMethod",
error) == 0)
result = -ECONNABORTED;
@@ -5182,8 +5187,10 @@ static void interface_p2p_connect_result(const char *error,
SUPPLICANT_DBG("");
- if (error)
+ if (error) {
+ SUPPLICANT_DBG("error: %s", error);
err = parse_supplicant_error(iter);
+ }
if (data->callback)
data->callback(err, data->interface, data->user_data);
--
1.9.1
5 years, 5 months
[PATCH v2] ofono: Fix segfault during set_property
by Scott Valentine
If the SIM card is ejected or the modem is reset / removed between the
set_property call and the set_property_reply callback, connmand will generally
abort, as the remove_all_contexts will get called, and the callback accesses a
reference to a stale context via the property_info pointer.
The following patch adds reference counting to the network_context struct to
prevent the segfault, and has been modified slightly after review.
diff -uNrp old/plugins/ofono.c new/plugins/ofono.c
--- old/plugins/ofono.c 2016-04-17 21:04:30.000000000 -1000
+++ new/plugins/ofono.c 2017-03-13 08:49:02.416476829 -1000
@@ -143,6 +143,8 @@ struct network_context {
struct connman_ipaddress *ipv6_address;
char *ipv6_nameservers;
+ int refcount;
+
bool active;
bool valid_apn; /* APN is 'valid' if length > 0 */
};
@@ -271,11 +273,23 @@ static struct network_context *network_c
context->ipv6_address = NULL;
context->ipv6_nameservers = NULL;
+ context->refcount = 1;
+
return context;
}
-static void network_context_free(struct network_context *context)
+static void network_context_ref(struct network_context *context)
+{
+ __sync_fetch_and_add(&context->refcount, 1);
+ DBG("%p ref %d", context, context->refcount);
+}
+
+static void network_context_unref(struct network_context *context)
{
+ DBG("%p ref %d", context, context->refcount - 1);
+ if (__sync_fetch_and_sub(&context->refcount, 1) != 1)
+ return;
+
g_free(context->path);
connman_ipaddress_free(context->ipv4_address);
@@ -389,6 +403,15 @@ struct property_info {
get_properties_cb get_properties_cb;
};
+static void free_property_info(void * memory)
+{
+ struct property_info * info = memory;
+ if (info->context)
+ network_context_unref(info->context);
+
+ g_free(info);
+}
+
static void set_property_reply(DBusPendingCall *call, void *user_data)
{
struct property_info *info = user_data;
@@ -476,8 +499,11 @@ static int set_property(struct modem_dat
info->property = property;
info->set_property_cb = notify;
+ if (info->context)
+ network_context_ref(info->context);
+
dbus_pending_call_set_notify(modem->call_set_property,
- set_property_reply, info, g_free);
+ set_property_reply, info, free_property_info);
dbus_message_unref(message);
@@ -1228,7 +1254,7 @@ static int add_cm_context(struct modem_d
}
if (g_strcmp0(context_type, "internet") != 0) {
- network_context_free(context);
+ network_context_unref(context);
return -EINVAL;
}
@@ -1261,7 +1287,7 @@ static void remove_cm_context(struct mod
remove_network(modem, context);
modem->context_list = g_slist_remove(modem->context_list, context);
- network_context_free(context);
+ network_context_unref(context);
context = NULL;
}
Note: There is a blank line at the end of the patch.
Mahalo,
-Scott V.
5 years, 5 months
Prevent scanning on tethering interface
by Jose Blanquicet
Hi,
The first issue takes place when user asks for a Scan on P2P technology and
Tethering is enabled for WiFi technology, ConnMan will reply with a success
to the request even if the P2P find does not actually started. The second
issue occurs when user asks for a Scan on WiFi technology and WiFi
tethering is enabled, in such case, ConnMan will never emit the reply and
client (e.g. connmanctl) will go in D-Bus time-out.
I investigated first case and I saw that ConnMan's scan algorithm replies
"success" to the request because ConnMan successfully makes the D-Bus call
P2PDevice.Find() to ask wpa_supplicant to launch the P2P find even if
wpa_supplicant will reply “ScanError”.
I suggest to check tethering state before calling P2PDevice.Find() as is
done for Scan() to solve first issue and return -EBUSY instead of zero
("success") if tethering is enabled to solve the second issue, see an
initial idea bellow. Doing so, ConnMan will save one useless D-Bus call
toward wpa_s and will be able to correctly reply "Error" to the scan
requests while tethering. We tested this in our systems and it seems to
work but I was wondering if this solution could have problem in systems
with other characteristics of WiFi interfaces/capabilities. What do people
think?
diff --git a/plugins/wifi.c b/plugins/wifi.c
index f8d88fa..a49031c 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1802,14 +1802,14 @@ static int wifi_scan(enum connman_service_type type,
if (wifi->p2p_device)
return 0;
+ if (wifi->tethering)
+ return -EBUSY;
+
if (type == CONNMAN_SERVICE_TYPE_P2P)
return p2p_find(device);
DBG("device %p wifi %p hidden ssid %s", device, wifi->interface,
ssid);
- if (wifi->tethering)
- return 0;
-
scanning = connman_device_get_scanning(device);
if (!ssid || ssid_len == 0 || ssid_len > 32) {
Regards,
Jose Blanquicet
5 years, 5 months
[PATCH] ofono: Fix segfault during set_property
by Scott Valentine
If the SIM card is ejected or the modem is reset / removed between the
set_property call and the set_property_reply callback, connmand will generally
abort, as the remove_all_contexts will get called, and the callback accesses a
reference to a stale context via the property_info pointer.
The following patch adds reference counting to the network_context struct to
prevent the segfault:
diff -uNrp old/plugins/ofono.c new/plugins/ofono.c
--- old/plugins/ofono.c 2016-04-17 21:04:30.000000000 -1000
+++ new/plugins/ofono.c 2017-03-03 17:39:02.922101490 -1000
@@ -143,6 +143,8 @@ struct network_context {
struct connman_ipaddress *ipv6_address;
char *ipv6_nameservers;
+ int refcount;
+
bool active;
bool valid_apn; /* APN is 'valid' if length > 0 */
};
@@ -271,11 +273,24 @@ static struct network_context *network_c
context->ipv6_address = NULL;
context->ipv6_nameservers = NULL;
+ context->refcount = 1;
+
return context;
}
-static void network_context_free(struct network_context *context)
+static void network_context_ref(struct network_context *context)
+{
+ __sync_fetch_and_add(&context->refcount, 1);
+ DBG("refcount = %d", context->refcount);
+}
+
+static void network_context_unref(struct network_context *context)
{
+ DBG("refcount = %d", context->refcount);
+ if (__sync_fetch_and_sub(&context->refcount, 1) != 1)
+ return;
+
+ DBG("free");
g_free(context->path);
connman_ipaddress_free(context->ipv4_address);
@@ -389,6 +404,15 @@ struct property_info {
get_properties_cb get_properties_cb;
};
+static void free_property_info(void * memory)
+{
+ struct property_info * info = memory;
+ if (info->context)
+ network_context_unref(info->context);
+
+ g_free(info);
+}
+
static void set_property_reply(DBusPendingCall *call, void *user_data)
{
struct property_info *info = user_data;
@@ -476,8 +500,11 @@ static int set_property(struct modem_dat
info->property = property;
info->set_property_cb = notify;
+ if (info->context)
+ network_context_ref(info->context);
+
dbus_pending_call_set_notify(modem->call_set_property,
- set_property_reply, info, g_free);
+ set_property_reply, info, free_property_info);
dbus_message_unref(message);
@@ -1228,7 +1255,7 @@ static int add_cm_context(struct modem_d
}
if (g_strcmp0(context_type, "internet") != 0) {
- network_context_free(context);
+ network_context_unref(context);
return -EINVAL;
}
@@ -1261,7 +1288,7 @@ static void remove_cm_context(struct mod
remove_network(modem, context);
modem->context_list = g_slist_remove(modem->context_list, context);
- network_context_free(context);
+ network_context_unref(context);
context = NULL;
}
NOTE: There is a blank line at the end of the patch
Mahalo,
-Scott V.
5 years, 5 months
[PATCH] technology: Deny P2P finding if technology is disabled
by blanquicet@gmail.com
From: Jose Blanquicet <jose.blanquicet-melendez(a)magnetimarelli.com>
Currently, when a scan is requested, it is only check if device is powered. It
prevents to start scanning or finding if WiFi technology is disabled. However,
when WiFi technolgy is enabled but P2P technology is not, the P2P finding
can be started anyway. This patch prevents it by adding an additional control
on the technology status only in case the technology where scan was requested is
P2P, doing so the return values for WiFi technology will not change.
---
src/technology.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/technology.c b/src/technology.c
index 4574f1e..d2f0ae2 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1077,6 +1077,10 @@ static DBusMessage *scan(DBusConnection *conn, DBusMessage *msg, void *data)
DBG("technology %p request from %s", technology,
dbus_message_get_sender(msg));
+ if (technology->type == CONNMAN_SERVICE_TYPE_P2P &&
+ !technology->enabled)
+ return __connman_error_permission_denied(msg);
+
dbus_message_ref(msg);
technology->scan_pending =
g_slist_prepend(technology->scan_pending, msg);
--
1.9.1
5 years, 5 months