1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-26 03:22:00 +03:00

network: use sd_netlink_message_read_string_strdup()

This commit is contained in:
Yu Watanabe 2021-07-15 13:20:04 +09:00
parent 6e86342bb8
commit fccf662c3f

View File

@ -922,10 +922,7 @@ static bool routing_policy_rule_is_created_by_kernel(const RoutingPolicyRule *ru
int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Manager *m) {
_cleanup_(routing_policy_rule_freep) RoutingPolicyRule *tmp = NULL;
RoutingPolicyRule *rule = NULL;
const char *iif = NULL, *oif = NULL;
bool adjust_protocol = false;
uint32_t suppress_prefixlen;
unsigned flags;
uint16_t type;
int r;
@ -988,6 +985,7 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
}
}
unsigned flags;
r = sd_rtnl_message_routing_policy_rule_get_flags(message, &flags);
if (r < 0) {
log_warning_errno(r, "rtnl: received rule message without valid flag, ignoring: %m");
@ -1034,23 +1032,17 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
return 0;
}
r = sd_netlink_message_read_string(message, FRA_IIFNAME, &iif);
r = sd_netlink_message_read_string_strdup(message, FRA_IIFNAME, &tmp->iif);
if (r < 0 && r != -ENODATA) {
log_warning_errno(r, "rtnl: could not get FRA_IIFNAME attribute, ignoring: %m");
return 0;
}
r = free_and_strdup(&tmp->iif, iif);
if (r < 0)
return log_oom();
r = sd_netlink_message_read_string(message, FRA_OIFNAME, &oif);
r = sd_netlink_message_read_string_strdup(message, FRA_OIFNAME, &tmp->oif);
if (r < 0 && r != -ENODATA) {
log_warning_errno(r, "rtnl: could not get FRA_OIFNAME attribute, ignoring: %m");
return 0;
}
r = free_and_strdup(&tmp->oif, oif);
if (r < 0)
return log_oom();
r = sd_netlink_message_read_u8(message, FRA_IP_PROTO, &tmp->ipproto);
if (r < 0 && r != -ENODATA) {
@ -1093,6 +1085,7 @@ int manager_rtnl_process_rule(sd_netlink *rtnl, sd_netlink_message *message, Man
return 0;
}
uint32_t suppress_prefixlen;
r = sd_netlink_message_read_u32(message, FRA_SUPPRESS_PREFIXLEN, &suppress_prefixlen);
if (r < 0 && r != -ENODATA) {
log_warning_errno(r, "rtnl: could not get FRA_SUPPRESS_PREFIXLEN attribute, ignoring: %m");