return is_new;
}
+static void log_nexthop_debug(const NextHop *nexthop, const char *str, const Link *link) {
+ assert(nexthop);
+ assert(str);
+ assert(link);
+
+ if (DEBUG_LOGGING) {
+ _cleanup_free_ char *gw = NULL;
+
+ (void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
+
+ log_link_debug(link, "%s nexthop: id: %"PRIu32", gw: %s",
+ str, nexthop->id, strna(gw));
+ }
+}
+
static int nexthop_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;
assert(link->ifindex > 0);
assert(IN_SET(nexthop->family, AF_INET, AF_INET6));
- if (DEBUG_LOGGING) {
- _cleanup_free_ char *gw = NULL;
-
- if (!in_addr_is_null(nexthop->family, &nexthop->gw))
- (void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
-
- log_link_debug(link, "Configuring nexthop: gw: %s", strna(gw));
- }
+ log_nexthop_debug(nexthop, "Configuring", link);
r = sd_rtnl_message_new_nexthop(link->manager->rtnl, &req,
RTM_NEWNEXTHOP, nexthop->family,
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;
uint32_t ifindex;
uint16_t type;
(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, id: %d", strna(gateway), tmp->id);
+ log_nexthop_debug(tmp, "Received remembered", link);
else {
- log_link_debug(link, "Remembering foreign nexthop: %s, id: %d", strna(gateway), tmp->id);
+ log_nexthop_debug(tmp, "Remembering foreign", link);
r = nexthop_add_foreign(link, tmp, &nexthop);
if (r < 0) {
log_link_warning_errno(link, r, "Could not remember foreign nexthop, ignoring: %m");
}
break;
case RTM_DELNEXTHOP:
- if (nexthop) {
- log_link_debug(link, "Forgetting nexthop: %s, id: %d", strna(gateway), tmp->id);
- nexthop_free(nexthop);
- } else
- log_link_debug(link, "Kernel removed a nexthop we don't remember: %s, id: %d, ignoring.",
- strna(gateway), tmp->id);
+ log_nexthop_debug(tmp, nexthop ? "Forgetting" : "Kernel removed unknown", link);
+ nexthop_free(nexthop);
break;
default: