mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
network: also show route protocol in debugging logs
This commit is contained in:
parent
1b64651bd1
commit
d3e291fd62
@ -436,7 +436,8 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, vo
|
|||||||
if (DEBUG_LOGGING) {
|
if (DEBUG_LOGGING) {
|
||||||
_cleanup_free_ char *buf_dst = NULL, *buf_dst_prefixlen = NULL,
|
_cleanup_free_ char *buf_dst = NULL, *buf_dst_prefixlen = NULL,
|
||||||
*buf_src = NULL, *buf_gw = NULL, *buf_prefsrc = NULL;
|
*buf_src = NULL, *buf_gw = NULL, *buf_prefsrc = NULL;
|
||||||
char buf_scope[ROUTE_SCOPE_STR_MAX], buf_table[ROUTE_TABLE_STR_MAX];
|
char buf_scope[ROUTE_SCOPE_STR_MAX], buf_table[ROUTE_TABLE_STR_MAX],
|
||||||
|
buf_protocol[ROUTE_PROTOCOL_STR_MAX];
|
||||||
|
|
||||||
if (!in_addr_is_null(family, &dst)) {
|
if (!in_addr_is_null(family, &dst)) {
|
||||||
(void) in_addr_to_string(family, &dst, &buf_dst);
|
(void) in_addr_to_string(family, &dst, &buf_dst);
|
||||||
@ -450,12 +451,13 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, vo
|
|||||||
(void) in_addr_to_string(family, &prefsrc, &buf_prefsrc);
|
(void) in_addr_to_string(family, &prefsrc, &buf_prefsrc);
|
||||||
|
|
||||||
log_link_debug(link,
|
log_link_debug(link,
|
||||||
"%s route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, type: %s",
|
"%s route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
|
||||||
type == RTM_DELROUTE ? "Forgetting" : route ? "Updating remembered" : "Remembering",
|
type == RTM_DELROUTE ? "Forgetting" : route ? "Updating remembered" : "Remembering",
|
||||||
strna(buf_dst), strempty(buf_dst_prefixlen),
|
strna(buf_dst), strempty(buf_dst_prefixlen),
|
||||||
strna(buf_src), strna(buf_gw), strna(buf_prefsrc),
|
strna(buf_src), strna(buf_gw), strna(buf_prefsrc),
|
||||||
format_route_scope(scope, buf_scope, sizeof buf_scope),
|
format_route_scope(scope, buf_scope, sizeof buf_scope),
|
||||||
format_route_table(table, buf_table, sizeof buf_table),
|
format_route_table(table, buf_table, sizeof buf_table),
|
||||||
|
format_route_protocol(protocol, buf_protocol, sizeof buf_protocol),
|
||||||
strna(route_type_to_string(rt_type)));
|
strna(route_type_to_string(rt_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ int route_remove(Route *route, Link *link,
|
|||||||
|
|
||||||
if (DEBUG_LOGGING) {
|
if (DEBUG_LOGGING) {
|
||||||
_cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL;
|
_cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL;
|
||||||
char scope[ROUTE_SCOPE_STR_MAX], table[ROUTE_TABLE_STR_MAX];
|
char scope[ROUTE_SCOPE_STR_MAX], table[ROUTE_TABLE_STR_MAX], protocol[ROUTE_PROTOCOL_STR_MAX];
|
||||||
|
|
||||||
if (!in_addr_is_null(route->family, &route->dst)) {
|
if (!in_addr_is_null(route->family, &route->dst)) {
|
||||||
(void) in_addr_to_string(route->family, &route->dst, &dst);
|
(void) in_addr_to_string(route->family, &route->dst, &dst);
|
||||||
@ -429,10 +429,11 @@ int route_remove(Route *route, Link *link,
|
|||||||
if (!in_addr_is_null(route->family, &route->prefsrc))
|
if (!in_addr_is_null(route->family, &route->prefsrc))
|
||||||
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
||||||
|
|
||||||
log_link_debug(link, "Removing route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, type: %s",
|
log_link_debug(link, "Removing route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
|
||||||
strna(dst), strempty(dst_prefixlen), strna(src), strna(gw), strna(prefsrc),
|
strna(dst), strempty(dst_prefixlen), strna(src), strna(gw), strna(prefsrc),
|
||||||
format_route_scope(route->scope, scope, sizeof(scope)),
|
format_route_scope(route->scope, scope, sizeof(scope)),
|
||||||
format_route_table(route->table, table, sizeof(table)),
|
format_route_table(route->table, table, sizeof(table)),
|
||||||
|
format_route_protocol(route->protocol, protocol, sizeof(protocol)),
|
||||||
strna(route_type_to_string(route->type)));
|
strna(route_type_to_string(route->type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,7 +538,7 @@ int route_configure(
|
|||||||
|
|
||||||
if (DEBUG_LOGGING) {
|
if (DEBUG_LOGGING) {
|
||||||
_cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL;
|
_cleanup_free_ char *dst = NULL, *dst_prefixlen = NULL, *src = NULL, *gw = NULL, *prefsrc = NULL;
|
||||||
char scope[ROUTE_SCOPE_STR_MAX], table[ROUTE_TABLE_STR_MAX];
|
char scope[ROUTE_SCOPE_STR_MAX], table[ROUTE_TABLE_STR_MAX], protocol[ROUTE_PROTOCOL_STR_MAX];
|
||||||
|
|
||||||
if (!in_addr_is_null(route->family, &route->dst)) {
|
if (!in_addr_is_null(route->family, &route->dst)) {
|
||||||
(void) in_addr_to_string(route->family, &route->dst, &dst);
|
(void) in_addr_to_string(route->family, &route->dst, &dst);
|
||||||
@ -550,10 +551,11 @@ int route_configure(
|
|||||||
if (!in_addr_is_null(route->family, &route->prefsrc))
|
if (!in_addr_is_null(route->family, &route->prefsrc))
|
||||||
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
(void) in_addr_to_string(route->family, &route->prefsrc, &prefsrc);
|
||||||
|
|
||||||
log_link_debug(link, "Configuring route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, type: %s",
|
log_link_debug(link, "Configuring route: dst: %s%s, src: %s, gw: %s, prefsrc: %s, scope: %s, table: %s, proto: %s, type: %s",
|
||||||
strna(dst), strempty(dst_prefixlen), strna(src), strna(gw), strna(prefsrc),
|
strna(dst), strempty(dst_prefixlen), strna(src), strna(gw), strna(prefsrc),
|
||||||
format_route_scope(route->scope, scope, sizeof(scope)),
|
format_route_scope(route->scope, scope, sizeof(scope)),
|
||||||
format_route_table(route->table, table, sizeof(table)),
|
format_route_table(route->table, table, sizeof(table)),
|
||||||
|
format_route_protocol(route->protocol, protocol, sizeof(protocol)),
|
||||||
strna(route_type_to_string(route->type)));
|
strna(route_type_to_string(route->type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +848,20 @@ static const char * const route_protocol_table[] = {
|
|||||||
[RTPROT_STATIC] = "static",
|
[RTPROT_STATIC] = "static",
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int);
|
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_protocol, int);
|
||||||
|
|
||||||
|
const char *format_route_protocol(int protocol, char *buf, size_t size) {
|
||||||
|
const char *s;
|
||||||
|
char *p = buf;
|
||||||
|
|
||||||
|
s = route_protocol_to_string(protocol);
|
||||||
|
if (s)
|
||||||
|
strpcpy(&p, size, s);
|
||||||
|
else
|
||||||
|
strpcpyf(&p, size, "%d", protocol);
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
int config_parse_gateway(
|
int config_parse_gateway(
|
||||||
const char *unit,
|
const char *unit,
|
||||||
|
@ -77,6 +77,9 @@ const char *format_route_scope(int scope, char *buf, size_t size);
|
|||||||
#define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
|
#define ROUTE_TABLE_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("default") + 1)
|
||||||
const char *format_route_table(int table, char *buf, size_t size);
|
const char *format_route_table(int table, char *buf, size_t size);
|
||||||
|
|
||||||
|
#define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("kernel") + 1)
|
||||||
|
const char *format_route_protocol(int protocol, char *buf, size_t size);
|
||||||
|
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
|
CONFIG_PARSER_PROTOTYPE(config_parse_gateway);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
|
CONFIG_PARSER_PROTOTYPE(config_parse_preferred_src);
|
||||||
CONFIG_PARSER_PROTOTYPE(config_parse_destination);
|
CONFIG_PARSER_PROTOTYPE(config_parse_destination);
|
||||||
|
Loading…
Reference in New Issue
Block a user