n-acd: use separate seed state for each probe of the same acd

Currently, all the probes of an acd instance share the same seed
state. This means that the state is updated by all the probes, and as
a consequence they get different jitters for the wait timeouts;
therefore the order in which addresses become available (and are
configured on the interface) is not deterministic.

Keep a separate seed state for each probe, initialized from the acd
seed. This ensures that all the probes use the same timeouts when
sending probe requests, and that in case of no collision, addresses
are available in the order of probe start.

n-acd pull request: https://github.com/nettools/n-acd/pull/10
This commit is contained in:
Beniamino Galvani 2023-09-01 16:40:29 +02:00
parent e97ebb2441
commit 23727917b2
2 changed files with 3 additions and 1 deletions

View File

@ -105,6 +105,7 @@ struct NAcdProbe {
void *userdata;
/* state */
unsigned int seed;
unsigned int state;
unsigned int n_iteration;
unsigned int defend;

View File

@ -172,7 +172,7 @@ static void n_acd_probe_schedule(NAcdProbe *probe, uint64_t n_timeout, unsigned
if (n_jitter) {
uint64_t random;
random = ((uint64_t)rand_r(&probe->acd->seed) << 32) | (uint64_t)rand_r(&probe->acd->seed);
random = ((uint64_t)rand_r(&probe->seed) << 32) | (uint64_t)rand_r(&probe->seed);
n_time += random % n_jitter;
}
@ -283,6 +283,7 @@ int n_acd_probe_new(NAcdProbe **probep, NAcd *acd, NAcdProbeConfig *config) {
*probe = (NAcdProbe)N_ACD_PROBE_NULL(*probe);
probe->acd = n_acd_ref(acd);
probe->ip = config->ip;
probe->seed = acd->seed;
/*
* We use the provided timeout-length as multiplier for all our