1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-20 14:03:39 +03:00

network-generator: relax requirement for peer address, route destination, and gateway

No functional changes, as the caller already sets them.

(cherry picked from commit 13a462b9d5dc9ccbbabdf8a37fd4b97c2e048d43)
(cherry picked from commit bb4ab1a5a8d2bbe36aecfd04e271c2b33c5d4f43)
This commit is contained in:
Yu Watanabe 2023-11-08 03:49:12 +09:00 committed by Luca Boccassi
parent a1295dd327
commit 326e756952

View File

@ -96,7 +96,7 @@ static int address_new(Network *network, int family, unsigned char prefixlen,
.family = family,
.prefixlen = prefixlen,
.address = *addr,
.peer = *peer,
.peer = peer ? *peer : IN_ADDR_NULL,
};
LIST_PREPEND(addresses, network->addresses, address);
@ -123,6 +123,8 @@ static int route_new(Network *network, int family, unsigned char prefixlen,
Route *route;
assert(network);
assert(IN_SET(family, AF_INET, AF_INET6));
assert(dest || gateway);
route = new(Route, 1);
if (!route)
@ -132,7 +134,7 @@ static int route_new(Network *network, int family, unsigned char prefixlen,
.family = family,
.prefixlen = prefixlen,
.dest = dest ? *dest : IN_ADDR_NULL,
.gateway = *gateway,
.gateway = gateway ? *gateway : IN_ADDR_NULL,
};
LIST_PREPEND(routes, network->routes, route);
@ -403,7 +405,8 @@ static int network_set_route(Context *context, const char *ifname, int family, u
Network *network;
int r;
if (!in_addr_is_set(family, gateway))
if (!(dest && in_addr_is_set(family, dest)) &&
!(gateway && in_addr_is_set(family, gateway)))
return 0;
network = network_get(context, ifname);
@ -1127,8 +1130,9 @@ static int route_dump(Route *route, FILE *f) {
if (in_addr_is_set(route->family, &route->dest))
fprintf(f, "Destination=%s\n",
IN_ADDR_PREFIX_TO_STRING(route->family, &route->dest, route->prefixlen));
fprintf(f, "Gateway=%s\n",
IN_ADDR_TO_STRING(route->family, &route->gateway));
if (in_addr_is_set(route->family, &route->gateway))
fprintf(f, "Gateway=%s\n",
IN_ADDR_TO_STRING(route->family, &route->gateway));
return 0;
}