BUG: file descriptor leak in DHCPv6
by Richard Genoud
Hi all,
I found a bug in connman, leading to a "too many open files" error.
( version used : 1.35 )
Here are the steps to reproduce.
On a shell, do :
while [ true ]; do ls -l /proc/$(pidof connmand)/fd/ | wc -l ; sleep 1; done
This will monitor the number of opened files/sockets of connmand.
Start connman with nothing else that ethernet connection (DHCP
client), on a network with a DHCPv4 server (this is important)
Then, plug / unplug several times the ethernet cable (every 2 seconds,
ten times should suffice)
The number of opened file descriptors should increase and increase.
The things I know :
- I can NOT reproduce it if there's no DHCPv4 server on the subnet and
connman is configured as DHCP client
- I can reproduce it configuring connman with a static IPv4
- If I add IPv6=off in the wired service, there's no more fd leak.
Trying to debug that, I found that it seems to be the file descriptor :
dhcp_client->listener_sockfd related to DHCPv6
that is not closed when the ethernet link goes down.
regards,
Richard.
3 years, 3 months
race between __connman_service_connect and config_notify_handler
by Vasyl Vavrychuk
Hi,
I have implemented GUI for connman which in particular connects to 802.1x
services.
Since for them we have to use provision file I have following simple
algorithm.
1. Write connection parameters in provision file and flush it.
2. Call connman service Connect method via D-Bus.
But it looks like sometimes I have Connect handled sooner than provision
file reloaded.
I am not 100% sure, but looking at the source code I think that this
situation is at least theoretically possible. Isn't it?
Kind regards,
Vasyl
3 years, 4 months
Re: connmand[186]: Online check failed but running dhclient manually fixes this issue
by Denis Kenzior
Hi,
On 09/05/2017 09:46 AM, Alexander Couzens wrote:
> On Thu, 10 Aug 2017 12:47:28 +0200
> Daniel Wagner <wagi(a)monom.org> wrote:
>
>>> Bus 001 Device 003: ID 1bc7:1201 Telit Wireless Solutions
>>
>> Here is a compile tested 'fix'. I don't know if this works and\
>> obviously it doesn't follow the coding guide lines for this
>> project. If you could test this and report back the outcome
>> that would be really helpful. Then I can create a proper
>> patch for Denis.
>
> I can confirm this bug with an quectel ec20 using the firmware
> EC20EQAR02A13E2G 1 [Jul 5 2017 10:49:17].
>
> To reproduce using ofono w/o connman. linux 4.12.8
> - call ofono "../context1 Active true"
> - set the ip by hand. No ping response.
> - using dhcpcd. Ping responses.
>
> The `ip addr show` looks the same, except the interface has now an ipv6
> link local address. Is this is problem of modern LTE cards?
> Could be raw-ip or 802.3 encapsulations the problem?
>
Here's something Reinhard said in a different thread that might be
applicable here:
"Unfortunately the PLS8 seems to need DHCP to be used as a trigger to
pass IPv4 traffic over the network interface even if the parameters
could be obtained from AT commands.
This restriction also holds for some other Qualcomm firmwares when the
QMI network interface is used in Ethernet mode instead of Raw IP mode."
If this is true, then falling back to DHCP would seem to be required for
many Qualcomm based devices. This seems to be a recently introduced
'bug' as older QMI devices did not need this workaround.
Regards,
-Denis
3 years, 4 months
[PATCH] wifi: Don't perform handle_wps_completion() when p2p is connecting
by Saurav Babu
When p2p is connecting and other device acts as Group owner then
G_SUPPLICANT_STATE_COMPLETED is received after P2P Group formation is
success. handle_wps_completion() function disconnects the network if
wps_ssid doesn't match with ssid, due to this reason P2P connection is
never successful.
---
plugins/wifi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 74f216d..a874112 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -2415,6 +2415,9 @@ static void interface_state(GSupplicantInterface *interface)
/* though it should be already stopped: */
stop_autoscan(device);
+ if (wifi->p2p_connecting)
+ break;
+
if (!handle_wps_completion(interface, network, device, wifi))
break;
--
1.9.1
3 years, 4 months
mac80211_hwsim device not powered
by BOURDIL Pierre-Alain
Hi,
i'm trying to get connman managing virtual wifi device created using mac80211_hwsim kernel module.
In this configuration, a scan wifi from connmanctl always return a "no carrier" error message.
Using gdb, i found that the connman_device is seen as unpowered. Hence, the test in device.c:610 fails and connmand return -ENOLINK (err code -67).
This does not seem logical to me. Is this a bug ?
+
3 years, 4 months
Predefined hostname in dhcp requests
by Marco Gigante
Hi all,
I'm new to connman. I'm writing here to ask for informations about
proposing modifications to connman.
I made changes to connman for a project I'm working on, which required
to send a fixed hostname in connman dhcp requests during network
interface configuration (regardless of the actual system hostname).
My system hostname may change since its startup, so I added a
configuration option to put into main.conf to have a fixed hostname into
dhcp requests.
Can such a modification be of any interest? I would be more than happy
to send a patch so you can evaluate it.
I also want to ask whether I can eventually send the git formatted-patch
directly to this ML or I have to follow some other procedure.
Thanks in advance
marco
3 years, 4 months
[PATCH 1/2] client: Added session create append dict
by sutar.mounesh@gmail.com
From: Mounesh Sutar <sutar.mounesh(a)gmail.com>
diff --git a/client/commands.c b/client/commands.c
index 7488850..4864ad1 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -901,6 +901,13 @@ struct config_append {
int values;
};
+struct session_options {
+ char **args;
+ int num;
+ char *notify_path;
+ struct connman_option *options;
+};
+
static void config_append_ipv4(DBusMessageIter *iter,
void *user_data)
{
@@ -1820,28 +1827,132 @@ static int session_create_cb(DBusMessageIter *iter, const char *error,
return -EINPROGRESS;
}
+static void session_config_append_array(DBusMessageIter *iter,
+ void *user_data)
+{
+ struct config_append *append = user_data;
+ char **opts = append->opts;
+ int i = 1;
+
+ if (!opts)
+ return;
+
+ while (opts[i] && strncmp(opts[i], "--", 2) != 0) {
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+ &opts[i]);
+ i++;
+ }
+
+ append->values = i;
+}
+
+static void session_create_append_dict(DBusMessageIter *iter, void *user_data)
+{
+ struct session_options *args_struct = user_data;
+ int index = 0, res = 0;
+ struct config_append append;
+ char c;
+ char *ifname;
+ dbus_bool_t source_ip_rule;
+
+ while (index < args_struct->num && args_struct->args[index]) {
+ append.opts = &args_struct->args[index];
+ append.values = 0;
+
+ c = parse_args(args_struct->args[index], args_struct->options);
+
+ switch (c) {
+ case 'b':
+ __connmanctl_dbus_append_dict_string_array(iter, "AllowedBearers",
+ session_config_append_array,
+ &append);
+ break;
+ case 't':
+ if (! args_struct->args[index + 1]) {
+ res = -EINVAL;
+ break;
+ }
+ __connmanctl_dbus_append_dict_entry(iter, "ConnectionType",
+ DBUS_TYPE_STRING,
+ &args_struct->args[index + 1]);
+ append.values = 2;
+ break;
+ case 'i':
+ if (index + 1 < args_struct->num)
+ ifname = args_struct->args[index + 1];
+ else
+ ifname = "";
+ __connmanctl_dbus_append_dict_entry(iter, "AllowedInterface",
+ DBUS_TYPE_STRING,
+ &ifname);
+ append.values = 2;
+ break;
+ case 's':
+ if (! args_struct->args[index + 1]) {
+ res = -EINVAL;
+ break;
+ }
+ switch (parse_boolean( args_struct->args[index + 1])) {
+ case 1:
+ source_ip_rule = TRUE;
+ break;
+ case 0:
+ source_ip_rule = FALSE;
+ break;
+ default:
+ res = -EINVAL;
+ break;
+ }
+ __connmanctl_dbus_append_dict_entry(iter, "SourceIPRule",
+ DBUS_TYPE_BOOLEAN,
+ &source_ip_rule);
+ append.values = 2;
+ break;
+ default:
+ res = -EINVAL;
+ }
+
+ if (res < 0 && res != -EINPROGRESS) {
+ printf("Error '%s': %s\n", args_struct->args[index],
+ strerror(-res));
+ return;
+ }
+
+ index += append.values;
+ }
+
+ return;
+}
+
static void session_create_append(DBusMessageIter *iter, void *user_data)
{
- const char *notify_path = user_data;
+ struct session_options *args_struct = user_data;
- __connmanctl_dbus_append_dict(iter, NULL, NULL);
+ __connmanctl_dbus_append_dict(iter, session_create_append_dict,
+ args_struct);
dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
- ¬ify_path);
+ &args_struct->notify_path);
}
-static int session_create(gboolean connect)
+static int session_create(gboolean connect, char *args[], int num,
+ struct connman_option *options)
{
int res;
char *notify_path;
+ struct session_options args_struct;
+ args_struct.args = args;
+ args_struct.num = num;
+ args_struct.options = options;
notify_path = g_strdup_printf("/net/connman/connmanctl%d", getpid());
session_notify_add(notify_path);
+ args_struct.notify_path = notify_path;
res = __connmanctl_dbus_method_call(connection, "net.connman", "/",
"net.connman.Manager", "CreateSession",
session_create_cb, GINT_TO_POINTER(connect),
- session_create_append, notify_path);
+ session_create_append, &args_struct);
g_free(notify_path);
@@ -1895,25 +2006,6 @@ static int session_config_return(DBusMessageIter *iter, const char *error,
return 0;
}
-static void session_config_append_array(DBusMessageIter *iter,
- void *user_data)
-{
- struct config_append *append = user_data;
- char **opts = append->opts;
- int i = 1;
-
- if (!opts)
- return;
-
- while (opts[i] && strncmp(opts[i], "--", 2) != 0) {
- dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
- &opts[i]);
- i++;
- }
-
- append->values = i;
-}
-
static int session_config(char *args[], int num,
struct connman_option *options)
{
@@ -2018,12 +2110,13 @@ static int cmd_session(char *args[], int num, struct connman_option *options)
case 1:
if (session_path)
return -EALREADY;
- return session_create(FALSE);
+ return session_create(FALSE, &args[2], num - 2, options);
default:
if (!strcmp(command, "connect")) {
if (!session_path)
- return session_create(TRUE);
+ return session_create(TRUE, &args[2], num - 2,
+ options);
return session_connect();
--
2.7.4
3 years, 4 months
[PATCH 0/3] Add options to configure Online check
by Christophe Ronco
Hi,
I have added some options to configure URLs used to do the online check.
I have added to options to set the URLs for IPv4 and IPv6 and another option
to disable the check of X-ConnMan-Status HTTP header.
The goal is to have this feature for boards that do not have access to Internet.
Best Regards,
Christophe Ronco
Christophe Ronco (3):
main: add options to configure Online check
wispr: implement options to configure Online check
main.conf: document options to configure Online check
doc/connman.conf.5.in | 15 +++++++++++++++
include/setting.h | 1 +
src/main.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-
src/main.conf | 15 +++++++++++++++
src/wispr.c | 17 +++++++++++------
5 files changed, 93 insertions(+), 7 deletions(-)
--
2.7.4
3 years, 4 months
[PATCH 1/2] wifi: Fix behaviour when Background scanning is disabled
by jose@blanquicet.com
From: Jose Blanquicet <jose(a)blanquicet.com>
Conditions when ConnMan will perform active instead of passive scanning:
1. WiFi Driver support active scanning, it means "MaxScanSSID" is
greater than 1.
2. User has successfully connected to at least one WiFi network in the
past so the service information is present in
{STOREDIR}/connman/wifi_* but none of those networks are currently in
range. They will be called "known-services" from now.
Current behaviour when BackgroundScanning is enabled:
- D-Bus scan request or at start-up of system -> Launch an
active/passive scan (Based on above conditions)
- 3 seconds -> Launch passive scan
- 9 seconds -> Launch passive scan
- ...
- 243 seconds -> Launch passive scan
- 300 seconds -> Launch passive scan
- Continue each 300 seconds unless user performs a new D-Bus scan call
which will cause the procedure to restart from 3 seconds.
This patch does not change the ConnMan's behaviour when
BackgroundScanning is enabled. However, when it is disabled and
conditions for active scanning are true, ConnMan could fall in the
following situation:
- D-Bus scan request or at start-up of system -> Launch an active scan
- Stop scanning
One single scan is done and it is an active one. It means that ConnMan
will perform an active scan looking for those known-services in their
specific frequencies, this kind of scanning is generally faster than a
passive one which allows to speed up auto-connection procedure.
However, we have seen that in case of none of these knwon-services is in
range some drivers reply only with all the networks in the specified
frequencies and some other does not reply any network. This could result
in an always empty services list.
Therefore, this patch looks for avoid such situation by adding a passive
scan in such cases. The new behaviour is also based on the conditions
mentioned at the beginning:
1. Active scanning:
- D-Bus scan request or at start-up of system -> Launch an active scan
- 3 seconds -> Launch passive scan
- Stop scanning
- New D-Bus scan request from user -> Launch an active scan
- 3 seconds -> Launch passive scan
- Stop scanning
2. Passive scanning:
- D-Bus scan request or at start-up of system -> Launch one passive scan
- Stop scanning
- New D-Bus scan request from user -> Launch one passive scan
- Stop scanning
Take into account that all the behaviours described above are followed
when wifi has not get connected. Once it is connected, ConnMan stops its
background scanning procedure and if BackgroundScanning is enabled, it
asks wpa_supplicant to perform the background scanning while connected
only for wifi roaming purposes. See "wpa_supplicant configuration"
section in README file for further details.
---
Hi Jonah,
Could you please test this patch and give us your feedback?
Thanks,
Jose Blanquicet
plugins/wifi.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 93 insertions(+), 16 deletions(-)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 34c16df..206c05e 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -64,7 +64,8 @@
#define FAVORITE_MAXIMUM_RETRIES 2
#define BGSCAN_DEFAULT "simple:30:-45:300"
-#define AUTOSCAN_DEFAULT "exponential:3:300"
+#define AUTOSCAN_EXPONENTIAL "exponential:3:300"
+#define AUTOSCAN_SINGLE "single:3"
#define P2P_FIND_TIMEOUT 30
#define P2P_CONNECTION_TIMEOUT 100
@@ -83,6 +84,12 @@ enum wifi_ap_capability{
WIFI_AP_NOT_SUPPORTED = 2,
};
+enum wifi_scanning_type {
+ WIFI_SCANNING_UNKNOWN = 0,
+ WIFI_SCANNING_PASSIVE = 1,
+ WIFI_SCANNING_ACTIVE = 2,
+};
+
struct hidden_params {
char ssid[32];
unsigned int ssid_len;
@@ -143,7 +150,7 @@ struct wifi_data {
* autoscan "emulation".
*/
struct autoscan_params *autoscan;
-
+ enum wifi_scanning_type scanning_type;
GSupplicantScanParams *scan_params;
unsigned int p2p_find_timeout;
unsigned int p2p_connection_timeout;
@@ -831,13 +838,13 @@ static void reset_autoscan(struct connman_device *device)
autoscan = wifi->autoscan;
- if (autoscan->timeout == 0 && autoscan->interval == 0)
+ autoscan->interval = 0;
+
+ if (autoscan->timeout == 0)
return;
g_source_remove(autoscan->timeout);
-
autoscan->timeout = 0;
- autoscan->interval = 0;
connman_device_unref(device);
}
@@ -1363,6 +1370,21 @@ static gboolean autoscan_timeout(gpointer data)
throw_wifi_scan(wifi->device, scan_callback_hidden);
+ /*
+ * In case BackgroundScanning is disabled, interval will reach the
+ * limit exactly after the very first passive scanning. It allows
+ * to ensure at most one passive scan is performed in such cases.
+ */
+ if (!connman_setting_get_bool("BackgroundScanning") &&
+ interval == autoscan->limit) {
+ g_source_remove(autoscan->timeout);
+ autoscan->timeout = 0;
+
+ connman_device_unref(device);
+
+ return FALSE;
+ }
+
set_interval:
DBG("interval %d", interval);
@@ -1409,19 +1431,25 @@ static struct autoscan_params *parse_autoscan_params(const char *params)
int limit;
int base;
- DBG("Emulating autoscan");
+ DBG("");
list_params = g_strsplit(params, ":", 0);
if (list_params == 0)
return NULL;
- if (g_strv_length(list_params) < 3) {
+ if (!g_strcmp0(list_params[0], "exponential") &&
+ g_strv_length(list_params) == 3) {
+ base = atoi(list_params[1]);
+ limit = atoi(list_params[2]);
+ } else if (!g_strcmp0(list_params[0], "single") &&
+ g_strv_length(list_params) == 2)
+ base = limit = atoi(list_params[1]);
+ else {
g_strfreev(list_params);
return NULL;
}
- base = atoi(list_params[1]);
- limit = atoi(list_params[2]);
+ DBG("Setup %s autoscanning", list_params[0]);
g_strfreev(list_params);
@@ -1440,10 +1468,37 @@ static struct autoscan_params *parse_autoscan_params(const char *params)
static void setup_autoscan(struct wifi_data *wifi)
{
- if (!wifi->autoscan)
- wifi->autoscan = parse_autoscan_params(AUTOSCAN_DEFAULT);
+ /*
+ * If BackgroundScanning is enabled, setup exponential
+ * autoscanning if it has not been previously done.
+ */
+ if (connman_setting_get_bool("BackgroundScanning")) {
+ wifi->autoscan = parse_autoscan_params(AUTOSCAN_EXPONENTIAL);
+ return;
+ }
- start_autoscan(wifi->device);
+ /*
+ * On the contrary, if BackgroundScanning is disabled, update autoscan
+ * parameters based on the type of scanning that is being performed.
+ */
+ if (wifi->autoscan) {
+ g_free(wifi->autoscan);
+ wifi->autoscan = NULL;
+ }
+
+ switch (wifi->scanning_type) {
+ case WIFI_SCANNING_PASSIVE:
+ /* Do not setup autoscan. */
+ break;
+ case WIFI_SCANNING_ACTIVE:
+ /* Setup one single passive scan after active. */
+ wifi->autoscan = parse_autoscan_params(AUTOSCAN_SINGLE);
+ break;
+ case WIFI_SCANNING_UNKNOWN:
+ /* Setup autoscan in this case but we should never fall here. */
+ wifi->autoscan = parse_autoscan_params(AUTOSCAN_SINGLE);
+ break;
+ }
}
static void finalize_interface_creation(struct wifi_data *wifi)
@@ -1457,13 +1512,13 @@ static void finalize_interface_creation(struct wifi_data *wifi)
connman_device_set_powered(wifi->device, true);
- if (!connman_setting_get_bool("BackgroundScanning"))
- return;
-
if (wifi->p2p_device)
return;
- setup_autoscan(wifi);
+ if (!wifi->autoscan)
+ setup_autoscan(wifi);
+
+ start_autoscan(wifi->device);
}
static void interface_create_callback(int result,
@@ -1691,10 +1746,29 @@ static int get_latest_connections(int max_ssids,
return num_ssids;
}
+static void wifi_update_scanner_type(struct wifi_data *wifi,
+ enum wifi_scanning_type new_type)
+{
+ DBG("");
+
+ if (!wifi || wifi->scanning_type == new_type)
+ return;
+
+ wifi->scanning_type = new_type;
+
+ setup_autoscan(wifi);
+}
+
static int wifi_scan_simple(struct connman_device *device)
{
+ struct wifi_data *wifi = connman_device_get_data(device);
+
reset_autoscan(device);
+ /* Distinguish between devices performing passive and active scanning */
+ if (wifi)
+ wifi_update_scanner_type(wifi, WIFI_SCANNING_PASSIVE);
+
return throw_wifi_scan(device, scan_callback_hidden);
}
@@ -1887,6 +1961,9 @@ static int wifi_scan(enum connman_service_type type,
}
}
+ /* Distinguish between devices performing passive and active scanning */
+ wifi_update_scanner_type(wifi, WIFI_SCANNING_ACTIVE);
+
connman_device_ref(device);
reset_autoscan(device);
--
1.9.1
3 years, 4 months