net: mdns_responder: Set socket of service for statistics purposes

If the dispatcher is muxing the connection i.e., so there are two
services for the same port, then mark service socket descriptor
of the service with the socket number so that "net sockets" shell
command can show a proper value for it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-09-09 10:27:16 +03:00 committed by Anas Nashif
parent caf9fd345f
commit 1f627e3a1b

View file

@ -678,6 +678,13 @@ static int register_dispatcher(struct mdns_responder_context *ctx,
ctx->dispatcher.mdns_ctx = ctx;
ctx->dispatcher.pair = NULL;
/* Mark the fd so that "net sockets" can show it. This is needed if there
* is already a socket bound to same port and the dispatcher will mux
* the connections. Without this, the FD in "net sockets" services list will
* show the socket descriptor value as -1.
*/
svc->pev[0].event.fd = ctx->sock;
if (IS_ENABLED(CONFIG_NET_IPV6) && local->sa_family == AF_INET6) {
memcpy(&ctx->dispatcher.local_addr, local,
sizeof(struct sockaddr_in6));