diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-01-04 19:16:01 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-01-05 11:36:04 +0100 |
commit | 5b80ecea55c4bce3534ed75abf9cef437850aefb (patch) | |
tree | 14e9b87a651c2dc29eece8b508ed839816446a61 /src/network/netdev/bond.c | |
parent | fuzz: no longer skip empty files (diff) | |
download | systemd-5b80ecea55c4bce3534ed75abf9cef437850aefb.tar.xz systemd-5b80ecea55c4bce3534ed75abf9cef437850aefb.zip |
network: replace detailed netlink append messages with a single generic message
This commit is the first in the series, and they generally follow the same
idea: we had very detailed logging for message append operations which would
only fail either with some type error or intrinsic limit (and then they would
fail everywhere, so this would be noticed during development or in CI), or they
would fail with ENOMEM, in which case the exact location is not very interesting
since this is not repeatable.
I am in general in favour of detailed logging messages, because it helps with
diagnosis of errors, but I think case is an exception. Despite not being very
useful, those messages required a lot of effort, because they were customized
for each and every append operation. In fact some of the messages contained copy
errors. The text of the messages (since they are generally unique) also added up
to a considerable size.
This removes the log messages after each sd_netlink_message_append_*() in
fill_message_create() with a single line in netdev_create(). As described
above, we are just appending fields to a message, so those calls would almost
never fail.
A forgotten 'return' was added in one place.
$ size build/systemd-networkd{.0,}
text data bss dec hex filename
1878634 394016 36 2272686 22adae build/systemd-networkd.0
1842450 394080 36 2236566 222096 build/systemd-networkd
… so we save 30k too.
Diffstat (limited to 'src/network/netdev/bond.c')
-rw-r--r-- | src/network/netdev/bond.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/network/netdev/bond.c b/src/network/netdev/bond.c index 5d94aa1d68..b0af12c8e2 100644 --- a/src/network/netdev/bond.c +++ b/src/network/netdev/bond.c @@ -71,50 +71,50 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin if (b->mode != _NETDEV_BOND_MODE_INVALID) { r = sd_netlink_message_append_u8(m, IFLA_BOND_MODE, b->mode); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MODE attribute: %m"); + return r; } if (b->xmit_hash_policy != _NETDEV_BOND_XMIT_HASH_POLICY_INVALID) { r = sd_netlink_message_append_u8(m, IFLA_BOND_XMIT_HASH_POLICY, b->xmit_hash_policy); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_XMIT_HASH_POLICY attribute: %m"); + return r; } if (b->lacp_rate != _NETDEV_BOND_LACP_RATE_INVALID && b->mode == NETDEV_BOND_MODE_802_3AD) { r = sd_netlink_message_append_u8(m, IFLA_BOND_AD_LACP_RATE, b->lacp_rate); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_LACP_RATE attribute: %m"); + return r; } if (b->miimon != 0) { r = sd_netlink_message_append_u32(m, IFLA_BOND_MIIMON, b->miimon / USEC_PER_MSEC); if (r < 0) - log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_BOND_MIIMON attribute: %m"); + return r; } if (b->downdelay != 0) { r = sd_netlink_message_append_u32(m, IFLA_BOND_DOWNDELAY, b->downdelay / USEC_PER_MSEC); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_DOWNDELAY attribute: %m"); + return r; } if (b->updelay != 0) { r = sd_netlink_message_append_u32(m, IFLA_BOND_UPDELAY, b->updelay / USEC_PER_MSEC); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_UPDELAY attribute: %m"); + return r; } if (b->arp_interval != 0) { r = sd_netlink_message_append_u32(m, IFLA_BOND_ARP_INTERVAL, b->arp_interval / USEC_PER_MSEC); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_INTERVAL attribute: %m"); + return r; if (b->lp_interval >= LEARNING_PACKETS_INTERVAL_MIN_SEC && b->lp_interval <= LEARNING_PACKETS_INTERVAL_MAX_SEC) { r = sd_netlink_message_append_u32(m, IFLA_BOND_LP_INTERVAL, b->lp_interval / USEC_PER_SEC); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_LP_INTERVAL attribute: %m"); + return r; } } @@ -122,85 +122,85 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin b->mode == NETDEV_BOND_MODE_802_3AD) { r = sd_netlink_message_append_u8(m, IFLA_BOND_AD_SELECT, b->ad_select); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_SELECT attribute: %m"); + return r; } if (b->fail_over_mac != _NETDEV_BOND_FAIL_OVER_MAC_INVALID && b->mode == NETDEV_BOND_MODE_ACTIVE_BACKUP) { r = sd_netlink_message_append_u8(m, IFLA_BOND_FAIL_OVER_MAC, b->fail_over_mac); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_FAIL_OVER_MAC attribute: %m"); + return r; } if (b->arp_validate != _NETDEV_BOND_ARP_VALIDATE_INVALID) { r = sd_netlink_message_append_u32(m, IFLA_BOND_ARP_VALIDATE, b->arp_validate); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_VALIDATE attribute: %m"); + return r; } if (b->arp_all_targets != _NETDEV_BOND_ARP_ALL_TARGETS_INVALID) { r = sd_netlink_message_append_u32(m, IFLA_BOND_ARP_ALL_TARGETS, b->arp_all_targets); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m"); + return r; } if (b->primary_reselect != _NETDEV_BOND_PRIMARY_RESELECT_INVALID) { r = sd_netlink_message_append_u8(m, IFLA_BOND_PRIMARY_RESELECT, b->primary_reselect); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_PRIMARY_RESELECT attribute: %m"); + return r; } if (b->resend_igmp <= RESEND_IGMP_MAX) { r = sd_netlink_message_append_u32(m, IFLA_BOND_RESEND_IGMP, b->resend_igmp); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_RESEND_IGMP attribute: %m"); + return r; } if (b->packets_per_slave <= PACKETS_PER_SLAVE_MAX && b->mode == NETDEV_BOND_MODE_BALANCE_RR) { r = sd_netlink_message_append_u32(m, IFLA_BOND_PACKETS_PER_SLAVE, b->packets_per_slave); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_PACKETS_PER_SLAVE attribute: %m"); + return r; } if (b->num_grat_arp <= GRATUITOUS_ARP_MAX) { r = sd_netlink_message_append_u8(m, IFLA_BOND_NUM_PEER_NOTIF, b->num_grat_arp); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_NUM_PEER_NOTIF attribute: %m"); + return r; } if (b->min_links != 0) { r = sd_netlink_message_append_u32(m, IFLA_BOND_MIN_LINKS, b->min_links); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MIN_LINKS attribute: %m"); + return r; } if (b->ad_actor_sys_prio != 0) { r = sd_netlink_message_append_u16(m, IFLA_BOND_AD_ACTOR_SYS_PRIO, b->ad_actor_sys_prio); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_ACTOR_SYS_PRIO attribute: %m"); + return r; } if (b->ad_user_port_key != 0) { r = sd_netlink_message_append_u16(m, IFLA_BOND_AD_USER_PORT_KEY, b->ad_user_port_key); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_USER_PORT_KEY attribute: %m"); + return r; } if (!ether_addr_is_null(&b->ad_actor_system)) { r = sd_netlink_message_append_ether_addr(m, IFLA_BOND_AD_ACTOR_SYSTEM, &b->ad_actor_system); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_ACTOR_SYSTEM attribute: %m"); + return r; } r = sd_netlink_message_append_u8(m, IFLA_BOND_ALL_SLAVES_ACTIVE, b->all_slaves_active); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ALL_SLAVES_ACTIVE attribute: %m"); + return r; if (b->tlb_dynamic_lb >= 0) { r = sd_netlink_message_append_u8(m, IFLA_BOND_TLB_DYNAMIC_LB, b->tlb_dynamic_lb); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_TLB_DYNAMIC_LB attribute: %m"); + return r; } if (b->arp_interval > 0 && !ordered_set_isempty(b->arp_ip_targets)) { @@ -209,17 +209,17 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_netlin r = sd_netlink_message_open_container(m, IFLA_BOND_ARP_IP_TARGET); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not open contaniner IFLA_BOND_ARP_IP_TARGET : %m"); + return r; ORDERED_SET_FOREACH(val, b->arp_ip_targets) { r = sd_netlink_message_append_u32(m, n++, PTR_TO_UINT32(val)); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m"); + return r; } r = sd_netlink_message_close_container(m); if (r < 0) - return log_netdev_error_errno(netdev, r, "Could not close contaniner IFLA_BOND_ARP_IP_TARGET : %m"); + return r; } return 0; |