network: use typesafe netlink_call_async() macro where applicable
This commit is contained in:
parent
10ff4eb621
commit
302a796f5a
|
@ -9,8 +9,7 @@
|
|||
#include "vlan-util.h"
|
||||
|
||||
/* callback for brige netdev's parameter set */
|
||||
static int netdev_bridge_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
NetDev *netdev = userdata;
|
||||
static int netdev_bridge_set_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) {
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
|
@ -129,8 +128,8 @@ static int netdev_bridge_post_create(NetDev *netdev, Link *link, sd_netlink_mess
|
|||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_INFO_DATA attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(netdev->manager->rtnl, NULL, req, netdev_bridge_set_handler,
|
||||
netdev_destroy_callback, netdev, 0, __func__);
|
||||
r = netlink_call_async(netdev->manager->rtnl, NULL, req, netdev_bridge_set_handler,
|
||||
netdev_destroy_callback, netdev);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
#include <net/if.h>
|
||||
|
||||
#include "sd-netlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "conf-parser.h"
|
||||
#include "extract-word.h"
|
||||
#include "geneve.h"
|
||||
#include "netlink-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "sd-netlink.h"
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "missing.h"
|
||||
|
@ -17,8 +19,7 @@
|
|||
#define DEFAULT_GENEVE_DESTINATION_PORT 6081
|
||||
|
||||
/* callback for geneve netdev's created without a backing Link */
|
||||
static int geneve_netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
NetDev *netdev = userdata;
|
||||
static int geneve_netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) {
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
|
@ -136,8 +137,8 @@ static int netdev_geneve_create(NetDev *netdev) {
|
|||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(netdev->manager->rtnl, NULL, m, geneve_netdev_create_handler,
|
||||
netdev_destroy_callback, netdev, 0, __func__);
|
||||
r = netlink_call_async(netdev->manager->rtnl, NULL, m, geneve_netdev_create_handler,
|
||||
netdev_destroy_callback, netdev);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -191,14 +191,6 @@ static NetDev *netdev_free(NetDev *netdev) {
|
|||
|
||||
DEFINE_TRIVIAL_REF_UNREF_FUNC(NetDev, netdev, netdev_free);
|
||||
|
||||
void netdev_destroy_callback(void *userdata) {
|
||||
NetDev *netdev = userdata;
|
||||
|
||||
assert(userdata);
|
||||
|
||||
netdev_unref(netdev);
|
||||
}
|
||||
|
||||
void netdev_drop(NetDev *netdev) {
|
||||
if (!netdev || netdev->state == NETDEV_STATE_LINGER)
|
||||
return;
|
||||
|
@ -242,7 +234,7 @@ static int netdev_enter_failed(NetDev *netdev) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_netlink_message_handler_t callback) {
|
||||
static int netdev_enslave_ready(NetDev *netdev, Link* link, link_netlink_message_handler_t callback) {
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
int r;
|
||||
|
||||
|
@ -269,8 +261,8 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_netlink_message_h
|
|||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_MASTER attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(netdev->manager->rtnl, NULL, req, callback,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(netdev->manager->rtnl, NULL, req, callback,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -314,8 +306,7 @@ static int netdev_enter_ready(NetDev *netdev) {
|
|||
}
|
||||
|
||||
/* callback for netdev's created without a backing Link */
|
||||
static int netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
NetDev *netdev = userdata;
|
||||
static int netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, NetDev *netdev) {
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
|
@ -336,7 +327,7 @@ static int netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, void *
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int netdev_enslave(NetDev *netdev, Link *link, sd_netlink_message_handler_t callback) {
|
||||
static int netdev_enslave(NetDev *netdev, Link *link, link_netlink_message_handler_t callback) {
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
|
@ -512,8 +503,7 @@ int netdev_get_mac(const char *ifname, struct ether_addr **ret) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int netdev_create(NetDev *netdev, Link *link,
|
||||
sd_netlink_message_handler_t callback) {
|
||||
static int netdev_create(NetDev *netdev, Link *link, link_netlink_message_handler_t callback) {
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
|
@ -580,15 +570,15 @@ static int netdev_create(NetDev *netdev, Link *link,
|
|||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_LINKINFO attribute: %m");
|
||||
|
||||
if (link) {
|
||||
r = sd_netlink_call_async(netdev->manager->rtnl, NULL, m, callback,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(netdev->manager->rtnl, NULL, m, callback,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
link_ref(link);
|
||||
} else {
|
||||
r = sd_netlink_call_async(netdev->manager->rtnl, NULL, m, netdev_create_handler,
|
||||
netdev_destroy_callback, netdev, 0, __func__);
|
||||
r = netlink_call_async(netdev->manager->rtnl, NULL, m, netdev_create_handler,
|
||||
netdev_destroy_callback, netdev);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -604,7 +594,7 @@ static int netdev_create(NetDev *netdev, Link *link,
|
|||
}
|
||||
|
||||
/* the callback must be called, possibly after a timeout, as otherwise the Link will hang */
|
||||
int netdev_join(NetDev *netdev, Link *link, sd_netlink_message_handler_t callback) {
|
||||
int netdev_join(NetDev *netdev, Link *link, link_netlink_message_handler_t callback) {
|
||||
int r;
|
||||
|
||||
assert(netdev);
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
#include "conf-parser.h"
|
||||
#include "list.h"
|
||||
#include "../networkd-link.h"
|
||||
#include "time-util.h"
|
||||
|
||||
typedef struct netdev_join_callback netdev_join_callback;
|
||||
typedef struct Link Link;
|
||||
|
||||
struct netdev_join_callback {
|
||||
sd_netlink_message_handler_t callback;
|
||||
link_netlink_message_handler_t callback;
|
||||
Link *link;
|
||||
|
||||
LIST_FIELDS(netdev_join_callback, callbacks);
|
||||
|
@ -153,13 +153,13 @@ void netdev_drop(NetDev *netdev);
|
|||
|
||||
NetDev *netdev_unref(NetDev *netdev);
|
||||
NetDev *netdev_ref(NetDev *netdev);
|
||||
void netdev_destroy_callback(void *userdata);
|
||||
DEFINE_TRIVIAL_DESTRUCTOR(netdev_destroy_callback, NetDev, netdev_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
|
||||
|
||||
int netdev_get(Manager *manager, const char *name, NetDev **ret);
|
||||
int netdev_set_ifindex(NetDev *netdev, sd_netlink_message *newlink);
|
||||
int netdev_get_mac(const char *ifname, struct ether_addr **ret);
|
||||
int netdev_join(NetDev *netdev, Link *link, sd_netlink_message_handler_t cb);
|
||||
int netdev_join(NetDev *netdev, Link *link, link_netlink_message_handler_t cb);
|
||||
|
||||
const char *netdev_kind_to_string(NetDevKind d) _const_;
|
||||
NetDevKind netdev_kind_from_string(const char *d) _pure_;
|
||||
|
|
|
@ -300,7 +300,7 @@ static int wireguard_resolve_handler(sd_resolve_query *q,
|
|||
return 0;
|
||||
}
|
||||
|
||||
r = sd_event_source_set_destroy_callback(s, netdev_destroy_callback);
|
||||
r = sd_event_source_set_destroy_callback(s, (sd_event_destroy_t) netdev_destroy_callback);
|
||||
if (r < 0) {
|
||||
log_netdev_warning_errno(netdev, r, "Failed to set destroy callback to event source: %m");
|
||||
return 0;
|
||||
|
|
|
@ -79,8 +79,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int address_label_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int address_label_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(rtnl);
|
||||
|
@ -109,7 +108,7 @@ static int address_label_handler(sd_netlink *rtnl, sd_netlink_message *m, void *
|
|||
int address_label_configure(
|
||||
AddressLabel *label,
|
||||
Link *link,
|
||||
sd_netlink_message_handler_t callback,
|
||||
link_netlink_message_handler_t callback,
|
||||
bool update) {
|
||||
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
|
@ -138,9 +137,9 @@ int address_label_configure(
|
|||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req,
|
||||
callback ?: address_label_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req,
|
||||
callback ?: address_label_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ void address_label_free(AddressLabel *label);
|
|||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(AddressLabel*, address_label_free);
|
||||
|
||||
int address_label_configure(AddressLabel *address, Link *link, sd_netlink_message_handler_t callback, bool update);
|
||||
int address_label_configure(AddressLabel *address, Link *link, link_netlink_message_handler_t callback, bool update);
|
||||
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_address_label);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_address_label_prefix);
|
||||
|
|
|
@ -428,8 +428,7 @@ int address_get(Link *link,
|
|||
return -ENOENT;
|
||||
}
|
||||
|
||||
static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -449,7 +448,7 @@ static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void
|
|||
int address_remove(
|
||||
Address *address,
|
||||
Link *link,
|
||||
sd_netlink_message_handler_t callback) {
|
||||
link_netlink_message_handler_t callback) {
|
||||
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
_cleanup_free_ char *b = NULL;
|
||||
|
@ -483,9 +482,9 @@ int address_remove(
|
|||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req,
|
||||
callback ?: address_remove_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req,
|
||||
callback ?: address_remove_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -558,7 +557,7 @@ static int address_acquire(Link *link, Address *original, Address **ret) {
|
|||
int address_configure(
|
||||
Address *address,
|
||||
Link *link,
|
||||
sd_netlink_message_handler_t callback,
|
||||
link_netlink_message_handler_t callback,
|
||||
bool update) {
|
||||
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
|
@ -664,8 +663,8 @@ int address_configure(
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0) {
|
||||
address_release(address);
|
||||
return log_error_errno(r, "Could not send rtnetlink message: %m");
|
||||
|
|
|
@ -54,8 +54,8 @@ int address_add(Link *link, int family, const union in_addr_union *in_addr, unsi
|
|||
int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
|
||||
int address_update(Address *address, unsigned char flags, unsigned char scope, const struct ifa_cacheinfo *cinfo);
|
||||
int address_drop(Address *address);
|
||||
int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback, bool update);
|
||||
int address_remove(Address *address, Link *link, sd_netlink_message_handler_t callback);
|
||||
int address_configure(Address *address, Link *link, link_netlink_message_handler_t callback, bool update);
|
||||
int address_remove(Address *address, Link *link, link_netlink_message_handler_t callback);
|
||||
bool address_equal(Address *a1, Address *a2);
|
||||
bool address_is_ready(const Address *a);
|
||||
|
||||
|
|
|
@ -135,8 +135,7 @@ static int append_vlan_info_data(Link *const link, sd_netlink_message *req, uint
|
|||
return cnt;
|
||||
}
|
||||
|
||||
static int set_brvlan_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int set_brvlan_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -195,8 +194,8 @@ int br_vlan_configure(Link *link, uint16_t pvid, uint32_t *br_vid_bitmap, uint32
|
|||
return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m");
|
||||
|
||||
/* send message to the kernel */
|
||||
r = sd_netlink_call_async(rtnl, NULL, req, set_brvlan_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(rtnl, NULL, req, set_brvlan_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
#include "string-util.h"
|
||||
#include "sysctl-util.h"
|
||||
|
||||
static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m,
|
||||
void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -300,9 +298,7 @@ static int dhcp_lease_lost(Link *link) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m,
|
||||
void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
|
|
@ -96,8 +96,7 @@ static int dhcp6_pd_prefix_assign(Link *link, struct in6_addr *prefix,
|
|||
return sd_radv_start(radv);
|
||||
}
|
||||
|
||||
static int dhcp6_route_remove_handler(sd_netlink *nl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int dhcp6_route_remove_handler(sd_netlink *nl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -243,8 +242,7 @@ static int dhcp6_pd_prefix_distribute(Link *dhcp6_link, Iterator *i,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dhcp6_route_handler(sd_netlink *nl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int dhcp6_route_handler(sd_netlink *nl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -402,9 +400,7 @@ int dhcp6_request_prefix_delegation(Link *link) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int dhcp6_address_handler(sd_netlink *rtnl, sd_netlink_message *m,
|
||||
void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int dhcp6_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
|
|
@ -87,8 +87,7 @@ int fdb_entry_new_static(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_fdb_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int set_fdb_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -147,8 +146,8 @@ int fdb_entry_configure(Link *link, FdbEntry *fdb_entry) {
|
|||
}
|
||||
|
||||
/* send message to the kernel to update its internal static MAC table. */
|
||||
r = sd_netlink_call_async(rtnl, NULL, req, set_fdb_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(rtnl, NULL, req, set_fdb_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -51,8 +51,7 @@ static int ipv4ll_address_lost(Link *link) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ipv4ll_route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int ipv4ll_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -72,8 +71,7 @@ static int ipv4ll_route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *u
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
|
|
@ -135,8 +135,7 @@ int config_parse_ipv6_proxy_ndp_address(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_ipv6_proxy_ndp_address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int set_ipv6_proxy_ndp_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -174,8 +173,8 @@ int ipv6_proxy_ndp_address_configure(Link *link, IPv6ProxyNDPAddress *ipv6_proxy
|
|||
if (r < 0)
|
||||
return rtnl_log_create_error(r);
|
||||
|
||||
r = sd_netlink_call_async(rtnl, NULL, req, set_ipv6_proxy_ndp_address_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(rtnl, NULL, req, set_ipv6_proxy_ndp_address_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -590,14 +590,6 @@ static Link *link_free(Link *link) {
|
|||
|
||||
DEFINE_TRIVIAL_REF_UNREF_FUNC(Link, link, link_free);
|
||||
|
||||
void link_netlink_destroy_callback(void *userdata) {
|
||||
Link *link = userdata;
|
||||
|
||||
assert(userdata);
|
||||
|
||||
link_unref(link);
|
||||
}
|
||||
|
||||
int link_get(Manager *m, int ifindex, Link **ret) {
|
||||
Link *link;
|
||||
|
||||
|
@ -821,8 +813,7 @@ static int link_set_routing_policy_rule(Link *link) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -892,8 +883,7 @@ static int link_enter_set_routes(Link *link) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(rtnl);
|
||||
|
@ -1222,8 +1212,7 @@ static int link_set_proxy_arp(Link *link) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int link_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int link_set_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -1241,8 +1230,7 @@ static int link_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userd
|
|||
|
||||
static int link_configure_after_setting_mtu(Link *link);
|
||||
|
||||
static int set_mtu_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int set_mtu_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -1303,8 +1291,8 @@ int link_set_mtu(Link *link, uint32_t mtu) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append MTU: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, set_mtu_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, set_mtu_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -1314,8 +1302,7 @@ int link_set_mtu(Link *link, uint32_t mtu) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int set_flags_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int set_flags_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -1374,8 +1361,8 @@ static int link_set_flags(Link *link) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set link flags: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, set_flags_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, set_flags_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -1450,8 +1437,8 @@ static int link_set_bridge(Link *link) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append IFLA_LINKINFO attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_set_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, link_set_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -1503,8 +1490,8 @@ static int link_bond_set(Link *link) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not append IFLA_INFO_DATA attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, set_flags_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, set_flags_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -1703,8 +1690,7 @@ bool link_has_carrier(Link *link) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static int link_up_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int link_up_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -1796,8 +1782,8 @@ int link_up(Link *link) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not close IFLA_AF_SPEC container: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_up_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, link_up_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -1822,8 +1808,8 @@ static int link_up_can(Link *link) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set link flags: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_up_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, link_up_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -1912,8 +1898,8 @@ static int link_set_can(Link *link) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Failed to close netlink container: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, m, link_set_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, m, link_set_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -1932,8 +1918,7 @@ static int link_set_can(Link *link) {
|
|||
return r;
|
||||
}
|
||||
|
||||
static int link_down_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int link_down_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -1970,8 +1955,8 @@ int link_down(Link *link) {
|
|||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not set link flags: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_down_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, link_down_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -2278,8 +2263,7 @@ static int link_joined(Link *link) {
|
|||
return link_enter_set_addresses(link);
|
||||
}
|
||||
|
||||
static int netdev_join_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int netdev_join_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -3102,8 +3086,8 @@ static int link_initialized_and_synced(Link *link) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int link_initialized_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
(void) link_initialized_and_synced(userdata);
|
||||
static int link_initialized_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
(void) link_initialized_and_synced(link);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -3136,8 +3120,8 @@ int link_initialized(Link *link, sd_device *device) {
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, link_initialized_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, link_initialized_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -126,12 +126,14 @@ typedef struct Link {
|
|||
Hashmap *bound_to_links;
|
||||
} Link;
|
||||
|
||||
typedef int (*link_netlink_message_handler_t)(sd_netlink*, sd_netlink_message*, Link*);
|
||||
|
||||
DUID *link_get_duid(Link *link);
|
||||
int get_product_uuid_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error);
|
||||
|
||||
Link *link_unref(Link *link);
|
||||
Link *link_ref(Link *link);
|
||||
void link_netlink_destroy_callback(void *userdata);
|
||||
DEFINE_TRIVIAL_DESTRUCTOR(link_netlink_destroy_callback, Link, link_unref);
|
||||
|
||||
int link_get(Manager *m, int ifindex, Link **ret);
|
||||
int link_add(Manager *manager, sd_netlink_message *message, Link **ret);
|
||||
|
|
|
@ -1237,8 +1237,7 @@ Link *manager_dhcp6_prefix_get(Manager *m, struct in6_addr *addr) {
|
|||
return hashmap_get(m->dhcp6_prefixes, addr);
|
||||
}
|
||||
|
||||
static int dhcp6_route_add_handler(sd_netlink *nl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int dhcp6_route_add_handler(sd_netlink *nl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
@ -1296,8 +1295,7 @@ int manager_dhcp6_prefix_add(Manager *m, struct in6_addr *addr, Link *link) {
|
|||
return hashmap_put(m->dhcp6_prefixes, addr, link);
|
||||
}
|
||||
|
||||
static int dhcp6_route_remove_handler(sd_netlink *nl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int dhcp6_route_remove_handler(sd_netlink *nl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#define NDISC_RDNSS_MAX 64U
|
||||
#define NDISC_PREFIX_LFT_MIN 7200U
|
||||
|
||||
static int ndisc_netlink_message_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int ndisc_netlink_message_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
|
|
|
@ -378,8 +378,7 @@ void route_update(Route *route,
|
|||
route->type = type;
|
||||
}
|
||||
|
||||
static int route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -397,7 +396,7 @@ static int route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *u
|
|||
}
|
||||
|
||||
int route_remove(Route *route, Link *link,
|
||||
sd_netlink_message_handler_t callback) {
|
||||
link_netlink_message_handler_t callback) {
|
||||
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
int r;
|
||||
|
@ -472,9 +471,9 @@ int route_remove(Route *route, Link *link,
|
|||
return log_error_errno(r, "Could not append RTA_OIF attribute: %m");
|
||||
}
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req,
|
||||
callback ?: route_remove_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req,
|
||||
callback ?: route_remove_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -501,7 +500,7 @@ int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
|
|||
int route_configure(
|
||||
Route *route,
|
||||
Link *link,
|
||||
sd_netlink_message_handler_t callback) {
|
||||
link_netlink_message_handler_t callback) {
|
||||
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
|
||||
_cleanup_(sd_event_source_unrefp) sd_event_source *expire = NULL;
|
||||
|
@ -655,8 +654,8 @@ int route_configure(
|
|||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_METRICS attribute: %m");
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, req, callback,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ struct Route {
|
|||
int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret);
|
||||
int route_new(Route **ret);
|
||||
void route_free(Route *route);
|
||||
int route_configure(Route *route, Link *link, sd_netlink_message_handler_t callback);
|
||||
int route_remove(Route *route, Link *link, sd_netlink_message_handler_t callback);
|
||||
int route_configure(Route *route, Link *link, link_netlink_message_handler_t callback);
|
||||
int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback);
|
||||
|
||||
int route_get(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
|
||||
int route_add(Link *link, int family, const union in_addr_union *dst, unsigned char dst_prefixlen, unsigned char tos, uint32_t priority, uint32_t table, Route **ret);
|
||||
|
|
|
@ -341,8 +341,7 @@ int routing_policy_rule_add_foreign(Manager *m,
|
|||
return routing_policy_rule_add_internal(m, &m->rules_foreign, family, from, from_prefixlen, to, to_prefixlen, tos, fwmark, table, iif, oif, protocol, sport, dport, ret);
|
||||
}
|
||||
|
||||
static int routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -361,7 +360,7 @@ static int routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_messa
|
|||
return 1;
|
||||
}
|
||||
|
||||
int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, sd_netlink_message_handler_t callback) {
|
||||
int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback) {
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
||||
int r;
|
||||
|
||||
|
@ -404,9 +403,9 @@ int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *lin
|
|||
return log_error_errno(r, "Could not set destination prefix length: %m");
|
||||
}
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, m,
|
||||
callback ?: routing_policy_rule_remove_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, m,
|
||||
callback ?: routing_policy_rule_remove_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
@ -462,8 +461,7 @@ static int routing_policy_rule_new_static(Network *network, const char *filename
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
Link *link = userdata;
|
||||
static int routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
int r;
|
||||
|
||||
assert(rtnl);
|
||||
|
@ -490,7 +488,7 @@ static int routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m,
|
|||
return 1;
|
||||
}
|
||||
|
||||
int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, sd_netlink_message_handler_t callback, bool update) {
|
||||
int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, link_netlink_message_handler_t callback, bool update) {
|
||||
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
|
||||
int r;
|
||||
|
||||
|
@ -598,9 +596,9 @@ int routing_policy_rule_configure(RoutingPolicyRule *rule, Link *link, sd_netlin
|
|||
|
||||
rule->link = link;
|
||||
|
||||
r = sd_netlink_call_async(link->manager->rtnl, NULL, m,
|
||||
callback ?: routing_policy_rule_handler,
|
||||
link_netlink_destroy_callback, link, 0, __func__);
|
||||
r = netlink_call_async(link->manager->rtnl, NULL, m,
|
||||
callback ?: routing_policy_rule_handler,
|
||||
link_netlink_destroy_callback, link);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not send rtnetlink message: %m");
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ void routing_policy_rule_free(RoutingPolicyRule *rule);
|
|||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free);
|
||||
|
||||
int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, sd_netlink_message_handler_t callback, bool update);
|
||||
int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, sd_netlink_message_handler_t callback);
|
||||
int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, link_netlink_message_handler_t callback, bool update);
|
||||
int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, link_netlink_message_handler_t callback);
|
||||
|
||||
int routing_policy_rule_add(Manager *m, int family, const union in_addr_union *from, uint8_t from_prefixlen, const union in_addr_union *to, uint8_t to_prefixlen,
|
||||
uint8_t tos, uint32_t fwmark, uint32_t table, const char *iif, const char *oif, uint8_t protocol, const struct fib_rule_port_range *sport,
|
||||
|
|
Loading…
Reference in New Issue