]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: route: read RTA_TABLE attribute to get route table
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 29 Nov 2021 10:38:24 +0000 (19:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 30 Nov 2021 18:53:09 +0000 (03:53 +0900)
If the table of a route is larger than 255, then the value is stored in
RTA_TABLE attribute. But the attribute is not supported by old kernels.
So, first try to read the value from RTA_TABLE attribute, then fallback
to the value in the message header.

src/network/networkd-route.c

index 23716342826713bb05ba061813b5f900891b45ed..6bda0833609636dc3a0e8fcf8e41df2ef348cb85 100644 (file)
@@ -1723,12 +1723,16 @@ int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Ma
                 return 0;
         }
 
-        r = sd_rtnl_message_route_get_table(message, &table);
+        r = sd_netlink_message_read_u32(message, RTA_TABLE, &tmp->table);
+        if (r == -ENODATA) {
+                r = sd_rtnl_message_route_get_table(message, &table);
+                if (r >= 0)
+                        tmp->table = table;
+        }
         if (r < 0) {
                 log_link_warning_errno(link, r, "rtnl: received route message with invalid table, ignoring: %m");
                 return 0;
         }
-        tmp->table = table;
 
         r = sd_netlink_message_read_u32(message, RTA_PRIORITY, &tmp->priority);
         if (r < 0 && r != -ENODATA) {