All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 05/15] netconfig: Use an internal rtnl socket for l_netconfig_apply_rtnl
@ 2022-05-20 15:43 Andrew Zaborowski
  0 siblings, 0 replies; only message in thread
From: Andrew Zaborowski @ 2022-05-20 15:43 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 3711 bytes --]

Since we'll need to keep an internal RTNL socket for DHCPv6
functionality anyway, change l_netconfig_apply_rtnl's signature to not
require an rtnl parameter.
---
 ell/netconfig.c | 24 ++++++++++++++++--------
 ell/netconfig.h |  3 +--
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/ell/netconfig.c b/ell/netconfig.c
index 2a1b3ed..f1cbbb9 100644
--- a/ell/netconfig.c
+++ b/ell/netconfig.c
@@ -64,6 +64,7 @@ struct l_netconfig {
 	char **v6_dns_override;
 	char **v6_domain_names_override;
 
+	struct l_netlink *rtnl;
 	bool started;
 	struct l_idle *do_static_work;
 	bool v4_configured;
@@ -1166,6 +1167,8 @@ LIB_EXPORT void l_netconfig_stop(struct l_netconfig *netconfig)
 
 	l_dhcp_client_stop(netconfig->dhcp_client);
 	l_dhcp6_client_stop(netconfig->dhcp6_client);
+
+	l_rtnl_put(&netconfig->rtnl);
 }
 
 LIB_EXPORT struct l_dhcp_client *l_netconfig_get_dhcp_client(
@@ -1211,41 +1214,46 @@ LIB_EXPORT void l_netconfig_set_event_handler(struct l_netconfig *netconfig,
 	netconfig->handler.destroy = destroy;
 }
 
-LIB_EXPORT void l_netconfig_apply_rtnl(struct l_netconfig *netconfig,
-					struct l_netlink *rtnl)
+LIB_EXPORT void l_netconfig_apply_rtnl(struct l_netconfig *netconfig)
 {
 	const struct l_queue_entry *entry;
 
 	for (entry = l_queue_get_entries(netconfig->addresses.removed); entry;
 			entry = entry->next)
-		l_rtnl_ifaddr_delete(rtnl, netconfig->ifindex, entry->data,
+		l_rtnl_ifaddr_delete(l_rtnl_get(&netconfig->rtnl),
+					netconfig->ifindex, entry->data,
 					NULL, NULL, NULL);
 
 	for (entry = l_queue_get_entries(netconfig->addresses.added); entry;
 			entry = entry->next)
-		l_rtnl_ifaddr_add(rtnl, netconfig->ifindex, entry->data,
+		l_rtnl_ifaddr_add(l_rtnl_get(&netconfig->rtnl),
+					netconfig->ifindex, entry->data,
 					NULL, NULL, NULL);
 
 	/* We can use l_rtnl_ifaddr_add here since that uses NLM_F_REPLACE */
 	for (entry = l_queue_get_entries(netconfig->addresses.updated); entry;
 			entry = entry->next)
-		l_rtnl_ifaddr_add(rtnl, netconfig->ifindex, entry->data,
+		l_rtnl_ifaddr_add(l_rtnl_get(&netconfig->rtnl),
+					netconfig->ifindex, entry->data,
 					NULL, NULL, NULL);
 
 	for (entry = l_queue_get_entries(netconfig->routes.removed); entry;
 			entry = entry->next)
-		l_rtnl_route_delete(rtnl, netconfig->ifindex, entry->data,
+		l_rtnl_route_delete(l_rtnl_get(&netconfig->rtnl),
+					netconfig->ifindex, entry->data,
 					NULL, NULL, NULL);
 
 	for (entry = l_queue_get_entries(netconfig->routes.added); entry;
 			entry = entry->next)
-		l_rtnl_route_add(rtnl, netconfig->ifindex, entry->data,
+		l_rtnl_route_add(l_rtnl_get(&netconfig->rtnl),
+					netconfig->ifindex, entry->data,
 					NULL, NULL, NULL);
 
 	/* We can use l_rtnl_route_add here since that uses NLM_F_REPLACE */
 	for (entry = l_queue_get_entries(netconfig->routes.updated); entry;
 			entry = entry->next)
-		l_rtnl_route_add(rtnl, netconfig->ifindex, entry->data,
+		l_rtnl_route_add(l_rtnl_get(&netconfig->rtnl),
+					netconfig->ifindex, entry->data,
 					NULL, NULL, NULL);
 }
 
diff --git a/ell/netconfig.h b/ell/netconfig.h
index 7796a2f..fddbac1 100644
--- a/ell/netconfig.h
+++ b/ell/netconfig.h
@@ -85,8 +85,7 @@ void l_netconfig_set_event_handler(struct l_netconfig *netconfig,
 					void *user_data,
 					l_netconfig_destroy_cb_t destroy);
 
-void l_netconfig_apply_rtnl(struct l_netconfig *netconfig,
-				struct l_netlink *rtnl);
+void l_netconfig_apply_rtnl(struct l_netconfig *netconfig);
 const struct l_queue_entry *l_netconfig_get_addresses(
 				struct l_netconfig *netconfig,
 				const struct l_queue_entry **out_added,
-- 
2.32.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-20 15:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 15:43 [PATCH 05/15] netconfig: Use an internal rtnl socket for l_netconfig_apply_rtnl Andrew Zaborowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.