Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [RFC 0/6] Clean up gateway selection (Patrik Flykt)
2. [RFC 4/6] connection: Remove 'order' variable (Patrik Flykt)
3. [RFC 3/6] connection: Use services to compare gateway
ordering (Patrik Flykt)
4. [RFC 6/6] TODO: Mark gateway selection simplification done
(Patrik Flykt)
5. [RFC 1/6] service: Add function to compare the order between
two services (Patrik Flykt)
6. [RFC 5/6] service: Remove obsolete
__connman_service_update_ordering() function (Patrik Flykt)
7. [RFC 2/6] connection: Use the sorted service list to find the
default gateway (Patrik Flykt)
8. [PATCH] network: Remove explicit gateway activation (Patrik Flykt)
9. Re: [TEST 1/4] service: Add function to compare the order
between two services (Peter Meerwald-Stadler)
10. Re: [PATCHv2] log: don't require backtrace() (Patrik Flykt)
----------------------------------------------------------------------
Message: 1
Date: Thu, 14 Jan 2016 10:47:31 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [RFC 0/6] Clean up gateway selection
Message-ID:
<[email protected]>
Hi,
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. This function is then used in
patch #3, throwing out the old code as a result. Patch #3 also combines
consecutive if statements.
Patch #2 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 #4,
the now unused function __connman_service_update_ordering() in patch #5 and
the TODO is updated in patch #6.
Before applying this patch set please run the "[TEST XX/4] Clean up gateway
selection" patch set to ensure no bugs have been introduced!
Cheers,
Patrik
Patrik Flykt (6):
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
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 | 12 ++++-----
4 files changed, 28 insertions(+), 74 deletions(-)
--
2.1.4
------------------------------
Message: 2
Date: Thu, 14 Jan 2016 10:47:35 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [RFC 4/6] connection: Remove 'order' variable
Message-ID:
<[email protected]>
Ordering is now done according to the order of the service list and
thus the 'order' variable becomes unnecessary.
---
src/connection.c | 21 ---------------------
1 file changed, 21 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index 414d3ac..f4ecd22 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -46,7 +46,6 @@ struct gateway_config {
struct gateway_data {
int index;
struct connman_service *service;
- unsigned int order;
struct gateway_config *ipv4_gateway;
struct gateway_config *ipv6_gateway;
bool default_checked;
@@ -381,8 +380,6 @@ static struct gateway_data *add_gateway(struct
connman_service *service,
data->service = service;
- data->order = __connman_service_get_order(service);
-
/*
* If the service is already in the hash, then we
* must not replace it blindly but disable the gateway
@@ -741,22 +738,6 @@ static struct gateway_data *find_active_gateway(void)
return NULL;
}
-static void update_order(void)
-{
- GHashTableIter iter;
- gpointer value, key;
-
- DBG("");
-
- g_hash_table_iter_init(&iter, gateway_hash);
-
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- struct gateway_data *data = value;
-
- data->order = __connman_service_get_order(data->service);
- }
-}
-
static void add_host_route(int family, int index, const char *gateway,
enum connman_service_type service_type)
{
@@ -994,8 +975,6 @@ bool __connman_connection_update_gateway(void)
if (!gateway_hash)
return updated;
- update_order();
-
default_gateway = find_default_gateway();
__connman_service_update_ordering();
--
2.1.4
------------------------------
Message: 3
Date: Thu, 14 Jan 2016 10:47:34 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [RFC 3/6] connection: Use services to compare gateway
ordering
Message-ID:
<[email protected]>
Use the service pointer in the gateway data to find out if the candidate
gateway should be chosen over the other gateway.
---
src/connection.c | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index b2d6f5b..414d3ac 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -577,37 +577,35 @@ static bool choose_default_gateway(struct gateway_data
*data,
* this one as default. If the other one is already active
* we mark this one as non default.
*/
- if (data->ipv4_gateway) {
- if (candidate->ipv4_gateway &&
- !candidate->ipv4_gateway->active) {
+ if (data->ipv4_gateway && candidate->ipv4_gateway) {
+
+ if (!candidate->ipv4_gateway->active) {
DBG("ipv4 downgrading %p", candidate);
unset_default_gateway(candidate,
CONNMAN_IPCONFIG_TYPE_IPV4);
}
- if (candidate->ipv4_gateway &&
- candidate->ipv4_gateway->active &&
- candidate->order > data->order) {
+
+ if (candidate->ipv4_gateway->active &&
+ __connman_service_compare(candidate->service,
+ data->service) < 0) {
DBG("ipv4 downgrading this %p", data);
- unset_default_gateway(data,
- CONNMAN_IPCONFIG_TYPE_IPV4);
+ unset_default_gateway(data, CONNMAN_IPCONFIG_TYPE_IPV4);
downgraded = true;
}
}
- if (data->ipv6_gateway) {
- if (candidate->ipv6_gateway &&
- !candidate->ipv6_gateway->active) {
+ if (data->ipv6_gateway && candidate->ipv6_gateway) {
+ if (!candidate->ipv6_gateway->active) {
DBG("ipv6 downgrading %p", candidate);
unset_default_gateway(candidate,
CONNMAN_IPCONFIG_TYPE_IPV6);
}
- if (candidate->ipv6_gateway &&
- candidate->ipv6_gateway->active &&
- candidate->order > data->order) {
+ if (candidate->ipv6_gateway->active &&
+ __connman_service_compare(candidate->service,
+ data->service) < 0) {
DBG("ipv6 downgrading this %p", data);
- unset_default_gateway(data,
- CONNMAN_IPCONFIG_TYPE_IPV6);
+ unset_default_gateway(data, CONNMAN_IPCONFIG_TYPE_IPV6);
downgraded = true;
}
}
--
2.1.4
------------------------------
Message: 4
Date: Thu, 14 Jan 2016 10:47:37 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [RFC 6/6] TODO: Mark gateway selection simplification done
Message-ID:
<[email protected]>
---
TODO | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/TODO b/TODO
index 1067367..41957e1 100644
--- a/TODO
+++ b/TODO
@@ -85,17 +85,6 @@ Core
utilize the information already provided by netlink in src/device.c.
-- Simplify gateway selection code
-
- Priority: Low
- Complexity: C4
-
- The service list is always sorted according to preference with the
- first service always owning the default route. See if update_order and
- find_default_gateway in src/connection.c can be modified to use the
- sorted service list instead of walking through the gateway_hash.
-
-
- Support D-Bus ObjectManager
Priority: Medium
--
2.1.4
------------------------------
Message: 5
Date: Thu, 14 Jan 2016 10:47:32 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [RFC 1/6] service: Add function to compare the order between
two services
Message-ID:
<[email protected]>
This function compares the order between two services and returns
-1, 0 or 1 respectively.
---
src/connman.h | 3 +++
src/service.c | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/src/connman.h b/src/connman.h
index 1767259..1e3fdce 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -654,6 +654,9 @@ int __connman_service_load_modifiable(struct
connman_service *service);
void __connman_service_list_struct(DBusMessageIter *iter);
+int __connman_service_compare(struct connman_service *a,
+ struct connman_service *b);
+
struct connman_service *__connman_service_lookup_from_index(int index);
struct connman_service *__connman_service_lookup_from_ident(const char
*identifier);
struct connman_service *__connman_service_create_from_network(struct
connman_network *network);
diff --git a/src/service.c b/src/service.c
index abf0899..030b353 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4785,6 +4785,12 @@ static void service_list_sort(void)
}
}
+int __connman_service_compare(struct connman_service *a,
+ struct connman_service *b)
+{
+ return service_compare(a, b);
+}
+
/**
* connman_service_get_type:
* @service: service structure
--
2.1.4
------------------------------
Message: 6
Date: Thu, 14 Jan 2016 10:47:36 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [RFC 5/6] service: Remove obsolete
__connman_service_update_ordering() function
Message-ID:
<[email protected]>
The function __connman_service_update_ordering() does not provide any
features anymore, thus it is removed.
---
src/connection.c | 2 --
src/connman.h | 1 -
src/service.c | 6 ------
3 files changed, 9 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index f4ecd22..6b005e7 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -977,8 +977,6 @@ bool __connman_connection_update_gateway(void)
default_gateway = find_default_gateway();
- __connman_service_update_ordering();
-
DBG("default %p", default_gateway);
/*
diff --git a/src/connman.h b/src/connman.h
index 1e3fdce..3adbddf 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -681,7 +681,6 @@ const char *__connman_service_get_path(struct
connman_service *service);
const char *__connman_service_get_name(struct connman_service *service);
unsigned int __connman_service_get_order(struct connman_service *service);
enum connman_service_state __connman_service_get_state(struct connman_service
*service);
-void __connman_service_update_ordering(void);
struct connman_network *__connman_service_get_network(struct connman_service
*service);
enum connman_service_security __connman_service_get_security(struct
connman_service *service);
const char *__connman_service_get_phase2(struct connman_service *service);
diff --git a/src/service.c b/src/service.c
index 030b353..8dde193 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6606,12 +6606,6 @@ unsigned int __connman_service_get_order(struct
connman_service *service)
return order;
}
-void __connman_service_update_ordering(void)
-{
- if (service_list && service_list->next)
- service_list = g_list_sort(service_list, service_compare);
-}
-
static enum connman_service_type convert_network_type(struct connman_network
*network)
{
enum connman_network_type type = connman_network_get_type(network);
--
2.1.4
------------------------------
Message: 7
Date: Thu, 14 Jan 2016 10:47:33 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [RFC 2/6] connection: Use the sorted service list to find the
default gateway
Message-ID:
<[email protected]>
The service list is always sorted and thus the service that should have
the default gateway is first in the list. The first service in the list
has coincidentally also the largest 'order' value.
---
src/connection.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/src/connection.c b/src/connection.c
index bbc5d83..b2d6f5b 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -558,25 +558,13 @@ static void unset_default_gateway(struct gateway_data
*data,
static struct gateway_data *find_default_gateway(void)
{
- struct gateway_data *found = NULL;
- unsigned int order = 0;
- GHashTableIter iter;
- gpointer value, key;
-
- g_hash_table_iter_init(&iter, gateway_hash);
-
- while (g_hash_table_iter_next(&iter, &key, &value)) {
- struct gateway_data *data = value;
-
- if (!found || data->order > order) {
- found = data;
- order = data->order;
+ struct connman_service *service;
- DBG("default %p order %d", found, order);
- }
- }
+ service = __connman_service_get_default();
+ if (!service)
+ return NULL;
- return found;
+ return g_hash_table_lookup(gateway_hash, service);
}
static bool choose_default_gateway(struct gateway_data *data,
--
2.1.4
------------------------------
Message: 8
Date: Thu, 14 Jan 2016 10:51:28 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH] network: Remove explicit gateway activation
Message-ID:
<[email protected]>
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
------------------------------
Message: 9
Date: Thu, 14 Jan 2016 10:22:05 +0100 (CET)
From: Peter Meerwald-Stadler <[email protected]>
To: Patrik Flykt <[email protected]>
Cc: [email protected]
Subject: Re: [TEST 1/4] service: Add function to compare the order
between two services
Message-ID: <[email protected]>
Content-Type: TEXT/PLAIN; charset=US-ASCII
> This function compares the order between two services and returns
> -1, 0 or 1 respectively.
> +int __connman_service_compare(struct connman_service *a,
> + struct connman_service *b)
> +{
> + return service_compare(a, b);
service_compare(gconstpointer a, gconstpointer b) seems to use const
pointers, so __connman_service_compare could use const as well
--
Peter Meerwald-Stadler
+43-664-2444418 (mobile)
------------------------------
Message: 10
Date: Thu, 14 Jan 2016 12:41:07 +0200
From: Patrik Flykt <[email protected]>
To: "Yann E. MORIN" <[email protected]>
Cc: [email protected]
Subject: Re: [PATCHv2] log: don't require backtrace()
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"
On Fri, 2016-01-01 at 15:20 +0100, Yann E. MORIN wrote:
> Not all toolchains have execinfo.h and backtrace(). For example,
> support for it is optional in uClibc, while it is entirely missing
> from musl.
>
> In glibc, execinfo.h only declares backtrace() and no other function,
> so we can rely on its presence/abscence to determine if we can use
> backtrace().
>
> We fix that by:
> - adding a ./configure check for execinfo.h;
> - moving backtrace to its own file;
> - compiling backtrace.c only when execinfo.h was found.
>
> Signed-off-by: "Yann E. MORIN" <[email protected]>
> Cc: Patrik Flykt <[email protected]>
>
> ---
> Changes v1 -> v2:
> - move backtrace to its own file and only compile it if execinfo.h was
> found (Patrik)
>
> Notes: this makes connman build under uClibc without execinfo.h and
> backtrace(), but more work is needed to make it build with musl. I may
> be able to work on this in the coming days/week, but I can't make any
> hard promise... :-/
Applied, thanks!
Patrik
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 3, Issue 10
**************************************