Skip to content
Snippets Groups Projects
Commit d241a2c0 authored by Dmitry Fleytman's avatar Dmitry Fleytman Committed by Pekka Enberg
Browse files

DHCP: Repeat DHCP discovery on timeout


It is a bad practice to have DHCP discovery without timeout
and retries. In case discovery packet gets lost boot stucks.

Beside this there is an interesting phenomena on some systems.
A few first DHCP discovery packets sent on boot get lost in some cases.

This started to happen from time to time on my KVM system and almost
every time on my Xen system after installing recent Fedora Core updates.
Packet leaves VM's interface but never arrives to bridge interface.
The packet itself built properly and arrives to DHCP server just fine
after a few retransmissions.

Most probably this phenomena is a bug (or limitation) in the current
Linux bridge version so this patch is actually a work-around, but
since in general case it is a good idea to have DHCP timeouts/retries
it worth to have it anyway.

Signed-off-by: default avatarDmitry Fleytman <dmitry@daynix.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent d8530b6d
No related branches found
No related tags found
No related merge requests found
...@@ -574,16 +574,23 @@ namespace dhcp { ...@@ -574,16 +574,23 @@ namespace dhcp {
_dhcp_thread = new sched::thread([&] { dhcp_worker_fn(); }); _dhcp_thread = new sched::thread([&] { dhcp_worker_fn(); });
_dhcp_thread->start(); _dhcp_thread->start();
// Send discover packets! do {
for (auto &it: _universe) { // Send discover packets!
it.second->discover(); for (auto &it: _universe) {
} it.second->discover();
}
if (wait) { if (wait) {
dhcp_i("Waiting for IP..."); dhcp_i("Waiting for IP...");
_waiter = sched::thread::current(); _waiter = sched::thread::current();
sched::thread::wait_until([&]{ return _have_ip; });
} sched::timer t(*sched::thread::current());
u64 cur_time = clock::get()->time();
t.set(cur_time + 3_s);
sched::thread::wait_until([&]{ return _have_ip || t.expired(); });
}
} while (!_have_ip && wait);
} }
void dhcp_worker::dhcp_worker_fn() void dhcp_worker::dhcp_worker_fn()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment