network: show known route protocol name nicely in debugging logs
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 14 Jul 2019 00:51:54 +0000 (09:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 14 Jul 2019 17:05:40 +0000 (02:05 +0900)
man/systemd.network.xml
src/network/networkd-route.c
src/network/networkd-route.h

index c9d6fd4..712de7d 100644 (file)
           <term><varname>Protocol=</varname></term>
           <listitem>
             <para>The protocol identifier for the route. Takes a number between 0 and 255 or the special values
-            <literal>kernel</literal>, <literal>boot</literal> and <literal>static</literal>. Defaults to
-            <literal>static</literal>.
+            <literal>kernel</literal>, <literal>boot</literal>, <literal>static</literal>,
+            <literal>ra</literal> and <literal>dhcp</literal>. Defaults to <literal>static</literal>.
             </para>
           </listitem>
         </varlistentry>
index ddc0fe2..a4b56ab 100644 (file)
@@ -848,13 +848,38 @@ static const char * const route_protocol_table[] = {
         [RTPROT_STATIC] = "static",
 };
 
-DEFINE_PRIVATE_STRING_TABLE_LOOKUP(route_protocol, int);
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(route_protocol, int);
+
+static const char * const route_protocol_full_table[] = {
+        [RTPROT_REDIRECT] = "redirect",
+        [RTPROT_KERNEL]   = "kernel",
+        [RTPROT_BOOT]     = "boot",
+        [RTPROT_STATIC]   = "static",
+        [RTPROT_GATED]    = "gated",
+        [RTPROT_RA]       = "ra",
+        [RTPROT_MRT]      = "mrt",
+        [RTPROT_ZEBRA]    = "zebra",
+        [RTPROT_BIRD]     = "bird",
+        [RTPROT_DNROUTED] = "dnrouted",
+        [RTPROT_XORP]     = "xorp",
+        [RTPROT_NTK]      = "ntk",
+        [RTPROT_DHCP]     = "dhcp",
+        [RTPROT_MROUTED]  = "mrouted",
+        [RTPROT_BABEL]    = "babel",
+        [RTPROT_BGP]      = "bgp",
+        [RTPROT_ISIS]     = "isis",
+        [RTPROT_OSPF]     = "ospf",
+        [RTPROT_RIP]      = "rip",
+        [RTPROT_EIGRP]    = "eigrp",
+};
+
+DEFINE_PRIVATE_STRING_TABLE_LOOKUP_TO_STRING(route_protocol_full, 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);
+        s = route_protocol_full_to_string(protocol);
         if (s)
                 strpcpy(&p, size, s);
         else
index 86a7a82..fda7dde 100644 (file)
@@ -77,7 +77,7 @@ 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)
 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)
+#define ROUTE_PROTOCOL_STR_MAX CONST_MAX(DECIMAL_STR_MAX(int), STRLEN("redirect") + 1)
 const char *format_route_protocol(int protocol, char *buf, size_t size);
 
 CONFIG_PARSER_PROTOTYPE(config_parse_gateway);