dhcp-transport: Do not leak fds during bind
When a lease is renewed, the transport bind operation is called. This
can be done multiple times by dhcp_client, whenever a lease has been
obtained or renewed. This can result in fds being leaked.
If bind operation has previously succeeded, simply return and reuse the
already created fd.
diff --git a/ell/dhcp-transport.c b/ell/dhcp-transport.c
index a00a4af..ef030de 100644
--- a/ell/dhcp-transport.c
+++ b/ell/dhcp-transport.c
@@ -362,6 +362,9 @@
if (!transport->io)
return -EIO;
+ if (transport->udp_fd >= 0)
+ return 0;
+
fd = kernel_udp_socket_open(transport->ifname, saddr, transport->port);
if (fd < 0)
return fd;
@@ -558,6 +561,7 @@
transport->super.ifindex = ifindex;
l_strlcpy(transport->ifname, ifname, IFNAMSIZ);
transport->port = port;
+ transport->udp_fd = -1;
return &transport->super;
}