From: Hazael Sanchez Date: Fri, 15 Aug 2025 17:26:15 +0000 (-0700) Subject: Introduce socket tagging capabilities to the DNS resolver X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fgoogle%2Fgrte%2Fv5-2.27%2Fmaster;p=thirdparty%2Fglibc.git Introduce socket tagging capabilities to the DNS resolver Internal bug: b/419200756 --- diff --git a/resolv/res_send.c b/resolv/res_send.c index 9e9541789b2..ce63ea8a91e 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -117,6 +117,13 @@ #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,