diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-09-29 17:20:40 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-10-07 02:39:51 +0900 |
commit | 454c87b5d53737243a157e319351288c498fea45 (patch) | |
tree | 14d0cad25daefe112cc8f1b547c5c77b7ee1c50d /src/network/networkd-manager.c | |
parent | c133770a6b73b669219742768e93d5393dbc4ec7 (diff) | |
download | systemd-454c87b5d53737243a157e319351288c498fea45.tar.gz |
network: move manager_rtnl_process_nexthop() to networkd-nexthop.c
Diffstat (limited to 'src/network/networkd-manager.c')
-rw-r--r-- | src/network/networkd-manager.c | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 2dc6ef0933..94b036e81e 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -966,125 +966,6 @@ static int manager_rtnl_process_link(sd_netlink *rtnl, sd_netlink_message *messa return 1; } -static int manager_rtnl_process_nexthop(sd_netlink *rtnl, sd_netlink_message *message, Manager *m) { - _cleanup_(nexthop_freep) NextHop *tmp = NULL; - _cleanup_free_ char *gateway = NULL; - NextHop *nexthop = NULL; - Link *link = NULL; - uint16_t type; - int r; - - assert(rtnl); - assert(message); - assert(m); - - if (sd_netlink_message_is_error(message)) { - r = sd_netlink_message_get_errno(message); - if (r < 0) - log_message_warning_errno(message, r, "rtnl: failed to receive rule message, ignoring"); - - return 0; - } - - r = sd_netlink_message_get_type(message, &type); - if (r < 0) { - log_warning_errno(r, "rtnl: could not get message type, ignoring: %m"); - return 0; - } else if (!IN_SET(type, RTM_NEWNEXTHOP, RTM_DELNEXTHOP)) { - log_warning("rtnl: received unexpected message type %u when processing nexthop, ignoring.", type); - return 0; - } - - r = nexthop_new(&tmp); - if (r < 0) - return log_oom(); - - r = sd_rtnl_message_get_family(message, &tmp->family); - if (r < 0) { - log_warning_errno(r, "rtnl: could not get nexthop family, ignoring: %m"); - return 0; - } else if (!IN_SET(tmp->family, AF_INET, AF_INET6)) { - log_debug("rtnl: received nexthop message with invalid family %d, ignoring.", tmp->family); - return 0; - } - - switch (tmp->family) { - case AF_INET: - r = sd_netlink_message_read_in_addr(message, NHA_GATEWAY, &tmp->gw.in); - if (r < 0 && r != -ENODATA) { - log_warning_errno(r, "rtnl: could not get NHA_GATEWAY attribute, ignoring: %m"); - return 0; - } - break; - - case AF_INET6: - r = sd_netlink_message_read_in6_addr(message, NHA_GATEWAY, &tmp->gw.in6); - if (r < 0 && r != -ENODATA) { - log_warning_errno(r, "rtnl: could not get NHA_GATEWAY attribute, ignoring: %m"); - return 0; - } - break; - - default: - assert_not_reached("Received rule message with unsupported address family"); - } - - r = sd_netlink_message_read_u32(message, NHA_ID, &tmp->id); - if (r < 0 && r != -ENODATA) { - log_warning_errno(r, "rtnl: could not get NHA_ID attribute, ignoring: %m"); - return 0; - } - - r = sd_netlink_message_read_u32(message, NHA_OIF, &tmp->oif); - if (r < 0 && r != -ENODATA) { - log_warning_errno(r, "rtnl: could not get NHA_OIF attribute, ignoring: %m"); - return 0; - } else if (tmp->oif <= 0) { - log_warning("rtnl: received nexthop message with invalid ifindex %d, ignoring.", tmp->oif); - return 0; - } - - r = link_get(m, tmp->oif, &link); - if (r < 0 || !link) { - if (!m->enumerating) - log_warning("rtnl: received nexthop message for link (%d) we do not know about, ignoring", tmp->oif); - return 0; - } - - (void) nexthop_get(link, tmp, &nexthop); - - if (DEBUG_LOGGING) - (void) in_addr_to_string(tmp->family, &tmp->gw, &gateway); - - switch (type) { - case RTM_NEWNEXTHOP: - if (nexthop) - log_link_debug(link, "Received remembered nexthop: %s, oif: %d, id: %d", strna(gateway), tmp->oif, tmp->id); - else { - log_link_debug(link, "Remembering foreign nexthop: %s, oif: %d, id: %d", strna(gateway), tmp->oif, tmp->id); - r = nexthop_add_foreign(link, tmp, &nexthop); - if (r < 0) { - log_link_warning_errno(link, r, "Could not remember foreign nexthop, ignoring: %m"); - return 0; - } - } - break; - case RTM_DELNEXTHOP: - if (nexthop) { - log_link_debug(link, "Forgetting nexthop: %s, oif: %d, id: %d", strna(gateway), tmp->oif, tmp->id); - nexthop_free(nexthop); - } else - log_link_debug(link, "Kernel removed a nexthop we don't remember: %s, oif: %d, id: %d, ignoring.", - strna(gateway), tmp->oif, tmp->id); - break; - - default: - assert_not_reached("Received invalid RTNL message type"); - } - - return 1; -} - static int systemd_netlink_fd(void) { int n, fd, rtnl_fd = -EINVAL; |