[PATCH 0/5] Avoid to keep service in list if AP is not found during scan
by blanquicet@gmail.com
From: Jose Blanquicet <jose.blanquicet-melendez(a)magnetimarelli.com>
This patch set does not remove any auto-connect/roaming functionality,
it aims to avoit keeping service in the list after AP deauthenticate
us and it is not found in the scan.
The first three patches revert the patches that add the connectable
flag because such implementation prevents ConnMan to remove the service
from the services list when it is no longer in range, resulting in a
confusion for users because they will continue seeing a service in their
list when it is not actually available.
Doing so, ConnMan will remove the service as other services and then,
once it comes back, wpa_s will notify ConnMan about it through a
"BSSAdded" signal which will start auto-connect procedure and state
machines would continue correctly. In case wpa_s does not send such
signal before notifying we got connected, which should not happen, the
last two patches of this set introduce a notification named
"network_associated" which should handle this border case. I tested it
by simulating ConnMan do not process "BSSAdded" signals and it worked,
it means that state machines moved correctly and connection trigger
from wpa_s completed successfully.
I do not think I could trigger all use cases thus I would appreciate if
people could test auto-connect and roaming use cases. Mainly
auto-connect when AP is who deauthenticate STA. For instance, Saurav
Babu in the scenario he recently mentioned when AP blocks STA's MAC
address.
Jose Blanquicet (5):
Revert "device: Use network's connectable flag"
Revert "plugins/wifi: Marking network's Connectable flag as true."
Revert "network: connectable flag in network structure"
gsupplicant: Add callback to notify the associated network
wifi: Set current network in case of reconnection
gsupplicant/gsupplicant.h | 1 +
gsupplicant/supplicant.c | 25 +++++++++++++++
include/network.h | 5 ---
plugins/wifi.c | 82 +++++++++++++++++++++++++++++------------------
src/device.c | 6 +---
src/network.c | 13 --------
6 files changed, 78 insertions(+), 54 deletions(-)
--
1.9.1
3 years, 7 months
[PATCH 1/2] service: Set method to AUTO when address is got through IPv4LL
by blanquicet@gmail.com
From: Jose Blanquicet <jose.blanquicet-melendez(a)magnetimarelli.com>
When DHCP fails and ConnMan obtains an address through IPv4LL, the method
stored/notified for that service must be "auto" instead of "dhcp" as has
been done so far. This patch aims to fix that misleading.
However, after a disconnection from a service with "auto" as IPv4 method,
ConnMan should use DHCP by first when user tries to reconnects or
auto-connect starts on that service. Same reasoning applies after a
power-cycle, i.e. when ConnMan starts up and reads "auto" as method from
the settings file, it should also use DHCP by first and only if it fails
then IPv4LL should be used.
The IPv4.Configuration is also set to "auto" in order to allow user to ask
ConnMan to try to get an address through DHCP at any time by manually
setting this property to "dhcp". On the other hand, "auto" cannot be set
by users from D-Bus API, as it has been so far.
---
src/connman.h | 2 ++
src/dhcp.c | 37 ++++++++++++++++++++++++++++++++++++-
src/ipconfig.c | 18 ++++++++++++++----
src/network.c | 13 ++++++++++++-
src/service.c | 9 +++++++++
5 files changed, 73 insertions(+), 6 deletions(-)
diff --git a/src/connman.h b/src/connman.h
index ce4d82e..21b7080 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -680,6 +680,8 @@ struct connman_ipconfig *__connman_service_get_ip6config(
struct connman_service *service);
struct connman_ipconfig *__connman_service_get_ipconfig(
struct connman_service *service, int family);
+void __connman_service_notify_ipv4_configuration(
+ struct connman_service *service);
bool __connman_service_is_connected_state(struct connman_service *service,
enum connman_ipconfig_type type);
const char *__connman_service_get_ident(struct connman_service *service);
diff --git a/src/dhcp.c b/src/dhcp.c
index 54fb64e..e797ae1 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -435,6 +435,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
{
struct connman_dhcp *dhcp = user_data;
GList *option = NULL;
+ enum connman_ipconfig_method old_method;
char *address, *netmask = NULL, *gateway = NULL;
const char *c_address, *c_gateway;
unsigned char prefixlen, c_prefixlen;
@@ -486,8 +487,24 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
} else if (prefixlen != c_prefixlen)
ip_change = true;
+ old_method = __connman_ipconfig_get_method(dhcp->ipconfig);
__connman_ipconfig_set_method(dhcp->ipconfig,
CONNMAN_IPCONFIG_METHOD_DHCP);
+
+ /*
+ * Notify IPv4.Configuration's method moved back to DHCP.
+ *
+ * This is the case ConnMan initially set an address by using
+ * IPv4LL because DHCP failed but now we got an address from DHCP.
+ */
+ if (old_method == CONNMAN_IPCONFIG_METHOD_AUTO) {
+ struct connman_service *service =
+ connman_service_lookup_from_network(dhcp->network);
+
+ if (service)
+ __connman_service_notify_ipv4_configuration(service);
+ }
+
if (ip_change) {
__connman_ipconfig_set_local(dhcp->ipconfig, address);
__connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
@@ -509,6 +526,7 @@ done:
static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
{
struct connman_dhcp *dhcp = user_data;
+ enum connman_ipconfig_method old_method;
char *address, *netmask;
unsigned char prefixlen;
@@ -519,8 +537,25 @@ static void ipv4ll_available_cb(GDHCPClient *ipv4ll_client, gpointer user_data)
prefixlen = connman_ipaddress_calc_netmask_len(netmask);
+ old_method = __connman_ipconfig_get_method(dhcp->ipconfig);
__connman_ipconfig_set_method(dhcp->ipconfig,
- CONNMAN_IPCONFIG_METHOD_DHCP);
+ CONNMAN_IPCONFIG_METHOD_AUTO);
+
+ /*
+ * Notify IPv4.Configuration's method is AUTO now.
+ *
+ * This is the case DHCP failed thus ConnMan used IPv4LL to get an
+ * address. Set IPv4.Configuration method to AUTO allows user to
+ * ask for a DHCP address by setting the method again to DHCP.
+ */
+ if (old_method == CONNMAN_IPCONFIG_METHOD_DHCP) {
+ struct connman_service *service =
+ connman_service_lookup_from_network(dhcp->network);
+
+ if (service)
+ __connman_service_notify_ipv4_configuration(service);
+ }
+
__connman_ipconfig_set_local(dhcp->ipconfig, address);
__connman_ipconfig_set_prefixlen(dhcp->ipconfig, prefixlen);
__connman_ipconfig_set_gateway(dhcp->ipconfig, NULL);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index bae988c..272925a 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1762,13 +1762,13 @@ void __connman_ipconfig_append_ipv4(struct connman_ipconfig *ipconfig,
switch (ipconfig->method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
- case CONNMAN_IPCONFIG_METHOD_AUTO:
return;
case CONNMAN_IPCONFIG_METHOD_FIXED:
append_addr = ipconfig->address;
break;
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
case CONNMAN_IPCONFIG_METHOD_DHCP:
append_addr = ipconfig->system;
@@ -2222,6 +2222,19 @@ int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
g_free(key);
break;
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
+
+ if (ipconfig->type != CONNMAN_IPCONFIG_TYPE_IPV4)
+ break;
+
+ /*
+ * If the last used method for IPv4 was AUTO then we
+ * try first DHCP. We will try also to use the last
+ * used DHCP address, if exits.
+ */
+ __connman_ipconfig_set_method(ipconfig,
+ CONNMAN_IPCONFIG_METHOD_DHCP);
+
case CONNMAN_IPCONFIG_METHOD_DHCP:
key = g_strdup_printf("%sDHCP.LastAddress", prefix);
@@ -2233,9 +2246,6 @@ int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
g_free(key);
break;
-
- case CONNMAN_IPCONFIG_METHOD_AUTO:
- break;
}
return 0;
diff --git a/src/network.c b/src/network.c
index 5b7ef55..a5b7d78 100644
--- a/src/network.c
+++ b/src/network.c
@@ -172,6 +172,8 @@ static void dhcp_success(struct connman_network *network)
if (err < 0)
goto err;
+ __connman_service_save(service);
+
return;
err:
@@ -647,10 +649,19 @@ static void set_disconnected(struct connman_network *network)
switch (ipv4_method) {
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
- case CONNMAN_IPCONFIG_METHOD_AUTO:
case CONNMAN_IPCONFIG_METHOD_FIXED:
case CONNMAN_IPCONFIG_METHOD_MANUAL:
break;
+ case CONNMAN_IPCONFIG_METHOD_AUTO:
+ /*
+ * If the current method is AUTO then next time we
+ * try first DHCP. DHCP also needs to be stopped
+ * in this case because if we fell in AUTO means
+ * that DHCP was launched for IPv4 but it failed.
+ */
+ __connman_ipconfig_set_method(ipconfig_ipv4,
+ CONNMAN_IPCONFIG_METHOD_DHCP);
+ __connman_service_notify_ipv4_configuration(service);
case CONNMAN_IPCONFIG_METHOD_DHCP:
__connman_dhcp_stop(ipconfig_ipv4);
break;
diff --git a/src/service.c b/src/service.c
index d9c1907..73832f8 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1988,6 +1988,15 @@ static void ipv4_configuration_changed(struct connman_service *service)
service);
}
+void __connman_service_notify_ipv4_configuration(
+ struct connman_service *service)
+{
+ if (!service)
+ return;
+
+ ipv4_configuration_changed(service);
+}
+
static void ipv6_configuration_changed(struct connman_service *service)
{
if (!allow_property_changed(service))
--
1.9.1
3 years, 7 months
Why I have no Scope:Global IPV6 address ?
by Pierre Couderc
I use connman but get no Scope:Global IPV6 address.
What so I miss ?
Thanks
PC
sudo ifconfig :
wlan0 Link encap:Ethernet HWaddr 40:f0:2f:c6:9a:d2
inet addr:192.168.163.11 Bcast:192.168.163.255
Mask:255.255.255.0
inet6 addr: fe80::42f0:2fff:fec6:9ad2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
....
3 years, 7 months
Iptables error with rule creation
by Jeff Gray
I am a new user of connman. The project is an older embedded system that is
being updated to use it.
Atmel AT91-RM9200 CPU
Linux-2.6.33-7 - older kernel which I can't upgrade due to binary drivers.
But I can recompile with new modules if needed. I have built almost
everything in the netfilter area as modules after reading several online
guides.
buildroot-2017-02 used to build system, so everything is pretty modern
apart from the kernel.
iptables-1.6.1
connman-1.34
Ethernet is working well. I am adding a USB gadget with tethering to allow
the device to be connected to Windows PCs as a USB device. This requires
the DHCP server in connman to be run. usb0 is recognized as a gadget by
connman. Tethering is initiated by sending:
connmanctl tether gadget on
After running my tethering command, lsmod shows:
iptable_filter 1184 1
iptable_nat 3573 0
nf_nat 15825 1 iptable_nat
nf_conntrack_ipv4 11680 3 iptable_nat,nf_nat
nf_conntrack 52431 3 iptable_nat,nf_nat,nf_conntrack_ipv4
nf_defrag_ipv4 857 1 nf_conntrack_ipv4
ip_tables 8885 2 iptable_filter,iptable_nat
x_tables 10528 2 iptable_nat,ip_tables
bridge 45118 0
stp 1318 1 bridge
llc 3094 2 bridge,stp
ipv6 221360 12
ohci_hcd 25436 0
cfg80211 116559 0
rfkill 13468 2 cfg80211
g_ether 42777 0
usbcore 151944 2 ohci_hcd
Running connmand with --debug=src/iptables.c,src/firewall-iptables.c:
Bridge firewalling registered
connmand[336]: Failed to bind UDP listener socket
connmand[336]: Failed to bind TCP listener socket
connmand[336]: DHCP server: option_code 1 option_value 255.255.255.0
connmand[336]: DHCP server: option_code 3 option_value 192.168.0.1
connmand[336]: DHCP server: option_code 6 option_value 192.168.0.1
connmand[336]: src/firewall-iptables.c:enable_rule() nat POSTROUTING -s
192.168.0.2/24 -o eth0 -j MASQUERADE
connmand[336]: src/iptables.c:__connman_iptables_new_chain() -t nat -N
connman-POSTROUTING
connmand[336]: src/iptables.c:iptables_init() nat
ip_tables: (C) 2000-2006 Netfilter Core Team
nf_conntrack version 0.5.0 (464 buckets, 1856 max)
CONFIG_NF_CT_ACCT is deprecated and will be removed soon. Please use
nf_conntrack.acct=1 kernel parameter, acct=1 nf_conntrack module option or
sysctl net.netfilter.nf_conntrack_acct=1 to enable it.
connmand[336]: src/iptables.c:iptables_add_chain() table nat chain
connman-POSTROUTING
connmand[336]: src/iptables.c:__connman_iptables_insert() -t nat -I
POSTROUTING -j connman-POSTROUTING
connmand[336]: src/iptables.c:iptables_insert_rule() table nat chain
POSTROUTING
connmand[336]: src/iptables.c:__connman_iptables_delete_chain() -t nat -X
connman-POSTROUTING
connmand[336]: src/iptables.c:iptables_delete_chain() table nat chain
connman-POSTROUTING
connmand[336]: Cannot enable NAT -22/Invalid argument
connmand[336]: Add interface to bridge error No such device
Debugging further I've found that find_chain_head is getting a target->data
value of "ERROR", so it returns null. iptables_insert_rule detects this, so
it returns -EINVAL.
I inserted a system() call to dump iptables just before the error & I can
see that nothing has been defined other than defaults. connman-POSTROUTING
does not exist (but I'm not sure if it's supposed to at this stage).
connmand appears to be working well in other regards. I can run many
commands & get good results. iptables is also working fine - I can add NAT
chains & rules without error.
At this stage I'm a bit lost as to where to look. Is it a problem with my
kernel/modules not being set up properly or in connman config?
3 years, 7 months
[PATCH v2 0/4] Device blacklisting
by Patrik Flykt
Hi,
Version 2 contains only commit message fixes, so no changes to the
code. I'm still waiting for a particular person/project to test this,
but if you have noticed a problem with interface blacklisting, go
ahead and test. If it works properly I won't wait forever for that
particular person :-)
Cheers,
Patrik
Patrik Flykt (4):
detect: Remove detect.c
rtnl: Always set service and device type
rtnl: Send also interface name in the RTNL callback
device: Check interface blacklist on receiving RTNL newlink
Makefile.am | 2 +-
include/rtnl.h | 4 +-
src/detect.c | 133 ---------------------------------------------------------
src/device.c | 89 +++++++++++++++++++++++++++++++++++---
src/main.c | 2 -
src/rtnl.c | 26 +++--------
6 files changed, 90 insertions(+), 166 deletions(-)
delete mode 100644 src/detect.c
--
2.11.0
3 years, 7 months
[PATCH 0/4] Device blacklisting
by Patrik Flykt
Hi,
Blacklisting does not work when devices change their interface name,
but this patch set attempts to fix that. With the following changes
blacklisting the first interface name should make ConnMan aware of
the interface when it is renamed and vice versa.
In patch 1/4 the functionality provided by detect.c is merged with
device.c. The code in detect.c does nothing else, so this simplifies
dependencies between the files.
Patch 2/4 removes the additional blacklisting done by rtnl.c. This
additional check will set the device type to unknown, but after that
the device may get its device and service types set to correct values
again. This is confusing and will confuse blacklisting later on.
Patch 3/4 adds interface names to newlink and dellink callbacks. As
the only callbacks are registered for device.c during initialization
time, it does not matter that trigger_rtnl passes NULL as interface
name as there will not be any ipdevices at that time.
Patch 4/4 moves the interface blacklist checking to the RTNL newlink
callback as this callback is the only function in ConnMan that uses
connman_device_create_from_index where the check was located previously.
With this the new name of the interface can be checked and the device
unregistered should the blacklisting entry be only for the renamed
device name.
As this is a bit difficult to test, I hope to have somebody running
this during their builds. But if someone feels like it, please test.
The code in device.c should see a make-over, it's a bit clunky as it
is right now. It would be especially useful to colled all interface
index to interface name mapping into device.c to get rid of an extra
ioctl where ConnMan code currently maps index numbers to interface
name strings and/or back. This requires all plugins to submit
such information and the best approach here probably is to create a
new function that creates and registers a device into ConnMan's data
structures. But that's another patch set.
Cheers,
Patrik
Patrik Flykt (4):
detect: Remove detect.c
rtnl: Always set service and device type
rtnl: Send also interface name in the RTNL callback
device: Check interface blacklist on receiving RTNL newlink
Makefile.am | 2 +-
include/rtnl.h | 4 +-
src/detect.c | 133 ---------------------------------------------------------
src/device.c | 89 +++++++++++++++++++++++++++++++++++---
src/main.c | 2 -
src/rtnl.c | 26 +++--------
6 files changed, 90 insertions(+), 166 deletions(-)
delete mode 100644 src/detect.c
--
2.11.0
3 years, 7 months
IPv4 Address Conflict Detection support?
by Dave Berg
Hello,
Does ConnMan support any type of IPv4 address conflict detection? I searched
the code, but wasn't able to find anything obvious. I need this functionality
for DHCP and manual configuration methods.
RFC5227 (https://tools.ietf.org/html/rfc5227) describes a sequence where a
client should probe an address with ARP, and not use the address if it's
already in use on the network.
Apparently udhcpc (https://busybox.net/downloads/BusyBox.html) supports this
functionality through its command line option --arping.
Thanks,
Dave Berg
3 years, 7 months
[PATCH v3 1/5] session: add parameter Service into createsession call of ConnMan session API
by sutar.mounesh@gmail.com
From: Bjoern Thorwirth <external.bjoern.thorwirth(a)de.bosch.com>
Extend the session API interface. enable a service differentiation
for processes run by the same user. allow ConnMan to differentiate between bearer
usage permissions and the respective priorities based on the requested service type.
Usually calling process that implements the session API is identified by the user ID
as it is runs. All processes of the same user share the same list of allowed bearers,
and the same priority for choosing between available bearers is applied.
This extension allows processes to select a service context
for which the routing decision is made.
---
doc/session-api.txt | 11 +++++++++++
include/session.h | 1 +
src/session.c | 17 +++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/doc/session-api.txt b/doc/session-api.txt
index e8da522..a449af2 100644
--- a/doc/session-api.txt
+++ b/doc/session-api.txt
@@ -205,3 +205,14 @@ Settings string State [readonly]
a default route. When the source IP rule is enabled,
an application can select which session/interface to
send traffic on, using bind-before-connect mechanism.
+
+ string Service [readonly]
+
+ The service context of the Session.
+ Usually calling process that implements the session API is identified
+ by the user ID as it is runs. All processes of the same user share the same list of
+ allowed bearers, and the same priority for choosing between available
+ bearers is applied.
+ This parameter can be used to implement service context dependent behavior
+ In session_policy_local.c. It should be supplied with the ���dict Settings��� parameter
+ supplied with CreateSession() call from within the manager-api.
diff --git a/include/session.h b/include/session.h
index 5106e88..3b3c53f 100644
--- a/include/session.h
+++ b/include/session.h
@@ -74,6 +74,7 @@ struct connman_session_config {
GSList *allowed_bearers;
char *allowed_interface;
bool source_ip_rule;
+ char *service;
};
typedef int (* connman_session_config_func_t) (struct connman_session *session,
diff --git a/src/session.c b/src/session.c
index 9dd183f..2437538 100644
--- a/src/session.c
+++ b/src/session.c
@@ -548,6 +548,7 @@ struct creation_data {
GSList *allowed_bearers;
char *allowed_interface;
bool source_ip_rule;
+ char *service;
};
static void cleanup_creation_data(struct creation_data *creation_data)
@@ -557,6 +558,8 @@ static void cleanup_creation_data(struct creation_data *creation_data)
if (creation_data->pending)
dbus_message_unref(creation_data->pending);
+ if (creation_data->service)
+ g_free(creation_data->service);
g_slist_free(creation_data->allowed_bearers);
g_free(creation_data->allowed_interface);
@@ -927,6 +930,17 @@ static void append_notify(DBusMessageIter *dict,
}
if (session->append_all ||
+ info->config.service != info_last->config.service) {
+ char *ifname = info->config.service;
+ if (!ifname)
+ ifname = "";
+ connman_dbus_dict_append_basic(dict, "Service",
+ DBUS_TYPE_STRING,
+ &ifname);
+ info_last->config.service = info->config.service;
+ }
+
+ if (session->append_all ||
info->config.source_ip_rule != info_last->config.source_ip_rule) {
dbus_bool_t source_ip_rule = FALSE;
if (info->config.source_ip_rule)
@@ -1474,6 +1488,9 @@ int __connman_session_create(DBusMessage *msg)
connman_session_parse_connection_type(val);
user_connection_type = true;
+ } else if (g_str_equal(key, "Service")) {
+ dbus_message_iter_get_basic(&value, &val);
+ creation_data->service = g_strdup(val);
} else if (g_str_equal(key, "AllowedInterface")) {
dbus_message_iter_get_basic(&value, &val);
creation_data->allowed_interface = g_strdup(val);
--
2.7.4
3 years, 7 months
[PATCH] main: Make -d option repeatable
by Slava Monich
Concatenating the patterns makes more sense than using the last
supplied value and leaking the previous allocated pattern like this:
==12150== 70 bytes in 2 blocks are definitely lost in loss record 2,908 of 3,330
==12150== at 0x483F3EC: malloc (vg_replace_malloc.c)
==12150== by 0x4CA90DF: g_malloc (gmem.c)
==12150== by 0x4CC0185: g_strdup (gstrfuncs.c)
==12150== by 0x40F85: parse_debug (main.c)
==12150== by 0x4CADFBB: parse_short_option (goption.c)
==12150== by 0x4CAFC3D: g_option_context_parse (goption.c)
==12150== by 0x1FEAB: main (main.c)
---
src/main.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/main.c b/src/main.c
index 3e6449a..b78a046 100644
--- a/src/main.c
+++ b/src/main.c
@@ -517,10 +517,19 @@ static gboolean option_version = FALSE;
static bool parse_debug(const char *key, const char *value,
gpointer user_data, GError **error)
{
- if (value)
- option_debug = g_strdup(value);
- else
+ if (value) {
+ if (option_debug) {
+ char *prev = option_debug;
+
+ option_debug = g_strconcat(prev, ",", value, NULL);
+ g_free(prev);
+ } else {
+ option_debug = g_strdup(value);
+ }
+ } else {
+ g_free(option_debug);
option_debug = g_strdup("*");
+ }
return true;
}
--
1.9.1
3 years, 8 months
Value of IPv4.Method when IPv4LL
by Jose Blanquicet
Hi,
After a successful connection to a service, ConnMan starts DHCP
procedure to get an IPv4. However, if such procedure fails then
ConnMan will assign a Link-local address to that given interface. At
the end of this process, ConnMan will notify the assigned IPv4 address
with "dhcp" as method. We consider it should be "auto" in order to let
know that the DHCP process failed and that address is a Link-local
address. What do people think?
Regards,
Jose Blanquicet
3 years, 8 months