ouput format: fix active lease printing

Earlier ethernet address collection did not remove duplicated.  Basically
the problem was the same as in problem fixed in commit
ae7747db87, but this time affecting only
the ethernet addresses.  The fix is, as one can see, to make ethernet
collection to share structure with the lease, so that if one is wrong
both are wrong the same way.

Reported-by: Gilles Bouthenot <gilles.bouthenot@univ-fcomte.fr>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-12-07 21:23:01 +00:00
parent d8aae53968
commit fdc560bab9
5 changed files with 38 additions and 50 deletions

View file

@ -50,6 +50,7 @@ void add_lease(union ipaddr_t *addr, enum ltype type)
} else {
HASH_ADD_INT(leases, ip.v4, l);
}
l->ethernet = NULL;
}
struct leases_t *find_lease(union ipaddr_t *addr)
@ -66,6 +67,8 @@ struct leases_t *find_lease(union ipaddr_t *addr)
void delete_lease(struct leases_t *lease)
{
if (lease->ethernet != NULL)
free(lease->ethernet);
HASH_DEL(leases, lease);
free(lease);
}
@ -86,6 +89,7 @@ void delete_all_leases()
struct leases_t *l;
while (leases) {
l = leases;
free(l->ethernet);
HASH_DEL(leases, l); /* leases advances to next on delete */
free(l);
}