]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
local-addresses: rename metric -> priority
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Jan 2024 10:24:45 +0000 (19:24 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 20 Jan 2024 07:07:19 +0000 (16:07 +0900)
To make it consistent with the netlink attribute RTA_PRIORITY.

src/shared/local-addresses.c
src/shared/local-addresses.h
src/test/test-local-addresses.c

index a1577de0df205a8aaf76b16220fcbfb8a79bc64b..216f5388c75791d4ea1990b3ad393a41044ec4a1 100644 (file)
@@ -25,7 +25,7 @@ static int address_compare(const struct local_address *a, const struct local_add
         if (r != 0)
                 return r;
 
-        r = CMP(a->metric, b->metric);
+        r = CMP(a->priority, b->priority);
         if (r != 0)
                 return r;
 
@@ -180,7 +180,7 @@ static int add_local_gateway(
                 size_t *n_list,
                 int af,
                 int ifindex,
-                uint32_t metric,
+                uint32_t priority,
                 const RouteVia *via) {
 
         assert(list);
@@ -195,7 +195,7 @@ static int add_local_gateway(
 
         (*list)[(*n_list)++] = (struct local_address) {
                 .ifindex = ifindex,
-                .metric = metric,
+                .priority = priority,
                 .family = via->family,
                 .address = via->address,
         };
@@ -249,7 +249,7 @@ int local_gateways(
                 union in_addr_union gateway;
                 uint16_t type;
                 unsigned char dst_len, src_len, table;
-                uint32_t ifi = 0, metric = 0;
+                uint32_t ifi = 0, priority = 0;
                 size_t rta_len;
                 int family;
                 RouteVia via;
@@ -283,7 +283,7 @@ int local_gateways(
                 if (table != RT_TABLE_MAIN)
                         continue;
 
-                r = sd_netlink_message_read_u32(m, RTA_PRIORITY, &metric);
+                r = sd_netlink_message_read_u32(m, RTA_PRIORITY, &priority);
                 if (r < 0 && r != -ENODATA)
                         return r;
 
@@ -308,7 +308,7 @@ int local_gateways(
                         if (r >= 0) {
                                 via.family = family;
                                 via.address = gateway;
-                                r = add_local_gateway(&list, &n_list, af, ifi, metric, &via);
+                                r = add_local_gateway(&list, &n_list, af, ifi, priority, &via);
                                 if (r < 0)
                                         return r;
 
@@ -322,7 +322,7 @@ int local_gateways(
                         if (r < 0 && r != -ENODATA)
                                 return r;
                         if (r >= 0) {
-                                r = add_local_gateway(&list, &n_list, af, ifi, metric, &via);
+                                r = add_local_gateway(&list, &n_list, af, ifi, priority, &via);
                                 if (r < 0)
                                         return r;
 
@@ -344,7 +344,7 @@ int local_gateways(
                                 if (ifindex > 0 && mr->ifindex != ifindex)
                                         continue;
 
-                                r = add_local_gateway(&list, &n_list, af, ifi, metric, &mr->gateway);
+                                r = add_local_gateway(&list, &n_list, af, ifi, priority, &mr->gateway);
                                 if (r < 0)
                                         return r;
                         }
index 38a17d233e61eb7d5847d510e781b5944e32b9ae..42bed2ba0d57fcf6f9639ef2d9d2a1d7c38ab66c 100644 (file)
@@ -6,9 +6,10 @@
 #include "in-addr-util.h"
 
 struct local_address {
-        int family, ifindex;
+        int ifindex;
         unsigned char scope;
-        uint32_t metric;
+        uint32_t priority;
+        int family;
         union in_addr_union address;
 };
 
index bad47bc088a1ed398246e5c9a6c7b4c100fbb3b6..c9ed7bf77d11fe136d647eed0891df864c34cbf7 100644 (file)
@@ -10,8 +10,8 @@
 
 static void print_local_addresses(const struct local_address *a, size_t n) {
         FOREACH_ARRAY(i, a, n)
-                log_debug("%s ifindex=%i scope=%u metric=%"PRIu32" address=%s",
-                          af_to_name(i->family), i->ifindex, i->scope, i->metric,
+                log_debug("%s ifindex=%i scope=%u priority=%"PRIu32" address=%s",
+                          af_to_name(i->family), i->ifindex, i->scope, i->priority,
                           IN_ADDR_TO_STRING(i->family, &i->address));
 }