* [PATCH] dhcp-transport: Do not leak fds during bind
@ 2022-05-16 19:55 Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-05-16 19:55 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]
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.
---
ell/dhcp-transport.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/ell/dhcp-transport.c b/ell/dhcp-transport.c
index 52da2db04f49..b466f136972c 100644
--- a/ell/dhcp-transport.c
+++ b/ell/dhcp-transport.c
@@ -361,6 +361,9 @@ static int _dhcp_default_transport_bind(struct dhcp_transport *s,
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;
@@ -552,6 +555,7 @@ struct dhcp_transport *_dhcp_default_transport_new(uint32_t ifindex,
transport->super.ifindex = ifindex;
l_strlcpy(transport->ifname, ifname, IFNAMSIZ);
transport->port = port;
+ transport->udp_fd = -1;
return &transport->super;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dhcp-transport: Do not leak fds during bind
@ 2022-05-18 16:22 Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-05-18 16:22 UTC (permalink / raw)
To: ell
[-- Attachment #1: Type: text/plain, Size: 445 bytes --]
On 5/16/22 14:55, Denis Kenzior wrote:
> 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.
> ---
> ell/dhcp-transport.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-18 16:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-16 19:55 [PATCH] dhcp-transport: Do not leak fds during bind Denis Kenzior
-- strict thread matches above, loose matches on Subject: below --
2022-05-18 16:22 Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.