Skip to content

net: mdns increase buf size #89338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

toonst
Copy link
Contributor

@toonst toonst commented Apr 30, 2025

for longer DNS-SD text records and instance names we need a bigger buffer

@@ -115,8 +115,9 @@ static int setup_dst_addr(int sock, sa_family_t family,
#define DNS_RESOLVER_BUF_CTR (DNS_RESOLVER_MIN_BUF + \
CONFIG_MDNS_RESOLVER_ADDITIONAL_BUF_CTR)

#define MDNS_RESOLVER_MAX_BUF_SIZE 1024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you introduce a Kconfig symbol for this, perhaps defaulting the previous default. This way it is easier to adjust the value according to the user needs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done

@toonst toonst force-pushed the mdns_increase_buf_size branch from d3e166a to 22760fa Compare April 30, 2025 15:53
@@ -116,7 +116,7 @@ static int setup_dst_addr(int sock, sa_family_t family,
CONFIG_MDNS_RESOLVER_ADDITIONAL_BUF_CTR)

NET_BUF_POOL_DEFINE(mdns_msg_pool, DNS_RESOLVER_BUF_CTR,
DNS_RESOLVER_MAX_BUF_SIZE, 0, NULL);
CONFIG_MDNS_RESOLVER_BUF_SIZE, 0, NULL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not enough to change this line only because the buffer size is also used in dns_read().
If we only want to use this extra size for mDNS, then we could do something like this:

diff --git a/subsys/net/lib/dns/mdns_responder.c b/subsys/net/lib/dns/mdns_responder.c
index 29f1c657ae1..0ddc08ebb56 100644
--- a/subsys/net/lib/dns/mdns_responder.c
+++ b/subsys/net/lib/dns/mdns_responder.c
@@ -115,8 +115,10 @@ static int setup_dst_addr(int sock, sa_family_t family,
 #define DNS_RESOLVER_BUF_CTR   (DNS_RESOLVER_MIN_BUF + \
                                 CONFIG_MDNS_RESOLVER_ADDITIONAL_BUF_CTR)
 
+#define MDNS_RESOLVER_MAX_BUF_SIZE CONFIG_MDNS_RESOLVER_BUF_SIZE
+
 NET_BUF_POOL_DEFINE(mdns_msg_pool, DNS_RESOLVER_BUF_CTR,
-                   DNS_RESOLVER_MAX_BUF_SIZE, 0, NULL);
+                   MDNS_RESOLVER_MAX_BUF_SIZE, 0, NULL);
 
 static void create_ipv6_addr(struct sockaddr_in6 *addr)
 {
@@ -595,7 +597,7 @@ static int dns_read(int sock,
        int queries;
        int ret;
 
-       data_len = MIN(len, DNS_RESOLVER_MAX_BUF_SIZE);
+       data_len = MIN(len, MDNS_RESOLVER_MAX_BUF_SIZE);
 
        /* Store the DNS query name into a temporary net_buf, which will be
         * eventually used to send a response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@toonst toonst force-pushed the mdns_increase_buf_size branch from 22760fa to 21185ae Compare May 13, 2025 15:15
NET_BUF_POOL_DEFINE(mdns_msg_pool, DNS_RESOLVER_BUF_CTR,
DNS_RESOLVER_MAX_BUF_SIZE, 0, NULL);
MDNS_RESOLVER_BUF_SIZE, 0, NULL);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please stick to the orignal alignment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

for longer DNS-SD text records and instance names we need a bigger
buffer

Signed-off-by: Toon Stegen <toon@toostsolutions.be>
@toonst toonst force-pushed the mdns_increase_buf_size branch from 21185ae to 3e0fe5a Compare May 14, 2025 08:26
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants