mirror of
https://github.com/systemd/systemd.git
synced 2024-10-30 06:25:37 +03:00
dhcp6: Compute the minimum lifetimes for T1 and T2
Compute one set of minimum lifetimes for T1 and T2, i.e. the smaller ones assigned to IA NA and IA PD. The lifetimes should be the same, see RFC 7550 for details.
This commit is contained in:
parent
103b81ee8c
commit
b47fb949b3
@ -772,6 +772,7 @@ static int client_parse_message(
|
||||
bool clientid = false;
|
||||
uint8_t *id = NULL;
|
||||
size_t id_len;
|
||||
uint32_t lt_t1 = ~0, lt_t2 = ~0;
|
||||
|
||||
assert(client);
|
||||
assert(message);
|
||||
@ -872,6 +873,11 @@ static int client_parse_message(
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (lease->ia.addresses) {
|
||||
lt_t1 = MIN(lt_t1, be32toh(lease->ia.ia_na.lifetime_t1));
|
||||
lt_t2 = MIN(lt_t2, be32toh(lease->ia.ia_na.lifetime_t1));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SD_DHCP6_OPTION_IA_PD:
|
||||
@ -895,6 +901,11 @@ static int client_parse_message(
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (lease->pd.addresses) {
|
||||
lt_t1 = MIN(lt_t1, be32toh(lease->pd.ia_pd.lifetime_t1));
|
||||
lt_t2 = MIN(lt_t2, be32toh(lease->pd.ia_pd.lifetime_t2));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SD_DHCP6_OPTION_RAPID_COMMIT:
|
||||
@ -947,6 +958,17 @@ static int client_parse_message(
|
||||
if (r < 0)
|
||||
log_dhcp6_client(client, "%s has no server id",
|
||||
dhcp6_message_type_to_string(message->type));
|
||||
return r;
|
||||
}
|
||||
|
||||
if (lease->ia.addresses) {
|
||||
lease->ia.ia_na.lifetime_t1 = htobe32(lt_t1);
|
||||
lease->ia.ia_na.lifetime_t2 = htobe32(lt_t2);
|
||||
}
|
||||
|
||||
if (lease->pd.addresses) {
|
||||
lease->pd.ia_pd.lifetime_t1 = htobe32(lt_t1);
|
||||
lease->pd.ia_pd.lifetime_t2 = htobe32(lt_t2);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
Loading…
Reference in New Issue
Block a user