Merge pull request #16163 from apolcyn/revert_revert_windows_breakage

Revert "Revert "Merge pull request #15797 from apolcyn/windows_compile_and_sort""
pull/16184/head
apolcyn 6 years ago committed by GitHub
commit 8fc60d3f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      BUILD
  2. 44
      CMakeLists.txt
  3. 42
      Makefile
  4. 15
      build.yaml
  5. 3
      config.m4
  6. 3
      config.w32
  7. 3
      gRPC-Core.podspec
  8. 3
      grpc.gemspec
  9. 6
      grpc.gyp
  10. 4
      include/grpc/impl/codegen/port_platform.h
  11. 3
      package.xml
  12. 5
      src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
  13. 6
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc
  14. 59
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
  15. 9
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
  16. 4
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h
  17. 29
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc
  18. 29
      src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc
  19. 29
      src/core/lib/iomgr/socket_windows.cc
  20. 4
      src/core/lib/iomgr/socket_windows.h
  21. 3
      src/python/grpcio/grpc_core_dependencies.py
  22. 13
      test/core/iomgr/BUILD
  23. 48
      test/core/iomgr/grpc_ipv6_loopback_available_test.cc
  24. 148
      test/cpp/naming/address_sorting_test.cc
  25. 2
      test/cpp/naming/gen_build_yaml.py
  26. 7
      third_party/address_sorting/address_sorting.c
  27. 46
      third_party/address_sorting/address_sorting_windows.c
  28. 3
      third_party/address_sorting/include/address_sorting/address_sorting.h
  29. 3
      tools/doxygen/Doxyfile.core.internal
  30. 22
      tools/run_tests/generated/sources_and_headers.json
  31. 38
      tools/run_tests/generated/tests.json

@ -1433,7 +1433,10 @@ grpc_cc_library(
"src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc",
], ],
hdrs = [ hdrs = [

@ -298,6 +298,7 @@ add_dependencies(buildtests_c grpc_completion_queue_test)
add_dependencies(buildtests_c grpc_completion_queue_threading_test) add_dependencies(buildtests_c grpc_completion_queue_threading_test)
add_dependencies(buildtests_c grpc_credentials_test) add_dependencies(buildtests_c grpc_credentials_test)
add_dependencies(buildtests_c grpc_fetch_oauth2) add_dependencies(buildtests_c grpc_fetch_oauth2)
add_dependencies(buildtests_c grpc_ipv6_loopback_available_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c grpc_json_token_test) add_dependencies(buildtests_c grpc_json_token_test)
endif() endif()
@ -671,12 +672,8 @@ endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx resolver_component_tests_runner_invoker) add_dependencies(buildtests_cxx resolver_component_tests_runner_invoker)
endif() endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx address_sorting_test_unsecure) add_dependencies(buildtests_cxx address_sorting_test_unsecure)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx address_sorting_test) add_dependencies(buildtests_cxx address_sorting_test)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx cancel_ares_query_test) add_dependencies(buildtests_cxx cancel_ares_query_test)
endif() endif()
@ -1236,8 +1233,11 @@ add_library(grpc
src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
src/cpp/ext/filters/census/grpc_context.cc src/cpp/ext/filters/census/grpc_context.cc
@ -2538,8 +2538,11 @@ add_library(grpc_unsecure
src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc
src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc
@ -7323,6 +7326,35 @@ target_link_libraries(grpc_fetch_oauth2
gpr gpr
) )
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_ipv6_loopback_available_test
test/core/iomgr/grpc_ipv6_loopback_available_test.cc
)
target_include_directories(grpc_ipv6_loopback_available_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
)
target_link_libraries(grpc_ipv6_loopback_available_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
@ -16351,7 +16383,6 @@ target_link_libraries(resolver_component_tests_runner_invoker
endif() endif()
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(address_sorting_test_unsecure add_executable(address_sorting_test_unsecure
test/cpp/naming/address_sorting_test.cc test/cpp/naming/address_sorting_test.cc
@ -16391,10 +16422,8 @@ target_link_libraries(address_sorting_test_unsecure
${_gRPC_GFLAGS_LIBRARIES} ${_gRPC_GFLAGS_LIBRARIES}
) )
endif()
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_executable(address_sorting_test add_executable(address_sorting_test
test/cpp/naming/address_sorting_test.cc test/cpp/naming/address_sorting_test.cc
@ -16434,7 +16463,6 @@ target_link_libraries(address_sorting_test
${_gRPC_GFLAGS_LIBRARIES} ${_gRPC_GFLAGS_LIBRARIES}
) )
endif()
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)

@ -1022,6 +1022,7 @@ grpc_completion_queue_threading_test: $(BINDIR)/$(CONFIG)/grpc_completion_queue_
grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt grpc_create_jwt: $(BINDIR)/$(CONFIG)/grpc_create_jwt
grpc_credentials_test: $(BINDIR)/$(CONFIG)/grpc_credentials_test grpc_credentials_test: $(BINDIR)/$(CONFIG)/grpc_credentials_test
grpc_fetch_oauth2: $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 grpc_fetch_oauth2: $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2
grpc_ipv6_loopback_available_test: $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test
grpc_json_token_test: $(BINDIR)/$(CONFIG)/grpc_json_token_test grpc_json_token_test: $(BINDIR)/$(CONFIG)/grpc_json_token_test
grpc_jwt_verifier_test: $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test grpc_jwt_verifier_test: $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test
grpc_print_google_default_creds_token: $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token grpc_print_google_default_creds_token: $(BINDIR)/$(CONFIG)/grpc_print_google_default_creds_token
@ -1472,6 +1473,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \ $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test \
$(BINDIR)/$(CONFIG)/grpc_credentials_test \ $(BINDIR)/$(CONFIG)/grpc_credentials_test \
$(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \ $(BINDIR)/$(CONFIG)/grpc_fetch_oauth2 \
$(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test \
$(BINDIR)/$(CONFIG)/grpc_json_token_test \ $(BINDIR)/$(CONFIG)/grpc_json_token_test \
$(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test \ $(BINDIR)/$(CONFIG)/grpc_jwt_verifier_test \
$(BINDIR)/$(CONFIG)/grpc_security_connector_test \ $(BINDIR)/$(CONFIG)/grpc_security_connector_test \
@ -2028,6 +2030,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test || ( echo test grpc_completion_queue_threading_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpc_completion_queue_threading_test || ( echo test grpc_completion_queue_threading_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_credentials_test" $(E) "[RUN] Testing grpc_credentials_test"
$(Q) $(BINDIR)/$(CONFIG)/grpc_credentials_test || ( echo test grpc_credentials_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpc_credentials_test || ( echo test grpc_credentials_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_ipv6_loopback_available_test"
$(Q) $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test || ( echo test grpc_ipv6_loopback_available_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_json_token_test" $(E) "[RUN] Testing grpc_json_token_test"
$(Q) $(BINDIR)/$(CONFIG)/grpc_json_token_test || ( echo test grpc_json_token_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpc_json_token_test || ( echo test grpc_json_token_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_jwt_verifier_test" $(E) "[RUN] Testing grpc_jwt_verifier_test"
@ -3704,8 +3708,11 @@ LIBGRPC_SRC = \
src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
src/cpp/ext/filters/census/grpc_context.cc \ src/cpp/ext/filters/census/grpc_context.cc \
@ -4972,8 +4979,11 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \
@ -12365,6 +12375,38 @@ endif
endif endif
GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_SRC = \
test/core/iomgr/grpc_ipv6_loopback_available_test.cc \
GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test: $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_ipv6_loopback_available_test
endif
$(OBJDIR)/$(CONFIG)/test/core/iomgr/grpc_ipv6_loopback_available_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_grpc_ipv6_loopback_available_test: $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(GRPC_IPV6_LOOPBACK_AVAILABLE_TEST_OBJS:.o=.dep)
endif
endif
GRPC_JSON_TOKEN_TEST_SRC = \ GRPC_JSON_TOKEN_TEST_SRC = \
test/core/security/json_token_test.cc \ test/core/security/json_token_test.cc \

@ -740,8 +740,11 @@ filegroups:
- src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc
- src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc
plugin: grpc_resolver_dns_ares plugin: grpc_resolver_dns_ares
uses: uses:
- grpc_base - grpc_base
@ -2730,6 +2733,18 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: grpc_ipv6_loopback_available_test
build: test
language: c
src:
- test/core/iomgr/grpc_ipv6_loopback_available_test.cc
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
exclude_iomgrs:
- uv
- name: grpc_json_token_test - name: grpc_json_token_test
build: test build: test
language: c language: c

@ -380,8 +380,11 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc \
src/cpp/ext/filters/census/grpc_context.cc \ src/cpp/ext/filters/census/grpc_context.cc \

@ -355,8 +355,11 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\dns_resolver_ares.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\dns_resolver_ares.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_ev_driver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_ev_driver.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_ev_driver_posix.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_ev_driver_posix.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_ev_driver_windows.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_posix.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_windows.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.cc " +
"src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.cc " +
"src\\cpp\\ext\\filters\\census\\grpc_context.cc " + "src\\cpp\\ext\\filters\\census\\grpc_context.cc " +

@ -802,8 +802,11 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
'src/cpp/ext/filters/census/grpc_context.cc', 'src/cpp/ext/filters/census/grpc_context.cc',

@ -742,8 +742,11 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc )
s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc )
s.files += %w( src/cpp/ext/filters/census/grpc_context.cc ) s.files += %w( src/cpp/ext/filters/census/grpc_context.cc )

@ -572,8 +572,11 @@
'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
'src/cpp/ext/filters/census/grpc_context.cc', 'src/cpp/ext/filters/census/grpc_context.cc',
@ -1287,8 +1290,11 @@
'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc',

@ -420,12 +420,8 @@ typedef unsigned __int64 uint64_t;
#define GPR_MAX_ALIGNMENT 16 #define GPR_MAX_ALIGNMENT 16
#ifndef GRPC_ARES #ifndef GRPC_ARES
#ifdef GPR_WINDOWS
#define GRPC_ARES 0
#else
#define GRPC_ARES 1 #define GRPC_ARES 1
#endif #endif
#endif
#ifndef GRPC_MUST_USE_RESULT #ifndef GRPC_MUST_USE_RESULT
#if defined(__GNUC__) && !defined(__MINGW32__) #if defined(__GNUC__) && !defined(__MINGW32__)

@ -747,8 +747,11 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc" role="src" />
<file baseinstalldir="/" name="src/cpp/ext/filters/census/grpc_context.cc" role="src" /> <file baseinstalldir="/" name="src/cpp/ext/filters/census/grpc_context.cc" role="src" />

@ -23,7 +23,6 @@
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -142,8 +141,8 @@ AresDnsResolver::AresDnsResolver(const ResolverArgs& args)
channel_args_ = grpc_channel_args_copy(args.args); channel_args_ = grpc_channel_args_copy(args.args);
const grpc_arg* arg = grpc_channel_args_find( const grpc_arg* arg = grpc_channel_args_find(
channel_args_, GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION); channel_args_, GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION);
request_service_config_ = !grpc_channel_arg_get_integer( grpc_integer_options integer_options = {false, false, true};
arg, (grpc_integer_options){false, false, true}); request_service_config_ = !grpc_channel_arg_get_integer(arg, integer_options);
arg = grpc_channel_args_find(channel_args_, arg = grpc_channel_args_find(channel_args_,
GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS); GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS);
min_time_between_resolutions_ = min_time_between_resolutions_ =

@ -18,11 +18,10 @@
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h" #include "src/core/lib/iomgr/port.h"
#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) #if GRPC_ARES == 1 && !defined(GRPC_UV)
#include <ares.h> #include <ares.h>
#include <string.h> #include <string.h>
#include <sys/ioctl.h>
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h"
@ -32,7 +31,6 @@
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr_utils.h"
@ -314,4 +312,4 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver) {
} }
} }
#endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) */ #endif /* GRPC_ARES == 1 && !defined(GRPC_UV) */

@ -0,0 +1,59 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h"
#if GRPC_ARES == 1 && defined(GPR_WINDOWS)
#include <ares.h>
#include <string.h>
#include "src/core/lib/gprpp/memory.h"
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h"
namespace grpc_core {
/* TODO: fill in the body of GrpcPolledFdWindows to enable c-ares on Windows.
This dummy implementation only allows grpc to compile on windows with
GRPC_ARES=1. */
class GrpcPolledFdWindows : public GrpcPolledFd {
public:
GrpcPolledFdWindows() { abort(); }
~GrpcPolledFdWindows() { abort(); }
void RegisterForOnReadableLocked(grpc_closure* read_closure) override {
abort();
}
void RegisterForOnWriteableLocked(grpc_closure* write_closure) override {
abort();
}
bool IsFdStillReadableLocked() override { abort(); }
void ShutdownLocked(grpc_error* error) override { abort(); }
ares_socket_t GetWrappedAresSocketLocked() override { abort(); }
const char* GetName() override { abort(); }
};
GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as,
grpc_pollset_set* driver_pollset_set) {
return nullptr;
}
void ConfigureAresChannelLocked(ares_channel* channel) { abort(); }
} // namespace grpc_core
#endif /* GRPC_ARES == 1 && defined(GPR_WINDOWS) */

@ -22,7 +22,6 @@
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h" #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
@ -215,7 +214,7 @@ static void on_hostbyname_done_locked(void* arg, int status, int timeouts,
memset(&addr, 0, addr_len); memset(&addr, 0, addr_len);
memcpy(&addr.sin6_addr, hostent->h_addr_list[i - prev_naddr], memcpy(&addr.sin6_addr, hostent->h_addr_list[i - prev_naddr],
sizeof(struct in6_addr)); sizeof(struct in6_addr));
addr.sin6_family = static_cast<sa_family_t>(hostent->h_addrtype); addr.sin6_family = static_cast<unsigned char>(hostent->h_addrtype);
addr.sin6_port = hr->port; addr.sin6_port = hr->port;
grpc_lb_addresses_set_address( grpc_lb_addresses_set_address(
*lb_addresses, i, &addr, addr_len, *lb_addresses, i, &addr, addr_len,
@ -236,7 +235,7 @@ static void on_hostbyname_done_locked(void* arg, int status, int timeouts,
memset(&addr, 0, addr_len); memset(&addr, 0, addr_len);
memcpy(&addr.sin_addr, hostent->h_addr_list[i - prev_naddr], memcpy(&addr.sin_addr, hostent->h_addr_list[i - prev_naddr],
sizeof(struct in_addr)); sizeof(struct in_addr));
addr.sin_family = static_cast<sa_family_t>(hostent->h_addrtype); addr.sin_family = static_cast<unsigned char>(hostent->h_addrtype);
addr.sin_port = hr->port; addr.sin_port = hr->port;
grpc_lb_addresses_set_address( grpc_lb_addresses_set_address(
*lb_addresses, i, &addr, addr_len, *lb_addresses, i, &addr, addr_len,
@ -281,7 +280,7 @@ static void on_srv_query_done_locked(void* arg, int status, int timeouts,
grpc_ares_ev_driver_get_channel_locked(r->ev_driver); grpc_ares_ev_driver_get_channel_locked(r->ev_driver);
for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr; for (struct ares_srv_reply* srv_it = reply; srv_it != nullptr;
srv_it = srv_it->next) { srv_it = srv_it->next) {
if (grpc_ipv6_loopback_available()) { if (grpc_ares_query_ipv6()) {
grpc_ares_hostbyname_request* hr = create_hostbyname_request_locked( grpc_ares_hostbyname_request* hr = create_hostbyname_request_locked(
r, srv_it->host, htons(srv_it->port), true /* is_balancer */); r, srv_it->host, htons(srv_it->port), true /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET6, ares_gethostbyname(*channel, hr->host, AF_INET6,
@ -452,7 +451,7 @@ static grpc_ares_request* grpc_dns_lookup_ares_locked_impl(
} }
} }
r->pending_queries = 1; r->pending_queries = 1;
if (grpc_ipv6_loopback_available()) { if (grpc_ares_query_ipv6()) {
hr = create_hostbyname_request_locked(r, host, strhtons(port), hr = create_hostbyname_request_locked(r, host, strhtons(port),
false /* is_balancer */); false /* is_balancer */);
ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked, ares_gethostbyname(*channel, hr->host, AF_INET6, on_hostbyname_done_locked,

@ -70,6 +70,10 @@ void grpc_ares_cleanup(void);
* and destroys the grpc_ares_request */ * and destroys the grpc_ares_request */
void grpc_ares_complete_request_locked(grpc_ares_request* request); void grpc_ares_complete_request_locked(grpc_ares_request* request);
/* Indicates whether or not AAAA queries should be attempted. */
/* E.g., return false if ipv6 is known to not be available. */
bool grpc_ares_query_ipv6();
/* Exposed only for testing */ /* Exposed only for testing */
void grpc_cares_wrapper_test_only_address_sorting_sort( void grpc_cares_wrapper_test_only_address_sorting_sort(
grpc_lb_addresses* lb_addrs); grpc_lb_addresses* lb_addrs);

@ -0,0 +1,29 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h"
#if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER)
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/lib/iomgr/socket_utils_posix.h"
bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
#endif /* GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET_ARES_EV_DRIVER) */

@ -0,0 +1,29 @@
/*
*
* Copyright 2016 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <grpc/support/port_platform.h>
#include "src/core/lib/iomgr/port.h"
#if GRPC_ARES == 1 && defined(GPR_WINDOWS)
#include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
#include "src/core/lib/iomgr/socket_windows.h"
bool grpc_ares_query_ipv6() { return grpc_ipv6_loopback_available(); }
#endif /* GRPC_ARES == 1 && defined(GPR_WINDOWS) */

@ -36,6 +36,7 @@
#include "src/core/lib/iomgr/iomgr_internal.h" #include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/pollset_windows.h" #include "src/core/lib/iomgr/pollset_windows.h"
#include "src/core/lib/iomgr/sockaddr_windows.h"
#include "src/core/lib/iomgr/socket_windows.h" #include "src/core/lib/iomgr/socket_windows.h"
grpc_winsocket* grpc_winsocket_create(SOCKET socket, const char* name) { grpc_winsocket* grpc_winsocket_create(SOCKET socket, const char* name) {
@ -148,4 +149,32 @@ void grpc_socket_become_ready(grpc_winsocket* socket,
if (should_destroy) destroy(socket); if (should_destroy) destroy(socket);
} }
static gpr_once g_probe_ipv6_once = GPR_ONCE_INIT;
static bool g_ipv6_loopback_available = false;
static void probe_ipv6_once(void) {
SOCKET s = socket(AF_INET6, SOCK_STREAM, 0);
g_ipv6_loopback_available = 0;
if (s == INVALID_SOCKET) {
gpr_log(GPR_INFO, "Disabling AF_INET6 sockets because socket() failed.");
} else {
grpc_sockaddr_in6 addr;
memset(&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
addr.sin6_addr.s6_addr[15] = 1; /* [::1]:0 */
if (bind(s, reinterpret_cast<grpc_sockaddr*>(&addr), sizeof(addr)) == 0) {
g_ipv6_loopback_available = 1;
} else {
gpr_log(GPR_INFO,
"Disabling AF_INET6 sockets because ::1 is not available.");
}
closesocket(s);
}
}
int grpc_ipv6_loopback_available(void) {
gpr_once_init(&g_probe_ipv6_once, probe_ipv6_once);
return g_ipv6_loopback_available;
}
#endif /* GRPC_WINSOCK_SOCKET */ #endif /* GRPC_WINSOCK_SOCKET */

@ -108,6 +108,10 @@ void grpc_socket_notify_on_read(grpc_winsocket* winsocket,
void grpc_socket_become_ready(grpc_winsocket* winsocket, void grpc_socket_become_ready(grpc_winsocket* winsocket,
grpc_winsocket_callback_info* ci); grpc_winsocket_callback_info* ci);
/* Returns true if this system can create AF_INET6 sockets bound to ::1.
The value is probed once, and cached for the life of the process. */
int grpc_ipv6_loopback_available(void);
#endif #endif
#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ #endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */

@ -354,8 +354,11 @@ CORE_SOURCE_FILES = [
'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc',
'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc',
'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc',
'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc',
'src/cpp/ext/filters/census/grpc_context.cc', 'src/cpp/ext/filters/census/grpc_context.cc',

@ -124,6 +124,19 @@ grpc_cc_test(
], ],
) )
grpc_cc_test(
name = "grpc_ipv6_loopback_available_test",
srcs = ["grpc_ipv6_loopback_available_test.cc"],
language = "C++",
deps = [
"//:gpr",
"//:grpc",
"//test/core/util:gpr_test_util",
"//test/core/util:grpc_test_util",
],
)
grpc_cc_test( grpc_cc_test(
name = "load_file_test", name = "load_file_test",
srcs = ["load_file_test.cc"], srcs = ["load_file_test.cc"],

@ -0,0 +1,48 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include "src/core/lib/iomgr/port.h"
// grpc_ipv6_loopback_available isn't currently available on UV.
#ifndef GRPC_UV
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "test/core/util/test_config.h"
#ifdef GPR_WINDOWS
#include "src/core/lib/iomgr/socket_windows.h"
#else
#include "src/core/lib/iomgr/socket_utils_posix.h"
#endif
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
grpc_init();
// This test assumes that the ipv6 loopback is available
// in all environments in which grpc tests run in.
GPR_ASSERT(grpc_ipv6_loopback_available());
grpc_shutdown();
return 0;
}
#else
int main(int argc, char** argv) { return 0; }
#endif /* GRPC_UV */

@ -24,10 +24,8 @@
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include <string.h> #include <string.h>
#include <arpa/inet.h>
#include <gflags/gflags.h> #include <gflags/gflags.h>
#include <gmock/gmock.h> #include <gmock/gmock.h>
#include <sys/socket.h>
#include <sys/types.h> #include <sys/types.h>
#include <vector> #include <vector>
@ -51,6 +49,11 @@
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#ifndef GPR_WINDOWS
#include <arpa/inet.h>
#include <sys/socket.h>
#endif
namespace { namespace {
struct TestAddress { struct TestAddress {
@ -190,10 +193,18 @@ void VerifyLbAddrOutputs(grpc_lb_addresses* lb_addrs,
grpc_lb_addresses_destroy(lb_addrs); grpc_lb_addresses_destroy(lb_addrs);
} }
} // namespace /* We need to run each test case inside of its own
* isolated grpc_init/grpc_shutdown pair, so that
* the "address sorting source addr factory" can be
* restored to its default for each test case. */
class AddressSortingTest : public ::testing::Test {
protected:
void SetUp() override { grpc_init(); }
void TearDown() override { grpc_shutdown(); }
};
/* Tests for rule 1 */ /* Tests for rule 1 */
TEST(AddressSortingTest, TestDepriotizesUnreachableAddresses) { TEST_F(AddressSortingTest, TestDepriotizesUnreachableAddresses) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -212,7 +223,7 @@ TEST(AddressSortingTest, TestDepriotizesUnreachableAddresses) {
}); });
} }
TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv6) { TEST_F(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv6) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = false; bool ipv6_supported = false;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -231,7 +242,7 @@ TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv6) {
}); });
} }
TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) { TEST_F(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) {
bool ipv4_supported = false; bool ipv4_supported = false;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -253,7 +264,7 @@ TEST(AddressSortingTest, TestDepriotizesUnsupportedDomainIpv4) {
/* Tests for rule 2 */ /* Tests for rule 2 */
TEST(AddressSortingTest, TestDepriotizesNonMatchingScope) { TEST_F(AddressSortingTest, TestDepriotizesNonMatchingScope) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -277,7 +288,7 @@ TEST(AddressSortingTest, TestDepriotizesNonMatchingScope) {
/* Tests for rule 5 */ /* Tests for rule 5 */
TEST(AddressSortingTest, TestUsesLabelFromDefaultTable) { TEST_F(AddressSortingTest, TestUsesLabelFromDefaultTable) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -300,7 +311,7 @@ TEST(AddressSortingTest, TestUsesLabelFromDefaultTable) {
/* Flip the input on the test above to reorder the sort function's /* Flip the input on the test above to reorder the sort function's
* comparator's inputs. */ * comparator's inputs. */
TEST(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) { TEST_F(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -323,7 +334,7 @@ TEST(AddressSortingTest, TestUsesLabelFromDefaultTableInputFlipped) {
/* Tests for rule 6 */ /* Tests for rule 6 */
TEST(AddressSortingTest, TEST_F(AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWithAnIpv4Address) { TestUsesDestinationWithHigherPrecedenceWithAnIpv4Address) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
@ -348,7 +359,7 @@ TEST(AddressSortingTest,
}); });
} }
TEST(AddressSortingTest, TEST_F(AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWithV4CompatAndLocalhostAddress) { TestUsesDestinationWithHigherPrecedenceWithV4CompatAndLocalhostAddress) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
@ -377,7 +388,7 @@ TEST(AddressSortingTest,
}); });
} }
TEST(AddressSortingTest, TEST_F(AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWithCatchAllAndLocalhostAddress) { TestUsesDestinationWithHigherPrecedenceWithCatchAllAndLocalhostAddress) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
@ -403,7 +414,7 @@ TEST(AddressSortingTest,
}); });
} }
TEST(AddressSortingTest, TEST_F(AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWith2000PrefixedAddress) { TestUsesDestinationWithHigherPrecedenceWith2000PrefixedAddress) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
@ -426,7 +437,7 @@ TEST(AddressSortingTest,
}); });
} }
TEST( TEST_F(
AddressSortingTest, AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWith2000PrefixedAddressEnsurePrefixMatchHasNoEffect) { TestUsesDestinationWithHigherPrecedenceWith2000PrefixedAddressEnsurePrefixMatchHasNoEffect) {
bool ipv4_supported = true; bool ipv4_supported = true;
@ -448,7 +459,7 @@ TEST(
}); });
} }
TEST(AddressSortingTest, TEST_F(AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWithLinkAndSiteLocalAddresses) { TestUsesDestinationWithHigherPrecedenceWithLinkAndSiteLocalAddresses) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
@ -469,19 +480,22 @@ TEST(AddressSortingTest,
}); });
} }
TEST( TEST_F(
AddressSortingTest, AddressSortingTest,
TestUsesDestinationWithHigherPrecedenceWithCatchAllAndAndV4MappedAddresses) { TestUsesDestinationWithHigherPrecedenceWithCatchAllAndAndV4MappedAddresses) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
// Use embedded ipv4 addresses with leading 1's instead of zero's to be
// compatible with inet_ntop implementations that can display such
// addresses with leading zero's as e.g.: "::ffff:0:2", as on windows.
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
ipv4_supported, ipv6_supported, ipv4_supported, ipv6_supported,
{ {
{"[::ffff:0.0.0.2]:443", {"[::ffff:0.0.0.3]:0", AF_INET6}}, {"[::ffff:1.1.1.2]:443", {"[::ffff:1.1.1.3]:0", AF_INET6}},
{"[1234::2]:443", {"[1234::3]:0", AF_INET6}}, {"[1234::2]:443", {"[1234::3]:0", AF_INET6}},
}); });
grpc_lb_addresses* lb_addrs = BuildLbAddrInputs({ grpc_lb_addresses* lb_addrs = BuildLbAddrInputs({
{"[::ffff:0.0.0.2]:443", AF_INET6}, {"[::ffff:1.1.1.2]:443", AF_INET6},
{"[1234::2]:443", AF_INET6}, {"[1234::2]:443", AF_INET6},
}); });
grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs); grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
@ -489,13 +503,13 @@ TEST(
// ::ffff:0:2 should match the v4-mapped // ::ffff:0:2 should match the v4-mapped
// precedence entry and be deprioritized. // precedence entry and be deprioritized.
"[1234::2]:443", "[1234::2]:443",
"[::ffff:0.0.0.2]:443", "[::ffff:1.1.1.2]:443",
}); });
} }
/* Tests for rule 8 */ /* Tests for rule 8 */
TEST(AddressSortingTest, TestPrefersSmallerScope) { TEST_F(AddressSortingTest, TestPrefersSmallerScope) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -520,7 +534,7 @@ TEST(AddressSortingTest, TestPrefersSmallerScope) {
/* Tests for rule 9 */ /* Tests for rule 9 */
TEST(AddressSortingTest, TestPrefersLongestMatchingSrcDstPrefix) { TEST_F(AddressSortingTest, TestPrefersLongestMatchingSrcDstPrefix) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -543,7 +557,7 @@ TEST(AddressSortingTest, TestPrefersLongestMatchingSrcDstPrefix) {
}); });
} }
TEST(AddressSortingTest, TEST_F(AddressSortingTest,
TestPrefersLongestMatchingSrcDstPrefixMatchesWholeAddress) { TestPrefersLongestMatchingSrcDstPrefixMatchesWholeAddress) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
@ -564,7 +578,7 @@ TEST(AddressSortingTest,
}); });
} }
TEST(AddressSortingTest, TestPrefersLongestPrefixStressInnerBytePrefix) { TEST_F(AddressSortingTest, TestPrefersLongestPrefixStressInnerBytePrefix) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -584,7 +598,7 @@ TEST(AddressSortingTest, TestPrefersLongestPrefixStressInnerBytePrefix) {
}); });
} }
TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersOnHighestBitOfByte) { TEST_F(AddressSortingTest, TestPrefersLongestPrefixDiffersOnHighestBitOfByte) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -604,7 +618,7 @@ TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersOnHighestBitOfByte) {
}); });
} }
TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) { TEST_F(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -628,7 +642,7 @@ TEST(AddressSortingTest, TestPrefersLongestPrefixDiffersByLastBit) {
/* Tests for rule 10 */ /* Tests for rule 10 */
TEST(AddressSortingTest, TestStableSort) { TEST_F(AddressSortingTest, TestStableSort) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -648,7 +662,7 @@ TEST(AddressSortingTest, TestStableSort) {
}); });
} }
TEST(AddressSortingTest, TestStableSortFiveElements) { TEST_F(AddressSortingTest, TestStableSortFiveElements) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory( OverrideAddressSortingSourceAddrFactory(
@ -677,7 +691,7 @@ TEST(AddressSortingTest, TestStableSortFiveElements) {
}); });
} }
TEST(AddressSortingTest, TestStableSortNoSrcAddrsExist) { TEST_F(AddressSortingTest, TestStableSortNoSrcAddrsExist) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(ipv4_supported, ipv6_supported, {}); OverrideAddressSortingSourceAddrFactory(ipv4_supported, ipv6_supported, {});
@ -698,7 +712,7 @@ TEST(AddressSortingTest, TestStableSortNoSrcAddrsExist) {
}); });
} }
TEST(AddressSortingTest, TestStableSortNoSrcAddrsExistWithIpv4) { TEST_F(AddressSortingTest, TestStableSortNoSrcAddrsExistWithIpv4) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
OverrideAddressSortingSourceAddrFactory(ipv4_supported, ipv6_supported, {}); OverrideAddressSortingSourceAddrFactory(ipv4_supported, ipv6_supported, {});
@ -713,7 +727,7 @@ TEST(AddressSortingTest, TestStableSortNoSrcAddrsExistWithIpv4) {
}); });
} }
TEST(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) { TEST_F(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) {
bool ipv4_supported = true; bool ipv4_supported = true;
bool ipv6_supported = true; bool ipv6_supported = true;
// Handle unique observed behavior of inet_ntop(v4-compatible-address) on OS X. // Handle unique observed behavior of inet_ntop(v4-compatible-address) on OS X.
@ -744,6 +758,78 @@ TEST(AddressSortingTest, TestStableSortV4CompatAndSiteLocalAddresses) {
}); });
} }
/* TestPrefersIpv6Loopback tests the actual "address probing" code
* for the current platform, without any mocks.
* This test relies on the assumption that the ipv6 loopback address is
* available in the hosts/containers that grpc C/C++ tests run on
* (whether ipv4 loopback is available or not, an available ipv6
* loopback should be preferred). */
TEST_F(AddressSortingTest, TestPrefersIpv6Loopback) {
grpc_lb_addresses* lb_addrs = BuildLbAddrInputs({
{"[::1]:443", AF_INET6},
{"127.0.0.1:443", AF_INET},
});
grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[::1]:443",
"127.0.0.1:443",
});
}
/* Flip the order of the inputs above and expect the same output order
* (try to rule out influence of arbitrary qsort ordering) */
TEST_F(AddressSortingTest, TestPrefersIpv6LoopbackInputsFlipped) {
grpc_lb_addresses* lb_addrs = BuildLbAddrInputs({
{"127.0.0.1:443", AF_INET},
{"[::1]:443", AF_INET6},
});
grpc_cares_wrapper_test_only_address_sorting_sort(lb_addrs);
VerifyLbAddrOutputs(lb_addrs, {
"[::1]:443",
"127.0.0.1:443",
});
}
/* Try to rule out false positives in the above two tests in which
* the sorter might think that neither ipv6 or ipv4 loopback is
* available, but ipv6 loopback is still preferred only due
* to precedance table lookups. */
TEST_F(AddressSortingTest, TestSorterKnowsIpv6LoopbackIsAvailable) {
sockaddr_in6 ipv6_loopback;
memset(&ipv6_loopback, 0, sizeof(ipv6_loopback));
ipv6_loopback.sin6_family = AF_INET6;
((char*)&ipv6_loopback.sin6_addr)[15] = 1;
ipv6_loopback.sin6_port = htons(443);
// Set up the source and destination parameters of
// address_sorting_get_source_addr
address_sorting_address sort_input_dest;
memcpy(&sort_input_dest.addr, &ipv6_loopback, sizeof(ipv6_loopback));
sort_input_dest.len = sizeof(ipv6_loopback);
address_sorting_address source_for_sort_input_dest;
memset(&source_for_sort_input_dest, 0, sizeof(source_for_sort_input_dest));
// address_sorting_get_source_addr returns true if a source address was found
// for the destination address, otherwise false.
EXPECT_TRUE(address_sorting_get_source_addr_for_testing(
&sort_input_dest, &source_for_sort_input_dest));
// Now also check that the source address was filled in correctly.
EXPECT_GT(source_for_sort_input_dest.len, 0u);
sockaddr_in6* source_addr_output =
(sockaddr_in6*)source_for_sort_input_dest.addr;
EXPECT_EQ(source_addr_output->sin6_family, AF_INET6);
char* buf = static_cast<char*>(gpr_zalloc(100));
EXPECT_NE(inet_ntop(AF_INET6, &source_addr_output->sin6_addr, buf, 100),
nullptr)
<< "inet_ntop failed. Errno: " + std::to_string(errno);
std::string source_addr_str(buf);
gpr_free(buf);
// This test
// assumes that the source address for any loopback destination is also the
// loopback address.
EXPECT_EQ(source_addr_str, "::1");
}
} // namespace
int main(int argc, char** argv) { int main(int argc, char** argv) {
char* resolver = gpr_getenv("GRPC_DNS_RESOLVER"); char* resolver = gpr_getenv("GRPC_DNS_RESOLVER");
if (resolver == nullptr || strlen(resolver) == 0) { if (resolver == nullptr || strlen(resolver) == 0) {
@ -754,9 +840,7 @@ int main(int argc, char** argv) {
gpr_free(resolver); gpr_free(resolver);
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
grpc_init();
auto result = RUN_ALL_TESTS(); auto result = RUN_ALL_TESTS();
grpc_shutdown();
// Test sequential and nested inits and shutdowns. // Test sequential and nested inits and shutdowns.
grpc_init(); grpc_init();
grpc_init(); grpc_init();

@ -110,7 +110,7 @@ def main():
'gtest': True, 'gtest': True,
'run': True, 'run': True,
'src': ['test/cpp/naming/address_sorting_test.cc'], 'src': ['test/cpp/naming/address_sorting_test.cc'],
'platforms': ['linux', 'posix', 'mac'], 'platforms': ['linux', 'posix', 'mac', 'windows'],
'deps': [ 'deps': [
'grpc++_test_util' + unsecure_build_config_suffix, 'grpc++_test_util' + unsecure_build_config_suffix,
'grpc_test_util' + unsecure_build_config_suffix, 'grpc_test_util' + unsecure_build_config_suffix,

@ -55,12 +55,17 @@ static const int kIPv6AddrScopeGlobal = 3;
static address_sorting_source_addr_factory* g_current_source_addr_factory = static address_sorting_source_addr_factory* g_current_source_addr_factory =
NULL; NULL;
static int address_sorting_get_source_addr(const address_sorting_address* dest, static bool address_sorting_get_source_addr(const address_sorting_address* dest,
address_sorting_address* source) { address_sorting_address* source) {
return g_current_source_addr_factory->vtable->get_source_addr( return g_current_source_addr_factory->vtable->get_source_addr(
g_current_source_addr_factory, dest, source); g_current_source_addr_factory, dest, source);
} }
bool address_sorting_get_source_addr_for_testing(
const address_sorting_address* dest, address_sorting_address* source) {
return address_sorting_get_source_addr(dest, source);
}
static int ipv6_prefix_match_length(const struct sockaddr_in6* sa, static int ipv6_prefix_match_length(const struct sockaddr_in6* sa,
const struct sockaddr_in6* sb) { const struct sockaddr_in6* sb) {
unsigned char* a = (unsigned char*)&sa->sin6_addr; unsigned char* a = (unsigned char*)&sa->sin6_addr;

@ -42,14 +42,54 @@
#if defined(ADDRESS_SORTING_WINDOWS) #if defined(ADDRESS_SORTING_WINDOWS)
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <sys/types.h>
/* TODO : Add address sorting functionality to work on windows. */ static bool windows_source_addr_factory_get_source_addr(
address_sorting_source_addr_factory* factory,
const address_sorting_address* dest_addr,
address_sorting_address* source_addr) {
bool source_addr_exists = false;
SOCKET s = socket(((struct sockaddr_in6*)dest_addr)->sin6_family, SOCK_DGRAM,
IPPROTO_UDP);
if (s != INVALID_SOCKET) {
if (connect(s, (struct sockaddr*)dest_addr, (int)dest_addr->len) == 0) {
address_sorting_address found_source_addr;
memset(&found_source_addr, 0, sizeof(found_source_addr));
found_source_addr.len = sizeof(found_source_addr.addr);
if (getsockname(s, (struct sockaddr*)&found_source_addr.addr,
(socklen_t*)&found_source_addr.len) == 0) {
source_addr_exists = true;
*source_addr = found_source_addr;
}
}
closesocket(s);
}
return source_addr_exists;
}
static void windows_source_addr_factory_destroy(
address_sorting_source_addr_factory* self) {
free(self);
}
static const address_sorting_source_addr_factory_vtable
windows_source_addr_factory_vtable = {
windows_source_addr_factory_get_source_addr,
windows_source_addr_factory_destroy,
};
address_sorting_source_addr_factory* address_sorting_source_addr_factory*
address_sorting_create_source_addr_factory_for_current_platform() { address_sorting_create_source_addr_factory_for_current_platform() {
abort(); address_sorting_source_addr_factory* factory =
return NULL; malloc(sizeof(address_sorting_source_addr_factory));
memset(factory, 0, sizeof(address_sorting_source_addr_factory));
factory->vtable = &windows_source_addr_factory_vtable;
return factory;
} }
#endif // defined(ADDRESS_SORTING_WINDOWS) #endif // defined(ADDRESS_SORTING_WINDOWS)

@ -103,6 +103,9 @@ address_sorting_family address_sorting_abstract_get_family(
void address_sorting_override_source_addr_factory_for_testing( void address_sorting_override_source_addr_factory_for_testing(
address_sorting_source_addr_factory* factory); address_sorting_source_addr_factory* factory);
bool address_sorting_get_source_addr_for_testing(
const address_sorting_address* dest, address_sorting_address* source);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -924,9 +924,12 @@ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc \
src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc \
src/core/ext/filters/client_channel/resolver/dns/native/README.md \ src/core/ext/filters/client_channel/resolver/dns/native/README.md \
src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc \
src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc \

@ -1032,6 +1032,23 @@
"third_party": false, "third_party": false,
"type": "target" "type": "target"
}, },
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c",
"name": "grpc_ipv6_loopback_available_test",
"src": [
"test/core/iomgr/grpc_ipv6_loopback_available_test.cc"
],
"third_party": false,
"type": "target"
},
{ {
"deps": [ "deps": [
"gpr", "gpr",
@ -10254,9 +10271,12 @@
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h", "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc" "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc",
"src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc"
], ],
"third_party": false, "third_party": false,
"type": "filegroup" "type": "filegroup"

@ -1313,6 +1313,32 @@
], ],
"uses_polling": true "uses_polling": true
}, },
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [
"uv"
],
"flaky": false,
"gtest": false,
"language": "c",
"name": "grpc_ipv6_loopback_available_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": true
},
{ {
"args": [], "args": [],
"benchmark": false, "benchmark": false,
@ -5710,7 +5736,8 @@
"ci_platforms": [ "ci_platforms": [
"linux", "linux",
"mac", "mac",
"posix" "posix",
"windows"
], ],
"cpu_cost": 1.0, "cpu_cost": 1.0,
"exclude_configs": [], "exclude_configs": [],
@ -5722,7 +5749,8 @@
"platforms": [ "platforms": [
"linux", "linux",
"mac", "mac",
"posix" "posix",
"windows"
], ],
"uses_polling": true "uses_polling": true
}, },
@ -5732,7 +5760,8 @@
"ci_platforms": [ "ci_platforms": [
"linux", "linux",
"mac", "mac",
"posix" "posix",
"windows"
], ],
"cpu_cost": 1.0, "cpu_cost": 1.0,
"exclude_configs": [], "exclude_configs": [],
@ -5744,7 +5773,8 @@
"platforms": [ "platforms": [
"linux", "linux",
"mac", "mac",
"posix" "posix",
"windows"
], ],
"uses_polling": true "uses_polling": true
}, },

Loading…
Cancel
Save