@@ -424,10 +424,9 @@ int manager_get_route_table_from_string(const Manager *m, const char *s, uint32_
424424 return 0 ;
425425}
426426
427- int manager_get_route_table_to_string (const Manager * m , uint32_t table , char * * ret ) {
427+ int manager_get_route_table_to_string (const Manager * m , uint32_t table , bool append_num , char * * ret ) {
428428 _cleanup_free_ char * str = NULL ;
429429 const char * s ;
430- int r ;
431430
432431 assert (m );
433432 assert (ret );
@@ -439,13 +438,16 @@ int manager_get_route_table_to_string(const Manager *m, uint32_t table, char **r
439438 if (!s )
440439 s = hashmap_get (m -> route_table_names_by_number , UINT32_TO_PTR (table ));
441440
442- if (s )
443- /* Currently, this is only used in debugging logs. To not confuse any bug
444- * reports, let's include the table number. */
445- r = asprintf (& str , "%s(%" PRIu32 ")" , s , table );
446- else
447- r = asprintf (& str , "%" PRIu32 , table );
448- if (r < 0 )
441+ if (s && !append_num ) {
442+ str = strdup (s );
443+ if (!str )
444+ return - ENOMEM ;
445+
446+ } else if (asprintf (& str , "%s%s%" PRIu32 "%s" ,
447+ strempty (s ),
448+ s ? "(" : "" ,
449+ table ,
450+ s ? ")" : "" ) < 0 )
449451 return - ENOMEM ;
450452
451453 * ret = TAKE_PTR (str );
@@ -512,9 +514,10 @@ int config_parse_route_table_names(
512514 "Route table name cannot be numeric. Ignoring assignment: %s:%s" , name , num );
513515 continue ;
514516 }
515- if (STR_IN_SET (name , "default" , "main" , "local" ) ) {
517+ if (route_table_from_string (name ) >= 0 ) {
516518 log_syntax (unit , LOG_WARNING , filename , line , 0 ,
517- "Route table name %s is already predefined. Ignoring assignment: %s:%s" , name , name , num );
519+ "Route table name %s is predefined for %i. Ignoring assignment: %s:%s" ,
520+ name , route_table_from_string (name ), name , num );
518521 continue ;
519522 }
520523
@@ -529,6 +532,12 @@ int config_parse_route_table_names(
529532 "Invalid route table number, ignoring assignment: %s:%s" , name , num );
530533 continue ;
531534 }
535+ if (route_table_to_string (table )) {
536+ log_syntax (unit , LOG_WARNING , filename , line , 0 ,
537+ "Route table name for %s is predefined (%s). Ignoring assignment: %s:%s" ,
538+ num , route_table_to_string (table ), name , num );
539+ continue ;
540+ }
532541
533542 r = hashmap_ensure_put (& m -> route_table_numbers_by_name , & string_hash_ops_free , name , UINT32_TO_PTR (table ));
534543 if (r == - ENOMEM )
0 commit comments