network: reduce indentation in log_address_debug() or friends
This commit is contained in:
@@ -486,37 +486,38 @@ int link_has_ipv6_address(Link *link, const struct in6_addr *address) {
|
||||
}
|
||||
|
||||
static void log_address_debug(const Address *address, const char *str, const Link *link) {
|
||||
_cleanup_free_ char *addr = NULL, *peer = NULL;
|
||||
char valid_buf[FORMAT_TIMESPAN_MAX], preferred_buf[FORMAT_TIMESPAN_MAX];
|
||||
const char *valid_str = NULL, *preferred_str = NULL;
|
||||
bool has_peer;
|
||||
|
||||
assert(address);
|
||||
assert(str);
|
||||
assert(link);
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *addr = NULL, *peer = NULL;
|
||||
char valid_buf[FORMAT_TIMESPAN_MAX], preferred_buf[FORMAT_TIMESPAN_MAX];
|
||||
const char *valid_str = NULL, *preferred_str = NULL;
|
||||
bool has_peer;
|
||||
if (!DEBUG_LOGGING)
|
||||
return;
|
||||
|
||||
(void) in_addr_to_string(address->family, &address->in_addr, &addr);
|
||||
has_peer = in_addr_is_set(address->family, &address->in_addr_peer);
|
||||
if (has_peer)
|
||||
(void) in_addr_to_string(address->family, &address->in_addr_peer, &peer);
|
||||
(void) in_addr_to_string(address->family, &address->in_addr, &addr);
|
||||
has_peer = in_addr_is_set(address->family, &address->in_addr_peer);
|
||||
if (has_peer)
|
||||
(void) in_addr_to_string(address->family, &address->in_addr_peer, &peer);
|
||||
|
||||
if (address->cinfo.ifa_valid != CACHE_INFO_INFINITY_LIFE_TIME)
|
||||
valid_str = format_timespan(valid_buf, FORMAT_TIMESPAN_MAX,
|
||||
address->cinfo.ifa_valid * USEC_PER_SEC,
|
||||
USEC_PER_SEC);
|
||||
if (address->cinfo.ifa_valid != CACHE_INFO_INFINITY_LIFE_TIME)
|
||||
valid_str = format_timespan(valid_buf, FORMAT_TIMESPAN_MAX,
|
||||
address->cinfo.ifa_valid * USEC_PER_SEC,
|
||||
USEC_PER_SEC);
|
||||
|
||||
if (address->cinfo.ifa_prefered != CACHE_INFO_INFINITY_LIFE_TIME)
|
||||
preferred_str = format_timespan(preferred_buf, FORMAT_TIMESPAN_MAX,
|
||||
address->cinfo.ifa_prefered * USEC_PER_SEC,
|
||||
USEC_PER_SEC);
|
||||
if (address->cinfo.ifa_prefered != CACHE_INFO_INFINITY_LIFE_TIME)
|
||||
preferred_str = format_timespan(preferred_buf, FORMAT_TIMESPAN_MAX,
|
||||
address->cinfo.ifa_prefered * USEC_PER_SEC,
|
||||
USEC_PER_SEC);
|
||||
|
||||
log_link_debug(link, "%s address: %s%s%s/%u (valid %s%s, preferred %s%s)",
|
||||
str, strnull(addr), has_peer ? " peer " : "",
|
||||
has_peer ? strnull(peer) : "", address->prefixlen,
|
||||
valid_str ? "for " : "forever", strempty(valid_str),
|
||||
preferred_str ? "for " : "forever", strempty(preferred_str));
|
||||
}
|
||||
log_link_debug(link, "%s address: %s%s%s/%u (valid %s%s, preferred %s%s)",
|
||||
str, strnull(addr), has_peer ? " peer " : "",
|
||||
has_peer ? strnull(peer) : "", address->prefixlen,
|
||||
valid_str ? "for " : "forever", strempty(valid_str),
|
||||
preferred_str ? "for " : "forever", strempty(preferred_str));
|
||||
}
|
||||
|
||||
static int address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
|
||||
@@ -336,23 +336,24 @@ set_manager:
|
||||
}
|
||||
|
||||
static void log_nexthop_debug(const NextHop *nexthop, uint32_t id, const char *str, const Link *link) {
|
||||
_cleanup_free_ char *gw = NULL;
|
||||
|
||||
assert(nexthop);
|
||||
assert(str);
|
||||
|
||||
/* link may be NULL. */
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *gw = NULL;
|
||||
if (!DEBUG_LOGGING)
|
||||
return;
|
||||
|
||||
(void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
|
||||
(void) in_addr_to_string(nexthop->family, &nexthop->gw, &gw);
|
||||
|
||||
if (nexthop->id == id)
|
||||
log_link_debug(link, "%s nexthop: id: %"PRIu32", gw: %s, blackhole: %s",
|
||||
str, nexthop->id, strna(gw), yes_no(nexthop->blackhole));
|
||||
else
|
||||
log_link_debug(link, "%s nexthop: id: %"PRIu32"→%"PRIu32", gw: %s, blackhole: %s",
|
||||
str, nexthop->id, id, strna(gw), yes_no(nexthop->blackhole));
|
||||
}
|
||||
if (nexthop->id == id)
|
||||
log_link_debug(link, "%s nexthop: id: %"PRIu32", gw: %s, blackhole: %s",
|
||||
str, nexthop->id, strna(gw), yes_no(nexthop->blackhole));
|
||||
else
|
||||
log_link_debug(link, "%s nexthop: id: %"PRIu32"→%"PRIu32", gw: %s, blackhole: %s",
|
||||
str, nexthop->id, id, strna(gw), yes_no(nexthop->blackhole));
|
||||
}
|
||||
|
||||
static int nexthop_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
|
||||
|
||||
@@ -605,35 +605,36 @@ static bool route_type_is_reject(const Route *route) {
|
||||
}
|
||||
|
||||
static void log_route_debug(const Route *route, const char *str, const Link *link, const Manager *m) {
|
||||
_cleanup_free_ char *dst = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL,
|
||||
*table = NULL, *scope = NULL, *proto = NULL;
|
||||
|
||||
assert(route);
|
||||
assert(str);
|
||||
assert(m);
|
||||
|
||||
/* link may be NULL. */
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *dst = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL,
|
||||
*table = NULL, *scope = NULL, *proto = NULL;
|
||||
if (!DEBUG_LOGGING)
|
||||
return;
|
||||
|
||||
if (in_addr_is_set(route->family, &route->dst))
|
||||
(void) in_addr_prefix_to_string(route->family, &route->dst, route->dst_prefixlen, &dst);
|
||||
if (in_addr_is_set(route->family, &route->src))
|
||||
(void) in_addr_to_string(route->family, &route->src, &src);
|
||||
if (in_addr_is_set(route->gw_family, &route->gw))
|
||||
(void) in_addr_to_string(route->gw_family, &route->gw, &gw);
|
||||
if (in_addr_is_set(route->family, &route->prefsrc))
|
||||
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
||||
(void) route_scope_to_string_alloc(route->scope, &scope);
|
||||
(void) manager_get_route_table_to_string(m, route->table, &table);
|
||||
(void) route_protocol_full_to_string_alloc(route->protocol, &proto);
|
||||
if (in_addr_is_set(route->family, &route->dst))
|
||||
(void) in_addr_prefix_to_string(route->family, &route->dst, route->dst_prefixlen, &dst);
|
||||
if (in_addr_is_set(route->family, &route->src))
|
||||
(void) in_addr_to_string(route->family, &route->src, &src);
|
||||
if (in_addr_is_set(route->gw_family, &route->gw))
|
||||
(void) in_addr_to_string(route->gw_family, &route->gw, &gw);
|
||||
if (in_addr_is_set(route->family, &route->prefsrc))
|
||||
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
||||
(void) route_scope_to_string_alloc(route->scope, &scope);
|
||||
(void) manager_get_route_table_to_string(m, route->table, &table);
|
||||
(void) route_protocol_full_to_string_alloc(route->protocol, &proto);
|
||||
|
||||
log_link_debug(link,
|
||||
"%s route: dst: %s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s, nexthop: %"PRIu32", priority: %"PRIu32,
|
||||
str, strna(dst), strna(src), strna(gw), strna(prefsrc),
|
||||
strna(scope), strna(table), strna(proto),
|
||||
strna(route_type_to_string(route->type)),
|
||||
route->nexthop_id, route->priority);
|
||||
}
|
||||
log_link_debug(link,
|
||||
"%s route: dst: %s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s, nexthop: %"PRIu32", priority: %"PRIu32,
|
||||
str, strna(dst), strna(src), strna(gw), strna(prefsrc),
|
||||
strna(scope), strna(table), strna(proto),
|
||||
strna(route_type_to_string(route->type)),
|
||||
route->nexthop_id, route->priority);
|
||||
}
|
||||
|
||||
static int route_set_netlink_message(const Route *route, sd_netlink_message *req, Link *link) {
|
||||
|
||||
@@ -391,6 +391,8 @@ static int routing_policy_rule_consume_foreign(Manager *m, RoutingPolicyRule *ru
|
||||
}
|
||||
|
||||
static void log_routing_policy_rule_debug(const RoutingPolicyRule *rule, int family, const char *str, const Link *link, const Manager *m) {
|
||||
_cleanup_free_ char *from = NULL, *to = NULL, *table = NULL;
|
||||
|
||||
assert(rule);
|
||||
assert(IN_SET(family, AF_INET, AF_INET6));
|
||||
assert(str);
|
||||
@@ -398,18 +400,17 @@ static void log_routing_policy_rule_debug(const RoutingPolicyRule *rule, int fam
|
||||
|
||||
/* link may be NULL. */
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
_cleanup_free_ char *from = NULL, *to = NULL, *table = NULL;
|
||||
if (!DEBUG_LOGGING)
|
||||
return;
|
||||
|
||||
(void) in_addr_prefix_to_string(family, &rule->from, rule->from_prefixlen, &from);
|
||||
(void) in_addr_prefix_to_string(family, &rule->to, rule->to_prefixlen, &to);
|
||||
(void) manager_get_route_table_to_string(m, rule->table, &table);
|
||||
(void) in_addr_prefix_to_string(family, &rule->from, rule->from_prefixlen, &from);
|
||||
(void) in_addr_prefix_to_string(family, &rule->to, rule->to_prefixlen, &to);
|
||||
(void) manager_get_route_table_to_string(m, rule->table, &table);
|
||||
|
||||
log_link_debug(link,
|
||||
"%s routing policy rule: priority: %"PRIu32", %s -> %s, iif: %s, oif: %s, table: %s",
|
||||
str, rule->priority, strna(from), strna(to),
|
||||
strna(rule->iif), strna(rule->oif), strna(table));
|
||||
}
|
||||
log_link_debug(link,
|
||||
"%s routing policy rule: priority: %"PRIu32", %s -> %s, iif: %s, oif: %s, table: %s",
|
||||
str, rule->priority, strna(from), strna(to),
|
||||
strna(rule->iif), strna(rule->oif), strna(table));
|
||||
}
|
||||
|
||||
static int routing_policy_rule_set_netlink_message(const RoutingPolicyRule *rule, sd_netlink_message *m, Link *link) {
|
||||
|
||||
Reference in New Issue
Block a user