nzrdhcp: define lease in request ack
This commit is contained in:
parent
37a1b0f3a0
commit
693156dc3e
|
@ -78,20 +78,18 @@ async fn handle_message(ctx: &Context, from: SocketAddr, msg: &Message) {
|
|||
let mut nak = false;
|
||||
|
||||
let mut response = match msg_type {
|
||||
MessageType::Discover => {
|
||||
lease_time = Some(DEFAULT_LEASE);
|
||||
make_reply(
|
||||
msg,
|
||||
MessageType::Offer,
|
||||
Some(instance.lease.addr.addr),
|
||||
true,
|
||||
)
|
||||
}
|
||||
MessageType::Discover => make_reply(
|
||||
msg,
|
||||
MessageType::Offer,
|
||||
Some(instance.lease.addr.addr),
|
||||
true,
|
||||
),
|
||||
MessageType::Request => {
|
||||
if let Some(DhcpOption::RequestedIpAddress(addr)) =
|
||||
msg.opts().get(OptionCode::RequestedIpAddress)
|
||||
{
|
||||
if *addr == instance.lease.addr.addr {
|
||||
lease_time = Some(DEFAULT_LEASE);
|
||||
make_reply(msg, MessageType::Ack, Some(instance.lease.addr.addr), true)
|
||||
} else {
|
||||
nak = true;
|
||||
|
@ -150,8 +148,6 @@ async fn handle_message(ctx: &Context, from: SocketAddr, msg: &Message) {
|
|||
};
|
||||
|
||||
opts.insert(DhcpOption::Hostname(instance.name.clone()));
|
||||
// TODO: hack for now. if this actually fixes the networkd issue, we'll need to figure out how to get the MTU
|
||||
opts.insert(DhcpOption::InterfaceMtu(1500));
|
||||
|
||||
if !subnet.dns.is_empty() {
|
||||
opts.insert(DhcpOption::DomainNameServer(subnet.dns));
|
||||
|
|
Loading…
Reference in a new issue