From: Andrew Zaborowski <andrew.zaborowski at intel.com>
To: ell at lists.01.org
Subject: [PATCH 07/17] netconfig: Use an internal rtnl socket for l_netconfig_apply_rtnl
Date: Fri, 13 May 2022 16:55:00 +0200 [thread overview]
Message-ID: <20220513145510.1408510-7-andrew.zaborowski@intel.com> (raw)
In-Reply-To: 20220513145510.1408510-1-andrew.zaborowski@intel.com
[-- Attachment #1: Type: text/plain, Size: 4246 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 | 34 ++++++++++++++++++++--------------
ell/netconfig.h | 3 +--
2 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/ell/netconfig.c b/ell/netconfig.c
index aee56a2..724cb38 100644
--- a/ell/netconfig.c
+++ b/ell/netconfig.c
@@ -63,6 +63,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;
@@ -725,8 +726,13 @@ static void netconfig_icmp6_event_handler(struct l_icmp6_client *client,
LIB_EXPORT struct l_netconfig *l_netconfig_new(uint32_t ifindex)
{
struct l_netconfig *nc;
+ struct l_netlink *rtnl = l_netlink_new(NETLINK_ROUTE);
+
+ if (!rtnl)
+ return NULL;
nc = l_new(struct l_netconfig, 1);
+ nc->rtnl = rtnl;
nc->ifindex = ifindex;
nc->v4_enabled = true;
@@ -784,6 +790,7 @@ LIB_EXPORT void l_netconfig_destroy(struct l_netconfig *netconfig)
l_queue_destroy(netconfig->routes.added, NULL);
l_queue_destroy(netconfig->routes.updated, NULL);
l_queue_destroy(netconfig->routes.removed, NULL);
+ l_netlink_destroy(netconfig->rtnl);
l_free(netconfig);
}
@@ -1188,42 +1195,41 @@ 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,
- NULL, NULL, NULL);
+ l_rtnl_ifaddr_delete(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,
- NULL, NULL, NULL);
+ l_rtnl_ifaddr_add(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,
- NULL, NULL, NULL);
+ l_rtnl_ifaddr_add(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,
- NULL, NULL, NULL);
+ l_rtnl_route_delete(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,
- NULL, NULL, NULL);
+ l_rtnl_route_add(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,
- NULL, NULL, NULL);
+ l_rtnl_route_add(netconfig->rtnl, netconfig->ifindex,
+ entry->data, NULL, NULL, NULL);
}
LIB_EXPORT const struct l_queue_entry *l_netconfig_get_addresses(
diff --git a/ell/netconfig.h b/ell/netconfig.h
index d58dda1..874491f 100644
--- a/ell/netconfig.h
+++ b/ell/netconfig.h
@@ -81,8 +81,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
next reply other threads:[~2022-05-13 14:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 14:55 Andrew Zaborowski [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-05-13 22:47 [PATCH 07/17] netconfig: Use an internal rtnl socket for l_netconfig_apply_rtnl Andrew Zaborowski
2022-05-18 18:58 Denis Kenzior
2022-05-19 11:52 Andrew Zaborowski
2022-05-19 20:28 Denis Kenzior
2022-05-19 20:53 Andrew Zaborowski
2022-05-19 21:28 Denis Kenzior
2022-05-19 21:38 Andrew Zaborowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220513145510.1408510-7-andrew.zaborowski@intel.com \
--to=ell@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).