From 49228c7520b55edbeb6f8ccc469ae6309363d876 Mon Sep 17 00:00:00 2001 From: Patrik Flykt Date: Fri, 7 Sep 2018 14:37:56 -0600 Subject: [PATCH] dhcp6-lease: Add function to fetch the IAID for the prefix Add function to fetch the IAID for the delegated IA_PD prefix. In order to keep things simple in the implemntation, the same IAID is used with IA_NA addresses and IA_PD prefixes. But the DHCPv6 server can choose to return only IA_PD prefixes, and the client can nowadays omit requesting of IA_NA addresses. Since the function fetching said IAID from the lease looks only for IA_NA ones, it will return an empty IAID, which of course does not match the one set for prefixes. Fix this by adding a function returning the IAID for the prefix. --- src/libsystemd-network/dhcp6-lease-internal.h | 1 + src/libsystemd-network/sd-dhcp6-client.c | 2 +- src/libsystemd-network/sd-dhcp6-lease.c | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libsystemd-network/dhcp6-lease-internal.h b/src/libsystemd-network/dhcp6-lease-internal.h index ff0b0f0..c05c32d 100644 --- a/src/libsystemd-network/dhcp6-lease-internal.h +++ b/src/libsystemd-network/dhcp6-lease-internal.h @@ -50,6 +50,7 @@ int dhcp6_lease_set_rapid_commit(sd_dhcp6_lease *lease); int dhcp6_lease_get_rapid_commit(sd_dhcp6_lease *lease, bool *rapid_commit); int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid); +int dhcp6_lease_get_pd_iaid(sd_dhcp6_lease *lease, be32_t *iaid); int dhcp6_lease_set_dns(sd_dhcp6_lease *lease, uint8_t *optval, size_t optlen); int dhcp6_lease_set_domains(sd_dhcp6_lease *lease, uint8_t *optval, diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index f857c79..a803097 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -955,7 +955,7 @@ static int client_parse_message( if (r < 0 && r != -ENOMSG) return r; - r = dhcp6_lease_get_iaid(lease, &iaid_lease); + r = dhcp6_lease_get_pd_iaid(lease, &iaid_lease); if (r < 0) return r; diff --git a/src/libsystemd-network/sd-dhcp6-lease.c b/src/libsystemd-network/sd-dhcp6-lease.c index 5428313..971d963 100644 --- a/src/libsystemd-network/sd-dhcp6-lease.c +++ b/src/libsystemd-network/sd-dhcp6-lease.c @@ -136,6 +136,15 @@ int dhcp6_lease_get_iaid(sd_dhcp6_lease *lease, be32_t *iaid) { return 0; } +int dhcp6_lease_get_pd_iaid(sd_dhcp6_lease *lease, be32_t *iaid) { + assert_return(lease, -EINVAL); + assert_return(iaid, -EINVAL); + + *iaid = lease->pd.ia_pd.id; + + return 0; +} + int sd_dhcp6_lease_get_address(sd_dhcp6_lease *lease, struct in6_addr *addr, uint32_t *lifetime_preferred, uint32_t *lifetime_valid) { -- 2.7.4