1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-24 02:03:54 +03:00

networkd: route - clean up confusion between 'metric' and 'priority'

Different tools use different terms for the same concept, let's try
to stick with 'priority', as that is what the netlink API uses.
This commit is contained in:
Tom Gundersen 2015-10-26 17:04:57 +01:00
parent 2ce4095690
commit 86655331bc
5 changed files with 12 additions and 14 deletions

View File

@ -92,7 +92,7 @@ static int link_set_dhcp_routes(Link *link) {
route_gw->prefsrc.in = address;
route_gw->scope = RT_SCOPE_LINK;
route_gw->protocol = RTPROT_DHCP;
route_gw->metrics = link->network->dhcp_route_metric;
route_gw->priority = link->network->dhcp_route_metric;
r = route_configure(route_gw, link, &dhcp4_route_handler);
if (r < 0)
@ -103,7 +103,7 @@ static int link_set_dhcp_routes(Link *link) {
route->family = AF_INET;
route->gw.in = gateway;
route->prefsrc.in = address;
route->metrics = link->network->dhcp_route_metric;
route->priority = link->network->dhcp_route_metric;
r = route_configure(route, link, &dhcp4_route_handler);
if (r < 0) {
@ -133,7 +133,7 @@ static int link_set_dhcp_routes(Link *link) {
route->gw.in = static_routes[i].gw_addr;
route->dst.in = static_routes[i].dst_addr;
route->dst_prefixlen = static_routes[i].dst_prefixlen;
route->metrics = link->network->dhcp_route_metric;
route->priority = link->network->dhcp_route_metric;
r = route_configure(route, link, &dhcp4_route_handler);
if (r < 0)

View File

@ -63,7 +63,7 @@ static int ipv4ll_address_lost(Link *link) {
route->family = AF_INET;
route->scope = RT_SCOPE_LINK;
route->metrics = IPV4LL_ROUTE_METRIC;
route->priority = IPV4LL_ROUTE_METRIC;
route_remove(route, link, &link_route_remove_handler);
@ -156,7 +156,7 @@ static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) {
route->family = AF_INET;
route->scope = RT_SCOPE_LINK;
route->protocol = RTPROT_STATIC;
route->metrics = IPV4LL_ROUTE_METRIC;
route->priority = IPV4LL_ROUTE_METRIC;
r = route_configure(route, link, ipv4ll_route_handler);
if (r < 0)

View File

@ -370,7 +370,7 @@ int network_apply(Manager *manager, Network *network, Link *link) {
route->family = AF_INET;
route->dst_prefixlen = 16;
route->scope = RT_SCOPE_LINK;
route->metrics = IPV4LL_ROUTE_METRIC;
route->priority = IPV4LL_ROUTE_METRIC;
route->protocol = RTPROT_STATIC;
}

View File

@ -134,7 +134,6 @@ static int route_compare_func(const void *_a, const void *_b) {
switch (a->family) {
case AF_INET:
case AF_INET6:
//TODO: check IPv6 routes
if (a->dst_prefixlen < b->dst_prefixlen)
return -1;
if (a->dst_prefixlen > b->dst_prefixlen)
@ -232,7 +231,7 @@ int route_remove(Route *route, Link *link,
if (r < 0)
return log_error_errno(r, "Could not set scope: %m");
r = sd_netlink_message_append_u32(req, RTA_PRIORITY, route->metrics);
r = sd_netlink_message_append_u32(req, RTA_PRIORITY, route->priority);
if (r < 0)
return log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m");
@ -314,7 +313,7 @@ int route_configure(Route *route, Link *link,
if (r < 0)
return log_error_errno(r, "Could not set scope: %m");
r = sd_netlink_message_append_u32(req, RTA_PRIORITY, route->metrics);
r = sd_netlink_message_append_u32(req, RTA_PRIORITY, route->priority);
if (r < 0)
return log_error_errno(r, "Could not append RTA_PRIORITY attribute: %m");
@ -521,9 +520,9 @@ int config_parse_route_priority(const char *unit,
if (r < 0)
return r;
r = config_parse_unsigned(unit, filename, line, section,
section_line, lvalue, ltype,
rvalue, &n->metrics, userdata);
r = config_parse_uint32(unit, filename, line, section,
section_line, lvalue, ltype,
rvalue, &n->priority, userdata);
if (r < 0)
return r;

View File

@ -34,10 +34,9 @@ struct Route {
unsigned char dst_prefixlen;
unsigned char src_prefixlen;
unsigned char scope;
uint32_t metrics;
unsigned char protocol; /* RTPROT_* */
unsigned char tos;
unsigned char priority;
uint32_t priority; /* note that ip(8) calls this 'metric' */
unsigned char table;
union in_addr_union gw;