summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-12-05 04:36:48 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-12-07 18:35:30 +0900
commit5ed10a194a5e577baadd49d10928550ee8b89142 (patch)
treec45317b6c53b076734a7d66a498ca451d51b7b85
parenta536ec3872b929e0036f894052d2f0a73c590a9c (diff)
downloadsystemd-5ed10a194a5e577baadd49d10928550ee8b89142.tar.gz
network: dhcp6pd: set server address for unreachable route
This is just for json output.
-rw-r--r--src/network/networkd-dhcp-prefix-delegation.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c
index b388a9f882..46e75e77c1 100644
--- a/src/network/networkd-dhcp-prefix-delegation.c
+++ b/src/network/networkd-dhcp-prefix-delegation.c
@@ -665,13 +665,20 @@ static int dhcp6_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li
return 1;
}
-static int dhcp6_request_unreachable_route(Link *link, const struct in6_addr *addr, uint8_t prefixlen, usec_t lifetime_usec) {
+static int dhcp6_request_unreachable_route(
+ Link *link,
+ const struct in6_addr *addr,
+ uint8_t prefixlen,
+ usec_t lifetime_usec,
+ const union in_addr_union *server_address) {
+
_cleanup_(route_freep) Route *route = NULL;
Route *existing;
int r;
assert(link);
assert(addr);
+ assert(server_address);
if (prefixlen >= 64) {
_cleanup_free_ char *buf = NULL;
@@ -687,6 +694,7 @@ static int dhcp6_request_unreachable_route(Link *link, const struct in6_addr *ad
return log_oom();
route->source = NETWORK_CONFIG_SOURCE_DHCP6;
+ route->provider = *server_address;
route->family = AF_INET6;
route->dst.in6 = *addr;
route->dst_prefixlen = prefixlen;
@@ -797,6 +805,7 @@ static int dhcp6_pd_assign_prefixes(Link *link, Link *uplink) {
}
int dhcp6_pd_prefix_acquired(Link *dhcp6_link) {
+ union in_addr_union server_address;
usec_t timestamp_usec;
Link *link;
int r;
@@ -804,6 +813,10 @@ int dhcp6_pd_prefix_acquired(Link *dhcp6_link) {
assert(dhcp6_link);
assert(dhcp6_link->dhcp6_lease);
+ r = sd_dhcp6_lease_get_server_address(dhcp6_link->dhcp6_lease, &server_address.in6);
+ if (r < 0)
+ return log_link_warning_errno(dhcp6_link, r, "Failed to get server address of DHCPv6 lease: %m");
+
r = sd_dhcp6_lease_get_timestamp(dhcp6_link->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec);
if (r < 0)
return log_link_warning_errno(dhcp6_link, r, "Failed to get timestamp of DHCPv6 lease: %m");
@@ -831,7 +844,7 @@ int dhcp6_pd_prefix_acquired(Link *dhcp6_link) {
if (r < 0)
return r;
- r = dhcp6_request_unreachable_route(dhcp6_link, &pd_prefix, pd_prefix_len, lifetime_valid_usec);
+ r = dhcp6_request_unreachable_route(dhcp6_link, &pd_prefix, pd_prefix_len, lifetime_valid_usec, &server_address);
if (r < 0)
return r;
}