Using NCS 3.1.0 - getaddrinfo with "offloaded sockets" (nrf9160/51) and ipv6 results in struct sockaddr_in6, where some "c struct padding bytes" (the last 3 of 24 bytes) are filled with garbage. That makes it impossible to handle them in a generic way using the pointer to that struct and the length (here 24).
E.g. sending data via UDP to that destination (with garbage padding) works, but receiving data with recvfrom fill the source address also with 24 bytes, but the 3 padding bytes differ from the random garbage. Therefore a memcmp(dest, source, source_size) will fail.
Please consider to add an initialization for these padding bytes, see attached patch.
4353.getaddrinfo-fix-garbage-in-struct-sockaddrin6-paddin.patch