summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-06-10 15:10:47 +0200
committerLennart Poettering <lennart@poettering.net>2015-06-10 15:10:47 +0200
commit0748385cc44824fee281f9de7547c4d91ab0f473 (patch)
tree563b210731050e323269b5b0a0ba1e886c6a48b2
parent521446dbff601603a8d41774eca8866a5613b04c (diff)
parenta668086ec7d27171eb3ed6bb49119b1c7602d337 (diff)
Merge pull request #132 from ssahani/bond
networkd: bond improve logging
-rw-r--r--src/network/networkd-netdev-bond.c173
1 files changed, 45 insertions, 128 deletions
diff --git a/src/network/networkd-netdev-bond.c b/src/network/networkd-netdev-bond.c
index 70df08a5e1..9919955f51 100644
--- a/src/network/networkd-netdev-bond.c
+++ b/src/network/networkd-netdev-bond.c
@@ -191,215 +191,132 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
if (b->mode != _NETDEV_BOND_MODE_INVALID) {
r = sd_rtnl_message_append_u8(m, IFLA_BOND_MODE,
bond_mode_to_kernel(b->mode));
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_MODE attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MODE attribute: %m");
}
if (b->xmit_hash_policy != _NETDEV_BOND_XMIT_HASH_POLICY_INVALID) {
r = sd_rtnl_message_append_u8(m, IFLA_BOND_XMIT_HASH_POLICY,
bond_xmit_hash_policy_to_kernel(b->xmit_hash_policy));
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_XMIT_HASH_POLICY attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_XMIT_HASH_POLICY attribute: %m");
}
if (b->lacp_rate != _NETDEV_BOND_LACP_RATE_INVALID &&
b->mode == NETDEV_BOND_MODE_802_3AD) {
r = sd_rtnl_message_append_u8(m, IFLA_BOND_AD_LACP_RATE, b->lacp_rate );
if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_AD_LACP_RATE attribute: %s",
- strerror(-r));
- return r;
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_LACP_RATE attribute: %m");
}
}
if (b->miimon != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_MIIMON, b->miimon / USEC_PER_MSEC);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_BOND_MIIMON attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_BOND_MIIMON attribute: %m");
}
if (b->downdelay != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_DOWNDELAY, b->downdelay / USEC_PER_MSEC);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_DOWNDELAY attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_DOWNDELAY attribute: %m");
}
if (b->updelay != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_UPDELAY, b->updelay / USEC_PER_MSEC);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_UPDELAY attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_UPDELAY attribute: %m");
}
if (b->arp_interval != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_INTERVAL, b->arp_interval / USEC_PER_MSEC);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_ARP_INTERVAL attribute: %s",
- strerror(-r));
- return r;
- }
- }
-
- if ((b->lp_interval >= LEARNING_PACKETS_INTERVAL_MIN_SEC) &&
- (b->lp_interval <= LEARNING_PACKETS_INTERVAL_MAX_SEC)) {
- r = sd_rtnl_message_append_u32(m, IFLA_BOND_LP_INTERVAL, b->lp_interval / USEC_PER_SEC);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_LP_INTERVAL attribute: %s",
- strerror(-r));
- return r;
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_INTERVAL attribute: %m");
+
+ if ((b->lp_interval >= LEARNING_PACKETS_INTERVAL_MIN_SEC) &&
+ (b->lp_interval <= LEARNING_PACKETS_INTERVAL_MAX_SEC)) {
+ r = sd_rtnl_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");
}
}
if (b->ad_select != _NETDEV_BOND_AD_SELECT_INVALID &&
b->mode == BOND_MODE_8023AD) {
r = sd_rtnl_message_append_u8(m, IFLA_BOND_AD_SELECT, b->ad_select);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_AD_SELECT attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_AD_SELECT attribute: %m");
}
if (b->fail_over_mac != _NETDEV_BOND_FAIL_OVER_MAC_INVALID &&
b->mode == NETDEV_BOND_MODE_ACTIVE_BACKUP) {
r = sd_rtnl_message_append_u8(m, IFLA_BOND_FAIL_OVER_MAC, b->fail_over_mac);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_FAIL_OVER_MAC attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_FAIL_OVER_MAC attribute: %m");
}
if (b->arp_validate != _NETDEV_BOND_ARP_VALIDATE_INVALID) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_VALIDATE, b->arp_validate);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_ARP_VALIDATE attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_VALIDATE attribute: %m");
}
if (b->arp_all_targets != _NETDEV_BOND_ARP_ALL_TARGETS_INVALID) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_ALL_TARGETS, b->arp_all_targets);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_ARP_VALIDATE attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_VALIDATE attribute: %m");
}
if (b->primary_reselect != _NETDEV_BOND_PRIMARY_RESELECT_INVALID) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_ARP_ALL_TARGETS, b->primary_reselect);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m");
}
if (b->resend_igmp <= RESEND_IGMP_MAX) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_RESEND_IGMP, b->resend_igmp);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_RESEND_IGMP attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_RESEND_IGMP attribute: %m");
}
if (b->packets_per_slave <= PACKETS_PER_SLAVE_MAX) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_PACKETS_PER_SLAVE, b->packets_per_slave);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_PACKETS_PER_SLAVE attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_PACKETS_PER_SLAVE attribute: %m");
}
if (b->num_grat_arp <= GRATUITOUS_ARP_MAX) {
r = sd_rtnl_message_append_u8(m, IFLA_BOND_NUM_PEER_NOTIF, b->num_grat_arp);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_NUM_PEER_NOTIF attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_NUM_PEER_NOTIF attribute: %m");
}
if (b->min_links != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_MIN_LINKS, b->min_links);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_MIN_LINKS attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_MIN_LINKS attribute: %m");
}
r = sd_rtnl_message_append_u8(m, IFLA_BOND_ALL_SLAVES_ACTIVE, b->all_slaves_active);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_ALL_SLAVES_ACTIVE attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ALL_SLAVES_ACTIVE attribute: %m");
if (b->arp_interval > 0) {
if (b->n_arp_ip_targets > 0) {
r = sd_rtnl_message_open_container(m, IFLA_BOND_ARP_IP_TARGET);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not open contaniner IFLA_BOND_ARP_IP_TARGET : %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not open contaniner IFLA_BOND_ARP_IP_TARGET : %m");
LIST_FOREACH(arp_ip_target, target, b->arp_ip_targets) {
r = sd_rtnl_message_append_u32(m, i++, target->ip.in.s_addr);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not append IFLA_BOND_ARP_ALL_TARGETS attribute: %m");
}
r = sd_rtnl_message_close_container(m);
- if (r < 0) {
- log_netdev_error(netdev,
- "Could not close contaniner IFLA_BOND_ARP_IP_TARGET : %s",
- strerror(-r));
- return r;
- }
+ if (r < 0)
+ return log_netdev_error_errno(netdev, r, "Could not close contaniner IFLA_BOND_ARP_IP_TARGET : %m");
}
}