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. [PATCH 25/27] network: send DHCP decline in case of address
conflict (Christian Spielberger)
2. [PATCH 26/27] acd: report address lost case per dbus also
(Christian Spielberger)
3. [PATCH 23/27] network: add function for delayed dhcp start
(Christian Spielberger)
----------------------------------------------------------------------
Message: 1
Date: Wed, 11 Apr 2018 16:00:45 +0200
From: Christian Spielberger <[email protected]>
To: Daniel Wagner <[email protected]>
Cc: [email protected], Christian Spielberger
<[email protected]>
Subject: [PATCH 25/27] network: send DHCP decline in case of address
conflict
Message-ID:
<1523455247-5877-26-git-send-email-christian.spielber...@gmail.com>
Try DHCP two times, then fallback is IPv4LL. Also invoke __connman_dhcp_decline
which sends a DHCP decline.
---
src/network.c | 40 ++++++++++++++++++++++++++++++++++++----
1 file changed, 36 insertions(+), 4 deletions(-)
diff --git a/src/network.c b/src/network.c
index 3cbf3bd..777966f 100644
--- a/src/network.c
+++ b/src/network.c
@@ -50,6 +50,8 @@
*/
#define RTR_SOLICITATION_INTERVAL 4
+#define DHCP_RETRY_TIMEOUT 10
+
static GSList *network_list = NULL;
static GSList *driver_list = NULL;
@@ -305,11 +307,41 @@ static void acdhost_ipv4_lost(acd_host *acd, gpointer
user_data)
static void acdhost_ipv4_conflict(acd_host *acd, gpointer user_data)
{
struct connman_network *network = user_data;
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig_ipv4;
+ enum connman_ipconfig_method method;
- /* Start IPv4LL ACD. */
- if (start_ipv4ll(network) < 0)
- connman_error("Could not start IPv4LL. "
- "No address will be assigned");
+ service = connman_service_lookup_from_network(network);
+ if (!service)
+ return;
+
+ ipconfig_ipv4 = __connman_service_get_ip4config(service);
+ if (!ipconfig_ipv4) {
+ connman_error("Service has no IPv4 configuration");
+ return;
+ }
+
+ method = __connman_ipconfig_get_method(ipconfig_ipv4);
+ connman_info("%s conflict counts=%u", __FUNCTION__,
+ acdhost_get_conflicts_count(acd));
+
+ if (method == CONNMAN_IPCONFIG_METHOD_DHCP &&
+ acdhost_get_conflicts_count(acd) < 2) {
+ connman_info("%s Sending DHCP decline", __FUNCTION__);
+ __connman_dhcp_decline(ipconfig_ipv4);
+
+ connman_network_set_connected_dhcp_later(network,
DHCP_RETRY_TIMEOUT);
+ __connman_ipconfig_set_local(ipconfig_ipv4, NULL);
+ } else {
+ if (method == CONNMAN_IPCONFIG_METHOD_DHCP) {
+ __connman_ipconfig_set_method(ipconfig_ipv4,
+ CONNMAN_IPCONFIG_METHOD_AUTO);
+ }
+ /* Start IPv4LL ACD. */
+ if (start_ipv4ll(network) < 0)
+ connman_error("Could not start IPv4LL. "
+ "No address will be assigned");
+ }
}
static void acdhost_ipv4_maxconflict(acd_host *acd, gpointer user_data)
--
2.7.4
------------------------------
Message: 2
Date: Wed, 11 Apr 2018 16:00:46 +0200
From: Christian Spielberger <[email protected]>
To: Daniel Wagner <[email protected]>
Cc: [email protected], Christian Spielberger
<[email protected]>
Subject: [PATCH 26/27] acd: report address lost case per dbus also
Message-ID:
<1523455247-5877-27-git-send-email-christian.spielber...@gmail.com>
We also want to report an address conflict if we loose our IPv4 address because
another host is using the same one.
---
src/acd.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/src/acd.c b/src/acd.c
index 9c8ed8f..4401e24 100644
--- a/src/acd.c
+++ b/src/acd.c
@@ -89,7 +89,7 @@ static gboolean acd_announce_timeout(gpointer acd_data);
static gboolean acd_defend_timeout(gpointer acd_data);
/* for DBus property */
-static void report_conflict(acd_host *acd);
+static void report_conflict(acd_host *acd, const struct ether_arp* arp);
static void debug(acd_host *acd, const char *format, ...)
{
@@ -384,10 +384,8 @@ static gboolean acd_announce_timeout(gpointer acd_data)
debug(acd, "switching to monitor mode");
acd->state = ACD_MONITOR;
- if (!acd->ac_resolved && !is_link_local(acd->requested_ip)) {
- acd->ac_resolved = true;
- report_conflict(acd);
- }
+ if (!acd->ac_resolved && !is_link_local(acd->requested_ip))
+ report_conflict(acd, NULL);
if (acd->ipv4_available_cb)
acd->ipv4_available_cb(acd,
@@ -459,19 +457,17 @@ static int acd_recv_arp_packet(acd_host *acd) {
return 0;
debug(acd, "LOST IPv4 address %s", inet_ntoa(addr));
+ if (!is_link_local(acd->requested_ip))
+ report_conflict(acd, &arp);
+
if (acd->ipv4_lost_cb)
acd->ipv4_lost_cb(acd, acd->ipv4_lost_data);
return 0;
}
if (acd->conflicts < MAX_CONFLICTS) {
- if (!is_link_local(acd->requested_ip)) {
- acd->ac_ip = acd->requested_ip;
- memcpy(acd->ac_mac, arp.arp_sha, sizeof(acd->ac_mac));
- acd->ac_timestamp = g_get_real_time();
- acd->ac_resolved = false;
- report_conflict(acd);
- }
+ if (!is_link_local(acd->requested_ip))
+ report_conflict(acd, &arp);
acdhost_stop(acd);
@@ -560,8 +556,17 @@ void acdhost_append_dbus_property(acd_host *acd,
DBusMessageIter *dict)
append_ac_property, acd);
}
-static void report_conflict(acd_host *acd)
+static void report_conflict(acd_host *acd, const struct ether_arp* arp)
{
+ if (arp) {
+ acd->ac_ip = acd->requested_ip;
+ memcpy(acd->ac_mac, arp->arp_sha, sizeof(acd->ac_mac));
+ acd->ac_timestamp = g_get_real_time();
+ acd->ac_resolved = false;
+ } else {
+ acd->ac_resolved = true;
+ }
+
connman_dbus_property_changed_dict(acd->path, CONNMAN_SERVICE_INTERFACE,
"LastAddressConflict", append_ac_property, acd);
}
--
2.7.4
------------------------------
Message: 3
Date: Wed, 11 Apr 2018 16:00:43 +0200
From: Christian Spielberger <[email protected]>
To: Daniel Wagner <[email protected]>
Cc: [email protected], Christian Spielberger
<[email protected]>
Subject: [PATCH 23/27] network: add function for delayed dhcp start
Message-ID:
<1523455247-5877-24-git-send-email-christian.spielber...@gmail.com>
In case of an address conflict for a DHCP lease we have to send a DHCP DECLINE
and then try DHCP process a second time after a delay of 10 seconds. If second
DHCP lease also has a conflict the fallback is IPv4LL.
---
include/network.h | 2 ++
src/network.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/include/network.h b/include/network.h
index 22463cc..11381dd 100644
--- a/include/network.h
+++ b/include/network.h
@@ -101,6 +101,8 @@ void connman_network_set_error(struct connman_network
*network,
int connman_network_set_connected(struct connman_network *network,
bool connected);
bool connman_network_get_connected(struct connman_network *network);
+void connman_network_set_connected_dhcp_later(struct connman_network *network,
+ uint32_t sec);
bool connman_network_get_associating(struct connman_network *network);
diff --git a/src/network.c b/src/network.c
index 399a0cd..3cbf3bd 100644
--- a/src/network.c
+++ b/src/network.c
@@ -71,6 +71,7 @@ struct connman_network {
int router_solicit_refresh_count;
acd_host *acdhost;
guint ipv4ll_timeout;
+ guint dhcp_timeout;
struct connman_network_driver *driver;
void *driver_data;
@@ -495,6 +496,14 @@ err:
return err;
}
+static void remove_dhcp_timeout(struct connman_network *network)
+{
+ if (network->dhcp_timeout > 0) {
+ g_source_remove(network->dhcp_timeout);
+ network->dhcp_timeout = 0;
+ }
+}
+
static int set_connected_dhcp(struct connman_network *network)
{
struct connman_service *service;
@@ -502,6 +511,7 @@ static int set_connected_dhcp(struct connman_network
*network)
int err;
DBG("network %p", network);
+ remove_dhcp_timeout(network);
service = connman_service_lookup_from_network(network);
ipconfig_ipv4 = __connman_service_get_ip4config(service);
@@ -517,6 +527,44 @@ static int set_connected_dhcp(struct connman_network
*network)
return 0;
}
+static gboolean set_connected_dhcp_timout(gpointer data)
+{
+ struct connman_network *network = data;
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig;
+ enum connman_ipconfig_method method;
+
+ network->dhcp_timeout = 0;
+
+ service = connman_service_lookup_from_network(network);
+ if (!service)
+ return FALSE;
+
+ ipconfig = __connman_service_get_ip4config(service);
+ if (!ipconfig)
+ return FALSE;
+
+ /* Method is still DHCP? */
+ method = __connman_ipconfig_get_method(ipconfig);
+ if (method == CONNMAN_IPCONFIG_METHOD_DHCP)
+ set_connected_dhcp(network);
+
+ return FALSE;
+}
+
+void connman_network_set_connected_dhcp_later(struct connman_network *network,
+ uint32_t sec)
+{
+ remove_dhcp_timeout(network);
+
+ network->dhcp_timeout =
+ g_timeout_add_seconds_full(G_PRIORITY_HIGH,
+ sec,
+ set_connected_dhcp_timout,
+ network,
+ NULL);
+}
+
static int manual_ipv6_set(struct connman_network *network,
struct connman_ipconfig *ipconfig_ipv6)
{
@@ -918,6 +966,7 @@ static void set_disconnected(struct connman_network
*network)
__connman_service_notify_ipv4_configuration(service);
/* fall through */
case CONNMAN_IPCONFIG_METHOD_DHCP:
+ remove_dhcp_timeout(network);
__connman_dhcp_stop(ipconfig_ipv4);
break;
}
@@ -1207,6 +1256,8 @@ struct connman_network *connman_network_create(const char
*identifier,
network_list = g_slist_prepend(network_list, network);
+ network->dhcp_timeout = 0;
+
DBG("network %p identifier %s type %s", network, identifier,
type2string(type));
return network;
@@ -1798,6 +1849,7 @@ int __connman_network_clear_ipconfig(struct
connman_network *network,
__connman_ipconfig_address_remove(ipconfig);
break;
case CONNMAN_IPCONFIG_METHOD_DHCP:
+ remove_dhcp_timeout(network);
__connman_dhcp_stop(ipconfig_ipv4);
break;
}
--
2.7.4
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 30, Issue 9
**************************************