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.
This commit is contained in:
@@ -24,12 +24,12 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlin
|
||||
|
||||
r = sd_netlink_message_append_u16(req, IFLA_VLAN_ID, v->id);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_ID attribute: %m");
|
||||
return r;
|
||||
|
||||
if (v->protocol >= 0) {
|
||||
r = sd_netlink_message_append_u16(req, IFLA_VLAN_PROTOCOL, htobe16(v->protocol));
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_PROTOCOL attribute: %m");
|
||||
return r;
|
||||
}
|
||||
|
||||
if (v->gvrp != -1) {
|
||||
@@ -54,24 +54,24 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlin
|
||||
|
||||
r = sd_netlink_message_append_data(req, IFLA_VLAN_FLAGS, &flags, sizeof(struct ifla_vlan_flags));
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_FLAGS attribute: %m");
|
||||
return r;
|
||||
|
||||
if (!set_isempty(v->egress_qos_maps)) {
|
||||
struct ifla_vlan_qos_mapping *m;
|
||||
|
||||
r = sd_netlink_message_open_container(req, IFLA_VLAN_EGRESS_QOS);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not open container IFLA_VLAN_EGRESS_QOS: %m");
|
||||
return r;
|
||||
|
||||
SET_FOREACH(m, v->egress_qos_maps) {
|
||||
r = sd_netlink_message_append_data(req, IFLA_VLAN_QOS_MAPPING, m, sizeof(struct ifla_vlan_qos_mapping));
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_QOS_MAPPING attribute: %m");
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_netlink_message_close_container(req);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not close container IFLA_VLAN_EGRESS_QOS: %m");
|
||||
return r;
|
||||
}
|
||||
|
||||
if (!set_isempty(v->ingress_qos_maps)) {
|
||||
@@ -79,17 +79,17 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_netlin
|
||||
|
||||
r = sd_netlink_message_open_container(req, IFLA_VLAN_INGRESS_QOS);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not open container IFLA_VLAN_INGRESS_QOS: %m");
|
||||
return r;
|
||||
|
||||
SET_FOREACH(m, v->ingress_qos_maps) {
|
||||
r = sd_netlink_message_append_data(req, IFLA_VLAN_QOS_MAPPING, m, sizeof(struct ifla_vlan_qos_mapping));
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not append IFLA_VLAN_QOS_MAPPING attribute: %m");
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_netlink_message_close_container(req);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r, "Could not close container IFLA_VLAN_INGRESS_QOS: %m");
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user