summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/fuzz-dhcp-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd-network/fuzz-dhcp-server.c')
-rw-r--r--src/libsystemd-network/fuzz-dhcp-server.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/libsystemd-network/fuzz-dhcp-server.c b/src/libsystemd-network/fuzz-dhcp-server.c
index 3929a2a4d7..3e1efcf7fe 100644
--- a/src/libsystemd-network/fuzz-dhcp-server.c
+++ b/src/libsystemd-network/fuzz-dhcp-server.c
@@ -18,16 +18,17 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags) {
}
static int add_lease(sd_dhcp_server *server, const struct in_addr *server_address, uint8_t i) {
- _cleanup_(dhcp_lease_freep) DHCPLease *lease = NULL;
+ _cleanup_(sd_dhcp_server_lease_unrefp) sd_dhcp_server_lease *lease = NULL;
int r;
assert(server);
- lease = new(DHCPLease, 1);
+ lease = new(sd_dhcp_server_lease, 1);
if (!lease)
return -ENOMEM;
- *lease = (DHCPLease) {
+ *lease = (sd_dhcp_server_lease) {
+ .n_ref = 1,
.address = htobe32(UINT32_C(10) << 24 | i),
.chaddr = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
.expiration = UINT64_MAX,
@@ -41,13 +42,7 @@ static int add_lease(sd_dhcp_server *server, const struct in_addr *server_addres
lease->client_id.raw[0] = 2;
lease->client_id.raw[1] = i;
- lease->server = server; /* This must be set just before hashmap_put(). */
-
- r = hashmap_ensure_put(&server->bound_leases_by_client_id, &dhcp_lease_hash_ops, &lease->client_id, lease);
- if (r < 0)
- return r;
-
- r = hashmap_ensure_put(&server->bound_leases_by_address, NULL, UINT32_TO_PTR(lease->address), lease);
+ r = dhcp_server_put_lease(server, lease, /* is_static = */ false);
if (r < 0)
return r;