From fccf662c3f57921a62cf848bcc1fd38f82e03c35 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 15 Jul 2021 13:20:04 +0900 Subject: [PATCH] network: use sd_netlink_message_read_string_strdup() --- src/network/networkd-routing-policy-rule.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index 1e56b79d84d..a89c5877d94 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -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");