diff mbox series

[1/5] inet: Use '__connman_inet_rtnl_recv' for RTNL default route transaction.

Message ID 20231220055613.2287074-2-gerickson@nuovations.com (mailing list archive)
State Accepted, archived
Headers show
Series Address Unhandled Gateway Route Lifecycle Events/Transitions | expand

Commit Message

Grant Erickson Dec. 20, 2023, 5:56 a.m. UTC
This leverages '__connman_inet_rtnl_recv', introduced at commit
97967b4aae40 ("inet: Add '__connman_inet_rtnl_recv'."), to complete
the Routing Netlink (rtnl) default route addition or deletion
transaction in 'iproute_default_modify'.

Every rtnl route addition or deletion transaction consists of a
request and a response phase. The request phase contains the details
of the route to be added or deleted. The response phase contains the
status of whether the request succeeded. Unfortunately, to date,
'iproute_default_modify' did not include the response phase.
Therefore, it did not complete the route request transaction,
rendering the returns status incomplete in that it only reflected the
success or failure of the request phase.

Unfortunately, for callers of interfaces that, in turn, called
'iproute_default_modify', this made all routing requests appear to
artificially succeed even when, in fact, they were failing and elided
response status that callers need to conditionally act in the face of
the transaction failure.

By adding '__connman_inet_rtnl_recv' to complete the response phase of
the rtnl route transaction, the return status of
'iproute_default_modify', and those interfaces that call it, now
accurately reflect both the request and response status of the
transaction.
---
 src/inet.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/src/inet.c b/src/inet.c
index e0f927a12dcb..8a1e34235230 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -4748,6 +4748,12 @@  static int iproute_default_modify(int cmd, uint32_t table_id, uint32_t metric,
 		goto done;
 
 	ret = __connman_inet_rtnl_send(&rth, &rth.req.n);
+	if (ret < 0)
+		goto done;
+
+	ret = __connman_inet_rtnl_recv(&rth, NULL);
+	if (ret < 0)
+		goto done;
 
 done:
 	__connman_inet_rtnl_close(&rth);