[PATCH] Force BSS expiration
by Yasser
We were having a problem with our wifi scanning, where the list of
wifi available would become empty and would not be repopulated until
after a long delay. Researching the problem it seemed that it was
related to BSS expiration age. There were already some people who had
faced the same issue, so inspired by this we developed the following
patch which allows us to set the BSS expiration age to match ConnMan
long scanning interval to avoid the loss of networks during a long
interval between two scans.
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index bfb52db..08d6b9e 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -267,7 +267,8 @@ int
g_supplicant_interface_connect(GSupplicantInterface *interface,
int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
GSupplicantInterfaceCallback callback,
void *user_data);
-
+int g_supplicant_interface_set_bss_expiration_age(GSupplicantInterface
*interface,
+ unsigned int
bss_expiration_age);
int g_supplicant_interface_set_apscan(GSupplicantInterface *interface,
unsigned int ap_scan);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 6052f7b..fe6ad48 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -981,6 +981,46 @@ static void interface_capability(const char *key,
DBusMessageIter *iter,
key, dbus_message_iter_get_arg_type(iter));
}
+struct g_supplicant_bss_expiration_age
+{
+ GSupplicantInterface *interface;
+ unsigned int bss_expiration_age;
+};
+
+static void set_bss_expiration_age(DBusMessageIter *iter, void *user_data)
+{
+ struct g_supplicant_bss_expiration_age *data = user_data;
+ unsigned int bss_expiration_age = data->bss_expiration_age;
+
+ dbus_free(data);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32,
&bss_expiration_age);
+}
+
+int g_supplicant_interface_set_bss_expiration_age(GSupplicantInterface
*interface,
+ unsigned int
bss_expiration_age)
+{
+ struct g_supplicant_bss_expiration_age *data;
+ int ret;
+
+ data = dbus_malloc0(sizeof(*data));
+
+ if (!data)
+ return -ENOMEM;
+
+ data->bss_expiration_age = bss_expiration_age;
+ data->interface = interface;
+
+ ret = supplicant_dbus_property_set(interface->path,
+ SUPPLICANT_INTERFACE ".Interface",
+ "BSSExpireAge", DBUS_TYPE_UINT32_AS_STRING,
+ set_bss_expiration_age, NULL, data, NULL);
+ if (ret < 0)
+ dbus_free(data);
+
+ return ret;
+}
+
+
struct set_apscan_data
{
unsigned int ap_scan;
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 910b739..57b63e2 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1522,6 +1522,7 @@ static void interface_create_callback(int result,
void *user_data)
{
struct wifi_data *wifi = user_data;
+ char * bgscan_range_max;
DBG("result %d ifname %s, wifi %p", result,
g_supplicant_interface_get_ifname(interface),
@@ -1537,6 +1538,13 @@ static void interface_create_callback(int result,
wifi->interface_ready = true;
finalize_interface_creation(wifi);
}
+ /* Force the BSS expiration age to match ConnMan long scanning
interval to avoid the loss of networks during a long interval between
two scannings. */
+ if ((bgscan_range_max = strrchr(BGSCAN_DEFAULT,':')) != NULL &&
+
g_supplicant_interface_set_bss_expiration_age(interface,
strtol(bgscan_range_max + 1, (char**)NULL, 10) + 10) >= 0) {
+ DBG("bss expiration age successfully updated");
+ } else {
+ DBG("bss expiration age update has failed");
+ }
}
static int wifi_enable(struct connman_device *device)
2 months, 2 weeks
[HELP :-) ] 3g modem auto connect
by nick83ola
Dear Connman developers,
I have a telit HE910-D modem that I need to make it work inside yocto.
the modem is correctly recognized both by connman and ofono
connmanctl services
*AO Wired ethernet_0001c021c253_cable
3 cellular_272023119202599_context1
...
And it work fine if I issue the command
connmanctl connect cellular_272023119202599_context1
And it also reconnect after reboot
My issue is that the first time that you connect the modem
(if there's no configuration folder for it in /var/lib/connman) it doesn't
connect automatically
I need a way to say to connman that if there's any cellular modem connected
just connect to it.
there's an option or something that I can do without monitoring connman
through dbus?
Is this the correct connman behaviour?
Kind Regards
Nicola Lunghi
cat /var/lib/connman/cellular_272023119202599_context1/settings
[cellular_272023119202599_context1]
Name=3
Favorite=true
AutoConnect=true
Modified=2019-10-12T09:23:12.647297Z
IPv4.method=fixed
IPv4.netmask_prefixlen=32
IPv4.local_address=100.71.238.126
IPv6.method=off
IPv6.privacy=disabled
cat /etc/connman/main.conf
[General]
SingleConnectedTechnology=false
FallbackTimeservers=
NetworkInterfaceBlacklist=vmnet,vboxnet,virbr,ifb,ve-,vb-,wlanap
AllowHostnameUpdates=false
DefaultAutoConnectTechnologies=cellular,wifi,ethernet
AlwaysConnectedTechnologies=cellular,wifi
PreferredTechnologies=cellular,wifi,ethernet
1 year, 2 months
Why can't connman automatically enable and connect to cellular network interface?
by JH
Hi,
I installed oFono plugin to an embedded system where the cellular is
used, I suppose that the connman should automatically enable and
connect to cellular when it first time boot up, it didn't, I have to
manually run the connmanctl command to enable and to connect it. In a
product due to limited Flash storage size, I'll not install connmanctl
and there will be no manual interactive process, how can I set up
connman to automatically enable and connect to cellular network
interface?
Thank you.
Kind regards,
- jupiter
1 year, 2 months
[PATCH] l2tp: Remove use of lock option for pppd
by Jussi Laakkonen
Connection with L2TP plugin cannot be established if the "lock" option
is used. When running xl2tpd in terminal with the file content created
by the plugin following is reported and connection fails:
xl2tpd -D -C control -c connman-xl2tpd.conf
xl2tpd[17773]: setsockopt recvref[30]: Protocol not available
xl2tpd[17773]: Using l2tp kernel support.
xl2tpd[17773]: xl2tpd version xl2tpd-1.3.8 started on Sailfish PID:17773
xl2tpd[17773]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.
xl2tpd[17773]: Forked by Scott Balmos and David Stipp, (C) 2001
xl2tpd[17773]: Inherited by Jeff McAdams, (C) 2002
xl2tpd[17773]: Forked again by Xelerance (www.xelerance.com) (C) 2006-2016
xl2tpd[17773]: Listening on IP address a.b.c.d, port 32000
xl2tpd[17773]: Connecting to host w.x.y.z, port 1701
xl2tpd[17773]: Connection established to w.x.y.z, 1701. Local: 18554, Remote: 20429 (ref=0/0).
xl2tpd[17773]: Calling on tunnel 18554
xl2tpd[17773]: Call established with w.x.y.z, Local: 42029, Remote: 24137, Serial: 1 (ref=0/0)
xl2tpd[17773]: start_pppd: I'm running:
xl2tpd[17773]: "/usr/sbin/pppd"
xl2tpd[17773]: "plugin"
xl2tpd[17773]: "pppol2tp.so"
xl2tpd[17773]: "pppol2tp"
xl2tpd[17773]: "7"
xl2tpd[17773]: "passive"
xl2tpd[17773]: "nodetach"
xl2tpd[17773]: ":" §
xl2tpd[17773]: "name"
xl2tpd[17773]: "user"
xl2tpd[17773]: "file"
xl2tpd[17773]: "/path/to/l2tp/connman-ppp-option.conf"
/usr/sbin/pppd: In file /path/to/l2tp/connman-ppp-option.conf: unrecognized option 'lock'
xl2tpd[17773]: child_handler : pppd exited for call 24137 with code 2
xl2tpd[17773]: call_close: Call 42029 to w.x.y.z disconnected
xl2tpd[17773]: write_packet: tty is not open yet.
xl2tpd[17773]: Terminating pppd: sending TERM signal to pid 17774
xl2tpd[17773]: get_call: can't find call 42029 in tunnel 18554
(ref=0/0)xl2tpd[17773]: get_call: can't find call 42029 in tunnel 18554
Tested with PPP built from commit
8e77984ac5d7acbe68b2b2f590abd17564c9730d.
---
vpn/plugins/l2tp.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/vpn/plugins/l2tp.c b/vpn/plugins/l2tp.c
index 2255daaa..705c87af 100644
--- a/vpn/plugins/l2tp.c
+++ b/vpn/plugins/l2tp.c
@@ -381,7 +381,6 @@ static int write_pppd_option(struct vpn_provider *provider, int fd)
const char *opt_s;
l2tp_write_option(fd, "nodetach", NULL);
- l2tp_write_option(fd, "lock", NULL);
l2tp_write_option(fd, "logfd", "2");
l2tp_write_option(fd, "usepeerdns", NULL);
l2tp_write_option(fd, "noipdefault", NULL);
--
2.20.1
1 year, 4 months
Is there anyway to get SIM ID?
by JH
Hi,
I am running connman in a 4G LTE device in Linux system, are there
anyway to get SIM ID? and the Operator and LTE signalling strength?
Unfoutuantly, I don't have connmanctl due to the limitation of the
space to install Python.
Thank you.
Kind regards,
- jh
1 year, 4 months
[PATCH] plugins/ethernet: fix strncpy errors with GCC>9.1
by Nicola Lunghi
From: Nicola Lunghi <nick83ola(a)gmail.com>
This fixes the following errors:
In function ‘strncpy’,
inlined from ‘get_dsa_port’ at plugins/ethernet.c:102:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10:
error: ‘__builtin_strncpy’ specified bound 16 equals destination size
[-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
inlined from ‘get_dsa_port’ at plugins/ethernet.c:106:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10:
error: ‘__builtin_strncpy’ specified bound 24 equals destination size
[-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘strncpy’,
inlined from ‘get_dsa_port’ at plugins/ethernet.c:109:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10:
error: ‘__builtin_strncpy’ output may be truncated copying 16 bytes
from a string of length 23 [-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC plugins/src_connmand-neard.o
CC src/shared/connmand-util.o
CC src/shared/connmand-netlink.o
CC src/shared/connmand-arp.o
In function ‘strncpy’,
inlined from ‘get_vlan_vid’ at plugins/ethernet.c:76:2,
inlined from ‘add_network’ at plugins/ethernet.c:199:9,
inlined from ‘ethernet_newlink’ at plugins/ethernet.c:253:4:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10:
error: ‘__builtin_strncpy’ specified bound 24 equals destination size
[-Werror=stringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Nicola Lunghi <nick83ola(a)gmail.com>
---
plugins/ethernet.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/plugins/ethernet.c b/plugins/ethernet.c
index b0395c83..6ceb2266 100644
--- a/plugins/ethernet.c
+++ b/plugins/ethernet.c
@@ -73,7 +73,7 @@ static int get_vlan_vid(const char *ifname)
return -errno;
vifr.cmd = GET_VLAN_VID_CMD;
- strncpy(vifr.device1, ifname, sizeof(vifr.device1));
+ strncpy(vifr.device1, ifname, sizeof(vifr.device1) - 1);
if(ioctl(sk, SIOCSIFVLAN, &vifr) >= 0)
vid = vifr.u.VID;
@@ -99,14 +99,17 @@ static int get_dsa_port(const char *ifname)
return -errno;
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
/* check if it is a vlan and get physical interface name*/
vifr.cmd = GET_VLAN_REALDEV_NAME_CMD;
- strncpy(vifr.device1, ifname, sizeof(vifr.device1));
+ strncpy(vifr.device1, ifname, sizeof(vifr.device1) - 1);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
if(ioctl(sk, SIOCSIFVLAN, &vifr) >= 0)
- strncpy(ifr.ifr_name, vifr.u.device2, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, vifr.u.device2, sizeof(ifr.ifr_name) - 1);
+#pragma GCC diagnostic pop
/* get driver info */
drvinfocmd.cmd = ETHTOOL_GDRVINFO;
--
2.20.1
1 year, 4 months
[PATCH] l2tp: Save 'exclusive' config value in lns context
by Jussi Laakkonen
The config value 'exclusive' must be saved in lns context. This is
because if written to lac context parsing will fail (versions 1.3.8 and
1.3.14 were tested):
xl2tpd[]: parse_config: line 12: 'exclusive' not valid in this context
This went undetected unless the option was set. By default, 'exclusive'
is not written to xl2tpd config. The xl2tpd documentation states that
"Most of those described in the LNS section may be used in a LAC
context, where it make common sense (essentially l2tp procotols tuning
flags and authentication / ppp related ones)."
Added a enum option OPT_L2LNS for defining other options to be used in
lns context only.
---
vpn/plugins/l2tp.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/vpn/plugins/l2tp.c b/vpn/plugins/l2tp.c
index ff5f08b9..422d6782 100644
--- a/vpn/plugins/l2tp.c
+++ b/vpn/plugins/l2tp.c
@@ -65,6 +65,7 @@ enum {
OPT_L2G = 2,
OPT_L2 = 3,
OPT_PPPD = 4,
+ OPT_L2LNS = 5,
};
struct {
@@ -83,7 +84,7 @@ struct {
{ "L2TP.DefaultRoute", "defaultroute", OPT_L2, NULL, OPT_STRING },
{ "L2TP.FlowBit", "flow bit", OPT_L2, NULL, OPT_STRING },
{ "L2TP.TunnelRWS", "tunnel rws", OPT_L2, NULL, OPT_STRING },
- { "L2TP.Exclusive", "exclusive", OPT_L2, NULL, OPT_STRING },
+ { "L2TP.Exclusive", "exclusive", OPT_L2LNS, NULL, OPT_STRING },
{ "L2TP.Autodial", "autodial", OPT_L2, "yes", OPT_STRING },
{ "L2TP.Redial", "redial", OPT_L2, "yes", OPT_STRING },
{ "L2TP.RedialTimeout", "redial timeout", OPT_L2, "10", OPT_STRING },
@@ -454,6 +455,9 @@ static int l2tp_write_config(struct vpn_provider *provider,
l2tp_write_option(fd, "[global]", NULL);
l2tp_write_fields(provider, fd, OPT_L2G);
+ l2tp_write_option(fd, "[lns]", NULL);
+ l2tp_write_fields(provider, fd, OPT_L2LNS);
+
l2tp_write_option(fd, "[lac l2tp]", NULL);
option = vpn_provider_get_string(provider, "Host");
--
2.20.1
1 year, 4 months
[PATCH] vpn: Set to use C locale with tasks used for running VPN processes
by Jussi Laakkonen
Set LANG and LC_ALL to C locale for each task used to run VPN processes.
This ensures that no translations are used.
The user for running VPN process can be changed with DACPrivileges
configuration (see commit 171989601a7a4fadafda20a7e6d30e9ada3fb516). If
the user is changed to other than what connman is ran with a specific
language may have been set. Plugins relying on correct output would fail in
such case.
---
vpn/plugins/vpn.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/vpn/plugins/vpn.c b/vpn/plugins/vpn.c
index eef8550e..16946c80 100644
--- a/vpn/plugins/vpn.c
+++ b/vpn/plugins/vpn.c
@@ -624,6 +624,15 @@ static int vpn_connect(struct vpn_provider *provider,
goto exist_err;
}
+ /*
+ * Change to use C locale, some VPN plugins use screen scraping for
+ * error parsing. To be on the safe side, set both LANG and LC_ALL.
+ * This is required especially when the VPN processes are ran using
+ * user other than root.
+ */
+ connman_task_add_variable(data->task,"LANG", "C");
+ connman_task_add_variable(data->task,"LC_ALL", "C");
+
ret = vpn_driver_data->vpn_driver->connect(provider, data->task,
data->if_name, cb, dbus_sender,
user_data);
--
2.20.1
1 year, 4 months
[PATCH] l2tp: Inform VPN agent about authentication errors
by Jussi Laakkonen
Send "VpnAgent.AuthFailure" to VPN agent if there are authentication
errors to indicate that previous login has failed and new credentials
are required to be given. The authentication errors with L2TP are
recorded when in notify function (l2tp_notify()) auth error is given
as reason -> vpn.c:vpn_nofity() calls vpn_provider_indicate_error().
---
vpn/plugins/l2tp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/vpn/plugins/l2tp.c b/vpn/plugins/l2tp.c
index 91137aae..2255daaa 100644
--- a/vpn/plugins/l2tp.c
+++ b/vpn/plugins/l2tp.c
@@ -605,6 +605,9 @@ static int request_input(struct vpn_provider *provider,
connman_dbus_dict_open(&iter, &dict);
+ if (vpn_provider_get_authentication_errors(provider))
+ vpn_agent_append_auth_failure(&dict, provider, NULL);
+
vpn_agent_append_user_info(&dict, provider, "L2TP.User");
vpn_agent_append_host_and_name(&dict, provider);
--
2.20.1
1 year, 4 months
[PATCH] l2tp: Cancel queued VPN agent msg when disconnected
by Jussi Laakkonen
Queued VPN agent messages must be canceled if the plugin timeouts
without starting the process. This fixes the issue of having multiple
VPN agent queries stacked on another in such scenario, where L2TP is
awaiting for user input.
---
vpn/plugins/l2tp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/vpn/plugins/l2tp.c b/vpn/plugins/l2tp.c
index ff5f08b9..91137aae 100644
--- a/vpn/plugins/l2tp.c
+++ b/vpn/plugins/l2tp.c
@@ -795,7 +795,12 @@ static int l2tp_error_code(struct vpn_provider *provider, int exit_code)
static void l2tp_disconnect(struct vpn_provider *provider)
{
+ if (!provider)
+ return;
+
vpn_provider_set_string(provider, "L2TP.Password", NULL);
+
+ connman_agent_cancel(provider);
}
static struct vpn_driver vpn_driver = {
--
2.20.1
1 year, 4 months