diff --git a/src/core/iomgr/socket_utils_common_posix.c b/src/core/iomgr/socket_utils_common_posix.c index 7b264a66504..594660f76dc 100644 --- a/src/core/iomgr/socket_utils_common_posix.c +++ b/src/core/iomgr/socket_utils_common_posix.c @@ -99,6 +99,16 @@ int grpc_set_socket_ip_pktinfo_if_possible(int fd) { #endif } +int grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd) { +#ifdef GPR_HAVE_IPV6_RECVPKTINFO + int get_local_ip = 1; + return setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &get_local_ip, + sizeof(get_local_ip)); +#else + return 1; +#endif +} + /* set a socket to close on exec */ int grpc_set_socket_cloexec(int fd, int close_on_exec) { int oldflags = fcntl(fd, F_GETFD, 0);