From: Denis Kenzior <denkenz at gmail.com>
To: ell at lists.01.org
Subject: [PATCH] dhcp-transport: Do not leak fds during bind
Date: Mon, 16 May 2022 14:55:33 -0500 [thread overview]
Message-ID: <20220516195533.31106-1-denkenz@gmail.com> (raw)
[-- 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
next reply other threads:[~2022-05-16 19:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 19:55 Denis Kenzior [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-05-18 16:22 [PATCH] dhcp-transport: Do not leak fds during bind Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220516195533.31106-1-denkenz@gmail.com \
--to=ell@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).