1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-10 05:18:17 +03:00

network: drop detailed log messages

This also renames netlink message `req` -> `m` for preparation of later
commits.

Follow-ups for #22014.
This commit is contained in:
Yu Watanabe 2022-02-24 10:48:53 +09:00
parent cae162a79c
commit a79a8d16d5
10 changed files with 226 additions and 193 deletions

View File

@ -96,7 +96,7 @@ static int address_label_configure_handler(sd_netlink *rtnl, sd_netlink_message
}
static int address_label_configure(AddressLabel *label, Link *link, link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
assert(label);
@ -106,31 +106,30 @@ static int address_label_configure(AddressLabel *label, Link *link, link_netlink
assert(link->manager->rtnl);
assert(callback);
r = sd_rtnl_message_new_addrlabel(link->manager->rtnl, &req, RTM_NEWADDRLABEL,
r = sd_rtnl_message_new_addrlabel(link->manager->rtnl, &m, RTM_NEWADDRLABEL,
link->ifindex, AF_INET6);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate RTM_NEWADDR message: %m");
return r;
r = sd_rtnl_message_addrlabel_set_prefixlen(req, label->prefixlen);
r = sd_rtnl_message_addrlabel_set_prefixlen(m, label->prefixlen);
if (r < 0)
return log_link_error_errno(link, r, "Could not set prefixlen: %m");
return r;
r = sd_netlink_message_append_u32(req, IFAL_LABEL, label->label);
r = sd_netlink_message_append_u32(m, IFAL_LABEL, label->label);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFAL_LABEL attribute: %m");
return r;
r = sd_netlink_message_append_in6_addr(req, IFA_ADDRESS, &label->prefix);
r = sd_netlink_message_append_in6_addr(m, IFA_ADDRESS, &label->prefix);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_ADDRESS attribute: %m");
return r;
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
return r;
link_ref(link);
return 1;
return 0;
}
int link_request_static_address_labels(Link *link) {
@ -161,15 +160,23 @@ int link_request_static_address_labels(Link *link) {
}
int request_process_address_label(Request *req) {
Link *link;
int r;
assert(req);
assert(req->link);
assert(req->label);
assert(req->type == REQUEST_TYPE_ADDRESS_LABEL);
if (!link_is_ready_to_configure(req->link, false))
link = ASSERT_PTR(req->link);
if (!link_is_ready_to_configure(link, false))
return 0;
return address_label_configure(req->label, req->link, req->netlink_handler);
r = address_label_configure(req->label, link, req->netlink_handler);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to configure address label: %m");
return 1;
}
static int address_label_section_verify(AddressLabel *label) {

View File

@ -656,36 +656,36 @@ static void log_address_debug(const Address *address, const char *str, const Lin
strna(flags_str), strna(scope_str));
}
static int address_set_netlink_message(const Address *address, sd_netlink_message *req, Link *link) {
static int address_set_netlink_message(const Address *address, sd_netlink_message *m, Link *link) {
uint32_t flags;
int r;
assert(address);
assert(req);
assert(m);
assert(link);
r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen);
r = sd_rtnl_message_addr_set_prefixlen(m, address->prefixlen);
if (r < 0)
return log_link_error_errno(link, r, "Could not set prefixlen: %m");
return r;
/* On remove, only IFA_F_MANAGETEMPADDR flag for IPv6 addresses are used. But anyway, set all
* flags except tentative flag here unconditionally. Without setting the flag, the template
* addresses generated by kernel will not be removed automatically when the main address is
* removed. */
flags = address->flags & ~IFA_F_TENTATIVE;
r = sd_rtnl_message_addr_set_flags(req, flags & 0xff);
r = sd_rtnl_message_addr_set_flags(m, flags & 0xff);
if (r < 0)
return log_link_error_errno(link, r, "Could not set flags: %m");
return r;
if ((flags & ~0xff) != 0) {
r = sd_netlink_message_append_u32(req, IFA_FLAGS, flags);
r = sd_netlink_message_append_u32(m, IFA_FLAGS, flags);
if (r < 0)
return log_link_error_errno(link, r, "Could not set extended flags: %m");
return r;
}
r = netlink_message_append_in_addr_union(req, IFA_LOCAL, address->family, &address->in_addr);
r = netlink_message_append_in_addr_union(m, IFA_LOCAL, address->family, &address->in_addr);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_LOCAL attribute: %m");
return r;
return 0;
}
@ -707,7 +707,7 @@ static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link
}
int address_remove(Address *address) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
Link *link;
int r;
@ -722,20 +722,20 @@ int address_remove(Address *address) {
log_address_debug(address, "Removing", link);
r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_DELADDR,
r = sd_rtnl_message_new_addr(link->manager->rtnl, &m, RTM_DELADDR,
link->ifindex, address->family);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate RTM_DELADDR message: %m");
return log_link_warning_errno(link, r, "Could not allocate RTM_DELADDR message: %m");
r = address_set_netlink_message(address, req, link);
r = address_set_netlink_message(address, m, link);
if (r < 0)
return r;
return log_link_warning_errno(link, r, "Could not set netlink attributes: %m");
r = netlink_call_async(link->manager->rtnl, NULL, req,
r = netlink_call_async(link->manager->rtnl, NULL, m,
address_remove_handler,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
return log_link_warning_errno(link, r, "Could not send rtnetlink message: %m");
link_ref(link);
@ -1025,7 +1025,7 @@ static int address_configure(
Link *link,
link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
assert(address);
@ -1038,47 +1038,46 @@ static int address_configure(
log_address_debug(address, "Configuring", link);
r = sd_rtnl_message_new_addr_update(link->manager->rtnl, &req,
link->ifindex, address->family);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate RTM_NEWADDR message: %m");
r = address_set_netlink_message(address, req, link);
r = sd_rtnl_message_new_addr_update(link->manager->rtnl, &m, link->ifindex, address->family);
if (r < 0)
return r;
r = sd_rtnl_message_addr_set_scope(req, address->scope);
r = address_set_netlink_message(address, m, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not set scope: %m");
return r;
r = sd_rtnl_message_addr_set_scope(m, address->scope);
if (r < 0)
return r;
if (in_addr_is_set(address->family, &address->in_addr_peer)) {
r = netlink_message_append_in_addr_union(req, IFA_ADDRESS, address->family, &address->in_addr_peer);
r = netlink_message_append_in_addr_union(m, IFA_ADDRESS, address->family, &address->in_addr_peer);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_ADDRESS attribute: %m");
return r;
} else if (in4_addr_is_set(&address->broadcast)) {
r = sd_netlink_message_append_in_addr(req, IFA_BROADCAST, &address->broadcast);
r = sd_netlink_message_append_in_addr(m, IFA_BROADCAST, &address->broadcast);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_BROADCAST attribute: %m");
return r;
}
if (address->family == AF_INET && address->label) {
r = sd_netlink_message_append_string(req, IFA_LABEL, address->label);
r = sd_netlink_message_append_string(m, IFA_LABEL, address->label);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_LABEL attribute: %m");
return r;
}
r = sd_netlink_message_append_cache_info(req, IFA_CACHEINFO,
r = sd_netlink_message_append_cache_info(m, IFA_CACHEINFO,
address_set_cinfo(address, &(struct ifa_cacheinfo) {}));
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_CACHEINFO attribute: %m");
return r;
r = sd_netlink_message_append_u32(req, IFA_RT_PRIORITY, address->route_metric);
r = sd_netlink_message_append_u32(m, IFA_RT_PRIORITY, address->route_metric);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFA_RT_PRIORITY attribute: %m");
return r;
r = netlink_call_async(link->manager->rtnl, NULL, req, callback, link_netlink_destroy_callback, link);
r = netlink_call_async(link->manager->rtnl, NULL, m, callback, link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
return r;
link_ref(link);
return 0;

View File

@ -168,6 +168,32 @@ static int bridge_fdb_configure_message(const BridgeFDB *fdb, Link *link, sd_net
return 0;
}
static int bridge_fdb_configure(BridgeFDB *fdb, Link *link, link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
assert(fdb);
assert(link);
assert(link->manager);
assert(callback);
r = sd_rtnl_message_new_neigh(link->manager->rtnl, &m, RTM_NEWNEIGH, link->ifindex, AF_BRIDGE);
if (r < 0)
return r;
r = bridge_fdb_configure_message(fdb, link, m);
if (r < 0)
return r;
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return r;
link_ref(link);
return 0;
}
int link_request_static_bridge_fdb(Link *link) {
BridgeFDB *fdb;
int r;
@ -221,34 +247,21 @@ static bool bridge_fdb_is_ready_to_configure(BridgeFDB *fdb, Link *link) {
}
int request_process_bridge_fdb(Request *req) {
BridgeFDB *fdb;
Link *link;
int r;
assert(req);
assert(req->fdb);
assert(req->type == REQUEST_TYPE_BRIDGE_FDB);
assert_se(link = req->link);
assert_se(fdb = req->fdb);
if (!bridge_fdb_is_ready_to_configure(req->fdb, link))
if (!bridge_fdb_is_ready_to_configure(fdb, link))
return 0;
/* create new RTM message */
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
r = sd_rtnl_message_new_neigh(link->manager->rtnl, &m, RTM_NEWNEIGH, link->ifindex, AF_BRIDGE);
r = bridge_fdb_configure(fdb, link, req->netlink_handler);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate netlink message: %m");
r = bridge_fdb_configure_message(req->fdb, link, m);
if (r < 0)
return log_link_error_errno(link, r, "Could not create netlink message: %m");
/* send message to the kernel to update its internal static MAC table. */
r = netlink_call_async(link->manager->rtnl, NULL, m, req->netlink_handler,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send netlink message: %m");
link_ref(link);
return log_link_warning_errno(link, r, "Failed to configure bridge FDB: %m");
return 1;
}

View File

@ -115,7 +115,7 @@ static int bridge_mdb_configure_handler(sd_netlink *rtnl, sd_netlink_message *m,
/* send a request to the kernel to add an MDB entry */
static int bridge_mdb_configure(BridgeMDB *mdb, Link *link, link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
struct br_mdb_entry entry;
int r;
@ -156,24 +156,22 @@ static int bridge_mdb_configure(BridgeMDB *mdb, Link *link, link_netlink_message
assert_not_reached();
}
/* create new RTM message */
r = sd_rtnl_message_new_mdb(link->manager->rtnl, &req, RTM_NEWMDB,
r = sd_rtnl_message_new_mdb(link->manager->rtnl, &m, RTM_NEWMDB,
link->master_ifindex > 0 ? link->master_ifindex : link->ifindex);
if (r < 0)
return log_link_error_errno(link, r, "Could not create RTM_NEWMDB message: %m");
return r;
r = sd_netlink_message_append_data(req, MDBA_SET_ENTRY, &entry, sizeof(entry));
r = sd_netlink_message_append_data(m, MDBA_SET_ENTRY, &entry, sizeof(entry));
if (r < 0)
return log_link_error_errno(link, r, "Could not append MDBA_SET_ENTRY attribute: %m");
return r;
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
return r;
link_ref(link);
return 1;
return 0;
}
int link_request_static_bridge_mdb(Link *link) {
@ -241,15 +239,22 @@ static bool bridge_mdb_is_ready_to_configure(Link *link) {
}
int request_process_bridge_mdb(Request *req) {
Link *link;
int r;
assert(req);
assert(req->link);
assert(req->mdb);
assert(req->type == REQUEST_TYPE_BRIDGE_MDB);
assert_se(link = req->link);
if (!bridge_mdb_is_ready_to_configure(req->link))
if (!bridge_mdb_is_ready_to_configure(link))
return 0;
return bridge_mdb_configure(req->mdb, req->link, req->netlink_handler);
r = bridge_mdb_configure(req->mdb, link, req->netlink_handler);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to configure bridge MDB: %m");
return 1;
}
static int bridge_mdb_verify(BridgeMDB *mdb) {

View File

@ -53,7 +53,7 @@ static int ipv6_proxy_ndp_address_configure(
Link *link,
link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
assert(address);
@ -63,26 +63,25 @@ static int ipv6_proxy_ndp_address_configure(
assert(callback);
/* create new netlink message */
r = sd_rtnl_message_new_neigh(link->manager->rtnl, &req, RTM_NEWNEIGH, link->ifindex, AF_INET6);
r = sd_rtnl_message_new_neigh(link->manager->rtnl, &m, RTM_NEWNEIGH, link->ifindex, AF_INET6);
if (r < 0)
return log_link_error_errno(link, r, "Could not create RTM_NEWNEIGH message: %m");
return r;
r = sd_rtnl_message_neigh_set_flags(req, NTF_PROXY);
r = sd_rtnl_message_neigh_set_flags(m, NTF_PROXY);
if (r < 0)
return log_link_error_errno(link, r, "Could not set neighbor flags: %m");
return r;
r = sd_netlink_message_append_in6_addr(req, NDA_DST, address);
r = sd_netlink_message_append_in6_addr(m, NDA_DST, address);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NDA_DST attribute: %m");
return r;
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
return r;
link_ref(link);
return 1;
return 0;
}
int link_request_static_ipv6_proxy_ndp_addresses(Link *link) {
@ -114,15 +113,22 @@ int link_request_static_ipv6_proxy_ndp_addresses(Link *link) {
}
int request_process_ipv6_proxy_ndp_address(Request *req) {
Link *link;
int r;
assert(req);
assert(req->link);
assert(req->ipv6_proxy_ndp);
assert(req->type == REQUEST_TYPE_IPV6_PROXY_NDP);
assert_se(link = req->link);
if (!link_is_ready_to_configure(req->link, false))
if (!link_is_ready_to_configure(link, false))
return 0;
return ipv6_proxy_ndp_address_configure(req->ipv6_proxy_ndp, req->link, req->netlink_handler);
r = ipv6_proxy_ndp_address_configure(req->ipv6_proxy_ndp, link, req->netlink_handler);
if (r < 0)
return log_link_warning_errno(link, r, "Failed to configure IPv6 proxy NDP address: %m");
return 1;
}
int config_parse_ipv6_proxy_ndp_address(

View File

@ -198,7 +198,7 @@ static int neighbor_configure(
Link *link,
link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
assert(neighbor);
@ -210,24 +210,23 @@ static int neighbor_configure(
log_neighbor_debug(neighbor, "Configuring", link);
r = sd_rtnl_message_new_neigh(link->manager->rtnl, &req, RTM_NEWNEIGH,
r = sd_rtnl_message_new_neigh(link->manager->rtnl, &m, RTM_NEWNEIGH,
link->ifindex, neighbor->family);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate netlink message: %m");
return r;
r = neighbor_configure_message(neighbor, link, req);
r = neighbor_configure_message(neighbor, link, m);
if (r < 0)
return log_link_error_errno(link, r, "Could not create netlink message: %m");
return r;
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send netlink message: %m");
return r;
link_ref(link);
neighbor_enter_configuring(neighbor);
return r;
return 0;
}
static int static_neighbor_configure_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
@ -449,20 +448,24 @@ void link_foreignize_neighbors(Link *link) {
}
int request_process_neighbor(Request *req) {
Neighbor *neighbor;
Link *link;
int r;
assert(req);
assert(req->link);
assert(req->neighbor);
assert(req->type == REQUEST_TYPE_NEIGHBOR);
if (!link_is_ready_to_configure(req->link, false))
neighbor = ASSERT_PTR(req->neighbor);
link = ASSERT_PTR(req->link);
if (!link_is_ready_to_configure(link, false))
return 0;
r = neighbor_configure(req->neighbor, req->link, req->netlink_handler);
r = neighbor_configure(neighbor, link, req->netlink_handler);
if (r < 0)
return r;
return log_link_warning_errno(link, r, "Failed to configure neighbor: %m");
neighbor_enter_configuring(neighbor);
return 1;
}

View File

@ -430,7 +430,7 @@ static int nexthop_configure(
Link *link,
link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
assert(link);
@ -442,16 +442,14 @@ static int nexthop_configure(
log_nexthop_debug(nexthop, "Configuring", link);
r = sd_rtnl_message_new_nexthop(link->manager->rtnl, &req,
RTM_NEWNEXTHOP, nexthop->family,
nexthop->protocol);
r = sd_rtnl_message_new_nexthop(link->manager->rtnl, &m, RTM_NEWNEXTHOP, nexthop->family, nexthop->protocol);
if (r < 0)
return log_link_error_errno(link, r, "Could not create RTM_NEWNEXTHOP message: %m");
return r;
if (nexthop->id > 0) {
r = sd_netlink_message_append_u32(req, NHA_ID, nexthop->id);
r = sd_netlink_message_append_u32(m, NHA_ID, nexthop->id);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NHA_ID attribute: %m");
return r;
}
if (!hashmap_isempty(nexthop->group)) {
@ -466,38 +464,36 @@ static int nexthop_configure(
HASHMAP_FOREACH(nhg, nexthop->group)
*p++ = *nhg;
r = sd_netlink_message_append_data(req, NHA_GROUP, group, sizeof(struct nexthop_grp) * hashmap_size(nexthop->group));
r = sd_netlink_message_append_data(m, NHA_GROUP, group, sizeof(struct nexthop_grp) * hashmap_size(nexthop->group));
if (r < 0)
return log_link_error_errno(link, r, "Could not append NHA_GROUP attribute: %m");
return r;
} else if (nexthop->blackhole) {
r = sd_netlink_message_append_flag(req, NHA_BLACKHOLE);
r = sd_netlink_message_append_flag(m, NHA_BLACKHOLE);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NHA_BLACKHOLE attribute: %m");
return r;
} else {
r = sd_netlink_message_append_u32(req, NHA_OIF, link->ifindex);
r = sd_netlink_message_append_u32(m, NHA_OIF, link->ifindex);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NHA_OIF attribute: %m");
return r;
if (in_addr_is_set(nexthop->family, &nexthop->gw)) {
r = netlink_message_append_in_addr_union(req, NHA_GATEWAY, nexthop->family, &nexthop->gw);
r = netlink_message_append_in_addr_union(m, NHA_GATEWAY, nexthop->family, &nexthop->gw);
if (r < 0)
return log_link_error_errno(link, r, "Could not append NHA_GATEWAY attribute: %m");
return r;
r = sd_rtnl_message_nexthop_set_flags(req, nexthop->flags & RTNH_F_ONLINK);
r = sd_rtnl_message_nexthop_set_flags(m, nexthop->flags & RTNH_F_ONLINK);
if (r < 0)
return log_link_error_errno(link, r, "Failed to set nexthop flags: %m");
return r;
}
}
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
return r;
link_ref(link);
nexthop_enter_configuring(nexthop);
return 0;
}
@ -808,20 +804,24 @@ static bool nexthop_is_ready_to_configure(Link *link, const NextHop *nexthop) {
}
int request_process_nexthop(Request *req) {
NextHop *nexthop;
Link *link;
int r;
assert(req);
assert(req->link);
assert(req->nexthop);
assert(req->type == REQUEST_TYPE_NEXTHOP);
if (!nexthop_is_ready_to_configure(req->link, req->nexthop))
nexthop = ASSERT_PTR(req->nexthop);
link = ASSERT_PTR(req->link);
if (!nexthop_is_ready_to_configure(link, nexthop))
return 0;
r = nexthop_configure(req->nexthop, req->link, req->netlink_handler);
r = nexthop_configure(nexthop, link, req->netlink_handler);
if (r < 0)
return r;
return log_link_warning_errno(link, r, "Failed to configure nexthop");
nexthop_enter_configuring(nexthop);
return 1;
}

View File

@ -1166,7 +1166,7 @@ static int route_configure(
Link *link,
link_netlink_message_handler_t callback) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
int r;
assert(route);
@ -1179,90 +1179,88 @@ static int route_configure(
log_route_debug(route, "Configuring", link, link->manager);
r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
RTM_NEWROUTE, route->family,
route->protocol);
r = sd_rtnl_message_new_route(link->manager->rtnl, &m, RTM_NEWROUTE, route->family, route->protocol);
if (r < 0)
return log_link_error_errno(link, r, "Could not create netlink message: %m");
return r;
r = sd_rtnl_message_route_set_type(req, route->type);
r = sd_rtnl_message_route_set_type(m, route->type);
if (r < 0)
return log_link_error_errno(link, r, "Could not set route type: %m");
return r;
r = route_set_netlink_message(route, req, link);
r = route_set_netlink_message(route, m, link);
if (r < 0)
return log_error_errno(r, "Could not fill netlink message: %m");
return r;
if (route->lifetime_usec != USEC_INFINITY) {
r = sd_netlink_message_append_u32(req, RTA_EXPIRES,
r = sd_netlink_message_append_u32(m, RTA_EXPIRES,
MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime_usec, now(clock_boottime_or_monotonic())), USEC_PER_SEC), UINT32_MAX));
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_EXPIRES attribute: %m");
return r;
}
if (route->ttl_propagate >= 0) {
r = sd_netlink_message_append_u8(req, RTA_TTL_PROPAGATE, route->ttl_propagate);
r = sd_netlink_message_append_u8(m, RTA_TTL_PROPAGATE, route->ttl_propagate);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_TTL_PROPAGATE attribute: %m");
return r;
}
r = sd_netlink_message_open_container(req, RTA_METRICS);
r = sd_netlink_message_open_container(m, RTA_METRICS);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_METRICS attribute: %m");
return r;
if (route->mtu > 0) {
r = sd_netlink_message_append_u32(req, RTAX_MTU, route->mtu);
r = sd_netlink_message_append_u32(m, RTAX_MTU, route->mtu);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_MTU attribute: %m");
return r;
}
if (route->initcwnd > 0) {
r = sd_netlink_message_append_u32(req, RTAX_INITCWND, route->initcwnd);
r = sd_netlink_message_append_u32(m, RTAX_INITCWND, route->initcwnd);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_INITCWND attribute: %m");
return r;
}
if (route->initrwnd > 0) {
r = sd_netlink_message_append_u32(req, RTAX_INITRWND, route->initrwnd);
r = sd_netlink_message_append_u32(m, RTAX_INITRWND, route->initrwnd);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_INITRWND attribute: %m");
return r;
}
if (route->quickack >= 0) {
r = sd_netlink_message_append_u32(req, RTAX_QUICKACK, route->quickack);
r = sd_netlink_message_append_u32(m, RTAX_QUICKACK, route->quickack);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_QUICKACK attribute: %m");
return r;
}
if (route->fast_open_no_cookie >= 0) {
r = sd_netlink_message_append_u32(req, RTAX_FASTOPEN_NO_COOKIE, route->fast_open_no_cookie);
r = sd_netlink_message_append_u32(m, RTAX_FASTOPEN_NO_COOKIE, route->fast_open_no_cookie);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_FASTOPEN_NO_COOKIE attribute: %m");
return r;
}
if (route->advmss > 0) {
r = sd_netlink_message_append_u32(req, RTAX_ADVMSS, route->advmss);
r = sd_netlink_message_append_u32(m, RTAX_ADVMSS, route->advmss);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTAX_ADVMSS attribute: %m");
return r;
}
r = sd_netlink_message_close_container(req);
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_METRICS attribute: %m");
return r;
if (!ordered_set_isempty(route->multipath_routes)) {
assert(route->nexthop_id == 0);
assert(!in_addr_is_set(route->gw_family, &route->gw));
r = append_nexthops(link, route, req);
r = append_nexthops(link, route, m);
if (r < 0)
return log_link_error_errno(link, r, "Could not append RTA_MULTIPATH attribute: %m");
return r;
}
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send rtnetlink message: %m");
return r;
link_ref(link);
return 0;

View File

@ -588,17 +588,17 @@ static int routing_policy_rule_remove(RoutingPolicyRule *rule) {
r = sd_rtnl_message_new_routing_policy_rule(rule->manager->rtnl, &m, RTM_DELRULE, rule->family);
if (r < 0)
return log_error_errno(r, "Could not allocate netlink message: %m");
return log_warning_errno(r, "Could not allocate netlink message: %m");
r = routing_policy_rule_set_netlink_message(rule, m, NULL);
if (r < 0)
return log_error_errno(r, "Could not create netlink message: %m");
return log_warning_errno(r, "Could not create netlink message: %m");
r = netlink_call_async(rule->manager->rtnl, NULL, m,
routing_policy_rule_remove_handler,
NULL, NULL);
if (r < 0)
return log_error_errno(r, "Could not send netlink message: %m");
return log_warning_errno(r, "Could not send netlink message: %m");
routing_policy_rule_enter_removing(rule);
return 0;
@ -624,21 +624,19 @@ static int routing_policy_rule_configure(
r = sd_rtnl_message_new_routing_policy_rule(link->manager->rtnl, &m, RTM_NEWRULE, rule->family);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate netlink message: %m");
return r;
r = routing_policy_rule_set_netlink_message(rule, m, link);
if (r < 0)
return log_error_errno(r, "Could not create netlink message: %m");
return r;
r = netlink_call_async(link->manager->rtnl, NULL, m, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_error_errno(link, r, "Could not send netlink message: %m");
return r;
link_ref(link);
routing_policy_rule_enter_configuring(rule);
return r;
return 0;
}
static void manager_mark_routing_policy_rules(Manager *m, bool foreign, const Link *except) {
@ -859,20 +857,24 @@ int link_request_static_routing_policy_rules(Link *link) {
}
int request_process_routing_policy_rule(Request *req) {
RoutingPolicyRule *rule;
Link *link;
int r;
assert(req);
assert(req->link);
assert(req->rule);
assert(req->type == REQUEST_TYPE_ROUTING_POLICY_RULE);
if (!link_is_ready_to_configure(req->link, false))
link = ASSERT_PTR(req->link);
rule = ASSERT_PTR(req->rule);
if (!link_is_ready_to_configure(link, false))
return 0;
r = routing_policy_rule_configure(req->rule, req->link, req->netlink_handler);
r = routing_policy_rule_configure(rule, link, req->netlink_handler);
if (r < 0)
return r;
return log_link_warning_errno(link, r, "Failed to configure routing policy rule: %m");
routing_policy_rule_enter_configuring(rule);
return 1;
}

View File

@ -1068,16 +1068,16 @@ static int link_up_or_down(Link *link, bool up, link_netlink_message_handler_t c
r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
if (r < 0)
return log_link_debug_errno(link, r, "Could not allocate RTM_SETLINK message: %m");
return r;
r = sd_rtnl_message_link_set_flags(req, up ? IFF_UP : 0, IFF_UP);
if (r < 0)
return log_link_debug_errno(link, r, "Could not set link flags: %m");
return r;
r = netlink_call_async(link->manager->rtnl, NULL, req, callback,
link_netlink_destroy_callback, link);
if (r < 0)
return log_link_debug_errno(link, r, "Could not send rtnetlink message: %m");
return r;
link_ref(link);
@ -1114,7 +1114,7 @@ int request_process_activation(Request *req) {
r = link_up_or_down(link, up, req->netlink_handler);
if (r < 0)
return log_link_error_errno(link, r, "Failed to bring %s: %m", up_or_down(up));
return log_link_warning_errno(link, r, "Failed to activate link: %m");
return 1;
}
@ -1209,7 +1209,7 @@ int request_process_link_up_or_down(Request *req) {
r = link_up_or_down(link, up, req->netlink_handler);
if (r < 0)
return log_link_error_errno(link, r, "Failed to bring %s: %m", up_or_down(up));
return log_link_warning_errno(link, r, "Failed to bring link %s: %m", up_or_down(up));
return 1;
}
@ -1223,8 +1223,8 @@ int link_request_to_bring_up_or_down(Link *link, bool up) {
r = link_queue_request(link, REQUEST_TYPE_UP_DOWN, NULL, false, &link->set_flags_messages,
up ? link_up_handler : link_down_handler, &req);
if (r < 0)
return log_link_error_errno(link, r, "Failed to request to bring %s link: %m",
up_or_down(up));
return log_link_warning_errno(link, r, "Failed to request to bring link %s: %m",
up_or_down(up));
req->userdata = INT_TO_PTR(up);