mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-24 02:03:54 +03:00
networkd: route - rename fields in struct
This commit is contained in:
parent
cb2266f931
commit
2ce4095690
@ -87,9 +87,9 @@ static int link_set_dhcp_routes(Link *link) {
|
||||
* route for the gw host so that we can route no matter the
|
||||
* netmask or existing kernel route tables. */
|
||||
route_gw->family = AF_INET;
|
||||
route_gw->dst_addr.in = gateway;
|
||||
route_gw->dst.in = gateway;
|
||||
route_gw->dst_prefixlen = 32;
|
||||
route_gw->prefsrc_addr.in = address;
|
||||
route_gw->prefsrc.in = address;
|
||||
route_gw->scope = RT_SCOPE_LINK;
|
||||
route_gw->protocol = RTPROT_DHCP;
|
||||
route_gw->metrics = link->network->dhcp_route_metric;
|
||||
@ -101,8 +101,8 @@ static int link_set_dhcp_routes(Link *link) {
|
||||
link->dhcp4_messages ++;
|
||||
|
||||
route->family = AF_INET;
|
||||
route->in_addr.in = gateway;
|
||||
route->prefsrc_addr.in = address;
|
||||
route->gw.in = gateway;
|
||||
route->prefsrc.in = address;
|
||||
route->metrics = link->network->dhcp_route_metric;
|
||||
|
||||
r = route_configure(route, link, &dhcp4_route_handler);
|
||||
@ -130,8 +130,8 @@ static int link_set_dhcp_routes(Link *link) {
|
||||
|
||||
route->family = AF_INET;
|
||||
route->protocol = RTPROT_DHCP;
|
||||
route->in_addr.in = static_routes[i].gw_addr;
|
||||
route->dst_addr.in = static_routes[i].dst_addr;
|
||||
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;
|
||||
|
||||
@ -170,8 +170,8 @@ static int dhcp_lease_lost(Link *link) {
|
||||
r = route_new(&route);
|
||||
if (r >= 0) {
|
||||
route->family = AF_INET;
|
||||
route->in_addr.in = routes[i].gw_addr;
|
||||
route->dst_addr.in = routes[i].dst_addr;
|
||||
route->gw.in = routes[i].gw_addr;
|
||||
route->dst.in = routes[i].dst_addr;
|
||||
route->dst_prefixlen = routes[i].dst_prefixlen;
|
||||
|
||||
route_remove(route, link,
|
||||
@ -191,7 +191,7 @@ static int dhcp_lease_lost(Link *link) {
|
||||
r = route_new(&route_gw);
|
||||
if (r >= 0) {
|
||||
route_gw->family = AF_INET;
|
||||
route_gw->dst_addr.in = gateway;
|
||||
route_gw->dst.in = gateway;
|
||||
route_gw->dst_prefixlen = 32;
|
||||
route_gw->scope = RT_SCOPE_LINK;
|
||||
|
||||
@ -202,7 +202,7 @@ static int dhcp_lease_lost(Link *link) {
|
||||
r = route_new(&route);
|
||||
if (r >= 0) {
|
||||
route->family = AF_INET;
|
||||
route->in_addr.in = gateway;
|
||||
route->gw.in = gateway;
|
||||
|
||||
route_remove(route, link,
|
||||
&link_route_remove_handler);
|
||||
|
@ -2450,9 +2450,9 @@ int link_save(Link *link) {
|
||||
}
|
||||
}
|
||||
|
||||
fputs("\n", f);
|
||||
fputc('\n', f);
|
||||
|
||||
fprintf(f, "NTP=");
|
||||
fputs("NTP=", f);
|
||||
space = false;
|
||||
STRV_FOREACH(address, link->network->ntp) {
|
||||
if (space)
|
||||
@ -2499,9 +2499,9 @@ int link_save(Link *link) {
|
||||
}
|
||||
}
|
||||
|
||||
fputs("\n", f);
|
||||
fputc('\n', f);
|
||||
|
||||
fprintf(f, "DOMAINS=");
|
||||
fputs("DOMAINS=", f);
|
||||
space = false;
|
||||
STRV_FOREACH(domain, link->network->domains) {
|
||||
if (space)
|
||||
@ -2537,7 +2537,7 @@ int link_save(Link *link) {
|
||||
}
|
||||
}
|
||||
|
||||
fputs("\n", f);
|
||||
fputc('\n', f);
|
||||
|
||||
fprintf(f, "WILDCARD_DOMAIN=%s\n",
|
||||
yes_no(link->network->wildcard_domain));
|
||||
@ -2545,7 +2545,7 @@ int link_save(Link *link) {
|
||||
fprintf(f, "LLMNR=%s\n",
|
||||
resolve_support_to_string(link->network->llmnr));
|
||||
|
||||
fprintf(f, "ADDRESSES=");
|
||||
fputs("ADDRESSES=", f);
|
||||
space = false;
|
||||
SET_FOREACH(a, link->addresses, i) {
|
||||
_cleanup_free_ char *address_str = NULL;
|
||||
@ -2558,7 +2558,7 @@ int link_save(Link *link) {
|
||||
space = true;
|
||||
}
|
||||
|
||||
fputs("\n", f);
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
if (!hashmap_isempty(link->bound_to_links)) {
|
||||
@ -2573,7 +2573,7 @@ int link_save(Link *link) {
|
||||
space = true;
|
||||
}
|
||||
|
||||
fputs("\n", f);
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
if (!hashmap_isempty(link->bound_by_links)) {
|
||||
@ -2588,7 +2588,7 @@ int link_save(Link *link) {
|
||||
space = true;
|
||||
}
|
||||
|
||||
fputs("\n", f);
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
if (link->dhcp_lease) {
|
||||
|
@ -361,7 +361,7 @@ int network_apply(Manager *manager, Network *network, Link *link) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = inet_pton(AF_INET, "169.254.0.0", &route->dst_addr.in);
|
||||
r = inet_pton(AF_INET, "169.254.0.0", &route->dst.in);
|
||||
if (r == 0)
|
||||
return -EINVAL;
|
||||
if (r < 0)
|
||||
|
@ -110,7 +110,7 @@ static void route_hash_func(const void *b, struct siphash *state) {
|
||||
case AF_INET6:
|
||||
/* Equality of routes are given by the 4-touple
|
||||
(dst_prefix,dst_prefixlen,tos,priority,table) */
|
||||
siphash24_compress(&route->dst_addr, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
siphash24_compress(&route->dst, FAMILY_ADDRESS_SIZE(route->family), state);
|
||||
siphash24_compress(&route->dst_prefixlen, sizeof(route->dst_prefixlen), state);
|
||||
siphash24_compress(&route->tos, sizeof(route->tos), state);
|
||||
siphash24_compress(&route->priority, sizeof(route->priority), state);
|
||||
@ -155,7 +155,7 @@ static int route_compare_func(const void *_a, const void *_b) {
|
||||
if (a->table > b->table)
|
||||
return 1;
|
||||
|
||||
return memcmp(&a->dst_addr, &b->dst_addr, FAMILY_ADDRESS_SIZE(a->family));
|
||||
return memcmp(&a->dst, &b->dst, FAMILY_ADDRESS_SIZE(a->family));
|
||||
default:
|
||||
/* treat any other address family as AF_UNSPEC */
|
||||
return 0;
|
||||
@ -184,20 +184,20 @@ int route_remove(Route *route, Link *link,
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not create RTM_DELROUTE message: %m");
|
||||
|
||||
if (!in_addr_is_null(route->family, &route->in_addr)) {
|
||||
if (!in_addr_is_null(route->family, &route->gw)) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->gw.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_GATEWAY, &route->gw.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m");
|
||||
}
|
||||
|
||||
if (route->dst_prefixlen) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_DST, &route->dst_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_DST, &route->dst.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_DST, &route->dst.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_DST attribute: %m");
|
||||
|
||||
@ -208,9 +208,9 @@ int route_remove(Route *route, Link *link,
|
||||
|
||||
if (route->src_prefixlen) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_SRC, &route->src_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_SRC, &route->src.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_SRC, &route->src_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_SRC, &route->src.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_DST attribute: %m");
|
||||
|
||||
@ -219,11 +219,11 @@ int route_remove(Route *route, Link *link,
|
||||
return log_error_errno(r, "Could not set source prefix length: %m");
|
||||
}
|
||||
|
||||
if (!in_addr_is_null(route->family, &route->prefsrc_addr)) {
|
||||
if (!in_addr_is_null(route->family, &route->prefsrc)) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m");
|
||||
}
|
||||
@ -266,20 +266,20 @@ int route_configure(Route *route, Link *link,
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not create RTM_NEWROUTE message: %m");
|
||||
|
||||
if (!in_addr_is_null(route->family, &route->in_addr)) {
|
||||
if (!in_addr_is_null(route->family, &route->gw)) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->in_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_GATEWAY, &route->gw.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_GATEWAY, &route->gw.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_GATEWAY attribute: %m");
|
||||
}
|
||||
|
||||
if (route->dst_prefixlen) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_DST, &route->dst_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_DST, &route->dst.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_DST, &route->dst.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_DST attribute: %m");
|
||||
|
||||
@ -290,9 +290,9 @@ int route_configure(Route *route, Link *link,
|
||||
|
||||
if (route->src_prefixlen) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_SRC, &route->src_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_SRC, &route->src.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_SRC, &route->src_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_SRC, &route->src.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_SRC attribute: %m");
|
||||
|
||||
@ -301,11 +301,11 @@ int route_configure(Route *route, Link *link,
|
||||
return log_error_errno(r, "Could not set source prefix length: %m");
|
||||
}
|
||||
|
||||
if (!in_addr_is_null(route->family, &route->prefsrc_addr)) {
|
||||
if (!in_addr_is_null(route->family, &route->prefsrc)) {
|
||||
if (route->family == AF_INET)
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in);
|
||||
r = sd_netlink_message_append_in_addr(req, RTA_PREFSRC, &route->prefsrc.in);
|
||||
else if (route->family == AF_INET6)
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6);
|
||||
r = sd_netlink_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc.in6);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not append RTA_PREFSRC attribute: %m");
|
||||
}
|
||||
@ -370,7 +370,7 @@ int config_parse_gateway(const char *unit,
|
||||
}
|
||||
|
||||
n->family = f;
|
||||
n->in_addr = buffer;
|
||||
n->gw = buffer;
|
||||
n = NULL;
|
||||
|
||||
return 0;
|
||||
@ -410,7 +410,7 @@ int config_parse_preferred_src(const char *unit,
|
||||
}
|
||||
|
||||
n->family = f;
|
||||
n->prefsrc_addr = buffer;
|
||||
n->prefsrc = buffer;
|
||||
n = NULL;
|
||||
|
||||
return 0;
|
||||
@ -484,10 +484,10 @@ int config_parse_destination(const char *unit,
|
||||
|
||||
n->family = f;
|
||||
if (streq(lvalue, "Destination")) {
|
||||
n->dst_addr = buffer;
|
||||
n->dst = buffer;
|
||||
n->dst_prefixlen = prefixlen;
|
||||
} else if (streq(lvalue, "Source")) {
|
||||
n->src_addr = buffer;
|
||||
n->src = buffer;
|
||||
n->src_prefixlen = prefixlen;
|
||||
} else
|
||||
assert_not_reached(lvalue);
|
||||
|
@ -40,10 +40,10 @@ struct Route {
|
||||
unsigned char priority;
|
||||
unsigned char table;
|
||||
|
||||
union in_addr_union in_addr;
|
||||
union in_addr_union dst_addr;
|
||||
union in_addr_union src_addr;
|
||||
union in_addr_union prefsrc_addr;
|
||||
union in_addr_union gw;
|
||||
union in_addr_union dst;
|
||||
union in_addr_union src;
|
||||
union in_addr_union prefsrc;
|
||||
|
||||
LIST_FIELDS(Route, routes);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user