Skip to contentSkip to conversation

service: Minor address_updated Changes

PATCH Superseded Grant Erickson 2 participants 11 messages Nov 16, 2023 – Nov 25, 2023

lore
Share & tools
lore
#0 lore raw

cover service: Minor address_updated Changes

This makes some minor changes to 'address_updated':

1. Leverage 'connman_service_is_default'.
2. Add 'DBG' statement.
3. Add documentation.

Grant Erickson (3):
service: Leverage 'connman_service_is_default'.
service: Add DBG statement to 'address_updated'.
service: Add documentation to 'address_updated'.

 src/service.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
Signature · 1 line
2.42.0
#1 lore raw

PATCH 1/3 service: Leverage 'connman_service_is_default'.

This leverages the recently-added 'connman_service_is_default' in 'address_updated' rather than duplicating the same logic from the former in the latter.

---
 src/service.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/service.c +2 -1
index 81a1bebdc14b..90ed111fc035 100644
@@ -164,6 +164,7 @@ static void complete_online_check(struct connman_service *service,
 					enum connman_ipconfig_type type,
 					bool success);
 static bool service_downgrade_online_state(struct connman_service *service);
+static bool connman_service_is_default(const struct connman_service *service);
 
 struct find_data {
 	const char *path;
@@ -2018,7 +2019,7 @@ static void address_updated(struct connman_service *service,
 			enum connman_ipconfig_type type)
 {
 	if (is_connected(service->state) &&
-			service == connman_service_get_default()) {
+			connman_service_is_default(service)) {
 		nameserver_remove_all(service, type);
 		nameserver_add_all(service, type);
 		start_online_check(service, type);
Signature · 1 line
2.42.0
#2 lore raw

PATCH 2/3 service: Add DBG statement to 'address_updated'.

In reply to Grant Erickson

This adds a DBG statement to 'address_upated' to aid in debugging.

---
 src/service.c | 5 +++++
 1 file changed, 5 insertions(+)
src/service.c +5 -0
index 90ed111fc035..f0e8364ee77b 100644
@@ -2018,6 +2018,11 @@ void __connman_service_wispr_start(struct connman_service *service,
 static void address_updated(struct connman_service *service,
 			enum connman_ipconfig_type type)
 {
+	DBG("service %p (%s) type %d (%s)",
+		service,
+		connman_service_get_identifier(service),
+		type, __connman_ipconfig_type2string(type));
+
 	if (is_connected(service->state) &&
 			connman_service_is_default(service)) {
 		nameserver_remove_all(service, type);
Signature · 1 line
2.42.0
#3 lore raw

PATCH 3/3 service: Add documentation to 'address_updated'.

In reply to Grant Erickson

This adds documentation to the 'address_updated' function.

---
 src/service.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
src/service.c +27 -0
index f0e8364ee77b..2f5c3c8934f5 100644
@@ -2015,6 +2015,33 @@ void __connman_service_wispr_start(struct connman_service *service,
 	__connman_wispr_start(service, type, complete_online_check);
 }
 
+/**
+ *  @brief
+ *    Handle an update to the address(es) for the specified network
+ *    service and IP configuration type.
+ *
+ *  This attempts to handle an address change or update for the
+ *  specified network service and IP configuration type if and only if
+ *  it is connected (that is, #is_connected returns true) and it is
+ *  the default service (that is, has the default route).
+ *
+ *  If the service meets those criteria, then nameservers are
+ *  refreshed, an "online" HTTP-based Internet reachability check is
+ *  initiated, and a time-of-day synchronization is requested.
+ *
+ *  @param[in,out]  service  A pointer to the mutable network service
+ *                           for which there was an address change or
+ *                           update.
+ *  @param[in]      type     The IP configuration type for @a service
+ *                           for which there was an address change or
+ *                           update.
+ *
+ *  @sa nameserver_remove_all
+ *  @sa nameserver_add_all
+ *  @sa start_online_check
+ *  @sa __connman_timeserver_sync
+ *
+ */
 static void address_updated(struct connman_service *service,
 			enum connman_ipconfig_type type)
 {
Signature · 1 line
2.42.0
#4 lore raw
In reply to Grant Erickson

Hi Grant,

Quoted 6 lines

This makes some minor changes to 'address_updated':

1. Leverage 'connman_service_is_default'.
2. Add 'DBG' statement.
3. Add documentation.

Quoted 7 lines

Grant Erickson (3):
service: Leverage 'connman_service_is_default'.
service: Add DBG statement to 'address_updated'.
service: Add documentation to 'address_updated'.

src/service.c | 35 ++++++++++++++++++++++++++++++++++-

1 file changed, 34 insertions(+), 1 deletion(-)

sadly this doesnt apply cleanly anymore.

Regards

Marcel

#5 lore raw
Quoted 11 lines · Marcel Holtmann
Quoted 11 lines

This makes some minor changes to 'address_updated':

1. Leverage 'connman_service_is_default'.
2. Add 'DBG' statement.
3. Add documentation.

Grant Erickson (3):
service: Leverage 'connman_service_is_default'.
service: Add DBG statement to 'address_updated'.
service: Add documentation to 'address_updated'.

Quoted 4 lines
Quoted 2 lines

src/service.c | 35 ++++++++++++++++++++++++++++++++++-

1 file changed, 34 insertions(+), 1 deletion(-)

sadly this doesnt apply cleanly anymore.

Thanks; resubmitted as v2.

Best,

Grant

Signature · 5 lines
Principal
Nuovations

[email protected]
http://www.nuovations.com/
#6 lore raw

v2 cover service: Minor address_updated Changes

In reply to Grant Erickson

This makes some minor changes to 'address_updated':

1. Leverage 'connman_service_is_default'.
2. Add 'DBG' statement.
3. Add documentation.

Grant Erickson (3):
service: Leverage 'connman_service_is_default'.
service: Add DBG statement to 'address_updated'.
service: Add documentation to 'address_updated'.

 src/service.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
Signature · 1 line
2.42.0
#7 lore raw

PATCH v2 1/3 service: Leverage 'connman_service_is_default'.

This leverages the recently-added 'connman_service_is_default' in 'address_updated' rather than duplicating the same logic from the former in the latter.

---
 src/service.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/service.c +1 -1
index dd50b81a7e5a..b98ec00f808c 100644
@@ -2239,7 +2239,7 @@ static void address_updated(struct connman_service *service,
 			enum connman_ipconfig_type type)
 {
 	if (is_connected(service->state) &&
-			service == connman_service_get_default()) {
+			connman_service_is_default(service)) {
 		nameserver_remove_all(service, type);
 		nameserver_add_all(service, type);
 		start_online_check(service, type);
Signature · 1 line
2.42.0
#8 lore raw

PATCH v2 2/3 service: Add DBG statement to 'address_updated'.

In reply to Grant Erickson

This adds a DBG statement to 'address_upated' to aid in debugging.

---
 src/service.c | 5 +++++
 1 file changed, 5 insertions(+)
src/service.c +5 -0
index b98ec00f808c..ce02aa62fb7c 100644
@@ -2238,6 +2238,11 @@ void __connman_service_wispr_start(struct connman_service *service,
 static void address_updated(struct connman_service *service,
 			enum connman_ipconfig_type type)
 {
+	DBG("service %p (%s) type %d (%s)",
+		service,
+		connman_service_get_identifier(service),
+		type, __connman_ipconfig_type2string(type));
+
 	if (is_connected(service->state) &&
 			connman_service_is_default(service)) {
 		nameserver_remove_all(service, type);
Signature · 1 line
2.42.0
#9 lore raw

PATCH v2 3/3 service: Add documentation to 'address_updated'.

In reply to Grant Erickson

This adds documentation to the 'address_updated' function.

---
 src/service.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
src/service.c +27 -0
index ce02aa62fb7c..86eb74d26c6e 100644
@@ -2235,6 +2235,33 @@ void __connman_service_wispr_start(struct connman_service *service,
 			online_check_connect_timeout_ms, complete_online_check);
 }
 
+/**
+ *  @brief
+ *    Handle an update to the address(es) for the specified network
+ *    service and IP configuration type.
+ *
+ *  This attempts to handle an address change or update for the
+ *  specified network service and IP configuration type if and only if
+ *  it is connected (that is, #is_connected returns true) and it is
+ *  the default service (that is, has the default route).
+ *
+ *  If the service meets those criteria, then nameservers are
+ *  refreshed, an "online" HTTP-based Internet reachability check is
+ *  initiated, and a time-of-day synchronization is requested.
+ *
+ *  @param[in,out]  service  A pointer to the mutable network service
+ *                           for which there was an address change or
+ *                           update.
+ *  @param[in]      type     The IP configuration type for @a service
+ *                           for which there was an address change or
+ *                           update.
+ *
+ *  @sa nameserver_remove_all
+ *  @sa nameserver_add_all
+ *  @sa start_online_check
+ *  @sa __connman_timeserver_sync
+ *
+ */
 static void address_updated(struct connman_service *service,
 			enum connman_ipconfig_type type)
 {
Signature · 1 line
2.42.0
#10 lore raw
In reply to Grant Erickson

Hi Grant,

Quoted 6 lines

This makes some minor changes to 'address_updated':

1. Leverage 'connman_service_is_default'.
2. Add 'DBG' statement.
3. Add documentation.

Quoted 7 lines

Grant Erickson (3):
service: Leverage 'connman_service_is_default'.
service: Add DBG statement to 'address_updated'.
service: Add documentation to 'address_updated'.

src/service.c | 34 +++++++++++++++++++++++++++++++++-

1 file changed, 33 insertions(+), 1 deletion(-)

all 3 patches have been applied.

Regards

Marcel