]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Introduce socket tagging capabilities to the DNS resolver google/grte/v5-2.27/master
authorHazael Sanchez <hazael@google.com>
Fri, 15 Aug 2025 17:26:15 +0000 (10:26 -0700)
committerPranav Kant <prka@google.com>
Fri, 15 Aug 2025 17:27:05 +0000 (10:27 -0700)
Internal bug: b/419200756

resolv/res_send.c

index 9e9541789b2e6eab77d7aaf083c61a8d73948072..ce63ea8a91ee22cd5b8a1d28999c7b1b853c46b4 100644 (file)
 #define MAXPACKET       65536
 #endif
 
+static inline void tag_socket(int fd) {
+#if defined(SO_NET_PROTOCOL_ID) && defined(PROTOCOL_ID_DNS)
+       int id = PROTOCOL_ID_DNS;
+       setsockopt(fd, SOL_SOCKET, SO_NET_PROTOCOL_ID, &id, sizeof(id));
+#endif
+}
+
 /* From ev_streams.c.  */
 
 static inline void
@@ -743,6 +750,7 @@ send_vc(res_state statp,
                        return (-1);
                }
                __set_errno (0);
+               tag_socket(statp->_vcsock);
                if (connect(statp->_vcsock, nsap,
                            nsap->sa_family == AF_INET
                            ? sizeof (struct sockaddr_in)
@@ -945,6 +953,7 @@ reopen (res_state statp, int *terrno, int ns)
                        *terrno = errno;
                        return (-1);
                }
+               tag_socket(EXT(statp).nssocks[ns]);
 
                /*
                 * On a 4.3BSD+ machine (client and server,