├── .github └── workflows │ ├── getdeps_linux.yml │ └── stale.yml ├── .gitignore ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── COPYING ├── DEVELOPING.md ├── EXAMPLE.md ├── LICENSE ├── README.md ├── USAGE.md ├── build ├── deps │ └── github_hashes │ │ ├── facebook │ │ └── folly-rev.txt │ │ └── facebookincubator │ │ └── fizz-rev.txt └── fbcode_builder │ ├── .gitignore │ ├── CMake │ ├── FBBuildOptions.cmake │ ├── FBCMakeParseArgs.cmake │ ├── FBCompilerSettings.cmake │ ├── FBCompilerSettingsMSVC.cmake │ ├── FBCompilerSettingsUnix.cmake │ ├── FBPythonBinary.cmake │ ├── FBPythonTestAddTests.cmake │ ├── FBThriftCppLibrary.cmake │ ├── FBThriftLibrary.cmake │ ├── FBThriftPyLibrary.cmake │ ├── FindDoubleConversion.cmake │ ├── FindGMock.cmake │ ├── FindGflags.cmake │ ├── FindGlog.cmake │ ├── FindLMDB.cmake │ ├── FindLibEvent.cmake │ ├── FindLibUnwind.cmake │ ├── FindPCRE.cmake │ ├── FindPCRE2.cmake │ ├── FindRe2.cmake │ ├── FindSodium.cmake │ ├── FindXxhash.cmake │ ├── FindZstd.cmake │ ├── RustStaticLibrary.cmake │ ├── fb_py_test_main.py │ ├── fb_py_win_main.c │ └── make_fbpy_archive.py │ ├── LICENSE │ ├── README.md │ ├── getdeps.py │ ├── getdeps │ ├── __init__.py │ ├── builder.py │ ├── buildopts.py │ ├── cache.py │ ├── cargo.py │ ├── copytree.py │ ├── dyndeps.py │ ├── envfuncs.py │ ├── errors.py │ ├── expr.py │ ├── fetcher.py │ ├── load.py │ ├── manifest.py │ ├── platform.py │ ├── py_wheel_builder.py │ ├── runcmd.py │ ├── subcmd.py │ └── test │ │ ├── expr_test.py │ │ ├── fixtures │ │ └── duplicate │ │ │ ├── foo │ │ │ └── subdir │ │ │ └── foo │ │ ├── manifest_test.py │ │ ├── platform_test.py │ │ ├── retry_test.py │ │ └── scratch_test.py │ ├── manifests │ ├── CLI11 │ ├── autoconf │ ├── automake │ ├── benchmark │ ├── blake3 │ ├── boost │ ├── bz2 │ ├── cabal │ ├── cachelib │ ├── clang │ ├── cmake │ ├── cpptoml │ ├── double-conversion │ ├── eden │ ├── edencommon │ ├── exprtk │ ├── fast_float │ ├── fatal │ ├── fb303 │ ├── fboss │ ├── fbthrift │ ├── fizz │ ├── fmt │ ├── folly │ ├── gflags │ ├── ghc │ ├── git-lfs │ ├── glean │ ├── glog │ ├── googletest │ ├── gperf │ ├── hexdump │ ├── hsthrift │ ├── iproute2 │ ├── jom │ ├── jq │ ├── katran │ ├── libaio │ ├── libbpf │ ├── libcurl │ ├── libdwarf │ ├── libelf │ ├── libevent │ ├── libffi │ ├── libgit2 │ ├── libgpiod │ ├── libiberty │ ├── libmnl │ ├── libnl │ ├── liboqs │ ├── libsai │ ├── libsodium │ ├── libtool │ ├── libunwind │ ├── libusb │ ├── libyaml │ ├── llvm │ ├── lmdb │ ├── lz4 │ ├── mcrouter │ ├── mononoke │ ├── mononoke_integration │ ├── mvfst │ ├── ncurses │ ├── nghttp2 │ ├── ninja │ ├── nlohmann-json │ ├── nmap │ ├── numa │ ├── openr │ ├── openssl │ ├── osxfuse │ ├── patchelf │ ├── pcre2 │ ├── perl │ ├── pexpect │ ├── proxygen │ ├── python │ ├── python-click │ ├── python-filelock │ ├── python-ptyprocess │ ├── python-setuptools │ ├── python-six │ ├── python-toml │ ├── ragel │ ├── range-v3 │ ├── re2 │ ├── ripgrep │ ├── rocksdb │ ├── rust-shed │ ├── sapling │ ├── snappy │ ├── sparsemap │ ├── sqlite3 │ ├── systemd │ ├── tree │ ├── wangle │ ├── watchman │ ├── xxhash │ ├── xz │ ├── yaml-cpp │ ├── zlib │ └── zstd │ └── patches │ ├── boost_comparator_operator_fix.patch │ ├── iproute2_oss.patch │ ├── libiberty_install_pic_lib.patch │ └── zlib_dont_build_more_than_needed.patch ├── build_bpf_modules_opensource.sh ├── build_katran.sh ├── cmake ├── FindBpfObject.cmake ├── KatranTest.cmake └── katran-config.cmake.in ├── collect_debug_lb.sh ├── collect_debug_real.sh ├── example └── CMakeLists.txt ├── example_grpc ├── CMakeLists.txt ├── GrpcSignalHandler.cpp ├── GrpcSignalHandler.h ├── KatranGrpcService.cpp ├── KatranGrpcService.h ├── build_grpc_client.sh ├── goclient │ └── src │ │ └── katranc │ │ ├── katranc │ │ └── katranc.go │ │ └── main │ │ └── main.go ├── katran_server.cpp └── protos │ └── katran.proto ├── imgs ├── katran_consistency.png └── katran_pktflow.png ├── install_xdproot.sh ├── katran ├── .clang-format ├── CMakeLists.txt ├── decap │ ├── CMakeLists.txt │ ├── Makefile-bpf │ ├── XdpDecap.cpp │ ├── XdpDecap.h │ ├── XdpDecapStructs.h │ ├── bpf │ │ ├── decap.bpf.c │ │ └── decap_maps.h │ ├── tc_bpf │ │ ├── pckt_helpers.h │ │ ├── tc_decap.bpf.c │ │ ├── tc_decap_info.bpf.c │ │ ├── tc_decap_info_maps.h │ │ ├── tc_decap_info_user_structs.h │ │ ├── tc_decap_kern_helpers.h │ │ ├── tc_decap_maps.h │ │ ├── tc_decap_stats.bpf.c │ │ └── tc_decap_stats_maps.h │ └── testing │ │ ├── CMakeLists.txt │ │ ├── XdpDecapGueTestFixtures.h │ │ ├── XdpDecapTestFixtures.h │ │ └── xdpdecap_tester.cpp ├── lib │ ├── BalancerStructs.h │ ├── BaseBpfAdapter.cpp │ ├── BaseBpfAdapter.h │ ├── BpfAdapter.cpp │ ├── BpfAdapter.h │ ├── BpfBatchUtil.h │ ├── BpfLoader.cpp │ ├── BpfLoader.h │ ├── ByteRangeWriter.cpp │ ├── ByteRangeWriter.h │ ├── CHHelpers.cpp │ ├── CHHelpers.h │ ├── CMakeLists.txt │ ├── DataWriter.h │ ├── EventPipeCallback.cpp │ ├── EventPipeCallback.h │ ├── FileWriter.cpp │ ├── FileWriter.h │ ├── IOBufWriter.cpp │ ├── IOBufWriter.h │ ├── IpHelpers.cpp │ ├── IpHelpers.h │ ├── KatranEventReader.cpp │ ├── KatranEventReader.h │ ├── KatranLb.cpp │ ├── KatranLb.h │ ├── KatranLbStructs.h │ ├── KatranMonitor.cpp │ ├── KatranMonitor.h │ ├── KatranSimulator.cpp │ ├── KatranSimulator.h │ ├── MacHelpers.cpp │ ├── MacHelpers.h │ ├── MaglevBase.cpp │ ├── MaglevBase.h │ ├── MaglevHash.cpp │ ├── MaglevHash.h │ ├── MaglevHashV2.cpp │ ├── MaglevHashV2.h │ ├── Makefile-bpf │ ├── MonitoringServiceCore.cpp │ ├── MonitoringServiceCore.h │ ├── MonitoringStructs.cpp │ ├── MonitoringStructs.h │ ├── MurmurHash3.cpp │ ├── MurmurHash3.h │ ├── Netlink.cpp │ ├── Netlink.h │ ├── PcapMsg.cpp │ ├── PcapMsg.h │ ├── PcapMsgMeta.cpp │ ├── PcapMsgMeta.h │ ├── PcapStructs.h │ ├── PcapWriter.cpp │ ├── PcapWriter.h │ ├── PerfBufferEventReader.cpp │ ├── PerfBufferEventReader.h │ ├── PipeWriter.cpp │ ├── PipeWriter.h │ ├── Vip.cpp │ ├── Vip.h │ ├── bpf │ │ ├── balancer.bpf.c │ │ ├── balancer_consts.h │ │ ├── balancer_helpers.h │ │ ├── balancer_kern-tpl.h │ │ ├── balancer_kern_flavors-tpl.h │ │ ├── balancer_maps.h │ │ ├── balancer_structs.h │ │ ├── control_data_maps.h │ │ ├── csum_helpers.h │ │ ├── encap_helpers.h │ │ ├── flow_debug.h │ │ ├── flow_debug_helpers.h │ │ ├── flow_debug_maps.h │ │ ├── handle_icmp.h │ │ ├── healthchecking.bpf.c │ │ ├── healthchecking_consts.h │ │ ├── healthchecking_helpers.h │ │ ├── healthchecking_ipip.c │ │ ├── healthchecking_maps.h │ │ ├── healthchecking_structs.h │ │ ├── introspection.h │ │ ├── pckt_encap.h │ │ ├── pckt_parsing.h │ │ ├── xdp_pktcntr.c │ │ └── xdp_root.c │ ├── linux_includes │ │ ├── bpf.h │ │ ├── bpf_common.h │ │ ├── bpf_endian.h │ │ ├── bpf_helpers.h │ │ └── jhash.h │ ├── maglev_integration_test.cpp │ ├── testing │ │ ├── Base64Helpers.cpp │ │ ├── Base64Helpers.h │ │ ├── Base64Test.cpp │ │ ├── BpfTester.cpp │ │ ├── BpfTester.h │ │ ├── CMakeLists.txt │ │ ├── KatranGueOptionalTestFixtures.h │ │ ├── KatranGueTestFixtures.h │ │ ├── KatranHCTestFixtures.h │ │ ├── KatranOptionalTestFixtures.h │ │ ├── KatranTPRTestFixtures.h │ │ ├── KatranTestFixtures.h │ │ ├── KatranTestProvision.cpp │ │ ├── KatranTestProvision.h │ │ ├── KatranTestUtil.cpp │ │ ├── KatranTestUtil.h │ │ ├── KatranUdpStableRtTestFixtures.h │ │ ├── KatranXPopDecapTestFixtures.h │ │ ├── PacketAttributes.h │ │ ├── PcapParser.cpp │ │ ├── PcapParser.h │ │ ├── fplane_testing.py │ │ └── katran_tester.cpp │ ├── tests │ │ ├── CHHelpersTest.cpp │ │ ├── CMakeLists.txt │ │ ├── EventPipeCallbackTest.cpp │ │ ├── IpHelpersTest.cpp │ │ ├── KatranLbTest.cpp │ │ ├── MonitoringServiceCoreTest.cpp │ │ ├── PcapWriterTest.cpp │ │ ├── PipeWriterTest.cpp │ │ ├── VipTest.cpp │ │ └── common │ │ │ └── TestMain.cpp │ └── xdproot.cpp └── tpr │ ├── CMakeLists.txt │ ├── README │ ├── TPRStatsPoller.cpp │ ├── TPRStatsPoller.h │ ├── TPRTypes.h │ ├── TcpPktRouter.cpp │ ├── TcpPktRouter.h │ ├── bpf │ ├── bpf_endian.h │ ├── tcp_pkt_router.bpf.c │ ├── tcp_pkt_router_active_hdlr.h │ ├── tcp_pkt_router_common.h │ ├── tcp_pkt_router_consts.h │ ├── tcp_pkt_router_maps.h │ ├── tcp_pkt_router_passive_hdlr.h │ ├── tcp_pkt_router_structs.h │ └── vmlinux.h │ └── bpf_util │ ├── BpfSkeleton.h │ ├── BpfUtil.cpp │ ├── BpfUtil.h │ ├── CMakeLists.txt │ └── SystemError.h ├── logo.png ├── os_run_tester.sh ├── start_katran_grpc_server.sh ├── start_katran_simple_server.sh └── tools ├── CMakeLists.txt ├── README.md ├── start_katran ├── README.md ├── build_start_katran.sh └── start_katran │ └── src │ └── start_katran │ ├── affinitize │ └── affinitize.go │ ├── default_watcher │ └── default_watcher.go │ ├── irq_parser │ └── irq_parser.go │ ├── katranc │ └── katranc.go │ ├── main │ └── main.go │ ├── start_binary │ └── start_binary.go │ └── topology_parser │ └── topology_parser.go ├── tcpdump_encap_helper ├── README.md └── tcpdump_encap_helper.py ├── wireshark ├── README.md └── guev1.lua └── xdpdump ├── CMakeLists.txt ├── README.md ├── XdpDump.cpp ├── XdpDump.h ├── XdpDumpKern.h ├── XdpDumpStructs.h ├── XdpEventLogger.cpp ├── XdpEventLogger.h ├── XdpEventReader.cpp ├── XdpEventReader.h └── xdpdump_tool.cpp /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | on: 3 | schedule: 4 | - cron: '0 12 * * 1-5' # every weekday at noon 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v8 11 | with: 12 | stale-issue-message: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. If you'd still having this issue please make a comment, 15 | make sure you've addressed any follow ups! 16 | stale-pr-message: > 17 | This pull request has been automatically marked as stale because it has not had 18 | recent activity. If you'd still like this PR merged, please comment on the PR, 19 | make sure you've addressed reviewer comments, and rebase on the latest main. 20 | Thank you for your contributions! 21 | close-issue-message: > 22 | This issue has been closed because it has not had recent activity. If you are 23 | still having this issue please feel free to create a new one. 24 | close-pr-message: > 25 | This pull request has been automatically closed it has not had 26 | recent activity. If you'd still like this PR merged, please feel free to reopen it, 27 | make sure you've addressed reviewer comments, and rebase on the latest main. 28 | Thank you for your contributions! 29 | days-before-stale: 90 # ~ 3 months 30 | days-before-close: 14 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _build/ 2 | .vscode/ 3 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.9 FATAL_ERROR) 2 | 3 | project( 4 | katran 5 | ) 6 | 7 | set(CMAKE_MODULE_PATH 8 | "${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake" 9 | ${CMAKE_MODULE_PATH}) 10 | 11 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 12 | # for modules vended by fbcode_builder and getdeps 13 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/build/fbcode_builder/CMake) 14 | 15 | # KATRAN_FBCODE_ROOT is where the top level katran/ directory resides, so 16 | # an #include will resolve to 17 | # $KATRAN_FBCODE_ROOT/katran/path/to/file on disk 18 | set(KATRAN_FBCODE_ROOT ${CMAKE_CURRENT_SOURCE_DIR}) 19 | 20 | set(KATRAN_INCLUDE_DIR "$") 21 | 22 | set(CMAKE_CXX_STANDARD 17) 23 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 24 | message(STATUS "setting C++ standard to C++${CMAKE_CXX_STANDARD}") 25 | 26 | # for clang's compile_commands.json 27 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 28 | 29 | # Dependencies 30 | find_package(fmt CONFIG REQUIRED) 31 | find_package(folly CONFIG REQUIRED) 32 | find_package(Glog REQUIRED) 33 | find_package(Gflags REQUIRED) 34 | find_package(Threads) 35 | 36 | include_directories(".") 37 | add_subdirectory(katran) 38 | 39 | if(BUILD_TESTS) 40 | enable_testing() 41 | include(KatranTest) 42 | endif() 43 | 44 | if(DEFINED ENV{CMAKE_BUILD_EXAMPLE_THRIFT}) 45 | message("Building example of thrift and grpc based katran server") 46 | add_subdirectory(example) 47 | endif() 48 | 49 | if(DEFINED ENV{CMAKE_BUILD_EXAMPLE_GRPC}) 50 | add_subdirectory(example_grpc) 51 | endif() 52 | 53 | if(DEFINED ENV{CMAKE_BUILD_TOOLS}) 54 | add_subdirectory(tools) 55 | endif() 56 | 57 | install( 58 | EXPORT katran-exports 59 | FILE katran-targets.cmake 60 | NAMESPACE katran:: 61 | DESTINATION lib/cmake/katran/ 62 | ) 63 | 64 | include(CMakePackageConfigHelpers) 65 | configure_package_config_file( 66 | cmake/katran-config.cmake.in 67 | ${CMAKE_CURRENT_BINARY_DIR}/katran-config.cmake 68 | INSTALL_DESTINATION lib/cmake/katran/ 69 | ) 70 | 71 | install( 72 | FILES ${CMAKE_CURRENT_BINARY_DIR}/katran-config.cmake 73 | DESTINATION lib/cmake/katran/ 74 | ) 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to katran 2 | We want to make contributing to this project as easy and transparent as 3 | possible. 4 | 5 | ## Pull Requests 6 | We actively welcome your pull requests. 7 | 8 | 1. Fork the repo and create your branch from `main`. 9 | 2. If you've added code that should be tested, add tests. 10 | 3. If you've changed APIs, update the documentation. 11 | 4. Ensure the test suite passes. 12 | 5. Make sure your code lints. 13 | 6. If you haven't already, complete the Contributor License Agreement ("CLA"). 14 | 15 | ## Contributor License Agreement ("CLA") 16 | In order to accept your pull request, we need you to submit a CLA. You only need 17 | to do this once to work on any of Facebook's open source projects. 18 | 19 | Complete your CLA here: 20 | 21 | ## Issues 22 | We use GitHub issues to track public bugs. Please ensure your description is 23 | clear and has sufficient instructions to be able to reproduce the issue. 24 | 25 | Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe 26 | disclosure of security bugs. In those cases, please go through the process 27 | outlined on that page and do not file a public issue. 28 | 29 | ## Coding Style 30 | we are using clang-format tool for coding style. please 31 | run `clang-format -i ` on file, where changes has been made, before 32 | you commit them. 33 | ## License 34 | By contributing to katran, you agree that your contributions will be licensed 35 | under the LICENSE file in the root directory of this source tree. 36 | -------------------------------------------------------------------------------- /build/deps/github_hashes/facebook/folly-rev.txt: -------------------------------------------------------------------------------- 1 | Subproject commit 82bfe10e7180d5537639a3717963c0049f8591f9 2 | -------------------------------------------------------------------------------- /build/deps/github_hashes/facebookincubator/fizz-rev.txt: -------------------------------------------------------------------------------- 1 | Subproject commit 9d59cc8565a2accb2416a94e2633e1404e3b3968 2 | -------------------------------------------------------------------------------- /build/fbcode_builder/.gitignore: -------------------------------------------------------------------------------- 1 | # Facebook-internal CI builds don't have write permission outside of the 2 | # source tree, so we install all projects into this directory. 3 | /facebook_ci 4 | __pycache__/ 5 | *.pyc 6 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBBuildOptions.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | function (fb_activate_static_library_option) 4 | option(USE_STATIC_DEPS_ON_UNIX 5 | "If enabled, use static dependencies on unix systems. This is generally discouraged." 6 | OFF 7 | ) 8 | # Mark USE_STATIC_DEPS_ON_UNIX as an "advanced" option, since enabling it 9 | # is generally discouraged. 10 | mark_as_advanced(USE_STATIC_DEPS_ON_UNIX) 11 | 12 | if(UNIX AND USE_STATIC_DEPS_ON_UNIX) 13 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE) 14 | endif() 15 | endfunction() 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBCompilerSettings.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This file applies common compiler settings that are shared across 4 | # a number of Facebook opensource projects. 5 | # Please use caution and your best judgement before making changes 6 | # to these shared compiler settings in order to avoid accidentally 7 | # breaking a build in another project! 8 | 9 | if (WIN32) 10 | include(FBCompilerSettingsMSVC) 11 | else() 12 | include(FBCompilerSettingsUnix) 13 | endif() 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBCompilerSettingsMSVC.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This file applies common compiler settings that are shared across 4 | # a number of Facebook opensource projects. 5 | # Please use caution and your best judgement before making changes 6 | # to these shared compiler settings in order to avoid accidentally 7 | # breaking a build in another project! 8 | 9 | add_compile_options( 10 | /wd4250 # 'class1' : inherits 'class2::member' via dominance 11 | ) 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBCompilerSettingsUnix.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # This file applies common compiler settings that are shared across 4 | # a number of Facebook opensource projects. 5 | # Please use caution and your best judgement before making changes 6 | # to these shared compiler settings in order to avoid accidentally 7 | # breaking a build in another project! 8 | 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wno-deprecated -Wno-deprecated-declarations") 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FBPythonTestAddTests.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | 3 | # Add a command to be emitted to the CTest file 4 | set(ctest_script) 5 | function(add_command CMD) 6 | set(escaped_args "") 7 | foreach(arg ${ARGN}) 8 | # Escape all arguments using "Bracket Argument" syntax 9 | # We could skip this for argument that don't contain any special 10 | # characters if we wanted to make the output slightly more human-friendly. 11 | set(escaped_args "${escaped_args} [==[${arg}]==]") 12 | endforeach() 13 | set(ctest_script "${ctest_script}${CMD}(${escaped_args})\n" PARENT_SCOPE) 14 | endfunction() 15 | 16 | if(NOT EXISTS "${TEST_EXECUTABLE}") 17 | message(FATAL_ERROR "Test executable does not exist: ${TEST_EXECUTABLE}") 18 | endif() 19 | execute_process( 20 | COMMAND ${CMAKE_COMMAND} -E env ${TEST_ENV} "${TEST_INTERPRETER}" "${TEST_EXECUTABLE}" --list-tests 21 | WORKING_DIRECTORY "${TEST_WORKING_DIR}" 22 | OUTPUT_VARIABLE output 23 | RESULT_VARIABLE result 24 | ) 25 | if(NOT "${result}" EQUAL 0) 26 | string(REPLACE "\n" "\n " output "${output}") 27 | message( 28 | FATAL_ERROR 29 | "Error running test executable: ${TEST_EXECUTABLE}\n" 30 | "Output:\n" 31 | " ${output}\n" 32 | ) 33 | endif() 34 | 35 | # Parse output 36 | string(REPLACE "\n" ";" tests_list "${output}") 37 | foreach(test_name ${tests_list}) 38 | add_command( 39 | add_test 40 | "${TEST_PREFIX}${test_name}" 41 | ${CMAKE_COMMAND} -E env ${TEST_ENV} 42 | "${TEST_INTERPRETER}" "${TEST_EXECUTABLE}" "${test_name}" 43 | ) 44 | add_command( 45 | set_tests_properties 46 | "${TEST_PREFIX}${test_name}" 47 | PROPERTIES 48 | WORKING_DIRECTORY "${TEST_WORKING_DIR}" 49 | ${TEST_PROPERTIES} 50 | ) 51 | endforeach() 52 | 53 | # Set a list of discovered tests in the parent scope, in case users 54 | # want access to this list as a CMake variable 55 | if(TEST_LIST) 56 | add_command(set ${TEST_LIST} ${tests_list}) 57 | endif() 58 | 59 | file(WRITE "${CTEST_FILE}" "${ctest_script}") 60 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindDoubleConversion.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | # Finds libdouble-conversion. 4 | # 5 | # This module defines: 6 | # DOUBLE_CONVERSION_INCLUDE_DIR 7 | # DOUBLE_CONVERSION_LIBRARY 8 | # 9 | 10 | find_path(DOUBLE_CONVERSION_INCLUDE_DIR double-conversion/double-conversion.h) 11 | find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion) 12 | 13 | include(FindPackageHandleStandardArgs) 14 | find_package_handle_standard_args( 15 | DoubleConversion 16 | DEFAULT_MSG 17 | DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR) 18 | 19 | mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY) 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindGlog.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # - Try to find Glog 3 | # Once done, this will define 4 | # 5 | # GLOG_FOUND - system has Glog 6 | # GLOG_INCLUDE_DIRS - the Glog include directories 7 | # GLOG_LIBRARIES - link these to use Glog 8 | 9 | include(FindPackageHandleStandardArgs) 10 | include(SelectLibraryConfigurations) 11 | 12 | find_library(GLOG_LIBRARY_RELEASE glog 13 | PATHS ${GLOG_LIBRARYDIR}) 14 | find_library(GLOG_LIBRARY_DEBUG glogd 15 | PATHS ${GLOG_LIBRARYDIR}) 16 | 17 | find_path(GLOG_INCLUDE_DIR glog/logging.h 18 | PATHS ${GLOG_INCLUDEDIR}) 19 | 20 | select_library_configurations(GLOG) 21 | 22 | find_package_handle_standard_args(Glog DEFAULT_MSG 23 | GLOG_LIBRARY 24 | GLOG_INCLUDE_DIR) 25 | 26 | mark_as_advanced( 27 | GLOG_LIBRARY 28 | GLOG_INCLUDE_DIR) 29 | 30 | set(GLOG_LIBRARIES ${GLOG_LIBRARY}) 31 | set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR}) 32 | 33 | if (NOT TARGET glog::glog) 34 | add_library(glog::glog UNKNOWN IMPORTED) 35 | set_target_properties(glog::glog PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}") 36 | set_target_properties(glog::glog PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${GLOG_LIBRARIES}") 37 | 38 | find_package(Gflags) 39 | if(GFLAGS_FOUND) 40 | message(STATUS "Found gflags as a dependency of glog::glog, include=${LIBGFLAGS_INCLUDE_DIR}, libs=${LIBGFLAGS_LIBRARY}") 41 | set_property(TARGET glog::glog APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES ${LIBGFLAGS_LIBRARY}) 42 | endif() 43 | 44 | find_package(LibUnwind) 45 | if(LIBUNWIND_FOUND) 46 | message(STATUS "Found LibUnwind as a dependency of glog::glog, include=${LIBUNWIND_INCLUDE_DIR}, libs=${LIBUNWIND_LIBRARY}") 47 | set_property(TARGET glog::glog APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES ${LIBUNWIND_LIBRARY}) 48 | endif() 49 | endif() 50 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindLMDB.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This software may be used and distributed according to the terms of the 4 | # GNU General Public License version 2. 5 | 6 | find_library(LMDB_LIBRARIES NAMES lmdb liblmdb) 7 | mark_as_advanced(LMDB_LIBRARIES) 8 | 9 | find_path(LMDB_INCLUDE_DIR NAMES lmdb.h) 10 | mark_as_advanced(LMDB_INCLUDE_DIR) 11 | 12 | find_package_handle_standard_args( 13 | LMDB 14 | REQUIRED_VARS LMDB_LIBRARIES LMDB_INCLUDE_DIR) 15 | 16 | if(LMDB_FOUND) 17 | set(LMDB_LIBRARIES ${LMDB_LIBRARIES}) 18 | set(LMDB_INCLUDE_DIR, ${LMDB_INCLUDE_DIR}) 19 | endif() 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindLibUnwind.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | find_path(LIBUNWIND_INCLUDE_DIR NAMES libunwind.h) 16 | mark_as_advanced(LIBUNWIND_INCLUDE_DIR) 17 | 18 | find_library(LIBUNWIND_LIBRARY NAMES unwind) 19 | mark_as_advanced(LIBUNWIND_LIBRARY) 20 | 21 | include(FindPackageHandleStandardArgs) 22 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 23 | LIBUNWIND 24 | REQUIRED_VARS LIBUNWIND_LIBRARY LIBUNWIND_INCLUDE_DIR) 25 | 26 | if(LIBUNWIND_FOUND) 27 | set(LIBUNWIND_LIBRARIES ${LIBUNWIND_LIBRARY}) 28 | set(LIBUNWIND_INCLUDE_DIRS ${LIBUNWIND_INCLUDE_DIR}) 29 | endif() 30 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindPCRE.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | include(FindPackageHandleStandardArgs) 3 | find_path(PCRE_INCLUDE_DIR NAMES pcre.h) 4 | find_library(PCRE_LIBRARY NAMES pcre) 5 | find_package_handle_standard_args( 6 | PCRE 7 | DEFAULT_MSG 8 | PCRE_LIBRARY 9 | PCRE_INCLUDE_DIR 10 | ) 11 | mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARY) 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindPCRE2.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | include(FindPackageHandleStandardArgs) 3 | find_path(PCRE2_INCLUDE_DIR NAMES pcre2.h) 4 | find_library(PCRE2_LIBRARY NAMES pcre2-8) 5 | find_package_handle_standard_args( 6 | PCRE2 7 | DEFAULT_MSG 8 | PCRE2_LIBRARY 9 | PCRE2_INCLUDE_DIR 10 | ) 11 | set(PCRE2_DEFINES "PCRE2_CODE_UNIT_WIDTH=8") 12 | mark_as_advanced(PCRE2_INCLUDE_DIR PCRE2_LIBRARY PCRE2_DEFINES) 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindRe2.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # This software may be used and distributed according to the terms of the 4 | # GNU General Public License version 2. 5 | 6 | find_library(RE2_LIBRARY re2) 7 | mark_as_advanced(RE2_LIBRARY) 8 | 9 | find_path(RE2_INCLUDE_DIR NAMES re2/re2.h) 10 | mark_as_advanced(RE2_INCLUDE_DIR) 11 | 12 | include(FindPackageHandleStandardArgs) 13 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 14 | RE2 15 | REQUIRED_VARS RE2_LIBRARY RE2_INCLUDE_DIR) 16 | 17 | if(RE2_FOUND) 18 | set(RE2_LIBRARY ${RE2_LIBRARY}) 19 | set(RE2_INCLUDE_DIR, ${RE2_INCLUDE_DIR}) 20 | endif() 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindXxhash.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # 16 | # - Try to find Facebook xxhash library 17 | # This will define 18 | # Xxhash_FOUND 19 | # Xxhash_INCLUDE_DIR 20 | # Xxhash_LIBRARY 21 | # 22 | 23 | find_path(Xxhash_INCLUDE_DIR NAMES xxhash.h) 24 | 25 | find_library(Xxhash_LIBRARY_RELEASE NAMES xxhash) 26 | 27 | include(SelectLibraryConfigurations) 28 | SELECT_LIBRARY_CONFIGURATIONS(Xxhash) 29 | 30 | include(FindPackageHandleStandardArgs) 31 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 32 | Xxhash DEFAULT_MSG 33 | Xxhash_LIBRARY Xxhash_INCLUDE_DIR 34 | ) 35 | 36 | if (Xxhash_FOUND) 37 | message(STATUS "Found xxhash: ${Xxhash_LIBRARY}") 38 | endif() 39 | 40 | mark_as_advanced(Xxhash_INCLUDE_DIR Xxhash_LIBRARY) 41 | -------------------------------------------------------------------------------- /build/fbcode_builder/CMake/FindZstd.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # 16 | # - Try to find Facebook zstd library 17 | # This will define 18 | # ZSTD_FOUND 19 | # ZSTD_INCLUDE_DIR 20 | # ZSTD_LIBRARY 21 | # 22 | 23 | find_path(ZSTD_INCLUDE_DIR NAMES zstd.h) 24 | 25 | find_library(ZSTD_LIBRARY_DEBUG NAMES zstdd zstd_staticd) 26 | find_library(ZSTD_LIBRARY_RELEASE NAMES zstd zstd_static) 27 | 28 | include(SelectLibraryConfigurations) 29 | SELECT_LIBRARY_CONFIGURATIONS(ZSTD) 30 | 31 | include(FindPackageHandleStandardArgs) 32 | FIND_PACKAGE_HANDLE_STANDARD_ARGS( 33 | Zstd DEFAULT_MSG 34 | ZSTD_LIBRARY ZSTD_INCLUDE_DIR 35 | ) 36 | 37 | if (ZSTD_FOUND) 38 | message(STATUS "Found Zstd: ${ZSTD_LIBRARY}") 39 | endif() 40 | 41 | mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY) 42 | -------------------------------------------------------------------------------- /build/fbcode_builder/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Facebook, Inc. and its affiliates. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/fbcode_builder/README.md: -------------------------------------------------------------------------------- 1 | # Easy builds for Facebook projects 2 | 3 | This directory contains tools designed to simplify continuous-integration 4 | (and other builds) of Facebook open source projects. In particular, this helps 5 | manage builds for cross-project dependencies. 6 | 7 | The main entry point is the `getdeps.py` script. This script has several 8 | subcommands, but the most notable is the `build` command. This will download 9 | and build all dependencies for a project, and then build the project itself. 10 | 11 | ## Deployment 12 | 13 | This directory is copied literally into a number of different Facebook open 14 | source repositories. Any change made to code in this directory will be 15 | automatically be replicated by our open source tooling into all GitHub hosted 16 | repositories that use `fbcode_builder`. Typically this directory is copied 17 | into the open source repositories as `build/fbcode_builder/`. 18 | 19 | 20 | # Project Configuration Files 21 | 22 | The `manifests` subdirectory contains configuration files for many different 23 | projects, describing how to build each project. These files also list 24 | dependencies between projects, enabling `getdeps.py` to build all dependencies 25 | for a project before building the project itself. 26 | 27 | 28 | # Shared CMake utilities 29 | 30 | Since this directory is copied into many Facebook open source repositories, 31 | it is also used to help share some CMake utility files across projects. The 32 | `CMake/` subdirectory contains a number of `.cmake` files that are shared by 33 | the CMake-based build systems across several different projects. 34 | 35 | 36 | # Older Build Scripts 37 | 38 | This directory also still contains a handful of older build scripts that 39 | pre-date the current `getdeps.py` build system. Most of the other `.py` files 40 | in this top directory, apart from `getdeps.py` itself, are from this older 41 | build system. This older system is only used by a few remaining projects, and 42 | new projects should generally use the newer `getdeps.py` script, by adding a 43 | new configuration file in the `manifests/` subdirectory. 44 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookincubator/katran/e4ca6397f39329431a8c080c7122d7ac5f3a69ad/build/fbcode_builder/getdeps/__init__.py -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/cache.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | 8 | 9 | class ArtifactCache(object): 10 | """The ArtifactCache is a small abstraction that allows caching 11 | named things in some external storage mechanism. 12 | The primary use case is for storing the build products on CI 13 | systems to accelerate the build""" 14 | 15 | def download_to_file(self, name, dest_file_name) -> bool: 16 | """If `name` exists in the cache, download it and place it 17 | in the specified `dest_file_name` location on the filesystem. 18 | If a transient issue was encountered a TransientFailure shall 19 | be raised. 20 | If `name` doesn't exist in the cache `False` shall be returned. 21 | If `dest_file_name` was successfully updated `True` shall be 22 | returned. 23 | All other conditions shall raise an appropriate exception.""" 24 | return False 25 | 26 | def upload_from_file(self, name, source_file_name) -> None: 27 | """Causes `name` to be populated in the cache by uploading 28 | the contents of `source_file_name` to the storage system. 29 | If a transient issue was encountered a TransientFailure shall 30 | be raised. 31 | If the upload failed for some other reason, an appropriate 32 | exception shall be raised.""" 33 | pass 34 | 35 | 36 | def create_cache() -> None: 37 | """This function is monkey patchable to provide an actual 38 | implementation""" 39 | return None 40 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/errors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | 8 | 9 | class TransientFailure(Exception): 10 | """Raising this error causes getdeps to return with an error code 11 | that Sandcastle will consider to be a retryable transient 12 | infrastructure error""" 13 | 14 | pass 15 | 16 | 17 | class ManifestNotFound(Exception): 18 | def __init__(self, manifest_name) -> None: 19 | super(Exception, self).__init__("Unable to find manifest '%s'" % manifest_name) 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/subcmd.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | 8 | 9 | class SubCmd(object): 10 | NAME = None 11 | HELP = None 12 | 13 | def run(self, args) -> int: 14 | """perform the command""" 15 | return 0 16 | 17 | def setup_parser(self, parser) -> None: 18 | # Subclasses should override setup_parser() if they have any 19 | # command line options or arguments. 20 | pass 21 | 22 | 23 | CmdTable = [] 24 | 25 | 26 | def add_subcommands(parser, common_args, cmd_table=CmdTable) -> None: 27 | """Register parsers for the defined commands with the provided parser""" 28 | for cls in cmd_table: 29 | command = cls() 30 | command_parser = parser.add_parser( 31 | command.NAME, help=command.HELP, parents=[common_args] 32 | ) 33 | command.setup_parser(command_parser) 34 | command_parser.set_defaults(func=command.run) 35 | 36 | 37 | def cmd(name, help=None, cmd_table=CmdTable): 38 | """ 39 | @cmd() is a decorator that can be used to help define Subcmd instances 40 | 41 | Example usage: 42 | 43 | @subcmd('list', 'Show the result list') 44 | class ListCmd(Subcmd): 45 | def run(self, args): 46 | # Perform the command actions here... 47 | pass 48 | """ 49 | 50 | def wrapper(cls): 51 | class SubclassedCmd(cls): 52 | NAME = name 53 | HELP = help 54 | 55 | cmd_table.append(SubclassedCmd) 56 | return SubclassedCmd 57 | 58 | return wrapper 59 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/expr_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | 8 | 9 | import unittest 10 | 11 | from ..expr import parse_expr 12 | 13 | 14 | class ExprTest(unittest.TestCase): 15 | def test_equal(self) -> None: 16 | valid_variables = {"foo", "some_var", "another_var"} 17 | e = parse_expr("foo=bar", valid_variables) 18 | self.assertTrue(e.eval({"foo": "bar"})) 19 | self.assertFalse(e.eval({"foo": "not-bar"})) 20 | self.assertFalse(e.eval({"not-foo": "bar"})) 21 | 22 | def test_not_equal(self) -> None: 23 | valid_variables = {"foo"} 24 | e = parse_expr("not(foo=bar)", valid_variables) 25 | self.assertFalse(e.eval({"foo": "bar"})) 26 | self.assertTrue(e.eval({"foo": "not-bar"})) 27 | 28 | def test_bad_not(self) -> None: 29 | valid_variables = {"foo"} 30 | with self.assertRaises(Exception): 31 | parse_expr("foo=not(bar)", valid_variables) 32 | 33 | def test_bad_variable(self) -> None: 34 | valid_variables = {"bar"} 35 | with self.assertRaises(Exception): 36 | parse_expr("foo=bar", valid_variables) 37 | 38 | def test_all(self) -> None: 39 | valid_variables = {"foo", "baz"} 40 | e = parse_expr("all(foo = bar, baz = qux)", valid_variables) 41 | self.assertTrue(e.eval({"foo": "bar", "baz": "qux"})) 42 | self.assertFalse(e.eval({"foo": "bar", "baz": "nope"})) 43 | self.assertFalse(e.eval({"foo": "nope", "baz": "nope"})) 44 | 45 | def test_any(self) -> None: 46 | valid_variables = {"foo", "baz"} 47 | e = parse_expr("any(foo = bar, baz = qux)", valid_variables) 48 | self.assertTrue(e.eval({"foo": "bar", "baz": "qux"})) 49 | self.assertTrue(e.eval({"foo": "bar", "baz": "nope"})) 50 | self.assertFalse(e.eval({"foo": "nope", "baz": "nope"})) 51 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/fixtures/duplicate/foo: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = foo 3 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/fixtures/duplicate/subdir/foo: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = foo 3 | -------------------------------------------------------------------------------- /build/fbcode_builder/getdeps/test/platform_test.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Meta Platforms, Inc. and affiliates. 2 | # 3 | # This source code is licensed under the MIT license found in the 4 | # LICENSE file in the root directory of this source tree. 5 | 6 | # pyre-unsafe 7 | 8 | 9 | import unittest 10 | 11 | from ..platform import HostType 12 | 13 | 14 | class PlatformTest(unittest.TestCase): 15 | def test_create(self) -> None: 16 | p = HostType() 17 | self.assertNotEqual(p.ostype, None, msg="probed and returned something") 18 | 19 | tuple_string = p.as_tuple_string() 20 | round_trip = HostType.from_tuple_string(tuple_string) 21 | self.assertEqual(round_trip, p) 22 | 23 | def test_rendering_of_none(self) -> None: 24 | p = HostType(ostype="foo") 25 | self.assertEqual(p.as_tuple_string(), "foo-none-none") 26 | 27 | def test_is_methods(self) -> None: 28 | p = HostType(ostype="windows") 29 | self.assertTrue(p.is_windows()) 30 | self.assertFalse(p.is_darwin()) 31 | self.assertFalse(p.is_linux()) 32 | 33 | p = HostType(ostype="darwin") 34 | self.assertFalse(p.is_windows()) 35 | self.assertTrue(p.is_darwin()) 36 | self.assertFalse(p.is_linux()) 37 | 38 | p = HostType(ostype="linux") 39 | self.assertFalse(p.is_windows()) 40 | self.assertFalse(p.is_darwin()) 41 | self.assertTrue(p.is_linux()) 42 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/CLI11: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = CLI11 3 | 4 | [download] 5 | url = https://github.com/CLIUtils/CLI11/archive/v2.0.0.tar.gz 6 | sha256 = 2c672f17bf56e8e6223a3bfb74055a946fa7b1ff376510371902adb9cb0ab6a3 7 | 8 | [build] 9 | builder = cmake 10 | subdir = CLI11-2.0.0 11 | 12 | [cmake.defines] 13 | CLI11_BUILD_TESTS = OFF 14 | CLI11_BUILD_EXAMPLES = OFF 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/autoconf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = autoconf 3 | 4 | [debs] 5 | autoconf 6 | 7 | [homebrew] 8 | autoconf 9 | 10 | [rpms] 11 | autoconf 12 | 13 | [pps] 14 | autoconf 15 | 16 | [download] 17 | url = http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz 18 | sha256 = 954bd69b391edc12d6a4a51a2dd1476543da5c6bbf05a95b59dc0dd6fd4c2969 19 | 20 | [build] 21 | builder = autoconf 22 | subdir = autoconf-2.69 23 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/automake: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = automake 3 | 4 | [homebrew] 5 | automake 6 | 7 | [debs] 8 | automake 9 | 10 | [rpms] 11 | automake 12 | 13 | [pps] 14 | automake 15 | 16 | [download] 17 | url = http://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz 18 | sha256 = 608a97523f97db32f1f5d5615c98ca69326ced2054c9f82e65bade7fc4c9dea8 19 | 20 | [build] 21 | builder = autoconf 22 | subdir = automake-1.16.1 23 | 24 | [dependencies] 25 | autoconf 26 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/benchmark: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = benchmark 3 | 4 | [download] 5 | url = https://github.com/google/benchmark/archive/refs/tags/v1.8.0.tar.gz 6 | sha256 = ea2e94c24ddf6594d15c711c06ccd4486434d9cf3eca954e2af8a20c88f9f172 7 | 8 | [build] 9 | builder = cmake 10 | subdir = benchmark-1.8.0/ 11 | 12 | [cmake.defines] 13 | BENCHMARK_ENABLE_TESTING=OFF 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/blake3: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = blake3 3 | 4 | [download] 5 | url = https://github.com/BLAKE3-team/BLAKE3/archive/refs/tags/1.5.1.tar.gz 6 | sha256 = 822cd37f70152e5985433d2c50c8f6b2ec83aaf11aa31be9fe71486a91744f37 7 | 8 | [build] 9 | builder = cmake 10 | subdir = BLAKE3-1.5.1/c 11 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/bz2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = bz2 3 | 4 | [debs] 5 | libbz2-dev 6 | bzip2 7 | 8 | [homebrew] 9 | bzip2 10 | 11 | [rpms] 12 | bzip2-devel 13 | bzip2 14 | 15 | [download] 16 | url = https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz 17 | sha256 = ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269 18 | 19 | [build.not(os=windows)] 20 | builder = make 21 | subdir = bzip2-1.0.8 22 | 23 | [make.build_args.os=linux] 24 | # python bz2 support on linux needs dynamic library 25 | -f 26 | Makefile-libbz2_so 27 | 28 | [make.install_args] 29 | install 30 | 31 | [build.os=windows] 32 | builder = nop 33 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/cabal: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = cabal 3 | 4 | [download.os=linux] 5 | url = https://downloads.haskell.org/~cabal/cabal-install-3.6.2.0/cabal-install-3.6.2.0-x86_64-linux-deb10.tar.xz 6 | sha256 = 4759b56e9257e02f29fa374a6b25d6cb2f9d80c7e3a55d4f678a8e570925641c 7 | 8 | [build] 9 | builder = nop 10 | 11 | [install.files] 12 | cabal = bin/cabal 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/cachelib: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = cachelib 3 | fbsource_path = fbcode/cachelib 4 | shipit_project = cachelib 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/cachelib.git 9 | 10 | [build] 11 | builder = cmake 12 | subdir = cachelib 13 | job_weight_mib = 2048 14 | 15 | [dependencies] 16 | zlib 17 | fizz 18 | fmt 19 | folly 20 | fbthrift 21 | googletest 22 | sparsemap 23 | wangle 24 | zstd 25 | mvfst 26 | numa 27 | libaio 28 | # cachelib also depends on openssl but since the latter requires a platform- 29 | # specific configuration we rely on the folly manifest to provide this 30 | # dependency to avoid duplication. 31 | 32 | [shipit.pathmap] 33 | fbcode/cachelib = cachelib 34 | fbcode/cachelib/public_tld = . 35 | 36 | [shipit.strip] 37 | ^fbcode/cachelib/examples(/|$) 38 | ^fbcode/cachelib/facebook(/|$) 39 | ^fbcode/cachelib/public_tld/website/docs/facebook(/|$) 40 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/clang: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = clang 3 | 4 | [rpms] 5 | clang15-devel 6 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/cmake: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = cmake 3 | 4 | [homebrew] 5 | cmake 6 | 7 | # 18.04 cmake is too old 8 | [debs.not(all(distro=ubuntu,distro_vers="18.04"))] 9 | cmake 10 | 11 | [rpms] 12 | cmake 13 | 14 | [pps] 15 | cmake 16 | 17 | [dependencies] 18 | ninja 19 | 20 | [download.os=windows] 21 | url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-windows-x86_64.zip 22 | sha256 = 15a49e2ab81c1822d75b1b1a92f7863f58e31f6d6aac1c4103eef2b071be3112 23 | 24 | [download.os=darwin] 25 | url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-macos-universal.tar.gz 26 | sha256 = 0100663380a3bd977b001183cd487412db7aad9de6859927bde97e1e6e44e645 27 | 28 | [download.any(os=linux,os=freebsd)] 29 | url = https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz 30 | sha256 = aecf6ecb975179eb3bb6a4a50cae192d41e92b9372b02300f9e8f1d5f559544e 31 | 32 | [build.os=windows] 33 | builder = nop 34 | subdir = cmake-3.20.2-windows-x86_64 35 | 36 | [build.os=darwin] 37 | builder = nop 38 | subdir = cmake-3.20.2-macos-universal 39 | 40 | [install.files.os=darwin] 41 | CMake.app/Contents/bin = bin 42 | CMake.app/Contents/share = share 43 | 44 | [build.any(os=linux,os=freebsd)] 45 | builder = cmakebootstrap 46 | subdir = cmake-3.20.2 47 | 48 | [make.install_args.any(os=linux,os=freebsd)] 49 | install 50 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/cpptoml: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = cpptoml 3 | 4 | [homebrew] 5 | cpptoml 6 | 7 | [download] 8 | url = https://github.com/chadaustin/cpptoml/archive/refs/tags/v0.1.2.tar.gz 9 | sha256 = beda37e94f9746874436c8090c045fd80ae6f8a51f7c668c932a2b110a4fc277 10 | 11 | [build] 12 | builder = cmake 13 | subdir = cpptoml-0.1.2 14 | 15 | [cmake.defines.os=freebsd] 16 | ENABLE_LIBCXX=NO 17 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/double-conversion: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = double-conversion 3 | 4 | [download] 5 | url = https://github.com/google/double-conversion/archive/v3.1.4.tar.gz 6 | sha256 = 95004b65e43fefc6100f337a25da27bb99b9ef8d4071a36a33b5e83eb1f82021 7 | 8 | [homebrew] 9 | double-conversion 10 | 11 | [debs] 12 | libdouble-conversion-dev 13 | 14 | [rpms] 15 | double-conversion 16 | double-conversion-devel 17 | 18 | [pps] 19 | double-conversion 20 | 21 | [build] 22 | builder = cmake 23 | subdir = double-conversion-3.1.4 24 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/edencommon: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = edencommon 3 | fbsource_path = fbcode/eden/common 4 | shipit_project = edencommon 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexperimental/edencommon.git 9 | 10 | [build] 11 | builder = cmake 12 | 13 | [dependencies] 14 | fbthrift 15 | fb303 16 | fmt 17 | folly 18 | gflags 19 | glog 20 | 21 | [cmake.defines.test=on] 22 | BUILD_TESTS=ON 23 | 24 | [cmake.defines.test=off] 25 | BUILD_TESTS=OFF 26 | 27 | [shipit.pathmap] 28 | fbcode/eden/common = eden/common 29 | fbcode/eden/common/oss = . 30 | 31 | [shipit.strip] 32 | @README.facebook@ 33 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/exprtk: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = exprtk 3 | 4 | [download] 5 | url = https://github.com/ArashPartow/exprtk/archive/refs/tags/0.0.1.tar.gz 6 | sha256 = fb72791c88ae3b3426e14fdad630027715682584daf56b973569718c56e33f28 7 | 8 | [build.not(os=windows)] 9 | builder = nop 10 | subdir = exprtk-0.0.1 11 | 12 | [install.files] 13 | exprtk.hpp = exprtk.hpp 14 | 15 | [dependencies] 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fast_float: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fast_float 3 | 4 | [download] 5 | url = https://github.com/fastfloat/fast_float/archive/refs/tags/v8.0.0.tar.gz 6 | sha256 = f312f2dc34c61e665f4b132c0307d6f70ad9420185fa831911bc24408acf625d 7 | 8 | [build] 9 | builder = cmake 10 | subdir = fast_float-8.0.0 11 | 12 | [cmake.defines] 13 | FASTFLOAT_TEST = OFF 14 | FASTFLOAT_SANITIZE = OFF 15 | 16 | [debs.not(all(distro=ubuntu,any(distro_vers="18.04",distro_vers="20.04",distro_vers="22.04",distro_vers="24.04")))] 17 | libfast-float-dev 18 | 19 | [rpms.distro=fedora] 20 | fast_float-devel 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fatal: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fatal 3 | fbsource_path = fbcode/fatal 4 | shipit_project = fatal 5 | 6 | [git] 7 | repo_url = https://github.com/facebook/fatal.git 8 | 9 | [shipit.pathmap] 10 | fbcode/fatal = fatal 11 | fbcode/fatal/public_tld = . 12 | 13 | [build] 14 | builder = nop 15 | subdir = . 16 | 17 | [install.files] 18 | fatal/portability.h = fatal/portability.h 19 | fatal/preprocessor.h = fatal/preprocessor.h 20 | fatal/container = fatal/container 21 | fatal/functional = fatal/functional 22 | fatal/math = fatal/math 23 | fatal/string = fatal/string 24 | fatal/type = fatal/type 25 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fb303: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fb303 3 | fbsource_path = fbcode/fb303 4 | shipit_project = fb303 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fb303.git 9 | 10 | [cargo] 11 | cargo_config_file = source/fb303/thrift/.cargo/config.toml 12 | 13 | [crate.pathmap] 14 | fb303_core = fb303/thrift 15 | 16 | [build] 17 | builder = cmake 18 | 19 | [dependencies] 20 | folly 21 | gflags 22 | glog 23 | fbthrift 24 | 25 | [cmake.defines.test=on] 26 | BUILD_TESTS=ON 27 | 28 | [cmake.defines.test=off] 29 | BUILD_TESTS=OFF 30 | 31 | [shipit.pathmap] 32 | fbcode/fb303/github = . 33 | fbcode/fb303/public_autocargo = fb303 34 | fbcode/fb303 = fb303 35 | 36 | [shipit.strip] 37 | ^fbcode/fb303/(?!public_autocargo).+/Cargo\.toml$ 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fboss: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fboss 3 | fbsource_path = fbcode/fboss 4 | shipit_project = fboss 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fboss.git 9 | 10 | [build.os=linux] 11 | builder = cmake 12 | # fboss files take a lot of RAM to compile. 13 | job_weight_mib = 3072 14 | 15 | [build.not(os=linux)] 16 | builder = nop 17 | 18 | [dependencies] 19 | folly 20 | fb303 21 | wangle 22 | fizz 23 | fmt 24 | libsodium 25 | googletest 26 | zstd 27 | fatal 28 | fbthrift 29 | iproute2 30 | libusb 31 | libcurl 32 | libnl 33 | libsai 34 | re2 35 | python 36 | yaml-cpp 37 | libyaml 38 | CLI11 39 | exprtk 40 | nlohmann-json 41 | libgpiod 42 | systemd 43 | range-v3 44 | 45 | [shipit.pathmap] 46 | fbcode/fboss/github = . 47 | fbcode/fboss/common = common 48 | fbcode/fboss = fboss 49 | 50 | [sandcastle] 51 | run_tests = off 52 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fbthrift: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fbthrift 3 | fbsource_path = xplat/thrift 4 | shipit_project = fbthrift 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/fbthrift.git 9 | 10 | [cargo] 11 | cargo_config_file = source/thrift/lib/rust/.cargo/config.toml 12 | 13 | [crate.pathmap] 14 | fbthrift = thrift/lib/rust 15 | 16 | [build] 17 | builder = cmake 18 | job_weight_mib = 2048 19 | 20 | [dependencies] 21 | fizz 22 | fmt 23 | folly 24 | googletest 25 | libsodium 26 | wangle 27 | zstd 28 | mvfst 29 | xxhash 30 | # Thrift also depends on openssl but since the latter requires a platform- 31 | # specific configuration we rely on the folly manifest to provide this 32 | # dependency to avoid duplication. 33 | 34 | [shipit.pathmap] 35 | xplat/thrift/public_tld = . 36 | xplat/thrift = thrift 37 | 38 | [shipit.strip] 39 | ^xplat/thrift/thrift-config\.h$ 40 | ^xplat/thrift/perf/canary.py$ 41 | ^xplat/thrift/perf/loadtest.py$ 42 | ^xplat/thrift/.castle/.* 43 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fizz: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fizz 3 | fbsource_path = fbcode/fizz 4 | shipit_project = fizz 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookincubator/fizz.git 9 | 10 | [build] 11 | builder = cmake 12 | subdir = fizz 13 | 14 | [cmake.defines] 15 | BUILD_EXAMPLES = OFF 16 | 17 | [cmake.defines.test=on] 18 | BUILD_TESTS = ON 19 | 20 | [cmake.defines.all(os=windows, test=on)] 21 | BUILD_TESTS = OFF 22 | 23 | [cmake.defines.test=off] 24 | BUILD_TESTS = OFF 25 | 26 | [dependencies] 27 | folly 28 | liboqs 29 | libsodium 30 | zlib 31 | zstd 32 | 33 | [dependencies.all(test=on, not(os=windows))] 34 | googletest 35 | 36 | [shipit.pathmap] 37 | fbcode/fizz/public_tld = . 38 | fbcode/fizz = fizz 39 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/fmt: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = fmt 3 | 4 | [download] 5 | url = https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.tar.gz 6 | sha256 = 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f 7 | 8 | [build] 9 | builder = cmake 10 | subdir = fmt-11.0.2 11 | 12 | [cmake.defines] 13 | FMT_TEST = OFF 14 | FMT_DOC = OFF 15 | 16 | [homebrew] 17 | fmt 18 | 19 | [rpms.distro=fedora] 20 | fmt-devel 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/folly: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = folly 3 | fbsource_path = fbcode/folly 4 | shipit_project = folly 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/folly.git 9 | 10 | [build] 11 | builder = cmake 12 | job_weight_mib = 1024 13 | 14 | [dependencies] 15 | gflags 16 | glog 17 | googletest 18 | boost 19 | libdwarf 20 | libevent 21 | libsodium 22 | double-conversion 23 | fast_float 24 | fmt 25 | lz4 26 | snappy 27 | zstd 28 | # no openssl or zlib in the linux case, why? 29 | # these are usually installed on the system 30 | # and are the easiest system deps to pull in. 31 | # In the future we want to be able to express 32 | # that a system dep is sufficient in the manifest 33 | # for eg: openssl and zlib, but for now we don't 34 | # have it. 35 | 36 | # macOS doesn't expose the openssl api so we need 37 | # to build our own. 38 | [dependencies.os=darwin] 39 | openssl 40 | 41 | # Windows has neither openssl nor zlib, so we get 42 | # to provide both 43 | [dependencies.os=windows] 44 | openssl 45 | zlib 46 | 47 | [dependencies.os=linux] 48 | libiberty 49 | libunwind 50 | 51 | # xz depends on autoconf which does not build on 52 | # Windows 53 | [dependencies.not(os=windows)] 54 | xz 55 | 56 | [shipit.pathmap] 57 | fbcode/folly/public_tld = . 58 | fbcode/folly = folly 59 | 60 | [shipit.strip] 61 | ^fbcode/folly/folly-config\.h$ 62 | ^fbcode/folly/public_tld/build/facebook_.* 63 | 64 | [cmake.defines] 65 | BUILD_SHARED_LIBS=OFF 66 | BOOST_LINK_STATIC=ON 67 | 68 | [cmake.defines.os=freebsd] 69 | LIBDWARF_FOUND=NO 70 | 71 | [cmake.defines.test=on] 72 | BUILD_TESTS=ON 73 | BUILD_BENCHMARKS=OFF 74 | 75 | [cmake.defines.test=off] 76 | BUILD_TESTS=OFF 77 | BUILD_BENCHMARKS=OFF 78 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gflags: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gflags 3 | 4 | [download] 5 | url = https://github.com/gflags/gflags/archive/v2.2.2.tar.gz 6 | sha256 = 34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf 7 | 8 | [build] 9 | builder = cmake 10 | subdir = gflags-2.2.2 11 | 12 | [cmake.defines] 13 | BUILD_SHARED_LIBS = ON 14 | BUILD_STATIC_LIBS = ON 15 | #BUILD_gflags_nothreads_LIB = OFF 16 | BUILD_gflags_LIB = ON 17 | 18 | [homebrew] 19 | gflags 20 | 21 | [debs] 22 | libgflags-dev 23 | 24 | [rpms.distro=fedora] 25 | gflags-devel 26 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/ghc: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = ghc 3 | 4 | [download.os=linux] 5 | url = https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-x86_64-fedora27-linux.tar.xz 6 | sha256 = 845f63cd365317bb764d81025554a2527dbe315d6fa268c9859e21b911bf2d3c 7 | 8 | [build] 9 | builder = autoconf 10 | subdir = ghc-9.2.8 11 | build_in_src_dir = true 12 | only_install = true 13 | 14 | [make.install_args] 15 | install 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/git-lfs: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = git-lfs 3 | 4 | [rpms] 5 | git-lfs 6 | 7 | [debs] 8 | git-lfs 9 | 10 | [homebrew] 11 | git-lfs 12 | 13 | # only used from system packages currently 14 | [build] 15 | builder = nop 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/glean: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = glean 3 | fbsource_path = fbcode/glean 4 | shipit_project = facebookincubator/Glean 5 | use_shipit = true 6 | 7 | [shipit.pathmap] 8 | # These are only used by target determinator to trigger builds, the 9 | # real path mappings are in the ShipIt config. 10 | fbcode/glean = glean 11 | fbcode/common/hs = hsthrift 12 | 13 | [subprojects] 14 | hsthrift = hsthrift 15 | 16 | [dependencies] 17 | cabal 18 | ghc 19 | gflags 20 | glog 21 | folly 22 | rocksdb 23 | xxhash 24 | llvm 25 | clang 26 | re2 27 | 28 | [build] 29 | builder = make 30 | 31 | [make.build_args] 32 | cabal-update 33 | all 34 | glean-hie 35 | glass 36 | glean-clang 37 | EXTRA_GHC_OPTS=-j4 +RTS -A32m -n4m -RTS 38 | CABAL_CONFIG_FLAGS=-f-hack-tests -f-typescript-tests -f-python-tests -f-dotnet-tests -f-go-tests -f-rust-tests -f-java-lsif-tests -f-flow-tests 39 | 40 | [make.install_args] 41 | install 42 | 43 | [make.test_args] 44 | test 45 | EXTRA_GHC_OPTS=-j4 +RTS -A32m -n4m -RTS 46 | CABAL_CONFIG_FLAGS=-f-hack-tests -f-typescript-tests -f-python-tests -f-dotnet-tests -f-go-tests -f-rust-tests -f-java-lsif-tests -f-flow-tests 47 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/glog: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = glog 3 | 4 | [download] 5 | url = https://github.com/google/glog/archive/v0.5.0.tar.gz 6 | sha256 = eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5 7 | 8 | [build] 9 | builder = cmake 10 | subdir = glog-0.5.0 11 | 12 | [dependencies] 13 | gflags 14 | 15 | [cmake.defines] 16 | BUILD_SHARED_LIBS=ON 17 | BUILD_TESTING=NO 18 | WITH_PKGCONFIG=ON 19 | 20 | [cmake.defines.os=freebsd] 21 | HAVE_TR1_UNORDERED_MAP=OFF 22 | HAVE_TR1_UNORDERED_SET=OFF 23 | 24 | [homebrew] 25 | glog 26 | 27 | # on ubuntu glog brings in liblzma-dev, which in turn breaks watchman tests 28 | [debs.not(distro=ubuntu)] 29 | libgoogle-glog-dev 30 | 31 | [rpms.distro=fedora] 32 | glog-devel 33 | 34 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/googletest: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = googletest 3 | 4 | [download] 5 | url = https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz 6 | sha256 = 81964fe578e9bd7c94dfdb09c8e4d6e6759e19967e397dbea48d1c10e45d0df2 7 | 8 | [build] 9 | builder = cmake 10 | subdir = googletest-release-1.12.1 11 | 12 | [cmake.defines] 13 | # Everything else defaults to the shared runtime, so tell gtest that 14 | # it should not use its choice of the static runtime 15 | gtest_force_shared_crt=ON 16 | 17 | [cmake.defines.os=windows] 18 | BUILD_SHARED_LIBS=ON 19 | 20 | [homebrew] 21 | googletest 22 | 23 | # packaged googletest is too old 24 | [debs.not(all(distro=ubuntu,any(distro_vers="18.04",distro_vers="20.04",distro_vers="22.04")))] 25 | libgtest-dev 26 | libgmock-dev 27 | 28 | [rpms.distro=fedora] 29 | gmock-devel 30 | gtest-devel 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/gperf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = gperf 3 | 4 | [download] 5 | url = http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz 6 | sha256 = 588546b945bba4b70b6a3a616e80b4ab466e3f33024a352fc2198112cdbb3ae2 7 | 8 | [build.not(os=windows)] 9 | builder = autoconf 10 | subdir = gperf-3.1 11 | 12 | [build.os=windows] 13 | builder = nop 14 | 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/hexdump: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = hexdump 3 | 4 | [rpms] 5 | util-linux 6 | 7 | [debs] 8 | bsdmainutils 9 | 10 | # only used from system packages currently 11 | [build] 12 | builder = nop 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/hsthrift: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = hsthrift 3 | fbsource_path = fbcode/common/hs 4 | shipit_project = facebookincubator/hsthrift 5 | use_shipit = true 6 | 7 | [shipit.pathmap] 8 | # These are only used by target determinator to trigger builds, the 9 | # real path mappings are in the ShipIt config. 10 | fbcode/common/hs = . 11 | 12 | [dependencies] 13 | cabal 14 | ghc 15 | gflags 16 | glog 17 | folly 18 | fbthrift 19 | wangle 20 | fizz 21 | boost 22 | 23 | [build] 24 | builder = make 25 | 26 | [make.build_args] 27 | cabal-update 28 | all 29 | 30 | [make.install_args] 31 | install 32 | 33 | [make.test_args] 34 | test 35 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/iproute2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = iproute2 3 | 4 | [download] 5 | url = https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/iproute2-4.12.0.tar.gz 6 | sha256 = 46612a1e2d01bb31932557bccdb1b8618cae9a439dfffc08ef35ed8e197f14ce 7 | 8 | [build.os=linux] 9 | builder = iproute2 10 | subdir = iproute2-4.12.0 11 | patchfile = iproute2_oss.patch 12 | 13 | [build.not(os=linux)] 14 | builder = nop 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/jom: -------------------------------------------------------------------------------- 1 | # jom is compatible with MSVC nmake, but adds the /j argment which 2 | # speeds up openssl build a lot 3 | [manifest] 4 | name = jom 5 | 6 | # see https://download.qt.io/official_releases/jom/changelog.txt for latest version 7 | [download.os=windows] 8 | url = https://download.qt.io/official_releases/jom/jom_1_1_4.zip 9 | sha256 = d533c1ef49214229681e90196ed2094691e8c4a0a0bef0b2c901debcb562682b 10 | 11 | [build.os=windows] 12 | builder = nop 13 | 14 | [install.files.os=windows] 15 | . = bin 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/jq: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = jq 3 | 4 | [rpms.distro=fedora] 5 | jq 6 | 7 | [homebrew] 8 | jq 9 | 10 | [download.not(os=windows)] 11 | # we use jq-1.7+ to get fix for number truncation https://github.com/jqlang/jq/pull/1752 12 | url = https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-1.7.1.tar.gz 13 | sha256 = 478c9ca129fd2e3443fe27314b455e211e0d8c60bc8ff7df703873deeee580c2 14 | 15 | [build.not(os=windows)] 16 | builder = autoconf 17 | subdir = jq-1.7.1 18 | 19 | [build.os=windows] 20 | builder = nop 21 | 22 | [autoconf.args] 23 | # This argument turns off some developers tool and it is recommended in jq's 24 | # README 25 | --disable-maintainer-mode 26 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/katran: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = katran 3 | fbsource_path = fbcode/katran 4 | shipit_project = katran 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookincubator/katran.git 9 | 10 | [build.not(os=linux)] 11 | builder = nop 12 | 13 | [build.os=linux] 14 | builder = cmake 15 | subdir = . 16 | 17 | [cmake.defines.test=on] 18 | BUILD_TESTS=ON 19 | 20 | [cmake.defines.test=off] 21 | BUILD_TESTS=OFF 22 | 23 | [dependencies] 24 | folly 25 | fizz 26 | libbpf 27 | libmnl 28 | zlib 29 | googletest 30 | fmt 31 | 32 | [debs] 33 | libssl-dev 34 | 35 | [shipit.pathmap] 36 | fbcode/katran/public_root = . 37 | fbcode/katran = katran 38 | 39 | [shipit.strip] 40 | ^fbcode/katran/facebook 41 | ^fbcode/katran/OSS_SYNC 42 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libaio: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libaio 3 | 4 | [debs] 5 | libaio-dev 6 | 7 | [rpms.distro=centos_stream] 8 | libaio-devel 9 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libbpf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libbpf 3 | 4 | [download] 5 | url = https://github.com/libbpf/libbpf/archive/refs/tags/v0.7.0.tar.gz 6 | sha256 = 5083588ce5a3a620e395ee1e596af77b4ec5771ffc71cff2af49dfee38c06361 7 | 8 | # BPF only builds on linux, so make it a NOP on other platforms 9 | [build.not(os=linux)] 10 | builder = nop 11 | 12 | [build.os=linux] 13 | builder = make 14 | subdir = libbpf-0.7.0/src 15 | 16 | [make.build_args] 17 | BUILD_STATIC_ONLY=y 18 | 19 | # libbpf-0.3 requires uapi headers >= 5.8 20 | [make.install_args] 21 | install 22 | install_uapi_headers 23 | BUILD_STATIC_ONLY=y 24 | 25 | [dependencies] 26 | libelf 27 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libcurl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libcurl 3 | 4 | [rpms] 5 | libcurl-devel 6 | libcurl-minimal 7 | 8 | [debs] 9 | libcurl4-openssl-dev 10 | 11 | [pps] 12 | libcurl-gnutls 13 | 14 | [download] 15 | url = https://curl.haxx.se/download/curl-7.65.1.tar.gz 16 | sha256 = 821aeb78421375f70e55381c9ad2474bf279fc454b791b7e95fc83562951c690 17 | 18 | [dependencies] 19 | nghttp2 20 | 21 | # We use system OpenSSL on Linux (see folly's manifest for details) 22 | [dependencies.not(os=linux)] 23 | openssl 24 | 25 | [build.not(os=windows)] 26 | builder = autoconf 27 | subdir = curl-7.65.1 28 | 29 | [autoconf.args] 30 | # fboss (which added the libcurl dep) doesn't need ldap so it is disabled here. 31 | # if someone in the future wants to add ldap for something else, it won't hurt 32 | # fboss. However, that would require adding an ldap manifest. 33 | # 34 | # For the same reason, we disable libssh2 and libidn2 which aren't really used 35 | # but would require adding manifests if we don't disable them. 36 | --disable-ldap 37 | --without-libssh2 38 | --without-libidn2 39 | 40 | [build.os=windows] 41 | builder = cmake 42 | subdir = curl-7.65.1 43 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libdwarf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libdwarf 3 | 4 | [rpms] 5 | libdwarf-devel 6 | libdwarf 7 | 8 | [debs] 9 | libdwarf-dev 10 | 11 | [homebrew] 12 | dwarfutils 13 | 14 | [download] 15 | url = https://www.prevanders.net/libdwarf-0.9.2.tar.xz 16 | sha256 = 22b66d06831a76f6a062126cdcad3fcc58540b89a1acb23c99f8861f50999ec3 17 | 18 | [build] 19 | builder = cmake 20 | subdir = libdwarf-0.9.2 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libelf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libelf 3 | 4 | [rpms] 5 | elfutils-libelf-devel-static 6 | 7 | [debs] 8 | libelf-dev 9 | 10 | [pps] 11 | libelf 12 | 13 | [download] 14 | url = https://ftp.osuosl.org/pub/blfs/conglomeration/libelf/libelf-0.8.13.tar.gz 15 | sha256 = 591a9b4ec81c1f2042a97aa60564e0cb79d041c52faa7416acb38bc95bd2c76d 16 | 17 | # libelf only makes sense on linux, so make it a NOP on other platforms 18 | [build.not(os=linux)] 19 | builder = nop 20 | 21 | [build.os=linux] 22 | builder = autoconf 23 | subdir = libelf-0.8.13 24 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libevent: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libevent 3 | 4 | [debs] 5 | libevent-dev 6 | 7 | [homebrew] 8 | libevent 9 | 10 | [rpms] 11 | libevent-devel 12 | 13 | [pps] 14 | libevent 15 | 16 | # Note that the CMakeLists.txt file is present only in 17 | # git repo and not in the release tarball, so take care 18 | # to use the github generated source tarball rather than 19 | # the explicitly uploaded source tarball 20 | [download] 21 | url = https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz 22 | sha256 = 92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb 23 | 24 | [build] 25 | builder = cmake 26 | subdir = libevent-2.1.12-stable 27 | 28 | [cmake.defines] 29 | EVENT__DISABLE_TESTS = ON 30 | EVENT__DISABLE_BENCHMARK = ON 31 | EVENT__DISABLE_SAMPLES = ON 32 | EVENT__DISABLE_REGRESS = ON 33 | 34 | [cmake.defines.shared_libs=on] 35 | EVENT__BUILD_SHARED_LIBRARIES = ON 36 | 37 | [cmake.defines.os=windows] 38 | EVENT__LIBRARY_TYPE = STATIC 39 | 40 | [dependencies.not(any(os=linux, os=freebsd))] 41 | openssl 42 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libffi: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libffi 3 | 4 | [debs] 5 | libffi-dev 6 | 7 | [homebrew] 8 | libffi 9 | 10 | [rpms] 11 | libffi-devel 12 | libffi 13 | 14 | [pps] 15 | libffi 16 | 17 | [download] 18 | url = https://github.com/libffi/libffi/releases/download/v3.4.2/libffi-3.4.2.tar.gz 19 | sha256 = 540fb721619a6aba3bdeef7d940d8e9e0e6d2c193595bc243241b77ff9e93620 20 | 21 | [build] 22 | builder = autoconf 23 | subdir = libffi-3.4.2 24 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libgit2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libgit2 3 | 4 | [homebrew] 5 | libgit2 6 | 7 | [rpms] 8 | libgit2-devel 9 | 10 | [pps] 11 | libgit2 12 | 13 | # Ubuntu 18.04 libgit2 has clash with libcurl4-openssl-dev as it depends on 14 | # libcurl4-gnutls-dev. Should be ok from 20.04 again 15 | # There is a description at https://github.com/r-hub/sysreqsdb/issues/77 16 | [debs.not(all(distro=ubuntu,distro_vers="18.04"))] 17 | libgit2-dev 18 | 19 | [download] 20 | url = https://github.com/libgit2/libgit2/archive/v0.28.1.tar.gz 21 | sha256 = 0ca11048795b0d6338f2e57717370208c2c97ad66c6d5eac0c97a8827d13936b 22 | 23 | [build] 24 | builder = cmake 25 | subdir = libgit2-0.28.1 26 | 27 | [cmake.defines] 28 | # Could turn this on if we also wanted to add a manifest for libssh2 29 | USE_SSH = OFF 30 | BUILD_CLAR = OFF 31 | # Have to build shared to work around annoying problems with cmake 32 | # mis-parsing the frameworks required to link this on macos :-/ 33 | BUILD_SHARED_LIBS = ON 34 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libgpiod: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libgpiod 3 | 4 | [download] 5 | url = https://cdn.kernel.org/pub/software/libs/libgpiod/libgpiod-1.6.tar.xz 6 | sha256 = 62908023d59e8cbb9137ddd14deec50ced862d8f9b8749f288d3dbe7967151ef 7 | 8 | [build] 9 | builder = autoconf 10 | subdir = libgpiod-1.6 11 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libiberty: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libiberty 3 | 4 | [rpms] 5 | binutils-devel 6 | binutils 7 | 8 | [debs] 9 | binutils-dev 10 | 11 | [download] 12 | url = https://ftp.gnu.org/gnu/binutils/binutils-2.43.tar.xz 13 | sha256 = b53606f443ac8f01d1d5fc9c39497f2af322d99e14cea5c0b4b124d630379365 14 | 15 | [dependencies] 16 | zlib 17 | 18 | [build] 19 | builder = autoconf 20 | subdir = binutils-2.43/libiberty 21 | patchfile = libiberty_install_pic_lib.patch 22 | 23 | # only build the parts needed for demangling 24 | # as we still want to use system linker and assembler etc 25 | [autoconf.args] 26 | --enable-install-libiberty 27 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libmnl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libmnl 3 | 4 | [rpms] 5 | libmnl-devel 6 | 7 | # all centos 8 distros are missing this, 8 | # but its in fedora so may be back in a later version 9 | [rpms.not(all(any(distro=centos_stream,distro=centos),distro_vers=8))] 10 | libmnl-static 11 | 12 | [debs] 13 | libmnl-dev 14 | 15 | [pps] 16 | libmnl 17 | 18 | [download] 19 | url = http://www.netfilter.org/pub/libmnl/libmnl-1.0.4.tar.bz2 20 | sha256 = 171f89699f286a5854b72b91d06e8f8e3683064c5901fb09d954a9ab6f551f81 21 | 22 | [build.os=linux] 23 | builder = autoconf 24 | subdir = libmnl-1.0.4 25 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libnl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libnl 3 | 4 | [rpms] 5 | libnl3-devel 6 | libnl3 7 | 8 | [debs] 9 | libnl-3-dev 10 | libnl-route-3-dev 11 | 12 | [pps] 13 | libnl 14 | 15 | [download] 16 | url = https://github.com/thom311/libnl/releases/download/libnl3_2_25/libnl-3.2.25.tar.gz 17 | sha256 = 8beb7590674957b931de6b7f81c530b85dc7c1ad8fbda015398bc1e8d1ce8ec5 18 | 19 | [build.os=linux] 20 | builder = autoconf 21 | subdir = libnl-3.2.25 22 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/liboqs: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = liboqs 3 | 4 | [download] 5 | url = https://github.com/open-quantum-safe/liboqs/archive/refs/tags/0.12.0.tar.gz 6 | sha256 = df999915204eb1eba311d89e83d1edd3a514d5a07374745d6a9e5b2dd0d59c08 7 | 8 | [build] 9 | builder = cmake 10 | subdir = liboqs-0.12.0 11 | 12 | [cmake.defines] 13 | OQS_MINIMAL_BUILD = KEM_kyber_512;KEM_kyber_768;KEM_kyber_1024;KEM_ml_kem_512;KEM_ml_kem_768;KEM_ml_kem_1024 14 | 15 | [dependencies] 16 | openssl 17 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libsai: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libsai 3 | 4 | [download] 5 | url = https://github.com/opencomputeproject/SAI/archive/v1.14.0.tar.gz 6 | sha256 = 4e3a1d010bda0c589db46e077725a2cd9624a5cc255c89d1caa79deb408d1fa7 7 | 8 | [build] 9 | builder = nop 10 | subdir = SAI-1.14.0 11 | 12 | [install.files] 13 | inc = include 14 | experimental = experimental 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libsodium: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libsodium 3 | 4 | [debs] 5 | libsodium-dev 6 | 7 | [homebrew] 8 | libsodium 9 | 10 | [rpms] 11 | libsodium-devel 12 | libsodium-static 13 | 14 | [pps] 15 | libsodium 16 | 17 | [download.not(os=windows)] 18 | url = https://github.com/jedisct1/libsodium/releases/download/1.0.20-RELEASE/libsodium-1.0.20.tar.gz 19 | sha256 = ebb65ef6ca439333c2bb41a0c1990587288da07f6c7fd07cb3a18cc18d30ce19 20 | 21 | [build.not(os=windows)] 22 | builder = autoconf 23 | subdir = libsodium-1.0.20 24 | 25 | [download.os=windows] 26 | url = https://github.com/jedisct1/libsodium/releases/download/1.0.20-RELEASE/libsodium-1.0.20-msvc.zip 27 | sha256 = 2ff97f9e3f5b341bdc808e698057bea1ae454f99e29ff6f9b62e14d0eb1b1baa 28 | 29 | [build.os=windows] 30 | builder = nop 31 | 32 | [install.files.os=windows] 33 | libsodium/x64/Release/v143/dynamic/libsodium.dll = bin/libsodium.dll 34 | libsodium/x64/Release/v143/dynamic/libsodium.lib = lib/libsodium.lib 35 | libsodium/x64/Release/v143/dynamic/libsodium.exp = lib/libsodium.exp 36 | libsodium/x64/Release/v143/dynamic/libsodium.pdb = lib/libsodium.pdb 37 | libsodium/include = include 38 | 39 | [autoconf.args] 40 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libtool: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libtool 3 | 4 | [homebrew] 5 | libtool 6 | 7 | [rpms] 8 | libtool 9 | 10 | [debs] 11 | libtool 12 | 13 | [pps] 14 | libtool 15 | 16 | [download] 17 | url = http://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz 18 | sha256 = e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3 19 | 20 | [build] 21 | builder = autoconf 22 | subdir = libtool-2.4.6 23 | 24 | [dependencies] 25 | automake 26 | 27 | [autoconf.args] 28 | --enable-ltdl-install 29 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libunwind: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libunwind 3 | 4 | [rpms] 5 | libunwind-devel 6 | libunwind 7 | 8 | # on ubuntu this brings in liblzma-dev, which in turn breaks watchman tests 9 | [debs.not(distro=ubuntu)] 10 | libunwind-dev 11 | 12 | # The current libunwind v1.8.1 release has compiler issues with aarch64 (https://github.com/libunwind/libunwind/issues/702). 13 | # This more recent libunwind version (based on the latest commit, not a release version) got it fixed. 14 | [download] 15 | url = https://github.com/libunwind/libunwind/archive/f081cf42917bdd5c428b77850b473f31f81767cf.tar.gz 16 | sha256 = 4ff5c335c02d225491d6c885db827fb5fa505fee4e68b4d7e866efc0087e7264 17 | 18 | [build] 19 | builder = autoconf 20 | subdir = libunwind-f081cf42917bdd5c428b77850b473f31f81767cf 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libusb: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libusb 3 | 4 | [debs] 5 | libusb-1.0-0-dev 6 | 7 | [homebrew] 8 | libusb 9 | 10 | [rpms] 11 | libusb-devel 12 | libusb 13 | 14 | [pps] 15 | libusb 16 | 17 | [download] 18 | url = https://github.com/libusb/libusb/releases/download/v1.0.22/libusb-1.0.22.tar.bz2 19 | sha256 = 75aeb9d59a4fdb800d329a545c2e6799f732362193b465ea198f2aa275518157 20 | 21 | [build.os=linux] 22 | builder = autoconf 23 | subdir = libusb-1.0.22 24 | 25 | [autoconf.args] 26 | # fboss (which added the libusb dep) doesn't need udev so it is disabled here. 27 | # if someone in the future wants to add udev for something else, it won't hurt 28 | # fboss. 29 | --disable-udev 30 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/libyaml: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = libyaml 3 | 4 | [download] 5 | url = http://pyyaml.org/download/libyaml/yaml-0.1.7.tar.gz 6 | sha256 = 8088e457264a98ba451a90b8661fcb4f9d6f478f7265d48322a196cec2480729 7 | 8 | [build.os=linux] 9 | builder = autoconf 10 | subdir = yaml-0.1.7 11 | 12 | [build.not(os=linux)] 13 | builder = nop 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/llvm: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = llvm 3 | 4 | [rpms] 5 | llvm15-devel 6 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/lmdb: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = lmdb 3 | 4 | [build] 5 | builder = make 6 | subdir = lmdb-LMDB_0.9.31/libraries/liblmdb 7 | 8 | [download] 9 | url = https://github.com/LMDB/lmdb/archive/refs/tags/LMDB_0.9.31.tar.gz 10 | sha256 = dd70a8c67807b3b8532b3e987b0a4e998962ecc28643e1af5ec77696b081c9b0 11 | 12 | [make.build_args] 13 | BUILD_STATIC_ONLY=y 14 | 15 | [make.install_args] 16 | install 17 | BUILD_STATIC_ONLY=y 18 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/lz4: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = lz4 3 | 4 | [homebrew] 5 | lz4 6 | 7 | [rpms] 8 | lz4-devel 9 | # centos 8 and centos_stream 9 are missing this rpm 10 | [rpms.not(any(all(distro=centos,distro_vers=8),all(distro=centos_stream,distro_vers=9)))] 11 | lz4-static 12 | 13 | [debs] 14 | liblz4-dev 15 | 16 | [pps] 17 | lz4 18 | 19 | [download] 20 | url = https://github.com/lz4/lz4/archive/v1.8.3.tar.gz 21 | sha256 = 33af5936ac06536805f9745e0b6d61da606a1f8b4cc5c04dd3cbaca3b9b4fc43 22 | 23 | [build] 24 | builder = cmake 25 | subdir = lz4-1.8.3/contrib/cmake_unofficial 26 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/mcrouter: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = mcrouter 3 | 4 | [git] 5 | repo_url = https://github.com/facebook/mcrouter.git 6 | 7 | [dependencies] 8 | folly 9 | wangle 10 | fizz 11 | fbthrift 12 | mvfst 13 | ragel 14 | 15 | [build] 16 | builder = cmake 17 | subdir = . 18 | 19 | [cmake.defines.test=on] 20 | BUILD_TESTS=ON 21 | 22 | [cmake.defines.test=off] 23 | BUILD_TESTS=OFF 24 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/mononoke: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = mononoke 3 | fbsource_path = fbcode/eden 4 | shipit_project = eden 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/sapling.git 9 | 10 | [build.not(os=windows)] 11 | builder = cargo 12 | 13 | [build.os=windows] 14 | # building Mononoke on windows is not supported 15 | builder = nop 16 | 17 | [cargo] 18 | build_doc = true 19 | workspace_dir = eden/mononoke 20 | 21 | [shipit.pathmap] 22 | fbcode/configerator/structs/scm/hg = configerator/structs/scm/hg 23 | fbcode/configerator/structs/scm/hg/public_autocargo = configerator/structs/scm/hg 24 | fbcode/configerator/structs/scm/mononoke/public_autocargo = configerator/structs/scm/mononoke 25 | fbcode/configerator/structs/scm/mononoke = configerator/structs/scm/mononoke 26 | fbcode/eden/oss = . 27 | fbcode/eden = eden 28 | fbcode/eden/fs/public_autocargo = eden/fs 29 | fbcode/eden/mononoke/public_autocargo = eden/mononoke 30 | fbcode/eden/scm/public_autocargo = eden/scm 31 | fbcode/tools/lfs = tools/lfs 32 | tools/rust/ossconfigs = . 33 | 34 | [shipit.strip] 35 | ^fbcode/configerator/structs/scm/hg(?!/public_autocargo).*/Cargo\.toml$ 36 | ^fbcode/configerator/structs/scm/mononoke(?!/public_autocargo).*/Cargo\.toml$ 37 | ^fbcode/eden/fs(?!/public_autocargo).*/Cargo\.toml$ 38 | ^fbcode/eden/scm/lib/third-party/rust/.*/Cargo\.toml$ 39 | ^fbcode/eden/mononoke(?!/public_autocargo).*/Cargo\.toml$ 40 | # strip other scm code unrelated to mononoke to prevent triggering unnecessary checks 41 | ^fbcode/eden(?!/mononoke|/scm/(lib|public_autocargo))/.*$ 42 | ^.*/facebook/.*$ 43 | ^.*/fb/.*$ 44 | 45 | [dependencies] 46 | fb303 47 | fbthrift 48 | rust-shed 49 | 50 | [dependencies.fb=on] 51 | rust 52 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/mononoke_integration: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = mononoke_integration 3 | fbsource_path = fbcode/eden 4 | shipit_project = eden 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/sapling.git 9 | 10 | [build.not(os=windows)] 11 | builder = make 12 | subdir = eden/mononoke/tests/integration 13 | 14 | [build.os=windows] 15 | # building Mononoke on windows is not supported 16 | builder = nop 17 | 18 | [make.build_args] 19 | build-getdeps 20 | 21 | [make.install_args] 22 | install-getdeps 23 | 24 | [make.test_args] 25 | test-getdeps 26 | 27 | [shipit.pathmap] 28 | fbcode/eden/mononoke/tests/integration = eden/mononoke/tests/integration 29 | 30 | [shipit.strip] 31 | ^.*/facebook/.*$ 32 | ^.*/fb/.*$ 33 | 34 | [dependencies] 35 | git-lfs 36 | jq 37 | mononoke 38 | nmap 39 | python 40 | python-click 41 | ripgrep 42 | sapling 43 | tree 44 | zstd 45 | 46 | [dependencies.os=linux] 47 | sqlite3 48 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/mvfst: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = mvfst 3 | fbsource_path = fbcode/quic 4 | shipit_project = mvfst 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/mvfst.git 9 | 10 | [build] 11 | builder = cmake 12 | subdir = . 13 | 14 | [cmake.defines.test=on] 15 | BUILD_TESTS = ON 16 | 17 | [cmake.defines.all(os=windows, test=on)] 18 | BUILD_TESTS = OFF 19 | 20 | [cmake.defines.test=off] 21 | BUILD_TESTS = OFF 22 | 23 | [dependencies] 24 | folly 25 | fizz 26 | 27 | [dependencies.all(test=on, not(os=windows))] 28 | googletest 29 | 30 | [shipit.pathmap] 31 | fbcode/quic/public_root = . 32 | fbcode/quic = quic 33 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/ncurses: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = ncurses 3 | 4 | [debs] 5 | libncurses-dev 6 | 7 | [homebrew] 8 | ncurses 9 | 10 | [rpms] 11 | ncurses-devel 12 | 13 | [download] 14 | url = https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.3.tar.gz 15 | sha256 = 97fc51ac2b085d4cde31ef4d2c3122c21abc217e9090a43a30fc5ec21684e059 16 | 17 | [build.not(os=windows)] 18 | builder = autoconf 19 | subdir = ncurses-6.3 20 | 21 | [autoconf.args] 22 | --without-cxx-binding 23 | --without-ada 24 | 25 | [autoconf.args.os=linux] 26 | --enable-shared 27 | --with-shared 28 | 29 | [build.os=windows] 30 | builder = nop 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/nghttp2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = nghttp2 3 | 4 | [rpms] 5 | libnghttp2-devel 6 | libnghttp2 7 | 8 | [debs] 9 | libnghttp2-dev 10 | 11 | [pps] 12 | libnghttp2 13 | 14 | [download] 15 | url = https://github.com/nghttp2/nghttp2/releases/download/v1.47.0/nghttp2-1.47.0.tar.gz 16 | sha256 = 62f50f0e9fc479e48b34e1526df8dd2e94136de4c426b7680048181606832b7c 17 | 18 | [build] 19 | builder = autoconf 20 | subdir = nghttp2-1.47.0 21 | 22 | [autoconf.args] 23 | --enable-lib-only 24 | --disable-dependency-tracking 25 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/ninja: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = ninja 3 | 4 | [debs] 5 | ninja-build 6 | 7 | [homebrew] 8 | ninja 9 | 10 | [rpms] 11 | ninja-build 12 | 13 | [pps] 14 | ninja 15 | 16 | [download.os=windows] 17 | url = https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip 18 | sha256 = bbde850d247d2737c5764c927d1071cbb1f1957dcabda4a130fa8547c12c695f 19 | 20 | [build.os=windows] 21 | builder = nop 22 | 23 | [install.files.os=windows] 24 | ninja.exe = bin/ninja.exe 25 | 26 | [download.not(os=windows)] 27 | url = https://github.com/ninja-build/ninja/archive/v1.10.2.tar.gz 28 | sha256 = ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed 29 | 30 | [build.not(os=windows)] 31 | builder = ninja_bootstrap 32 | subdir = ninja-1.10.2 33 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/nlohmann-json: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = nlohmann-json 3 | 4 | [download] 5 | url = https://github.com/nlohmann/json/archive/refs/tags/v3.10.5.tar.gz 6 | sha256 = 5daca6ca216495edf89d167f808d1d03c4a4d929cef7da5e10f135ae1540c7e4 7 | 8 | [dependencies] 9 | 10 | [build] 11 | builder = cmake 12 | subdir = json-3.10.5 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/nmap: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = nmap 3 | 4 | [rpms] 5 | nmap 6 | nmap-ncat 7 | 8 | [debs] 9 | nmap 10 | 11 | # 18.04 combines ncat into the nmap package, newer need the separate one 12 | [debs.not(all(distro=ubuntu,distro_vers="18.04"))] 13 | ncat 14 | 15 | [download.not(os=windows)] 16 | url = https://api.github.com/repos/nmap/nmap/tarball/ef8213a36c2e89233c806753a57b5cd473605408 17 | sha256 = eda39e5a8ef4964fac7db16abf91cc11ff568eac0fa2d680b0bfa33b0ed71f4a 18 | 19 | [build.not(os=windows)] 20 | builder = autoconf 21 | subdir = nmap-nmap-ef8213a 22 | build_in_src_dir = true 23 | 24 | [build.os=windows] 25 | builder = nop 26 | 27 | [autoconf.args] 28 | # Without this option the build was filing to find some third party libraries 29 | # that we don't need 30 | enable_rdma=no 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/numa: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = numa 3 | 4 | [download] 5 | url = https://github.com/numactl/numactl/releases/download/v2.0.19/numactl-2.0.19.tar.gz 6 | sha256 = f2672a0381cb59196e9c246bf8bcc43d5568bc457700a697f1a1df762b9af884 7 | 8 | [build] 9 | builder = autoconf 10 | subdir = numactl-2.0.19 11 | 12 | [rpms.distro=centos_stream] 13 | numactl-devel 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/openr: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = openr 3 | fbsource_path = facebook/openr 4 | shipit_project = openr 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/openr.git 9 | 10 | [build.os=linux] 11 | builder = cmake 12 | # openr files take a lot of RAM to compile. 13 | job_weight_mib = 3072 14 | 15 | [build.not(os=linux)] 16 | # boost.fiber is required and that is not available on macos. 17 | builder = nop 18 | 19 | [dependencies] 20 | boost 21 | fb303 22 | fbthrift 23 | folly 24 | googletest 25 | re2 26 | range-v3 27 | 28 | [cmake.defines.test=on] 29 | BUILD_TESTS=ON 30 | ADD_ROOT_TESTS=OFF 31 | 32 | [cmake.defines.test=off] 33 | BUILD_TESTS=OFF 34 | 35 | 36 | [shipit.pathmap] 37 | fbcode/openr = openr 38 | fbcode/openr/public_tld = . 39 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/openssl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = openssl 3 | 4 | [debs] 5 | libssl-dev 6 | 7 | [homebrew] 8 | openssl 9 | # on homebrew need the matching curl and ca- 10 | 11 | [rpms] 12 | openssl 13 | openssl-devel 14 | openssl-libs 15 | 16 | [pps] 17 | openssl 18 | 19 | # no need to download on the systems where we always use the system libs 20 | [download.not(any(os=linux, os=freebsd))] 21 | # match the openssl version packages in ubuntu LTS folly current supports 22 | url = https://www.openssl.org/source/openssl-3.0.15.tar.gz 23 | sha256 = 23c666d0edf20f14249b3d8f0368acaee9ab585b09e1de82107c66e1f3ec9533 24 | 25 | # We use the system openssl on these platforms even without --allow-system-packages 26 | [build.any(os=linux, os=freebsd)] 27 | builder = nop 28 | 29 | [build.not(any(os=linux, os=freebsd))] 30 | builder = openssl 31 | subdir = openssl-3.0.15 32 | 33 | [dependencies.os=windows] 34 | jom 35 | perl 36 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/osxfuse: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = osxfuse 3 | 4 | [download] 5 | url = https://github.com/osxfuse/osxfuse/archive/osxfuse-3.8.3.tar.gz 6 | sha256 = 93bab6731bdfe8dc1ef069483437270ce7fe5a370f933d40d8d0ef09ba846c0c 7 | 8 | [build] 9 | builder = nop 10 | 11 | [install.files] 12 | osxfuse-osxfuse-3.8.3/common = include 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/patchelf: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = patchelf 3 | 4 | [rpms] 5 | patchelf 6 | 7 | [debs] 8 | patchelf 9 | 10 | [pps] 11 | patchelf 12 | 13 | [download] 14 | url = https://github.com/NixOS/patchelf/archive/0.10.tar.gz 15 | sha256 = b3cb6bdedcef5607ce34a350cf0b182eb979f8f7bc31eae55a93a70a3f020d13 16 | 17 | [build] 18 | builder = autoconf 19 | subdir = patchelf-0.10 20 | 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/pcre2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = pcre2 3 | 4 | [homebrew] 5 | pcre2 6 | 7 | [rpms] 8 | pcre2-devel 9 | pcre-static 10 | 11 | [debs] 12 | libpcre2-dev 13 | 14 | [download] 15 | url = https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.40/pcre2-10.40.tar.bz2 16 | sha256 = 14e4b83c4783933dc17e964318e6324f7cae1bc75d8f3c79bc6969f00c159d68 17 | 18 | [build] 19 | builder = cmake 20 | subdir = pcre2-10.40 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/perl: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = perl 3 | 4 | [download.os=windows] 5 | url = http://strawberryperl.com/download/5.28.1.1/strawberry-perl-5.28.1.1-64bit-portable.zip 6 | sha256 = 935c95ba096fa11c4e1b5188732e3832d330a2a79e9882ab7ba8460ddbca810d 7 | 8 | [build.os=windows] 9 | builder = nop 10 | subdir = perl 11 | 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/pexpect: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = pexpect 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/0e/3e/377007e3f36ec42f1b84ec322ee12141a9e10d808312e5738f52f80a232c/pexpect-4.7.0-py2.py3-none-any.whl 6 | sha256 = 2094eefdfcf37a1fdbfb9aa090862c1a4878e5c7e0e7e7088bdb511c558e5cd1 7 | 8 | [build] 9 | builder = python-wheel 10 | 11 | [dependencies] 12 | python-ptyprocess 13 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/proxygen: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = proxygen 3 | fbsource_path = fbcode/proxygen 4 | shipit_project = proxygen 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/proxygen.git 9 | 10 | [build.os=windows] 11 | builder = nop 12 | 13 | [build] 14 | builder = cmake 15 | subdir = . 16 | job_weight_mib = 3072 17 | 18 | [cmake.defines.test=on] 19 | BUILD_TESTS = ON 20 | 21 | [cmake.defines.test=off] 22 | BUILD_TESTS = OFF 23 | 24 | [dependencies] 25 | zlib 26 | gperf 27 | folly 28 | fizz 29 | wangle 30 | mvfst 31 | 32 | [dependencies.test=on] 33 | googletest 34 | 35 | [shipit.pathmap] 36 | fbcode/proxygen/public_tld = . 37 | fbcode/proxygen = proxygen 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python 3 | 4 | [homebrew] 5 | python@3.8 6 | 7 | [rpms] 8 | python3 9 | python3-devel 10 | 11 | # sapling needs dataclasses which arrive in 3.7, and the bionic python is 3.6 12 | [debs.all(distro=ubuntu,distro_vers="18.04")] 13 | python3.8-dev 14 | 15 | [debs.not(all(distro=ubuntu,distro_vers="18.04"))] 16 | python3-all-dev 17 | 18 | [pps] 19 | python3 20 | 21 | [download] 22 | url = https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz 23 | sha256 = 903b92d76354366b1d9c4434d0c81643345cef87c1600adfa36095d7b00eede4 24 | 25 | [build] 26 | builder = autoconf 27 | subdir = Python-3.8.13 28 | 29 | [autoconf.args] 30 | --enable-shared 31 | --with-ensurepip=install 32 | 33 | # python's pkg-config libffi detection is broken 34 | # See https://bugs.python.org/issue34823 for clearest description 35 | # and pending PR https://github.com/python/cpython/pull/20451 36 | # The documented workaround requires an environment variable derived from 37 | # pkg-config to be passed into its configure step 38 | [autoconf.envcmd.LDFLAGS] 39 | pkg-config 40 | --libs-only-L 41 | libffi 42 | 43 | [dependencies] 44 | libffi 45 | # eden tests expect the python bz2 support 46 | bz2 47 | # eden tests expect the python curses support 48 | ncurses 49 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-click: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-click 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl 6 | sha256 = dacca89f4bfadd5de3d7489b7c8a566eee0d3676333fbb50030263894c38c0dc 7 | 8 | [build] 9 | builder = python-wheel 10 | 11 | [rpms] 12 | python3-click 13 | 14 | [debs] 15 | python3-click 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-filelock: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-filelock 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/31/24/ee722b92f23b9ebd87783e893a75352c048bbbc1f67dce0d63b58b46cb48/filelock-3.3.2-py3-none-any.whl 6 | sha256 = bb2a1c717df74c48a2d00ed625e5a66f8572a3a30baacb7657add1d7bac4097b 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-ptyprocess: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-ptyprocess 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/d1/29/605c2cc68a9992d18dada28206eeada56ea4bd07a239669da41674648b6f/ptyprocess-0.6.0-py2.py3-none-any.whl 6 | sha256 = d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-setuptools: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-setuptools 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/c0/7a/3da654f49c95d0cc6e9549a855b5818e66a917e852ec608e77550c8dc08b/setuptools-69.1.1-py3-none-any.whl 6 | sha256 = 02fa291a0471b3a18b2b2481ed902af520c69e8ae0919c13da936542754b4c56 7 | 8 | [build] 9 | builder = python-wheel 10 | 11 | [rpms] 12 | python3-setuptools 13 | 14 | [homebrew] 15 | python-setuptools 16 | 17 | [debs] 18 | python3-setuptools 19 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-six: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-six 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl 6 | sha256 = 3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/python-toml: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = python-toml 3 | 4 | [download] 5 | url = https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl 6 | sha256 = 235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e 7 | 8 | [build] 9 | builder = python-wheel 10 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/ragel: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = ragel 3 | 4 | [debs] 5 | ragel 6 | 7 | [homebrew] 8 | ragel 9 | 10 | [rpms] 11 | ragel 12 | 13 | [download] 14 | url = https://www.colm.net/files/ragel/ragel-6.10.tar.gz 15 | sha256 = 5f156edb65d20b856d638dd9ee2dfb43285914d9aa2b6ec779dac0270cd56c3f 16 | 17 | [build] 18 | builder = autoconf 19 | subdir = ragel-6.10 20 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/range-v3: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = range-v3 3 | 4 | [download] 5 | url = https://github.com/ericniebler/range-v3/archive/refs/tags/0.11.0.tar.gz 6 | sha256 = 376376615dbba43d3bef75aa590931431ecb49eb36d07bb726a19f680c75e20c 7 | 8 | 9 | [build] 10 | builder = cmake 11 | subdir = range-v3-0.11.0 12 | 13 | [cmake.defines] 14 | RANGE_V3_EXAMPLES=OFF 15 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/re2: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = re2 3 | 4 | [homebrew] 5 | re2 6 | 7 | [debs] 8 | libre2-dev 9 | 10 | [rpms] 11 | re2 12 | re2-devel 13 | 14 | [pps] 15 | re2 16 | 17 | [download] 18 | url = https://github.com/google/re2/archive/2020-11-01.tar.gz 19 | sha256 = 8903cc66c9d34c72e2bc91722288ebc7e3ec37787ecfef44d204b2d6281954d7 20 | 21 | [build] 22 | builder = cmake 23 | subdir = re2-2020-11-01 24 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/ripgrep: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = ripgrep 3 | 4 | [rpms] 5 | ripgrep 6 | 7 | [debs] 8 | ripgrep 9 | 10 | [homebrew] 11 | ripgrep 12 | 13 | # only used from system packages currently 14 | [build] 15 | builder = nop 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/rocksdb: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = rocksdb 3 | 4 | [download] 5 | url = https://github.com/facebook/rocksdb/archive/refs/tags/v8.7.3.zip 6 | sha256 = 36c06b61dc167f2455990d60dd88d734b73aa8c4dfc095243efd0243834c6cd3 7 | 8 | [dependencies] 9 | lz4 10 | snappy 11 | 12 | [build] 13 | builder = cmake 14 | subdir = rocksdb-8.7.3 15 | 16 | [cmake.defines] 17 | WITH_SNAPPY=ON 18 | WITH_LZ4=ON 19 | WITH_TESTS=OFF 20 | WITH_BENCHMARK_TOOLS=OFF 21 | # We get relocation errors with the static gflags lib, 22 | # and there's no clear way to make it pick the shared gflags 23 | # so just turn it off. 24 | WITH_GFLAGS=OFF 25 | # Disable the use of -Werror 26 | FAIL_ON_WARNINGS = OFF 27 | 28 | [cmake.defines.os=windows] 29 | ROCKSDB_INSTALL_ON_WINDOWS=ON 30 | # RocksDB hard codes the paths to the snappy libs to something 31 | # that doesn't exist; ignoring the usual cmake rules. As a result, 32 | # we can't build it with snappy without either patching rocksdb or 33 | # without introducing more complex logic to the build system to 34 | # connect the snappy build outputs to rocksdb's custom logic here. 35 | # Let's just turn it off on windows. 36 | WITH_SNAPPY=OFF 37 | WITH_LZ4=ON 38 | ROCKSDB_SKIP_THIRDPARTY=ON 39 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/rust-shed: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = rust-shed 3 | fbsource_path = fbcode/common/rust/shed 4 | shipit_project = rust-shed 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebookexperimental/rust-shed.git 9 | 10 | [build] 11 | builder = cargo 12 | 13 | [cargo] 14 | build_doc = true 15 | workspace_dir = 16 | 17 | [shipit.pathmap] 18 | fbcode/common/rust/shed = shed 19 | fbcode/common/rust/shed/public_autocargo = shed 20 | fbcode/common/rust/shed/public_tld = . 21 | tools/rust/ossconfigs = . 22 | 23 | [shipit.strip] 24 | ^fbcode/common/rust/shed/(?!public_autocargo|public_tld).+/Cargo\.toml$ 25 | 26 | [dependencies] 27 | fbthrift 28 | fb303 29 | 30 | # We use the system openssl on linux 31 | [dependencies.not(os=linux)] 32 | openssl 33 | 34 | [dependencies.fbsource=on] 35 | rust 36 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/sapling: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = sapling 3 | fbsource_path = fbcode/eden 4 | shipit_project = eden 5 | shipit_fbcode_builder = true 6 | 7 | [github.actions] 8 | required_locales = en_US.UTF-8 9 | 10 | [git] 11 | repo_url = https://github.com/facebook/sapling.git 12 | 13 | [build.not(os=windows)] 14 | builder = make 15 | subdir = eden/scm 16 | 17 | [build.os=windows] 18 | # For now the biggest blocker is missing "make" on windows, but there are bound 19 | # to be more 20 | builder = nop 21 | 22 | [make.build_args] 23 | getdepsbuild 24 | 25 | [make.install_args] 26 | install-getdeps 27 | 28 | [make.test_args] 29 | test-getdeps 30 | 31 | [shipit.pathmap] 32 | fbcode/configerator/structs/scm/hg = configerator/structs/scm/hg 33 | fbcode/configerator/structs/scm/hg/public_autocargo = configerator/structs/scm/hg 34 | fbcode/eden/oss = . 35 | fbcode/eden = eden 36 | fbcode/eden/fs/public_autocargo = eden/fs 37 | fbcode/eden/mononoke/public_autocargo = eden/mononoke 38 | fbcode/eden/scm/public_autocargo = eden/scm 39 | fbcode/tools/lfs = tools/lfs 40 | 41 | [shipit.strip] 42 | ^fbcode/configerator/structs/scm/hg(?!/public_autocargo).*/Cargo\.toml$ 43 | ^fbcode/eden/addons/.*$ 44 | ^fbcode/eden/fs/eden-config\.h$ 45 | ^fbcode/eden/fs/py/eden/config\.py$ 46 | ^fbcode/eden/hg-server/.*$ 47 | ^fbcode/eden/fs(?!/public_autocargo).*/Cargo\.toml$ 48 | ^fbcode/eden/mononoke(?!/public_autocargo).*/Cargo\.toml$ 49 | ^fbcode/eden/scm(?!/public_autocargo|/edenscmnative/bindings).*/Cargo\.toml$ 50 | ^fbcode/eden/scm/build/.*$ 51 | ^fbcode/eden/website/.*$ 52 | ^fbcode/eden/.*/\.cargo/.*$ 53 | ^.*/facebook/.*$ 54 | ^.*/fb/.*$ 55 | /Cargo\.lock$ 56 | \.pyc$ 57 | 58 | [dependencies] 59 | fb303 60 | fbthrift 61 | rust-shed 62 | 63 | [dependencies.all(test=on,not(os=darwin))] 64 | hexdump 65 | 66 | [dependencies.not(os=windows)] 67 | python 68 | python-setuptools 69 | 70 | # We use the system openssl on linux 71 | [dependencies.not(os=linux)] 72 | openssl 73 | 74 | [dependencies.fbsource=on] 75 | rust 76 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/snappy: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = snappy 3 | 4 | [homebrew] 5 | snappy 6 | 7 | [debs] 8 | libsnappy-dev 9 | 10 | [rpms] 11 | snappy-devel 12 | 13 | [pps] 14 | snappy 15 | 16 | [download] 17 | url = https://github.com/google/snappy/archive/1.1.7.tar.gz 18 | sha256 = 3dfa02e873ff51a11ee02b9ca391807f0c8ea0529a4924afa645fbf97163f9d4 19 | 20 | [build] 21 | builder = cmake 22 | subdir = snappy-1.1.7 23 | 24 | [cmake.defines] 25 | SNAPPY_BUILD_TESTS = OFF 26 | 27 | # Avoid problems like `relocation R_X86_64_PC32 against symbol` on ELF systems 28 | # when linking rocksdb, which builds PIC even when building a static lib 29 | [cmake.defines.os=linux] 30 | BUILD_SHARED_LIBS = ON 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/sparsemap: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = sparsemap 3 | 4 | [download] 5 | url = https://github.com/Tessil/sparse-map/archive/refs/tags/v0.6.2.tar.gz 6 | sha256 = 7020c21e8752e59d72e37456cd80000e18671c803890a3e55ae36b295eba99f6 7 | 8 | [build] 9 | builder = cmake 10 | subdir = sparse-map-0.6.2/ 11 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/sqlite3: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = sqlite3 3 | 4 | [debs] 5 | libsqlite3-dev 6 | sqlite3 7 | 8 | [homebrew] 9 | sqlite 10 | 11 | [rpms] 12 | sqlite-devel 13 | sqlite-libs 14 | sqlite 15 | 16 | [pps] 17 | sqlite3 18 | 19 | [download] 20 | url = https://sqlite.org/2019/sqlite-amalgamation-3280000.zip 21 | sha256 = d02fc4e95cfef672b45052e221617a050b7f2e20103661cda88387349a9b1327 22 | 23 | [dependencies] 24 | cmake 25 | ninja 26 | 27 | [build] 28 | builder = sqlite 29 | subdir = sqlite-amalgamation-3280000 30 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/systemd: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = systemd 3 | 4 | [rpms] 5 | systemd 6 | systemd-devel 7 | 8 | [download] 9 | url = https://github.com/systemd/systemd/archive/refs/tags/v256.7.tar.gz 10 | sha256 = 896d76ff65c88f5fd9e42f90d152b0579049158a163431dd77cdc57748b1d7b0 11 | 12 | 13 | [build] 14 | builder = systemd 15 | subdir = systemd-256.7 16 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/tree: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = tree 3 | 4 | [debs] 5 | tree 6 | 7 | [homebrew] 8 | tree 9 | 10 | [rpms] 11 | tree 12 | 13 | [download.os=linux] 14 | url = https://salsa.debian.org/debian/tree-packaging/-/archive/debian/1.8.0-1/tree-packaging-debian-1.8.0-1.tar.gz 15 | sha256 = a841eee1d52bfd64a48f54caab9937b9bd92935055c48885c4ab1ae4dab7fae5 16 | 17 | [download.os=darwin] 18 | # The official package of tree source requires users of non-Linux platform to 19 | # comment/uncomment certain lines in the Makefile to build for their platform. 20 | # Besauce getdeps.py doesn't have that functionality we just use this custom 21 | # fork of tree which has proper lines uncommented for a OSX build 22 | url = https://github.com/lukaspiatkowski/tree-command/archive/debian/1.8.0-1-macos.tar.gz 23 | sha256 = 9cbe889553d95cf5a2791dd0743795d46a3c092c5bba691769c0e5c52e11229e 24 | 25 | [build.os=linux] 26 | builder = make 27 | subdir = tree-packaging-debian-1.8.0-1 28 | 29 | [build.os=darwin] 30 | builder = make 31 | subdir = tree-command-debian-1.8.0-1-macos 32 | 33 | [build.os=windows] 34 | builder = nop 35 | 36 | [make.install_args] 37 | install 38 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/wangle: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = wangle 3 | fbsource_path = fbcode/wangle 4 | shipit_project = wangle 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/wangle.git 9 | 10 | [build] 11 | builder = cmake 12 | subdir = wangle 13 | 14 | [cmake.defines.test=on] 15 | BUILD_TESTS=ON 16 | 17 | [cmake.defines.test=off] 18 | BUILD_TESTS=OFF 19 | 20 | [dependencies] 21 | folly 22 | googletest 23 | fizz 24 | 25 | [shipit.pathmap] 26 | fbcode/wangle/public_tld = . 27 | fbcode/wangle = wangle 28 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/watchman: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = watchman 3 | fbsource_path = fbcode/watchman 4 | shipit_project = watchman 5 | shipit_fbcode_builder = true 6 | 7 | [git] 8 | repo_url = https://github.com/facebook/watchman.git 9 | 10 | [build] 11 | builder = cmake 12 | 13 | [dependencies] 14 | boost 15 | cpptoml 16 | edencommon 17 | fb303 18 | fbthrift 19 | folly 20 | pcre2 21 | googletest 22 | python-setuptools 23 | 24 | [dependencies.fbsource=on] 25 | rust 26 | 27 | [shipit.pathmap] 28 | fbcode/watchman = watchman 29 | fbcode/watchman/oss = . 30 | fbcode/eden/fs = eden/fs 31 | 32 | [shipit.strip] 33 | ^fbcode/eden/fs/(?!.*\.thrift|service/shipit_test_file\.txt) 34 | 35 | [cmake.defines.fb=on] 36 | ENABLE_EDEN_SUPPORT=ON 37 | IS_FB_BUILD=ON 38 | 39 | # FB macos specific settings 40 | [cmake.defines.all(fb=on,os=darwin)] 41 | # this path is coupled with the FB internal watchman-osx.spec 42 | WATCHMAN_STATE_DIR=/opt/facebook/watchman/var/run/watchman 43 | # tell cmake not to try to create /opt/facebook/... 44 | INSTALL_WATCHMAN_STATE_DIR=OFF 45 | USE_SYS_PYTHON=OFF 46 | 47 | [depends.environment] 48 | WATCHMAN_VERSION_OVERRIDE 49 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/xxhash: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = xxhash 3 | 4 | [download] 5 | url = https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.2.tar.gz 6 | sha256 = baee0c6afd4f03165de7a4e67988d16f0f2b257b51d0e3cb91909302a26a79c4 7 | 8 | [rpms] 9 | xxhash-devel 10 | 11 | [debs] 12 | libxxhash-dev 13 | xxhash 14 | 15 | [homebrew] 16 | xxhash 17 | 18 | [build.not(os=windows)] 19 | builder = make 20 | subdir = xxHash-0.8.2 21 | 22 | [make.build_args] 23 | all 24 | 25 | [make.install_args] 26 | install 27 | 28 | [build.os=windows] 29 | builder = cmake 30 | subdir = xxHash-0.8.2/cmake_unofficial 31 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/xz: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = xz 3 | 4 | # ubuntu's package causes watchman's tests to hang 5 | [debs.not(distro=ubuntu)] 6 | liblzma-dev 7 | 8 | [homebrew] 9 | xz 10 | 11 | [rpms] 12 | xz-devel 13 | 14 | [download] 15 | url = https://tukaani.org/xz/xz-5.2.5.tar.gz 16 | sha256 = f6f4910fd033078738bd82bfba4f49219d03b17eb0794eb91efbae419f4aba10 17 | 18 | [build] 19 | builder = autoconf 20 | subdir = xz-5.2.5 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/yaml-cpp: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = yaml-cpp 3 | 4 | [download] 5 | url = https://github.com/jbeder/yaml-cpp/archive/yaml-cpp-0.6.2.tar.gz 6 | sha256 = e4d8560e163c3d875fd5d9e5542b5fd5bec810febdcba61481fe5fc4e6b1fd05 7 | 8 | [build.os=linux] 9 | builder = cmake 10 | subdir = yaml-cpp-yaml-cpp-0.6.2 11 | 12 | [build.not(os=linux)] 13 | builder = nop 14 | 15 | [dependencies] 16 | boost 17 | googletest 18 | 19 | [cmake.defines] 20 | YAML_CPP_BUILD_TESTS=OFF 21 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/zlib: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = zlib 3 | 4 | [debs] 5 | zlib1g-dev 6 | 7 | [homebrew] 8 | zlib 9 | 10 | [rpms.not(distro=fedora)] 11 | zlib-devel 12 | zlib-static 13 | 14 | [rpms.distro=fedora] 15 | zlib-ng-compat-devel 16 | zlib-ng-compat-static 17 | 18 | [pps] 19 | zlib 20 | 21 | [download] 22 | url = https://zlib.net/zlib-1.3.1.tar.gz 23 | sha256 = 9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23 24 | 25 | [build] 26 | builder = cmake 27 | subdir = zlib-1.3.1 28 | patchfile = zlib_dont_build_more_than_needed.patch 29 | -------------------------------------------------------------------------------- /build/fbcode_builder/manifests/zstd: -------------------------------------------------------------------------------- 1 | [manifest] 2 | name = zstd 3 | 4 | [homebrew] 5 | zstd 6 | 7 | # 18.04 zstd is too old 8 | [debs.not(all(distro=ubuntu,distro_vers="18.04"))] 9 | libzstd-dev 10 | zstd 11 | 12 | [rpms] 13 | libzstd-devel 14 | libzstd 15 | 16 | [pps] 17 | zstd 18 | 19 | [download] 20 | url = https://github.com/facebook/zstd/releases/download/v1.5.5/zstd-1.5.5.tar.gz 21 | sha256 = 9c4396cc829cfae319a6e2615202e82aad41372073482fce286fac78646d3ee4 22 | 23 | [build] 24 | builder = cmake 25 | subdir = zstd-1.5.5/build/cmake 26 | 27 | # The zstd cmake build explicitly sets the install name 28 | # for the shared library in such a way that cmake discards 29 | # the path to the library from the install_name, rendering 30 | # the library non-resolvable during the build. The short 31 | # term solution for this is just to link static on macos. 32 | # 33 | # And while we're at it, let's just always link statically. 34 | [cmake.defines] 35 | ZSTD_BUILD_SHARED = OFF 36 | -------------------------------------------------------------------------------- /build/fbcode_builder/patches/boost_comparator_operator_fix.patch: -------------------------------------------------------------------------------- 1 | diff --git a/boost/serialization/strong_typedef.hpp b/boost/serialization/strong_typedef.hpp 2 | --- a/boost/serialization/strong_typedef.hpp 3 | +++ b/boost/serialization/strong_typedef.hpp 4 | @@ -44,6 +44,7 @@ 5 | operator const T&() const {return t;} \ 6 | operator T&() {return t;} \ 7 | bool operator==(const D& rhs) const {return t == rhs.t;} \ 8 | + bool operator==(const T& lhs) const {return t == lhs;} \ 9 | bool operator<(const D& rhs) const {return t < rhs.t;} \ 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /build/fbcode_builder/patches/iproute2_oss.patch: -------------------------------------------------------------------------------- 1 | diff --git a/bridge/fdb.c b/bridge/fdb.c 2 | --- a/bridge/fdb.c 3 | +++ b/bridge/fdb.c 4 | @@ -31,7 +31,7 @@ 5 | 6 | static unsigned int filter_index, filter_vlan, filter_state; 7 | 8 | -json_writer_t *jw_global; 9 | +static json_writer_t *jw_global; 10 | 11 | static void usage(void) 12 | { 13 | diff --git a/ip/ipmroute.c b/ip/ipmroute.c 14 | --- a/ip/ipmroute.c 15 | +++ b/ip/ipmroute.c 16 | @@ -44,7 +44,7 @@ 17 | exit(-1); 18 | } 19 | 20 | -struct rtfilter { 21 | +static struct rtfilter { 22 | int tb; 23 | int af; 24 | int iif; 25 | diff --git a/ip/xfrm_monitor.c b/ip/xfrm_monitor.c 26 | --- a/ip/xfrm_monitor.c 27 | +++ b/ip/xfrm_monitor.c 28 | @@ -34,7 +34,7 @@ 29 | #include "ip_common.h" 30 | 31 | static void usage(void) __attribute__((noreturn)); 32 | -int listen_all_nsid; 33 | +static int listen_all_nsid; 34 | 35 | static void usage(void) 36 | { 37 | -------------------------------------------------------------------------------- /build/fbcode_builder/patches/libiberty_install_pic_lib.patch: -------------------------------------------------------------------------------- 1 | diff --git a/Makefile.in b/Makefile.in 2 | index b77a41c..cbe71fe 100644 3 | --- a/Makefile.in 4 | +++ b/Makefile.in 5 | @@ -389,7 +389,7 @@ MULTIOSDIR = `$(CC) $(CFLAGS) -print-multi-os-directory` 6 | install_to_libdir: all 7 | if test -n "${target_header_dir}"; then \ 8 | ${mkinstalldirs} $(DESTDIR)$(libdir)/$(MULTIOSDIR); \ 9 | - $(INSTALL_DATA) $(TARGETLIB) $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n; \ 10 | + $(INSTALL_DATA) pic/$(TARGETLIB) $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n; \ 11 | ( cd $(DESTDIR)$(libdir)/$(MULTIOSDIR) ; chmod 644 $(TARGETLIB)n ;$(RANLIB) $(TARGETLIB)n ); \ 12 | mv -f $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB); \ 13 | case "${target_header_dir}" in \ 14 | -------------------------------------------------------------------------------- /build/fbcode_builder/patches/zlib_dont_build_more_than_needed.patch: -------------------------------------------------------------------------------- 1 | diff -Naur ../zlib-1.3.1/CMakeLists.txt ./CMakeLists.txt 2 | --- ../zlib-1.3.1/CMakeLists.txt 2024-01-22 10:32:37.000000000 -0800 3 | +++ ./CMakeLists.txt 2024-01-23 13:14:09.870289968 -0800 4 | @@ -149,10 +149,8 @@ 5 | set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) 6 | endif(MINGW) 7 | 8 | -add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 9 | +add_library(zlib ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 10 | target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 11 | -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 12 | -target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) 13 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 14 | set_target_properties(zlib PROPERTIES SOVERSION 1) 15 | 16 | @@ -169,7 +167,7 @@ 17 | 18 | if(UNIX) 19 | # On unix-like platforms the library is almost always called libz 20 | - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) 21 | + set_target_properties(zlib PROPERTIES OUTPUT_NAME z) 22 | if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX)) 23 | set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") 24 | endif() 25 | @@ -179,7 +177,7 @@ 26 | endif() 27 | 28 | if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) 29 | - install(TARGETS zlib zlibstatic 30 | + install(TARGETS zlib 31 | RUNTIME DESTINATION "${INSTALL_BIN_DIR}" 32 | ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" 33 | LIBRARY DESTINATION "${INSTALL_LIB_DIR}" ) 34 | -------------------------------------------------------------------------------- /cmake/katran-config.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | # 3 | # This program is free software; you can redistribute it and/or modify 4 | # it under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation; version 2 of the License. 6 | # 7 | # This program is distributed in the hope that it will be useful, 8 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | # GNU General Public License for more details. 11 | # 12 | # You should have received a copy of the GNU General Public License along 13 | # with this program; if not, write to the Free Software Foundation, Inc., 14 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | # 17 | # This module sets the following variables: 18 | # katran_FOUND 19 | # katran_INCLUDE_DIRS 20 | # 21 | # This module exports targets such as: 22 | # katran::bpfadapter 23 | # 24 | # which can be used with target_link_libraries() 25 | 26 | @PACKAGE_INIT@ 27 | 28 | include(CMakeFindDependencyMacro) 29 | find_dependency(folly) 30 | find_dependency(Fizz) 31 | find_dependency(Threads) 32 | find_dependency(Glog) 33 | find_dependency(Gflags) 34 | find_dependency(Bpf) 35 | 36 | if(NOT TARGET katran::bpfadapter) 37 | include("${CMAKE_CURRENT_LIST_DIR}/katran-targets.cmake") 38 | get_target_property(katran_INCLUDE_DIRS katran::bpfadapter INTERFACE_INCLUDE_DIRECTORIES) 39 | endif() 40 | 41 | if(NOT katran_FIND_QUIETLY) 42 | message(STATUS "Found katran: ${PACKAGE_PREFIX_DIR}") 43 | endif() 44 | -------------------------------------------------------------------------------- /collect_debug_lb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2019-present, Facebook, Inc. 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; version 2 of the License. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License along 14 | # with this program; if not, write to the Free Software Foundation, Inc., 15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | echo "### links ###" 17 | ip link show 18 | echo "### default route ###" 19 | ip route show | grep default 20 | echo "### neighbors ###" 21 | ip neighbor show 22 | echo "### ps ###" 23 | ps ax | grep katran 24 | echo "### sysctl ###" 25 | sysctl -a 2>&1 | grep bpf | grep -v denied 26 | -------------------------------------------------------------------------------- /collect_debug_real.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2019-present, Facebook, Inc. 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; version 2 of the License. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License along 14 | # with this program; if not, write to the Free Software Foundation, Inc., 15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | echo "### links ###" 17 | ip link show 18 | echo "### default route ###" 19 | ip route show | grep default 20 | echo "### neighbors ###" 21 | ip neighbor show 22 | echo "### sysctl ###" 23 | sysctl -a 2>&1 | grep rp_filter | grep -v denied 24 | echo "### iptables ###" 25 | sudo iptables -vnL 26 | -------------------------------------------------------------------------------- /example_grpc/GrpcSignalHandler.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "GrpcSignalHandler.h" 18 | 19 | #include 20 | 21 | namespace lb { 22 | namespace katran { 23 | 24 | GrpcSignalHandler::GrpcSignalHandler( 25 | std::shared_ptr evb, 26 | grpc::Server* server, 27 | int32_t delay) 28 | : folly::AsyncSignalHandler(evb.get()), delay_(delay) { 29 | server_ = server; 30 | evb_ = evb; 31 | }; 32 | 33 | void GrpcSignalHandler::signalReceived(int signum) noexcept { 34 | if (shutdownScheduled_) { 35 | LOG(INFO) << "Ignoring signal: " << signum << " as we already scheduled" 36 | << " sighandler to run."; 37 | return; 38 | }; 39 | LOG(INFO) << "Signal: " << signum << ", stopping service in " << delay_ 40 | << " milliseconds."; 41 | evb_->runInEventBaseThread([this]() { 42 | evb_->runAfterDelay( 43 | [this]() { 44 | LOG(INFO) << "Stopping Katran!"; 45 | server_->Shutdown(); 46 | }, 47 | delay_); 48 | }); 49 | shutdownScheduled_ = true; 50 | }; 51 | } // namespace katran 52 | } // namespace lb 53 | -------------------------------------------------------------------------------- /example_grpc/GrpcSignalHandler.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace folly { 25 | class EventBase; 26 | } 27 | 28 | namespace lb { 29 | namespace katran { 30 | 31 | /** 32 | * class which implements sighandler for katran's grpc server 33 | */ 34 | class GrpcSignalHandler : public folly::AsyncSignalHandler { 35 | public: 36 | /** 37 | * @param EventBase* evb event base thread 38 | * @param grpc::Server* server katran's grpc server 39 | * @param int32_t delay in ms between recving signal and stopping katran 40 | */ 41 | GrpcSignalHandler( 42 | std::shared_ptr evb, 43 | grpc::Server* server, 44 | int32_t delay); 45 | ~GrpcSignalHandler() override {} 46 | 47 | void signalReceived(int signum) noexcept override; 48 | 49 | private: 50 | grpc::Server* server_; 51 | std::shared_ptr evb_; 52 | int32_t delay_; 53 | bool shutdownScheduled_{false}; 54 | }; 55 | 56 | } // namespace katran 57 | } // namespace lb 58 | -------------------------------------------------------------------------------- /imgs/katran_consistency.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookincubator/katran/e4ca6397f39329431a8c080c7122d7ac5f3a69ad/imgs/katran_consistency.png -------------------------------------------------------------------------------- /imgs/katran_pktflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookincubator/katran/e4ca6397f39329431a8c080c7122d7ac5f3a69ad/imgs/katran_pktflow.png -------------------------------------------------------------------------------- /install_xdproot.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (C) 2018-present, Facebook, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; version 2 of the License. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | # Example script to start and run xdproot program 19 | set -xeo pipefail 20 | 21 | if [ -z "${KATRAN_INTERFACE}" ] 22 | then 23 | KATRAN_INTERFACE=enp0s3 24 | fi 25 | 26 | out=$(mount | grep bpffs) || true 27 | if [ -z "$out" ]; then 28 | sudo mount -t bpf bpffs /sys/fs/bpf/ 29 | fi 30 | 31 | # By default this script assumes to be invoked from the root dir. 32 | if [ -z "${KATRAN_BUILD_DIR}" ] 33 | then 34 | KATRAN_BUILD_DIR=$(pwd)/_build/build 35 | fi 36 | 37 | if [ -z "${DEPS_DIR}" ] 38 | then 39 | DEPS_DIR=$(pwd)/_build/deps 40 | fi 41 | 42 | if [ ! -f "/sys/fs/bpf/jmp_${KATRAN_INTERFACE}" ]; then 43 | echo "Assuming ${KATRAN_INTERFACE} exists. please change script to actual interface if it does not" 44 | sudo sh -c "${KATRAN_BUILD_DIR}/katran/lib/xdproot -bpfprog ${DEPS_DIR}/bpfprog/bpf/xdp_root.o -bpfpath=/sys/fs/bpf/jmp_${KATRAN_INTERFACE} -intf=${KATRAN_INTERFACE}" 45 | fi 46 | -------------------------------------------------------------------------------- /katran/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | set(CMAKE_CXX_STANDARD 20) 3 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 4 | add_subdirectory(lib) 5 | add_subdirectory(decap) 6 | if(DEFINED ENV{CMAKE_BUILD_KATRAN_TPR}) 7 | add_subdirectory(tpr) 8 | endif() 9 | -------------------------------------------------------------------------------- /katran/decap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.9) 2 | set(KATRAN_INCLUDE_DIR "$") 3 | 4 | find_package(Glog REQUIRED) 5 | find_package(folly CONFIG REQUIRED) 6 | find_package(Threads) 7 | 8 | add_library(decap STATIC 9 | XdpDecap.cpp 10 | XdpDecap.h 11 | XdpDecapStructs.h 12 | ) 13 | 14 | target_link_libraries(decap 15 | bpfadapter 16 | "Folly::folly" 17 | glog::glog 18 | ) 19 | 20 | target_include_directories( 21 | decap PUBLIC 22 | ${GFLAGS_INCLUDE_DIR} 23 | ${KATRAN_INCLUDE_DIR} 24 | ) 25 | 26 | install(TARGETS decap 27 | EXPORT katran-exports 28 | DESTINATION decap 29 | ) 30 | 31 | if (BUILD_TESTS) 32 | add_subdirectory(testing) 33 | endif() 34 | -------------------------------------------------------------------------------- /katran/decap/Makefile-bpf: -------------------------------------------------------------------------------- 1 | obj := . 2 | src := . 3 | 4 | 5 | DEBUGBPF = -DDEBUG 6 | DEBUGFLAGS = -O0 -g -Wall 7 | PFLAGS = $(DEBUGFLAGS) 8 | 9 | INCLUDEFLAGS = -I$(obj)/usr/include \ 10 | -I$(obj)/include \ 11 | #-I$(obj)/bpfprog/include \ 12 | 13 | 14 | 15 | always = bpf/decap_kern.o 16 | 17 | HOSTCFLAGS += $(INCLUDEFLAGS) $(PFLAGS) 18 | 19 | # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: 20 | # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang 21 | LLC ?= llc 22 | CLANG ?= clang 23 | 24 | # Trick to allow make to be run from this directory 25 | all: $(always) 26 | $(MAKE) -C .. $$PWD/ 27 | 28 | clean: 29 | $(MAKE) -C .. M=$$PWD clean 30 | @rm -f *~ 31 | 32 | $(obj)/bpf/%.o: $(src)/bpf/%.c 33 | $(CLANG) $(INCLUDEFLAGS) $(EXTRA_CFLAGS) \ 34 | $(DEBUGBPF) -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \ 35 | -Wno-compare-distinct-pointer-types \ 36 | -O2 -emit-llvm -c -g $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ 37 | 38 | -------------------------------------------------------------------------------- /katran/decap/bpf/decap_maps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __DECAP_MAPS_H 18 | #define __DECAP_MAPS_H 19 | 20 | /* 21 | * This file contains definition of all maps which has been used by balancer 22 | */ 23 | 24 | #include "katran/lib/linux_includes/bpf.h" 25 | #include "katran/lib/linux_includes/bpf_helpers.h" 26 | 27 | #include "katran/lib/bpf/balancer_consts.h" 28 | 29 | #ifndef DECAP_STATS_MAP_SIZE 30 | #define DECAP_STATS_MAP_SIZE 1 31 | #endif 32 | 33 | struct decap_stats { 34 | __u64 decap_v4; 35 | __u64 decap_v6; 36 | __u64 total; 37 | __u64 tpr_misrouted; 38 | __u64 tpr_total; 39 | }; 40 | 41 | // map w/ per vip statistics 42 | struct { 43 | __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); 44 | __type(key, __u32); 45 | __type(value, struct decap_stats); 46 | __uint(max_entries, DECAP_STATS_MAP_SIZE); 47 | __uint(map_flags, NO_FLAGS); 48 | } decap_counters SEC(".maps"); 49 | 50 | // map, which contains server_id info 51 | struct { 52 | __uint(type, BPF_MAP_TYPE_ARRAY); 53 | __type(key, __u32); 54 | __type(value, __u32); 55 | __uint(max_entries, 1); 56 | __uint(map_flags, NO_FLAGS); 57 | } tpr_server_id SEC(".maps"); 58 | 59 | #endif // of _DECAP_MAPS 60 | -------------------------------------------------------------------------------- /katran/decap/tc_bpf/tc_decap_info_maps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __DECAP_INFO_MAPS_H 18 | #define __DECAP_INFO_MAPS_H 19 | 20 | /* 21 | * This file contains definition of all maps which has been used by balancer 22 | */ 23 | #include "katran/lib/bpf/balancer_consts.h" 24 | #include "katran/lib/bpf/balancer_structs.h" 25 | #include "katran/lib/linux_includes/bpf.h" 26 | #include "katran/lib/linux_includes/bpf_helpers.h" 27 | 28 | #ifndef PCKT_INFO_MAP_SIZE 29 | #define PCKT_INFO_MAP_SIZE 100000 30 | #endif 31 | 32 | struct { 33 | __uint(type, BPF_MAP_TYPE_LRU_HASH); 34 | __type(key, struct flow_key); 35 | __type(value, struct flow_key); 36 | __uint(max_entries, PCKT_INFO_MAP_SIZE); 37 | __uint(map_flags, NO_FLAGS); 38 | } pkt_encap_info SEC(".maps"); 39 | 40 | #endif // of _DECAP_INFO_MAPS 41 | -------------------------------------------------------------------------------- /katran/decap/tc_bpf/tc_decap_info_user_structs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __DECAP_INFO_USER_STRUCTS_H 18 | #define __DECAP_INFO_USER_STRUCTS_H 19 | 20 | struct flow_key { 21 | union { 22 | uint32_t src; 23 | uint32_t srcv6[4]; 24 | }; 25 | union { 26 | uint32_t dst; 27 | uint32_t dstv6[4]; 28 | }; 29 | union { 30 | uint32_t ports; 31 | uint16_t port16[2]; 32 | }; 33 | uint8_t proto; 34 | }; 35 | 36 | #endif // of __DECAP_INFO_USER_STRUCTS 37 | -------------------------------------------------------------------------------- /katran/decap/tc_bpf/tc_decap_maps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __DECAP_MAPS_H 18 | #define __DECAP_MAPS_H 19 | 20 | /* 21 | * This file contains definition of all maps which has been used by balancer 22 | */ 23 | 24 | #include "katran/lib/linux_includes/bpf.h" 25 | #include "katran/lib/linux_includes/bpf_helpers.h" 26 | 27 | #include "katran/lib/bpf/balancer_consts.h" 28 | 29 | #ifndef DECAP_STATS_MAP_SIZE 30 | #define DECAP_STATS_MAP_SIZE 1 31 | #endif 32 | 33 | struct decap_stats { 34 | __u64 decap_v4; 35 | __u64 decap_v6; 36 | __u64 total; 37 | }; 38 | 39 | // map w/ per vip statistics 40 | struct { 41 | __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); 42 | __type(key, __u32); 43 | __type(value, struct decap_stats); 44 | __uint(max_entries, DECAP_STATS_MAP_SIZE); 45 | __uint(map_flags, NO_FLAGS); 46 | } decap_counters SEC(".maps"); 47 | 48 | #endif // of _DECAP_MAPS 49 | -------------------------------------------------------------------------------- /katran/decap/testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(xdpdecap_tester 2 | xdpdecap_tester.cpp 3 | XdpDecapGueTestFixtures.h 4 | XdpDecapTestFixtures.h 5 | ) 6 | 7 | target_link_libraries(xdpdecap_tester 8 | "${GFLAGS}" 9 | "${PTHREAD}" 10 | bpftester 11 | decap 12 | ) 13 | -------------------------------------------------------------------------------- /katran/lib/ByteRangeWriter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "katran/lib/ByteRangeWriter.h" 18 | 19 | #include 20 | 21 | namespace katran { 22 | 23 | ByteRangeWriter::ByteRangeWriter(folly::MutableByteRange& buffer) 24 | : buffer_(buffer) {} 25 | 26 | void ByteRangeWriter::writeData(const void* ptr, std::size_t size) { 27 | ::memcpy(static_cast(&(buffer_.front())), ptr, size); 28 | buffer_.advance(size); 29 | writtenBytes_ += size; 30 | } 31 | 32 | bool ByteRangeWriter::available(std::size_t amount) { 33 | return buffer_.size() >= amount; 34 | } 35 | 36 | } // namespace katran 37 | -------------------------------------------------------------------------------- /katran/lib/ByteRangeWriter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include "katran/lib/DataWriter.h" 22 | 23 | namespace katran { 24 | 25 | /** 26 | * ByteRangeWriter is used to write pcap-data into MutableByteRange. 27 | */ 28 | 29 | class ByteRangeWriter : public DataWriter { 30 | public: 31 | /** 32 | * @param MutableByteRange buffer for packets to written into 33 | */ 34 | explicit ByteRangeWriter(folly::MutableByteRange& buffer); 35 | 36 | void writeData(const void* ptr, std::size_t size) override; 37 | 38 | bool available(std::size_t amount) override; 39 | 40 | bool restart() override { 41 | return true; 42 | } 43 | 44 | bool stop() override { 45 | return true; 46 | } 47 | 48 | private: 49 | folly::MutableByteRange& buffer_; 50 | }; 51 | 52 | } // namespace katran 53 | -------------------------------------------------------------------------------- /katran/lib/CHHelpers.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "katran/lib/CHHelpers.h" 18 | #include "katran/lib/MaglevHash.h" 19 | #include "katran/lib/MaglevHashV2.h" 20 | namespace katran { 21 | std::unique_ptr CHFactory::make(HashFunction func) { 22 | switch (func) { 23 | case HashFunction::Maglev: 24 | return std::make_unique(); 25 | case HashFunction::MaglevV2: 26 | return std::make_unique(); 27 | default: 28 | // fallback to default maglev's implementation 29 | return std::make_unique(); 30 | } 31 | } 32 | } // namespace katran 33 | -------------------------------------------------------------------------------- /katran/lib/FileWriter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "katran/lib/FileWriter.h" 18 | #include 19 | #include 20 | 21 | namespace katran { 22 | 23 | FileWriter::FileWriter(const std::string& filename) 24 | : pcapFile_(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC) { 25 | filename_ = filename; 26 | } 27 | 28 | void FileWriter::writeData(const void* ptr, std::size_t size) { 29 | auto successfullyWritten = folly::writeFull(pcapFile_.fd(), ptr, size); 30 | if (successfullyWritten < 0) { 31 | LOG(ERROR) << "Error while trying to write to pcap file: " << filename_; 32 | } else { 33 | writtenBytes_ += size; 34 | } 35 | } 36 | 37 | bool FileWriter::available(size_t /* unused */) { 38 | return true; 39 | } 40 | 41 | bool FileWriter::stop() { 42 | pcapFile_.closeNoThrow(); 43 | return true; 44 | } 45 | 46 | bool FileWriter::restart() { 47 | pcapFile_.closeNoThrow(); 48 | pcapFile_ = folly::File(filename_.c_str(), O_RDWR | O_CREAT | O_TRUNC); 49 | return true; 50 | } 51 | 52 | } // namespace katran 53 | -------------------------------------------------------------------------------- /katran/lib/FileWriter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include "katran/lib/DataWriter.h" 22 | 23 | namespace katran { 24 | /** 25 | * FileWriter is used to write pcap-data into file. 26 | */ 27 | class FileWriter : public DataWriter { 28 | public: 29 | /** 30 | * @param const string filename where we are going to write data 31 | */ 32 | explicit FileWriter(const std::string& filename); 33 | 34 | void writeData(const void* ptr, std::size_t size) override; 35 | 36 | bool available(std::size_t amount) override; 37 | 38 | bool restart() override; 39 | 40 | bool stop() override; 41 | 42 | private: 43 | folly::File pcapFile_; 44 | std::string filename_; 45 | }; 46 | 47 | } // namespace katran 48 | -------------------------------------------------------------------------------- /katran/lib/IOBufWriter.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "katran/lib/IOBufWriter.h" 18 | #include 19 | 20 | namespace katran { 21 | 22 | IOBufWriter::IOBufWriter(folly::IOBuf* iobuf) : iobuf_(iobuf) {} 23 | 24 | void IOBufWriter::writeData(const void* ptr, std::size_t size) { 25 | ::memcpy(static_cast(iobuf_->writableTail()), ptr, size); 26 | iobuf_->append(size); 27 | } 28 | 29 | bool IOBufWriter::available(std::size_t amount) { 30 | return iobuf_->tailroom() >= amount; 31 | } 32 | 33 | bool IOBufWriter::restart() { 34 | iobuf_->clear(); 35 | return true; 36 | } 37 | 38 | } // namespace katran 39 | -------------------------------------------------------------------------------- /katran/lib/IOBufWriter.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "katran/lib/DataWriter.h" 23 | 24 | namespace katran { 25 | 26 | /** 27 | * IOBufWriter is used to write pcap-data into IOBuf. 28 | */ 29 | class IOBufWriter : public DataWriter { 30 | public: 31 | /** 32 | * @param unique_ptr iobuf for packets to written into 33 | */ 34 | explicit IOBufWriter(folly::IOBuf* iobuf); 35 | 36 | void writeData(const void* ptr, std::size_t size) override; 37 | 38 | bool available(std::size_t amount) override; 39 | 40 | bool restart() override; 41 | 42 | bool stop() override { 43 | return true; 44 | } 45 | 46 | private: 47 | folly::IOBuf* iobuf_; 48 | }; 49 | 50 | } // namespace katran 51 | -------------------------------------------------------------------------------- /katran/lib/IpHelpers.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace katran { 23 | 24 | /** 25 | * struct, which represent given ip address in 26 | * big endian uint32_t ([4]) format for v4(v6) 27 | */ 28 | struct beaddr { 29 | union { 30 | uint32_t daddr; 31 | uint32_t v6daddr[4]; 32 | }; 33 | uint8_t flags; 34 | }; 35 | 36 | class IpHelpers { 37 | public: 38 | /** 39 | * @param const string addr address to translate 40 | * @return struct beaddr representation of given address 41 | * 42 | * helper function to translate addr to it's be representation if format 43 | * of beaddr structure. this function could throw, if given string is not 44 | * an ip address. 45 | */ 46 | static struct beaddr parseAddrToBe( 47 | const std::string& addr, 48 | bool bigendian = true); 49 | static struct beaddr parseAddrToInt(const std::string& addr); 50 | 51 | static struct beaddr parseAddrToBe( 52 | const folly::IPAddress& addr, 53 | bool bigendian = true); 54 | static struct beaddr parseAddrToInt(const folly::IPAddress& addr); 55 | }; 56 | 57 | } // namespace katran 58 | -------------------------------------------------------------------------------- /katran/lib/KatranEventReader.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | #include "katran/lib/KatranEventReader.h" 17 | 18 | #include "katran/lib/BalancerStructs.h" 19 | 20 | namespace katran { 21 | 22 | void KatranEventReader::handlePerfBufferEvent( 23 | int /* cpu */, 24 | const char* data, 25 | size_t size) noexcept { 26 | if (size < sizeof(struct event_metadata)) { 27 | LOG(ERROR) << "size " << size 28 | << " is less than sizeof(struct event_metadata) " 29 | << sizeof(struct event_metadata) << ", skipping"; 30 | return; 31 | } 32 | auto mdata = (struct event_metadata*)data; 33 | PcapMsg pcap_msg( 34 | data + sizeof(struct event_metadata), mdata->pkt_size, mdata->data_len); 35 | PcapMsgMeta pcap_msg_meta(std::move(pcap_msg), mdata->event); 36 | auto res = queue_->write(std::move(pcap_msg_meta)); 37 | if (!res) { 38 | LOG(ERROR) << "writer queue is full"; 39 | } 40 | LOG(INFO) << __func__ 41 | << "write perf event to queue, queue stats: " << queue_->size() 42 | << "/" << queue_->capacity(); 43 | } 44 | 45 | } // namespace katran 46 | -------------------------------------------------------------------------------- /katran/lib/KatranEventReader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include "katran/lib/PcapMsgMeta.h" 21 | #include "katran/lib/PerfBufferEventReader.h" 22 | 23 | namespace folly { 24 | class EventBase; 25 | } 26 | 27 | namespace katran { 28 | class KatranEventReader : public PerfBufferEventReader { 29 | public: 30 | explicit KatranEventReader( 31 | std::shared_ptr> queue) 32 | : queue_(queue) {} 33 | 34 | /** 35 | * @param int cpu 36 | * @param const char* data received from the XDP prog. 37 | * @param size_t size of the data chunk 38 | */ 39 | void handlePerfBufferEvent(int cpu, const char* data, size_t size) noexcept 40 | override; 41 | 42 | private: 43 | /** 44 | * queue toward PcapWriter 45 | */ 46 | std::shared_ptr> queue_; 47 | }; 48 | } // namespace katran 49 | -------------------------------------------------------------------------------- /katran/lib/MacHelpers.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "katran/lib/MacHelpers.h" 18 | 19 | #include 20 | 21 | #include 22 | 23 | namespace katran { 24 | 25 | std::vector convertMacToUint(const std::string& macAddress) { 26 | std::vector mac(6); 27 | 28 | folly::MacAddress default_mac; 29 | try { 30 | default_mac.parse(macAddress); 31 | } catch (const std::exception& e) { 32 | LOG(ERROR) << "Exception: " << e.what() << std::endl; 33 | return mac; 34 | } 35 | 36 | auto mac_bytes = default_mac.bytes(); 37 | for (int i = 0; i < 6; i++) { 38 | mac[i] = mac_bytes[i]; 39 | } 40 | return mac; 41 | } 42 | 43 | std::string convertMacToString(std::vector mac) { 44 | if (mac.size() != 6) { 45 | return "unknown"; 46 | } 47 | uint16_t mac_part; 48 | std::string mac_part_string; 49 | std::string mac_string; 50 | for (auto m : mac) { 51 | mac_part = m; 52 | mac_part_string = fmt::format("{0:02x}:", mac_part); 53 | mac_string += mac_part_string; 54 | } 55 | return mac_string; 56 | } 57 | 58 | } // namespace katran 59 | -------------------------------------------------------------------------------- /katran/lib/MacHelpers.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | namespace katran { 24 | std::vector convertMacToUint(const std::string& macAddress); 25 | std::string convertMacToString(std::vector mac); 26 | } // namespace katran 27 | -------------------------------------------------------------------------------- /katran/lib/MaglevBase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation; version 2 of the License. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License along 12 | * with this program; if not, write to the Free Software Foundation, Inc., 13 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 14 | */ 15 | 16 | #include "katran/lib/MaglevBase.h" 17 | #include "katran/lib/MurmurHash3.h" 18 | 19 | namespace katran { 20 | 21 | namespace { 22 | constexpr uint32_t kHashSeed0 = 0; 23 | constexpr uint32_t kHashSeed1 = 2307; 24 | constexpr uint32_t kHashSeed2 = 42; 25 | constexpr uint32_t kHashSeed3 = 2718281828; 26 | } // namespace 27 | 28 | void MaglevBase::genMaglevPermutation( 29 | std::vector& permutation, 30 | const Endpoint& endpoint, 31 | const uint32_t pos, 32 | const uint32_t ring_size) { 33 | auto offset_hash = MurmurHash3_x64_64(endpoint.hash, kHashSeed2, kHashSeed0); 34 | 35 | auto offset = offset_hash % ring_size; 36 | 37 | auto skip_hash = MurmurHash3_x64_64(endpoint.hash, kHashSeed3, kHashSeed1); 38 | 39 | auto skip = (skip_hash % (ring_size - 1)) + 1; 40 | 41 | permutation[2 * pos] = offset; 42 | permutation[2 * pos + 1] = skip; 43 | } 44 | 45 | } // namespace katran 46 | -------------------------------------------------------------------------------- /katran/lib/MaglevBase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation; version 2 of the License. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License along 12 | * with this program; if not, write to the Free Software Foundation, Inc., 13 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include "katran/lib/CHHelpers.h" 22 | 23 | namespace katran { 24 | 25 | /** 26 | * MaglevBase class implements Maglev's permutation and should be used as a base 27 | * class for all versions of Maglev's hashing (more info: 28 | * http://research.google.com/pubs/pub44824.html ; section 3.4) 29 | */ 30 | class MaglevBase : public ConsistentHash { 31 | public: 32 | MaglevBase() {} 33 | /** 34 | * @param vector& container for generated permutations 35 | * @param Endpoint& endpoint endpoint for which permutation is going to be 36 | * generated 37 | * @param uint32_t pos position of specified endpoint 38 | * @param uint32_t ring_size size of the hash ring 39 | * 40 | * helper function which will generate Maglev's permutation array for 41 | * specified endpoint on specified possition 42 | */ 43 | static void genMaglevPermutation( 44 | std::vector& permutation, 45 | const Endpoint& endpoint, 46 | const uint32_t pos, 47 | const uint32_t ring_size); 48 | }; 49 | 50 | } // namespace katran 51 | -------------------------------------------------------------------------------- /katran/lib/MaglevHash.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2020-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | #include "katran/lib/MaglevBase.h" 23 | 24 | namespace katran { 25 | 26 | /** 27 | * MaglevHash class implements Maglev's hash algo 28 | * (more info: http://research.google.com/pubs/pub44824.html ; section 3.4) 29 | */ 30 | class MaglevHash : public MaglevBase { 31 | public: 32 | MaglevHash() {} 33 | /** 34 | * @param std::vector& endpoints, which will be used for CH 35 | * @param uint32_t ring_size size of the CH ring 36 | * @return std::vector vector, which describe CH ring. 37 | * it's size would be ring_size and 38 | * which will have Endpoints.num as a values. 39 | * ring_size must be prime number. 40 | * this function could throw because allocation for vector could fail. 41 | */ 42 | std::vector generateHashRing( 43 | std::vector, 44 | const uint32_t ring_size = kDefaultChRingSize) override; 45 | }; 46 | 47 | } // namespace katran 48 | -------------------------------------------------------------------------------- /katran/lib/MaglevHashV2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This program is free software; you can redistribute it and/or modify 3 | * it under the terms of the GNU General Public License as published by 4 | * the Free Software Foundation; version 2 of the License. 5 | * 6 | * This program is distributed in the hope that it will be useful, 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | * GNU General Public License for more details. 10 | * 11 | * You should have received a copy of the GNU General Public License along 12 | * with this program; if not, write to the Free Software Foundation, Inc., 13 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 14 | */ 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | 21 | #include "katran/lib/MaglevBase.h" 22 | 23 | namespace katran { 24 | 25 | /** 26 | * MaglevHashV2 class implements another version of Maglev's hash which does not 27 | * require the sum of all weights to be equal to the size of the hash ring. 28 | */ 29 | class MaglevHashV2 : public MaglevBase { 30 | public: 31 | MaglevHashV2() {} 32 | /** 33 | * @param std::vector& endpoints, which will be used for CH 34 | * @param uint32_t ring_size size of the CH ring 35 | * @return std::vector vector, which describe CH ring. 36 | * it's size would be ring_size and 37 | * which will have Endpoints.num as a values. 38 | * ring_size must be prime number. 39 | * this function could throw because allocation for vector could fail. 40 | */ 41 | std::vector generateHashRing( 42 | std::vector, 43 | const uint32_t ring_size = kDefaultChRingSize) override; 44 | }; 45 | 46 | } // namespace katran 47 | -------------------------------------------------------------------------------- /katran/lib/Makefile-bpf: -------------------------------------------------------------------------------- 1 | obj := . 2 | src := . 3 | 4 | 5 | DEBUGBPF = -DDEBUG 6 | DEBUGFLAGS = -O0 -g -Wall 7 | PFLAGS = $(DEBUGFLAGS) 8 | 9 | INCLUDEFLAGS = -I$(obj)/usr/include \ 10 | -I$(obj)/include \ 11 | -I$(obj) 12 | 13 | 14 | 15 | always = bpf/balancer.bpf.o 16 | always += bpf/healthchecking_ipip.o 17 | always += bpf/healthchecking.bpf.o 18 | always += bpf/xdp_pktcntr.o 19 | always += bpf/xdp_root.o 20 | 21 | HOSTCFLAGS += $(INCLUDEFLAGS) $(PFLAGS) 22 | HOSTCFLAGS_bpf_load.o += $(INCLUDEFLAGS) $(PFLAGS) -Wno-unused-variable 23 | 24 | 25 | # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: 26 | # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang 27 | LLC ?= llc 28 | CLANG ?= clang 29 | 30 | # Trick to allow make to be run from this directory 31 | all: $(always) 32 | $(MAKE) -C .. $$PWD/ 33 | 34 | clean: 35 | $(MAKE) -C .. M=$$PWD clean 36 | @rm -f *~ 37 | 38 | $(obj)/bpf/%.o: $(src)/katran/lib/bpf/%.c 39 | $(CLANG) $(INCLUDEFLAGS) $(EXTRA_CFLAGS) \ 40 | $(DEBUGBPF) -D__KERNEL__ -Wno-unused-value -Wno-pointer-sign \ 41 | -Wno-compare-distinct-pointer-types \ 42 | -O2 -emit-llvm -c -g $< -o -| $(LLC) -march=bpf -filetype=obj -o $@ 43 | -------------------------------------------------------------------------------- /katran/lib/MonitoringStructs.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | #include "katran/lib/MonitoringStructs.h" 4 | 5 | namespace katran { 6 | namespace monitoring { 7 | 8 | std::set kAllEventIds = { 9 | EventId::TCP_NONSYN_LRUMISS, 10 | EventId::PACKET_TOOBIG, 11 | EventId::QUIC_PACKET_DROP_NO_REAL, 12 | }; 13 | 14 | std::string toString(const EventId& eventId) { 15 | switch (eventId) { 16 | case (EventId::TCP_NONSYN_LRUMISS): 17 | return "TCP_NONSYN_LRUMISS"; 18 | case (EventId::PACKET_TOOBIG): 19 | return "PACKET_TOOBIG"; 20 | case (EventId::QUIC_PACKET_DROP_NO_REAL): 21 | return "QUIC_PACKET_DROP_NO_REAL"; 22 | default: 23 | return "UNKOWN"; 24 | } 25 | } 26 | 27 | std::ostream& operator<<(std::ostream& os, const EventId& eventId) { 28 | os << toString(eventId); 29 | return os; 30 | } 31 | 32 | } // namespace monitoring 33 | } // namespace katran 34 | -------------------------------------------------------------------------------- /katran/lib/MonitoringStructs.h: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | #pragma once 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | namespace katran { 11 | namespace monitoring { 12 | 13 | constexpr auto kDefaultClientLimit = 10; 14 | 15 | // This is the internal enum for event id. Protocol specific types will need to 16 | // be casted to/from this type. One can take advantage of the UNKNOWN event id 17 | // for handling casting exception. 18 | enum class EventId : uint8_t { 19 | TCP_NONSYN_LRUMISS = 0, 20 | PACKET_TOOBIG = 1, 21 | QUIC_PACKET_DROP_NO_REAL = 2, 22 | UNKNOWN = 255, 23 | }; 24 | 25 | // A set of all valid events 26 | extern std::set kAllEventIds; 27 | 28 | // Enum of response status 29 | enum ResponseStatus { 30 | OK = 0, 31 | NOT_SUPPORTED = 1, 32 | TOOMANY_CLIENTS = 2, 33 | INTERNAL_ERROR = 3, 34 | }; 35 | 36 | // Helper function converting event to string 37 | std::string toString(const EventId& eventId); 38 | 39 | // Helper operator definition that makes logging easier 40 | std::ostream& operator<<(std::ostream& os, const EventId& eventId); 41 | 42 | struct Event { 43 | EventId id; 44 | uint32_t pktsize; 45 | std::string data; 46 | }; 47 | 48 | using ClientId = uint32_t; 49 | using EventIds = std::set; 50 | 51 | /** 52 | * A helper class to store both subscribed events and publisher 53 | */ 54 | class ClientSubscriptionIf { 55 | public: 56 | virtual ~ClientSubscriptionIf() = default; 57 | /** 58 | * Stream event to client. 59 | */ 60 | virtual void sendEvent(const Event& event) = 0; 61 | 62 | /** 63 | * Return true if this subscription contains the event 64 | */ 65 | virtual bool hasEvent(const EventId& event_id) = 0; 66 | }; 67 | 68 | using ClientSubscriptionMap = 69 | std::unordered_map>; 70 | 71 | } // namespace monitoring 72 | } // namespace katran 73 | -------------------------------------------------------------------------------- /katran/lib/MurmurHash3.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "MurmurHash3.h" 18 | 19 | namespace katran { 20 | 21 | static inline uint64_t rotl64(uint64_t x, int8_t r) { 22 | return (x << r) | (x >> (64 - r)); 23 | } 24 | 25 | uint64_t 26 | MurmurHash3_x64_64(const uint64_t& A, const uint64_t& B, const uint32_t seed) { 27 | uint64_t h1 = seed; 28 | uint64_t h2 = seed; 29 | 30 | uint64_t c1 = 0x87c37b91114253d5llu; 31 | uint64_t c2 = 0x4cf5ad432745937fllu; 32 | 33 | //---------- 34 | // body 35 | 36 | uint64_t k1 = A; 37 | uint64_t k2 = B; 38 | 39 | k1 *= c1; 40 | k1 = rotl64(k1, 31); 41 | k1 *= c2; 42 | h1 ^= k1; 43 | 44 | h1 = rotl64(h1, 27); 45 | h1 += h2; 46 | h1 = h1 * 5 + 0x52dce729; 47 | 48 | k2 *= c2; 49 | k2 = rotl64(k2, 33); 50 | k2 *= c1; 51 | h2 ^= k2; 52 | 53 | h2 = rotl64(h2, 31); 54 | h2 += h1; 55 | h2 = h2 * 5 + 0x38495ab5; 56 | 57 | //---------- 58 | // finalization 59 | 60 | h1 ^= 16; 61 | h2 ^= 16; 62 | 63 | h1 += h2; 64 | h2 += h1; 65 | 66 | h1 ^= h1 >> 33; 67 | h1 *= 0xff51afd7ed558ccdllu; 68 | h1 ^= h1 >> 33; 69 | h1 *= 0xc4ceb9fe1a85ec53llu; 70 | h1 ^= h1 >> 33; 71 | 72 | h2 ^= h2 >> 33; 73 | h2 *= 0xff51afd7ed558ccdllu; 74 | h2 ^= h2 >> 33; 75 | h2 *= 0xc4ceb9fe1a85ec53llu; 76 | h2 ^= h2 >> 33; 77 | 78 | h1 += h2; 79 | 80 | return h1; 81 | } 82 | 83 | } // namespace katran 84 | -------------------------------------------------------------------------------- /katran/lib/MurmurHash3.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | namespace katran { 22 | uint64_t 23 | MurmurHash3_x64_64(const uint64_t& A, const uint64_t& B, const uint32_t seed); 24 | } 25 | -------------------------------------------------------------------------------- /katran/lib/PcapMsg.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "katran/lib/PcapMsg.h" 18 | 19 | namespace katran { 20 | 21 | PcapMsg::PcapMsg() { 22 | pckt_ = nullptr; 23 | } 24 | 25 | PcapMsg::PcapMsg(const char* pckt, uint32_t origLen, uint32_t capturedLen) 26 | : origLen_(origLen), capturedLen_(capturedLen) { 27 | if (pckt != nullptr) { 28 | pckt_ = folly::IOBuf::copyBuffer(pckt, capturedLen); 29 | } 30 | } 31 | 32 | PcapMsg::~PcapMsg() {} 33 | 34 | PcapMsg& PcapMsg::operator=(PcapMsg&& msg) noexcept { 35 | pckt_ = std::move(msg.pckt_); 36 | origLen_ = msg.origLen_; 37 | capturedLen_ = msg.capturedLen_; 38 | return *this; 39 | } 40 | 41 | PcapMsg::PcapMsg(PcapMsg&& msg) noexcept 42 | : pckt_(std::move(msg.pckt_)), 43 | origLen_(msg.origLen_), 44 | capturedLen_(msg.capturedLen_) {} 45 | } // namespace katran 46 | -------------------------------------------------------------------------------- /katran/lib/PcapMsgMeta.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | #include "katran/lib/PcapMsgMeta.h" 17 | #include 18 | 19 | namespace katran { 20 | 21 | using EventId = monitoring::EventId; 22 | 23 | PcapMsgMeta::PcapMsgMeta(PcapMsg&& msg, uint32_t event) 24 | : msg_(std::move(msg)), event_(event) {} 25 | 26 | PcapMsgMeta::PcapMsgMeta(PcapMsgMeta&& msg) noexcept 27 | : msg_(std::move(msg.msg_)), 28 | event_(msg.event_), 29 | packetLimit_(msg.packetLimit_), 30 | restart_(msg.restart_), 31 | control_(msg.control_), 32 | stop_(msg.stop_), 33 | shutdown_(msg.shutdown_) {} 34 | 35 | PcapMsgMeta& PcapMsgMeta::operator=(PcapMsgMeta&& msg) noexcept { 36 | msg_ = std::move(msg.msg_); 37 | event_ = msg.event_; 38 | packetLimit_ = msg.packetLimit_; 39 | restart_ = msg.restart_; 40 | control_ = msg.control_; 41 | stop_ = msg.stop_; 42 | shutdown_ = msg.shutdown_; 43 | return *this; 44 | } 45 | 46 | PcapMsg& PcapMsgMeta::getPcapMsg() { 47 | return msg_; 48 | } 49 | 50 | EventId PcapMsgMeta::getEventId() { 51 | try { 52 | return static_cast(event_); 53 | } catch (const std::exception& e) { 54 | LOG(ERROR) << fmt::format("invalid event {}: {}", event_, e.what()); 55 | return EventId::UNKNOWN; 56 | } 57 | } 58 | 59 | } // namespace katran 60 | -------------------------------------------------------------------------------- /katran/lib/PcapStructs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | namespace katran { 20 | 21 | // reference to headers format: 22 | // https://wiki.wireshark.org/Development/LibpcapFileFormat 23 | struct pcap_hdr_s { 24 | uint32_t magic_number; /* magic number */ 25 | uint16_t version_major; /* major version number */ 26 | uint16_t version_minor; /* minor version number */ 27 | int32_t thiszone; /* GMT to local correction */ 28 | uint32_t sigfigs; /* accuracy of timestamps */ 29 | uint32_t snaplen; /* max length of captured packets, in octets */ 30 | uint32_t network; /* data link type */ 31 | }; 32 | 33 | struct pcaprec_hdr_s { 34 | uint32_t ts_sec; /* timestamp seconds */ 35 | uint32_t ts_usec; /* timestamp microseconds */ 36 | uint32_t incl_len; /* number of octets of packet saved in file */ 37 | uint32_t orig_len; /* actual length of packet */ 38 | }; 39 | 40 | } // namespace katran 41 | -------------------------------------------------------------------------------- /katran/lib/PipeWriter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2004-present Facebook. All Rights Reserved. 2 | 3 | #include "katran/lib/PipeWriter.h" 4 | #include 5 | #include 6 | 7 | namespace katran { 8 | PipeWriter::PipeWriter() {} 9 | 10 | void PipeWriter::writeData(const void* ptr, std::size_t size) { 11 | VLOG_EVERY_N(4, 10) << __func__ << " write " << size << " bytes"; 12 | 13 | if (size == 0) { 14 | LOG(ERROR) << "Zero-sized data. Skipping"; 15 | return; 16 | } 17 | 18 | if (!enabled_) { 19 | VLOG_EVERY_N(4, 10) << "Disabled pipe writer. Skipping"; 20 | return; 21 | } 22 | 23 | pipe_->write(&writeCallback_, ptr, size); 24 | } 25 | 26 | void PipeWriter::writeHeader(const void* ptr, std::size_t size) { 27 | // This could overwrite pre-existing header 28 | headerBuf_ = folly::IOBuf::copyBuffer(ptr, size); 29 | } 30 | 31 | void PipeWriter::setWriterDestination( 32 | std::shared_ptr pipeWriter) { 33 | CHECK(pipeWriter) << "Null pipe writer"; 34 | pipe_ = pipeWriter; 35 | } 36 | 37 | void PipeWriter::unsetWriterDestination() { 38 | pipe_.reset(); 39 | } 40 | } // namespace katran 41 | -------------------------------------------------------------------------------- /katran/lib/bpf/balancer_kern-tpl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | #pragma once 4 | 5 | namespace katran { 6 | 7 | unsigned char kBalancerKernProgBuffer[] = {__HexdumpPlaceholder__}; 8 | 9 | } // namespace katran 10 | -------------------------------------------------------------------------------- /katran/lib/bpf/balancer_kern_flavors-tpl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | #pragma once 4 | 5 | namespace katran { 6 | 7 | unsigned char kBalancerKernProgBuffer_{flavor}[] = {__HexdumpPlaceholder__}; 8 | 9 | } // namespace katran 10 | -------------------------------------------------------------------------------- /katran/lib/bpf/flow_debug.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __FLOW_DEBUG_H 18 | #define __FLOW_DEBUG_H 19 | 20 | #ifdef RECORD_FLOW_INFO 21 | 22 | #ifndef FLOW_DEBUG_MAP_SIZE 23 | #define FLOW_DEBUG_MAP_SIZE 1000000 24 | #endif // of FLOW_DEBUG_MAP_SIZE 25 | 26 | #define NO_FLAGS 0 27 | 28 | #include "katran/lib/bpf/flow_debug_helpers.h" 29 | 30 | // Flow debug enabled, enable helpers 31 | #define RECORD_GUE_ROUTE(old_eth, new_eth, data_end, outer_v4, inner_v4) \ 32 | gue_record_route(old_eth, new_eth, data_end, outer_v4, inner_v4) 33 | 34 | #else 35 | 36 | // Flow debug disabled, define helpers to be noop 37 | #define RECORD_GUE_ROUTE(...) \ 38 | {} 39 | 40 | #endif // of RECORD_FLOW_INFO 41 | 42 | #endif // of __FLOW_DEBUG_H 43 | -------------------------------------------------------------------------------- /katran/lib/bpf/flow_debug_maps.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __FLOW_DEBUG_MAPS_H 18 | #define __FLOW_DEBUG_MAPS_H 19 | 20 | #include "katran/lib/linux_includes/bpf.h" 21 | #include "katran/lib/linux_includes/bpf_helpers.h" 22 | 23 | #include "katran/lib/bpf/balancer_structs.h" 24 | #include "katran/lib/bpf/flow_debug.h" 25 | 26 | struct { 27 | __uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS); 28 | __type(key, __u32); 29 | __type(value, __u32); 30 | __uint(max_entries, MAX_SUPPORTED_CPUS); 31 | __uint(map_flags, NO_FLAGS); 32 | __array( 33 | values, 34 | struct { 35 | __uint(type, BPF_MAP_TYPE_LRU_HASH); 36 | __uint(key_size, sizeof(struct flow_key)); 37 | __uint(value_size, sizeof(struct flow_debug_info)); 38 | __uint(max_entries, DEFAULT_LRU_SIZE); 39 | }); 40 | } flow_debug_maps SEC(".maps"); 41 | 42 | #endif // of __FLOW_DEBUG_MAPS_H 43 | -------------------------------------------------------------------------------- /katran/lib/bpf/healthchecking_consts.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __HEALTHCHECKING_CONSTS_H 18 | #define __HEALTHCHECKING_CONSTS_H 19 | 20 | #define CTRL_MAP_SIZE 4 21 | // position of ifindex of main interface inside hc ctrl array 22 | #define HC_MAIN_INTF_POSITION 3 23 | 24 | #define REDIRECT_EGRESS 0 25 | #define DEFAULT_TTL 64 26 | 27 | // Specify max packet size to avoid packets exceed mss (after encapsulation) 28 | // when set to 0, the healthchecker_kern would not perform skb length check, 29 | // relying on GSO to segment packets exceeding MSS on transmit path 30 | #ifndef HC_MAX_PACKET_SIZE 31 | #define HC_MAX_PACKET_SIZE 0 32 | #endif 33 | 34 | // position in stats map where we are storing generic counters. 35 | #define GENERIC_STATS_INDEX 0 36 | 37 | // code to indicate that packet should be futher processed by pipeline 38 | #define HC_FURTHER_PROCESSING -2 39 | 40 | // size of stats map. 41 | #define STATS_SIZE 1 42 | 43 | #define NO_FLAGS 0 44 | 45 | // for ip-in-ip encap 46 | // source address of the healthcheck would be crafted the same way as data 47 | // packet 48 | // #define MANGLE_HC_SRC 1 49 | #define MANGLED_HC_SRC_PORT 31337 50 | 51 | #define V6DADDR (1 << 0) 52 | 53 | #define HC_SRC_MAC_POS 0 54 | #define HC_DST_MAC_POS 1 55 | 56 | #endif // of __HEALTHCHECKING_CONSTS_H 57 | -------------------------------------------------------------------------------- /katran/lib/bpf/healthchecking_structs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #ifndef __HEALTHCHECKING_STRUCTS_H 18 | #define __HEALTHCHECKING_STRUCTS_H 19 | 20 | struct hc_real_definition { 21 | union { 22 | __be32 daddr; 23 | __be32 v6daddr[4]; 24 | }; 25 | __u8 flags; 26 | }; 27 | 28 | // struct to record packet level for counters for relevant events 29 | struct hc_stats { 30 | __u64 pckts_processed; 31 | __u64 pckts_dropped; 32 | __u64 pckts_skipped; 33 | __u64 pckts_too_big; 34 | }; 35 | 36 | // hc_key's definition 37 | struct hc_key { 38 | union { 39 | __be32 addr; 40 | __be32 addrv6[4]; 41 | }; 42 | __u16 port; 43 | __u8 proto; 44 | }; 45 | 46 | // struct to store mac address 47 | struct hc_mac { 48 | __u8 mac[6]; 49 | }; 50 | 51 | #endif // of __HEALTHCHECKING_STRUCTS_H 52 | -------------------------------------------------------------------------------- /katran/lib/bpf/introspection.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | // if KATRAN_INTROSPECTION is enabled 18 | #define MAX_EVENT_SIZE 128 19 | 20 | // introspection events, they are defined regardless because they are used in 21 | // constants which does not depend on the introspection flag 22 | #define TCP_NONSYN_LRUMISS 0 23 | #define PACKET_TOOBIG 1 24 | #define QUIC_PACKET_DROP_NO_REAL 2 25 | 26 | #ifdef KATRAN_INTROSPECTION 27 | // Introspection enabled, enable helpers 28 | #define REPORT_EVENT(xdp, event, data, size, meta_only) \ 29 | ({ submit_event((xdp), &event_pipe, (event), data, size, meta_only); }) 30 | #define REPORT_TCP_NONSYN_LRUMISS(xdp, data, size, meta_only) \ 31 | REPORT_EVENT(xdp, TCP_NONSYN_LRUMISS, data, size, meta_only) 32 | #define REPORT_PACKET_TOOBIG(xdp, data, size, meta_only) \ 33 | REPORT_EVENT(xdp, PACKET_TOOBIG, data, size, meta_only) 34 | #define REPORT_QUIC_PACKET_DROP_NO_REAL(xdp, data, size, meta_only) \ 35 | REPORT_EVENT(xdp, QUIC_PACKET_DROP_NO_REAL, data, size, meta_only) 36 | #else 37 | // Introspection disabled, define helpers to be noop 38 | #define REPORT_TCP_NONSYN_LRUMISS(...) \ 39 | {} 40 | #define REPORT_PACKET_TOOBIG(...) \ 41 | {} 42 | #define REPORT_QUIC_PACKET_DROP_NO_REAL(...) \ 43 | {} 44 | #endif 45 | -------------------------------------------------------------------------------- /katran/lib/bpf/xdp_pktcntr.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "bpf.h" 26 | #include "bpf_helpers.h" 27 | 28 | #define CTRL_ARRAY_SIZE 2 29 | #define CNTRS_ARRAY_SIZE 512 30 | 31 | struct { 32 | __uint(type, BPF_MAP_TYPE_ARRAY); 33 | __type(key, __u32); 34 | __type(value, __u32); 35 | __uint(max_entries, CTRL_ARRAY_SIZE); 36 | } ctl_array SEC(".maps"); 37 | 38 | struct { 39 | __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); 40 | __type(key, __u32); 41 | __type(value, __u64); 42 | __uint(max_entries, CNTRS_ARRAY_SIZE); 43 | } cntrs_array SEC(".maps"); 44 | 45 | SEC("xdp") 46 | int pktcntr(struct xdp_md* ctx) { 47 | void* data_end = (void*)(long)ctx->data_end; 48 | void* data = (void*)(long)ctx->data; 49 | __u32 ctl_flag_pos = 0; 50 | __u32 cntr_pos = 0; 51 | __u32* flag = bpf_map_lookup_elem(&ctl_array, &ctl_flag_pos); 52 | 53 | if (!flag || (*flag == 0)) { 54 | return XDP_PASS; 55 | }; 56 | 57 | __u64* cntr_val = bpf_map_lookup_elem(&cntrs_array, &cntr_pos); 58 | if (cntr_val) { 59 | *cntr_val += 1; 60 | }; 61 | return XDP_PASS; 62 | } 63 | 64 | char _license[] SEC("license") = "GPL"; 65 | -------------------------------------------------------------------------------- /katran/lib/bpf/xdp_root.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "bpf.h" 18 | #include "bpf_helpers.h" 19 | 20 | #define ROOT_ARRAY_SIZE 3 21 | 22 | struct { 23 | __uint(type, BPF_MAP_TYPE_PROG_ARRAY); 24 | __type(key, __u32); 25 | __type(value, __u32); 26 | __uint(max_entries, ROOT_ARRAY_SIZE); 27 | } root_array SEC(".maps"); 28 | 29 | SEC("xdp") 30 | int xdp_root(struct xdp_md* ctx) { 31 | __u32* fd; 32 | #pragma clang loop unroll(full) 33 | for (__u32 i = 0; i < ROOT_ARRAY_SIZE; i++) { 34 | bpf_tail_call(ctx, &root_array, i); 35 | } 36 | return XDP_PASS; 37 | } 38 | 39 | char _license[] SEC("license") = "GPL"; 40 | -------------------------------------------------------------------------------- /katran/lib/linux_includes/bpf_common.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPI__LINUX_BPF_COMMON_H__ 2 | #define _UAPI__LINUX_BPF_COMMON_H__ 3 | 4 | /* Instruction classes */ 5 | #define BPF_CLASS(code) ((code) & 0x07) 6 | #define BPF_LD 0x00 7 | #define BPF_LDX 0x01 8 | #define BPF_ST 0x02 9 | #define BPF_STX 0x03 10 | #define BPF_ALU 0x04 11 | #define BPF_JMP 0x05 12 | #define BPF_RET 0x06 13 | #define BPF_MISC 0x07 14 | 15 | /* ld/ldx fields */ 16 | #define BPF_SIZE(code) ((code) & 0x18) 17 | #define BPF_W 0x00 /* 32-bit */ 18 | #define BPF_H 0x08 /* 16-bit */ 19 | #define BPF_B 0x10 /* 8-bit */ 20 | /* eBPF BPF_DW 0x18 64-bit */ 21 | #define BPF_MODE(code) ((code) & 0xe0) 22 | #define BPF_IMM 0x00 23 | #define BPF_ABS 0x20 24 | #define BPF_IND 0x40 25 | #define BPF_MEM 0x60 26 | #define BPF_LEN 0x80 27 | #define BPF_MSH 0xa0 28 | 29 | /* alu/jmp fields */ 30 | #define BPF_OP(code) ((code) & 0xf0) 31 | #define BPF_ADD 0x00 32 | #define BPF_SUB 0x10 33 | #define BPF_MUL 0x20 34 | #define BPF_DIV 0x30 35 | #define BPF_OR 0x40 36 | #define BPF_AND 0x50 37 | #define BPF_LSH 0x60 38 | #define BPF_RSH 0x70 39 | #define BPF_NEG 0x80 40 | #define BPF_MOD 0x90 41 | #define BPF_XOR 0xa0 42 | 43 | #define BPF_JA 0x00 44 | #define BPF_JEQ 0x10 45 | #define BPF_JGT 0x20 46 | #define BPF_JGE 0x30 47 | #define BPF_JSET 0x40 48 | #define BPF_SRC(code) ((code) & 0x08) 49 | #define BPF_K 0x00 50 | #define BPF_X 0x08 51 | 52 | #ifndef BPF_MAXINSNS 53 | #define BPF_MAXINSNS 4096 54 | #endif 55 | 56 | #endif /* _UAPI__LINUX_BPF_COMMON_H__ */ 57 | -------------------------------------------------------------------------------- /katran/lib/linux_includes/bpf_endian.h: -------------------------------------------------------------------------------- 1 | /* SPDX-License-Identifier: GPL-2.0 */ 2 | #ifndef __BPF_ENDIAN__ 3 | #define __BPF_ENDIAN__ 4 | 5 | #include 6 | 7 | /* LLVM's BPF target selects the endianness of the CPU 8 | * it compiles on, or the user specifies (bpfel/bpfeb), 9 | * respectively. The used __BYTE_ORDER__ is defined by 10 | * the compiler, we cannot rely on __BYTE_ORDER from 11 | * libc headers, since it doesn't reflect the actual 12 | * requested byte order. 13 | * 14 | * Note, LLVM's BPF target has different __builtin_bswapX() 15 | * semantics. It does map to BPF_ALU | BPF_END | BPF_TO_BE 16 | * in bpfel and bpfeb case, which means below, that we map 17 | * to cpu_to_be16(). We could use it unconditionally in BPF 18 | * case, but better not rely on it, so that this header here 19 | * can be used from application and BPF program side, which 20 | * use different targets. 21 | */ 22 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 23 | #define __bpf_ntohs(x) __builtin_bswap16(x) 24 | #define __bpf_htons(x) __builtin_bswap16(x) 25 | #define __bpf_constant_ntohs(x) ___constant_swab16(x) 26 | #define __bpf_constant_htons(x) ___constant_swab16(x) 27 | #define __bpf_ntohl(x) __builtin_bswap32(x) 28 | #define __bpf_htonl(x) __builtin_bswap32(x) 29 | #define __bpf_constant_ntohl(x) ___constant_swab32(x) 30 | #define __bpf_constant_htonl(x) ___constant_swab32(x) 31 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 32 | #define __bpf_ntohs(x) (x) 33 | #define __bpf_htons(x) (x) 34 | #define __bpf_constant_ntohs(x) (x) 35 | #define __bpf_constant_htons(x) (x) 36 | #define __bpf_ntohl(x) (x) 37 | #define __bpf_htonl(x) (x) 38 | #define __bpf_constant_ntohl(x) (x) 39 | #define __bpf_constant_htonl(x) (x) 40 | #else 41 | #error "Fix your compiler's __BYTE_ORDER__?!" 42 | #endif 43 | 44 | #define bpf_htons(x) \ 45 | (__builtin_constant_p(x) ? __bpf_constant_htons(x) : __bpf_htons(x)) 46 | #define bpf_ntohs(x) \ 47 | (__builtin_constant_p(x) ? __bpf_constant_ntohs(x) : __bpf_ntohs(x)) 48 | #define bpf_htonl(x) \ 49 | (__builtin_constant_p(x) ? __bpf_constant_htonl(x) : __bpf_htonl(x)) 50 | #define bpf_ntohl(x) \ 51 | (__builtin_constant_p(x) ? __bpf_constant_ntohl(x) : __bpf_ntohl(x)) 52 | 53 | #endif /* __BPF_ENDIAN__ */ 54 | -------------------------------------------------------------------------------- /katran/lib/testing/Base64Helpers.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | 21 | namespace folly { 22 | class IOBuf; 23 | } 24 | 25 | namespace katran { 26 | 27 | /** 28 | * helper class to do base64 encoding/decoding. 29 | * built to be as simple as possible. only intented to be used in BpfTester 30 | */ 31 | class Base64Helpers { 32 | public: 33 | /** 34 | * @param IOBuf* buf pointer to memory, which we want to encode 35 | * @return string base64 encoded memory region, where buf was pointing to 36 | * 37 | * helper function to encode data, stored in IOBuf as base64 encoded string 38 | */ 39 | static std::string base64Encode(folly::IOBuf* buf); 40 | 41 | /** 42 | * @param string encoded base64 encoded value 43 | * @return string decoded value 44 | * 45 | * helper function to decode base64 encoded string 46 | */ 47 | static std::string base64Decode(std::string encoded); 48 | }; 49 | 50 | } // namespace katran 51 | -------------------------------------------------------------------------------- /katran/lib/testing/Base64Test.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include "katran/lib/testing/Base64Helpers.h" 22 | 23 | namespace katran { 24 | 25 | TEST(Base64Tests, testEncode) { 26 | auto test_string = "Test Data!"; 27 | auto buf = folly::IOBuf::copyBuffer(test_string); 28 | ASSERT_STREQ( 29 | Base64Helpers::base64Encode(buf.get()).c_str(), "VGVzdCBEYXRhIQ=="); 30 | }; 31 | 32 | TEST(Base64Tests, testDecode) { 33 | ASSERT_STREQ( 34 | Base64Helpers::base64Decode("VGVzdCBEYXRhIQ==").c_str(), "Test Data!"); 35 | }; 36 | 37 | } // namespace katran 38 | -------------------------------------------------------------------------------- /katran/lib/testing/KatranTestUtil.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | #include 19 | #include 20 | #include "katran/lib/KatranLb.h" 21 | #include "katran/lib/testing/KatranTestProvision.h" 22 | 23 | namespace katran { 24 | namespace testing { 25 | 26 | bool testSimulator(katran::KatranLb& lb); 27 | KatranTestParam createDefaultTestParam(TestMode testMode); 28 | KatranTestParam createTPRTestParam(); 29 | KatranTestParam createUdpStableRtTestParam(); 30 | KatranTestParam createXPopDecapTestParam(); 31 | void testOptionalLbCounters(katran::KatranLb& lb, KatranTestParam& testParam); 32 | void testStableRtCounters(katran::KatranLb& lb, KatranTestParam& testParam); 33 | void validateMapSize( 34 | katran::KatranLb& lb, 35 | const std::string& map_name, 36 | int expected_current, 37 | int expected_max); 38 | void preTestOptionalLbCounters( 39 | katran::KatranLb& lb, 40 | const std::string& healthcheckingProg); 41 | void postTestOptionalLbCounters( 42 | katran::KatranLb& lb, 43 | const std::string& healthcheckingProg); 44 | bool testLbCounters(katran::KatranLb& lb, KatranTestParam& testParam); 45 | void testXPopDecapCounters(katran::KatranLb& lb, KatranTestParam& testParam); 46 | std::string toString(katran::KatranFeatureEnum feature); 47 | 48 | } // namespace testing 49 | } // namespace katran 50 | -------------------------------------------------------------------------------- /katran/lib/testing/PacketAttributes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | 19 | #include 20 | #include 21 | 22 | namespace katran { 23 | 24 | struct PacketAttributes { 25 | // Base-64 encoded value of the packet sent to Katran 26 | std::string inputPacket; 27 | 28 | // Human-readable description of the packet being sent 29 | std::string description; 30 | 31 | // Expected return value of the balancer bpf program. Example: "XDP_TX" 32 | std::string expectedReturnValue; 33 | 34 | // Base-64 encoded value of the packet we expect after passing 35 | // the input packet through Katran. 36 | std::string expectedOutputPacket; 37 | 38 | // We set this if we want to verify whether or not the packet was 39 | // routed through global lru 40 | std::optional routedThroughGlobalLru{std::nullopt}; 41 | }; 42 | 43 | } // namespace katran 44 | -------------------------------------------------------------------------------- /katran/lib/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # find libraries 2 | find_library(CHHELPERS chhelpers) 3 | find_path(CHHELPERS_INCLUDE_DIR chhelpers) 4 | include(KatranTest) 5 | 6 | katran_add_test(TARGET iphelpers-tests 7 | SOURCES 8 | IpHelpersTest.cpp 9 | DEPENDS 10 | iphelpers 11 | ${GTEST} 12 | ${PTHREAD} 13 | "Folly::folly" 14 | ) 15 | 16 | katran_add_test(TARGET chhelpers-tests 17 | SOURCES 18 | CHHelpersTest.cpp 19 | DEPENDS 20 | katranlb 21 | ${GTEST} 22 | ${PTHREAD} 23 | ) 24 | 25 | katran_add_test(TARGET libkatran-tests 26 | SOURCES 27 | KatranLbTest.cpp 28 | DEPENDS 29 | katranlb 30 | ${GTEST} 31 | ${PTHREAD} 32 | "Folly::folly" 33 | ) 34 | 35 | katran_add_test(TARGET vip-tests 36 | SOURCES 37 | VipTest.cpp 38 | DEPENDS 39 | katranlb 40 | ${GTEST} 41 | ${PTHREAD} 42 | "Folly::folly" 43 | ) 44 | 45 | katran_add_test(TARGET eventpipe-callback-test 46 | SOURCES 47 | EventPipeCallbackTest.cpp 48 | DEPENDS 49 | katranlb 50 | ${GTEST} 51 | ${GMOCK} 52 | ${PTHREAD} 53 | "Folly::folly" 54 | ) 55 | 56 | katran_add_test(TARGET monitoring-service-core-test 57 | SOURCES 58 | MonitoringServiceCoreTest.cpp 59 | DEPENDS 60 | katranlb 61 | ${GTEST} 62 | ${PTHREAD} 63 | "Folly::folly" 64 | ) 65 | 66 | katran_add_test(TARGET pcap-writer-test 67 | SOURCES 68 | PcapWriterTest.cpp 69 | DEPENDS 70 | katranlb 71 | ${GMOCK} 72 | ${GTEST} 73 | ${PTHREAD} 74 | "Folly::folly" 75 | ) 76 | -------------------------------------------------------------------------------- /katran/lib/tests/common/TestMain.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | /* 24 | * This is the recommended main function for all tests. 25 | * The Makefile links it into all of the test programs so that tests do not need 26 | * to - and indeed should typically not - define their own main() functions 27 | */ 28 | FOLLY_ATTR_WEAK int main(int argc, char** argv); 29 | 30 | int main(int argc, char** argv) { 31 | #if FOLLY_HAVE_LIBGFLAGS 32 | // Enable glog logging to stderr by default. 33 | gflags::SetCommandLineOptionWithMode( 34 | "logtostderr", "1", gflags::SET_FLAGS_DEFAULT); 35 | #endif 36 | 37 | ::testing::InitGoogleTest(&argc, argv); 38 | folly::Init init(&argc, &argv); 39 | 40 | return RUN_ALL_TESTS(); 41 | } 42 | -------------------------------------------------------------------------------- /katran/tpr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.9) 2 | set(KATRAN_TPR_INCLUDE_DIR "$") 3 | 4 | find_package(Glog REQUIRED) 5 | find_package(folly CONFIG REQUIRED) 6 | find_package(Threads) 7 | 8 | add_subdirectory(bpf_util) 9 | 10 | set(LIBBPF_INCLUDE_DIRS "${LIB_BPF_PREFIX}/include") 11 | set(LIBBPF_LIBRARIES "${LIB_BPF_PREFIX}/lib") 12 | set(BPFOBJECT_VMLINUX_H "bpf/vmlinux/vmlinux.h") 13 | set(BPFOBJECT_BPFTOOL_EXE "${CMAKE_INSTALL_PREFIX}/bin/bpftool") 14 | set(BPFOBJECT_EXTRA_DEFINES "-DKATRAN_CMAKE_BUILD") 15 | find_package(BpfObject REQUIRED) 16 | 17 | bpf_object(tpr_bpf 18 | bpf/tcp_pkt_router.bpf.c 19 | 20 | ) 21 | 22 | add_library(katran_tpr STATIC 23 | TPRStatsPoller.cpp 24 | TcpPktRouter.cpp 25 | ) 26 | 27 | target_compile_definitions(katran_tpr PUBLIC KATRAN_CMAKE_BUILD=1) 28 | 29 | target_link_libraries(katran_tpr 30 | "Folly::folly" 31 | glog::glog 32 | ${BPF_LINK_LIBRARIES} 33 | tpr_bpf_skel 34 | ) 35 | 36 | target_include_directories( 37 | katran_tpr PUBLIC 38 | ${GFLAGS_INCLUDE_DIR} 39 | ${KATRAN_TPR_INCLUDE_DIR} 40 | ) 41 | -------------------------------------------------------------------------------- /katran/tpr/README: -------------------------------------------------------------------------------- 1 | TPR: TCP Packet Routing is a STATELESS solution to consistently route TCP packets where both 2 | endpoints can be controlled. 3 | -------------------------------------------------------------------------------- /katran/tpr/bpf/tcp_pkt_router_consts.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | #pragma once 4 | 5 | /* size of stats map */ 6 | #define STATS_SIZE 1 7 | 8 | /* position in stats map where we store generic counters */ 9 | #define GENERIC_STATS_INDEX 0 10 | 11 | /* position in stats map where we store server_info */ 12 | #define SERVER_INFO_INDEX 0 13 | 14 | /* 15 | * Currently, servers use TCP_HDR_OPT_KIND, but we'll be migrating them 16 | * to use TCP_SRV_HDR_OPT_KIND because we want the server and client to 17 | * use different OPTs. 18 | */ 19 | #define TCP_SRV_HDR_OPT_KIND 0xB6 20 | 21 | /* Reserved hdr-opt-value for this case. 22 | * Picked random unused value from IANA TCP Option Kind Numbers 23 | */ 24 | #define TCP_HDR_OPT_KIND 0xB7 25 | 26 | /* 27 | * We don't insert the TPR opt on the server side if this opt is present 28 | * in the client's SYN 29 | */ 30 | #define KDE_CLT_TCP_HDR_OPT_KIND 0xB8 31 | 32 | /* 4 bytes len for the server-id in TCP_HDR_OPT + KIND and LEN */ 33 | #define TCP_HDR_OPT_LEN 6 34 | 35 | /* For consistent handling of success vs failues */ 36 | #define CG_OK 1 37 | #define CG_ERR 0 38 | 39 | /* value to represent the 'server' side */ 40 | #define SERVER_MODE 1 41 | #define CLIENT_MODE 2 42 | 43 | /* Server info map has only 1 item */ 44 | #define SERVER_INFO_MAP_SIZE 1 45 | 46 | #define TCPHDR_SYN 0x02 47 | #define TCPHDR_ACK 0x10 48 | #define TCPHDR_SYNACK (TCPHDR_SYN | TCPHDR_ACK) 49 | 50 | #define NO_FLAGS 0 51 | #define SUCCESS 0 52 | #define PASS -1 53 | -------------------------------------------------------------------------------- /katran/tpr/bpf/tcp_pkt_router_maps.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | #pragma once 4 | 5 | #include "tcp_pkt_router_structs.h" 6 | 7 | /* map to store server related info, such as server-id */ 8 | struct { 9 | __uint(type, BPF_MAP_TYPE_ARRAY); 10 | __uint(map_flags, NO_FLAGS); 11 | __uint(max_entries, SERVER_INFO_MAP_SIZE); 12 | __type(key, __u32); // index of the array 13 | __type(value, struct server_info); 14 | } server_infos SEC(".maps"); 15 | 16 | /* BPF sk_storage map to store info for each connection */ 17 | struct { 18 | __uint(type, BPF_MAP_TYPE_SK_STORAGE); 19 | __uint(map_flags, BPF_F_NO_PREALLOC); 20 | __type(key, __u32); // socket-fd 21 | __type(value, __u32); // 4-bytes server_id 22 | } sk_sid_store SEC(".maps"); 23 | 24 | /* map which contains counters for different packet level events for monitoring 25 | * purpose */ 26 | struct { 27 | __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); 28 | __uint(map_flags, NO_FLAGS); 29 | __uint(max_entries, STATS_SIZE); 30 | __type(key, __u32); // index of the array 31 | __type(value, struct stats); 32 | } tpr_stats SEC(".maps"); 33 | -------------------------------------------------------------------------------- /katran/tpr/bpf/tcp_pkt_router_structs.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | #pragma once 4 | 5 | struct server_info { 6 | // 1 == server, 2 == client 7 | __u8 running_mode; 8 | // 0 = no, otherwise yes 9 | __u8 kde_enabled; 10 | __u32 server_id; 11 | }; 12 | 13 | // struct that represents a header options in TCP packet 14 | struct tcp_opt { 15 | __u8 kind; 16 | __u8 len; 17 | __u32 server_id; 18 | } __attribute__((packed)); 19 | 20 | // struct that represents an option that, if present in the incoming 21 | // syn from the client, indicates that we shouldn't use TPR. 22 | struct kde_clt_tcp_opt_v2 { 23 | __u8 kind; 24 | __u8 len; 25 | __u8 zone; 26 | } __attribute__((packed)); 27 | #define KDE_CLT_TCP_HDR_OPT_LEN 2 28 | #define KDE_CLT_TCP_HDR_OPT_V2_LEN 3 29 | 30 | // stats for different packet events 31 | struct stats { 32 | // TODO: these are tentative fields for now 33 | __u64 server_id_read; 34 | __u64 server_id_set; 35 | __u64 conns_skipped; 36 | __u64 no_tcp_opt_hdr; 37 | __u64 error_bad_id; 38 | __u64 error_write_opt; 39 | __u64 error_sys_calls; 40 | __u64 ignoring_due_to_kde; 41 | // stats for the rollout of the new TPR server OPT 42 | __u64 legacy_server_opt; 43 | __u64 new_server_opt; 44 | }; 45 | -------------------------------------------------------------------------------- /katran/tpr/bpf_util/BpfUtil.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Meta Platforms, Inc. and affiliates. 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace katran_tpr::BpfUtil { 12 | 13 | constexpr int kNoFlags = 0; 14 | 15 | SystemMaybe init() noexcept; 16 | 17 | SystemMaybe setRLimit() noexcept; 18 | 19 | int getDirFd(const std::string& path) noexcept; 20 | 21 | SystemMaybe attachCgroupProg( 22 | int progFd, 23 | const std::string& cgroup, 24 | unsigned int flags) noexcept; 25 | 26 | SystemMaybe detachCgroupProg( 27 | int progFd, 28 | const std::string& cgroup) noexcept; 29 | 30 | template 31 | SystemMaybe 32 | updateMapElement(int mapFd, const K& key, const V& value) noexcept { 33 | if (mapFd < 0) { 34 | return SYSTEM_ERROR(EINVAL, fmt::format("Invalid map-fd given: {}", mapFd)); 35 | } 36 | if (::bpf_map_update_elem(mapFd, &key, &value, kNoFlags)) { 37 | int savedErrno = errno; 38 | return SYSTEM_ERROR( 39 | savedErrno, 40 | fmt::format( 41 | "Error while updating map: {}, error: {}", 42 | mapFd, 43 | folly::errnoStr(savedErrno))); 44 | } 45 | return noSystemError(); 46 | } 47 | 48 | template 49 | SystemMaybe 50 | lookupMapElement(int mapFd, const K& key, V& value) noexcept { 51 | if (mapFd < 0) { 52 | return SYSTEM_ERROR(EINVAL, fmt::format("Invalid map-fd given: {}", mapFd)); 53 | } 54 | if (::bpf_map_lookup_elem(mapFd, &key, &value)) { 55 | int savedErrno = errno; 56 | return SYSTEM_ERROR( 57 | savedErrno, 58 | fmt::format( 59 | "Error while looking up in bpf map: {}, error: {}", 60 | mapFd, 61 | folly::errnoStr(savedErrno))); 62 | } 63 | return noSystemError(); 64 | } 65 | 66 | } // namespace katran_tpr::BpfUtil 67 | -------------------------------------------------------------------------------- /katran/tpr/bpf_util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.9) 2 | set(KATRAN_TPR_INCLUDE_DIR "$") 3 | 4 | find_package(Glog REQUIRED) 5 | find_package(folly CONFIG REQUIRED) 6 | find_package(Threads) 7 | 8 | add_library(bpf_util STATIC 9 | BpfUtil.cpp 10 | ) 11 | 12 | target_compile_definitions(bpf_util PUBLIC KATRAN_CMAKE_BUILD=1) 13 | 14 | target_link_libraries(bpf_util 15 | "Folly::folly" 16 | glog::glog 17 | ${BPF_LINK_LIBRARIES} 18 | ) 19 | 20 | target_include_directories( 21 | bpf_util PUBLIC 22 | ${GFLAGS_INCLUDE_DIR} 23 | ${KATRAN_TPR_INCLUDE_DIR} 24 | ) 25 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/facebookincubator/katran/e4ca6397f39329431a8c080c7122d7ac5f3a69ad/logo.png -------------------------------------------------------------------------------- /os_run_tester.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (C) 2018-present, Facebook, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; version 2 of the License. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | set -xeo pipefail 19 | 20 | # By default this script assumes to be invoked from the root dir. 21 | if [ -z "${KATRAN_BUILD_DIR}" ] 22 | then 23 | KATRAN_BUILD_DIR=$(pwd)/_build/build 24 | fi 25 | 26 | if [ -z "${DEPS_DIR}" ] 27 | then 28 | DEPS_DIR=$(pwd)/_build/deps 29 | fi 30 | 31 | sudo sh -c "${KATRAN_BUILD_DIR}/katran/lib/testing/katran_tester -balancer_prog ${DEPS_DIR}/bpfprog/bpf/balancer.bpf.o -test_from_fixtures=true $1" 32 | -------------------------------------------------------------------------------- /start_katran_grpc_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (C) 2018-present, Facebook, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; version 2 of the License. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | # this script will start simple_katran_server w/ xdproot 19 | set -xeo pipefail 20 | 21 | if [ -z "${KATRAN_INTERFACE}" ] 22 | then 23 | KATRAN_INTERFACE=enp0s3 24 | fi 25 | 26 | # By default this script assumes to be invoked from the root dir. 27 | if [ -z "${KATRAN_BUILD_DIR}" ] 28 | then 29 | KATRAN_BUILD_DIR=$(pwd)/_build/build 30 | fi 31 | 32 | if [ -z "${DEPS_DIR}" ] 33 | then 34 | DEPS_DIR=$(pwd)/_build/deps 35 | fi 36 | 37 | ./install_xdproot.sh -b "${KATRAN_BUILD_DIR}" -d "${DEPS_DIR}" 38 | sudo sh -c "${KATRAN_BUILD_DIR}/example_grpc/katran_server_grpc -balancer_prog=${DEPS_DIR}/bpfprog/bpf/balancer.bpf.o -intf=${KATRAN_INTERFACE} -hc_forwarding=false -map_path=/sys/fs/bpf/jmp_${KATRAN_INTERFACE} -prog_pos=2" 39 | -------------------------------------------------------------------------------- /start_katran_simple_server.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (C) 2018-present, Facebook, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; version 2 of the License. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | # this script will start simple_katran_server w/ xdproot 19 | set -xeo pipefail 20 | 21 | if [ -z "${KATRAN_INTERFACE}" ] 22 | then 23 | KATRAN_INTERFACE=enp0s3 24 | fi 25 | 26 | # By default this script assumes to be invoked from the root dir. 27 | if [ -z "${KATRAN_BUILD_DIR}" ] 28 | then 29 | KATRAN_BUILD_DIR=$(pwd)/_build/build 30 | fi 31 | 32 | if [ -z "${DEPS_DIR}" ] 33 | then 34 | DEPS_DIR=$(pwd)/_build/deps 35 | fi 36 | 37 | ./install_xdproot.sh -b "${KATRAN_BUILD_DIR}" -d "${DEPS_DIR}" 38 | sudo sh -c "${KATRAN_BUILD_DIR}/example/simple_katran_server -balancer_prog=${DEPS_DIR}/bpfprog/bpf/balancer.bpf.o -intf=${KATRAN_INTERFACE} -hc_forwarding=false -map_path=/sys/fs/bpf/jmp_${KATRAN_INTERFACE} -prog_pos=2" 39 | -------------------------------------------------------------------------------- /tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | add_subdirectory(xdpdump) 3 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # collection of tools for katran 2 | 3 | ### xdpdump 4 | tcpdump like tool, which is working in XDP environment 5 | 6 | ### tcpdump_encap_helper 7 | helper script to create filters for tcpdump based on inner ip header 8 | 9 | ### start_katran 10 | helper tool (example of how it could looks like to be more precise) 11 | to do cpu/NUMA topology discovery, NIC's IRQ affinitization and start katran 12 | server (GRPc only in this example) 13 | -------------------------------------------------------------------------------- /tools/start_katran/build_start_katran.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (C) 2018-present, Facebook, Inc. 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; version 2 of the License. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License along 14 | # with this program; if not, write to the Free Software Foundation, Inc., 15 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | 17 | set -xeo pipefail 18 | 19 | create_grpc_template () { 20 | rm -rf start_katran/src/start_katran/lb_katran 21 | mkdir -p start_katran/src/start_katran/lb_katran 22 | protoc -I ../../example_grpc/protos/ ../../example_grpc/protos/katran.proto --go_out=plugins=grpc:start_katran/src/start_katran/lb_katran 23 | } 24 | 25 | get_start_katran_deps() { 26 | pushd . 27 | cd start_katran/src/start_katran/main 28 | go get 29 | popd 30 | } 31 | 32 | build_start_katran() { 33 | pushd . 34 | cd start_katran/src/start_katran/main 35 | go build 36 | popd 37 | } 38 | 39 | echo """ 40 | Please make sure that go and grpc dependencies are installed 41 | ( 42 | follow instructions @ https://grpc.io/docs/tutorials/basic/go.html 43 | but TL;DR 44 | go get -u google.golang.org/grpc 45 | go get -u github.com/golang/protobuf/protoc-gen-go 46 | ) 47 | This script will fail if go is not present 48 | """ 49 | 50 | go version 1>/dev/null 51 | export GOPATH=$(pwd)/start_katran 52 | create_grpc_template 53 | get_start_katran_deps 54 | build_start_katran 55 | -------------------------------------------------------------------------------- /tools/start_katran/start_katran/src/start_katran/katranc/katranc.go: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2019-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | package katranc 18 | 19 | import ( 20 | "log" 21 | "start_katran/lb_katran" 22 | 23 | "golang.org/x/net/context" 24 | "google.golang.org/grpc" 25 | ) 26 | 27 | func checkError(err error) { 28 | if err != nil { 29 | log.Fatal("Error: ", err) 30 | } 31 | } 32 | 33 | type KatranClient struct { 34 | client lb_katran.KatranServiceClient 35 | } 36 | 37 | func (kc *KatranClient) Init() { 38 | var opts []grpc.DialOption 39 | opts = append(opts, grpc.WithInsecure()) 40 | conn, err := grpc.Dial("127.0.0.1:50051", opts...) 41 | if err != nil { 42 | log.Fatalf("Can't connect to local katran server! err is %v\n", err) 43 | } 44 | kc.client = lb_katran.NewKatranServiceClient(conn) 45 | } 46 | 47 | func (kc *KatranClient) ChangeMac(mac string) { 48 | newMac := lb_katran.Mac{Mac: mac} 49 | res, err := kc.client.ChangeMac(context.Background(), &newMac) 50 | checkError(err) 51 | if res.Success { 52 | log.Print("Mac address changed!") 53 | } else { 54 | log.Print("Mac was not changed") 55 | } 56 | } 57 | 58 | func (kc *KatranClient) GetMac() bool { 59 | mac, err := kc.client.GetMac(context.Background(), &lb_katran.Empty{}) 60 | if err != nil { 61 | return false 62 | } 63 | log.Printf("Mac address is %v\n", mac.GetMac()) 64 | return true 65 | } 66 | -------------------------------------------------------------------------------- /tools/wireshark/README.md: -------------------------------------------------------------------------------- 1 | # wireshark plugin to parse GUE variant 1 encapsulation 2 | 3 | ## installation: 4 | in your home dir create this directory: 5 | ``` 6 | mkdir -p ~/.config/wireshark/plugins/guev1 7 | ``` 8 | 9 | then copy guev1.lua into it. wireshark on startup automatically enables this plugin and would try to parse everything w/ UDP destination port 6080 as GUEv1 encapsulated 10 | -------------------------------------------------------------------------------- /tools/wireshark/guev1.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved 2 | -- 3 | -- This program is free software; you can redistribute it and/or modify 4 | -- it under the terms of the GNU General Public License as published by 5 | -- the Free Software Foundation; version 2 of the License. 6 | -- 7 | -- This program is distributed in the hope that it will be useful, 8 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | -- GNU General Public License for more details. 11 | -- 12 | -- You should have received a copy of the GNU General Public License along 13 | -- with this program; if not, write to the Free Software Foundation, Inc., 14 | -- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | 16 | -- wireshark dissector for GUE variant 1 17 | 18 | do 19 | local ip = Dissector.get("ip") 20 | local ipv6 = Dissector.get("ipv6") 21 | 22 | local guev1 = Proto("guev1", "GUE variant 1") 23 | local proto = ProtoField.new("Protocol", "guev1.proto", ftypes.UINT8, nil, base.DEC, 0xF0) 24 | guev1.fields = {proto} 25 | 26 | local proto_field = Field.new("guev1.proto") 27 | 28 | function guev1.dissector(tvb, pinfo, tree) 29 | pinfo.cols.protocol:set("GUEv1") 30 | 31 | local subtree = tree:add(guev1, tvb(0,1)) 32 | subtree:add(proto, tvb(0,1)) 33 | 34 | if proto_field()() == 6 then 35 | ipv6:call(tvb, pinfo, tree) 36 | else 37 | ip:call(tvb, pinfo, tree) 38 | end 39 | end 40 | 41 | local udp_table = DissectorTable.get("udp.port") 42 | udp_table:add(6080, guev1) 43 | end 44 | -------------------------------------------------------------------------------- /tools/xdpdump/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | project(xdpdump) 3 | set (CMAKE_CXX_STANDARD 17) 4 | 5 | find_library(LIBBCC bcc) 6 | find_library(DL dl) 7 | find_library(LIBIBERTY libiberty.a iberty) 8 | find_library(EVENT_CORE libevent_core.a event_core) 9 | 10 | add_library(xdp_event_logger 11 | XdpEventLogger.h 12 | XdpEventReader.h 13 | XdpEventReader.cpp 14 | XdpEventLogger.cpp 15 | ) 16 | 17 | target_link_libraries(xdp_event_logger 18 | katranlb 19 | pcapwriter 20 | "Folly::folly" 21 | "glog::glog" 22 | ) 23 | 24 | add_library(lxdpdump 25 | XdpDump.h 26 | XdpDump.cpp 27 | XdpDumpKern.h 28 | ) 29 | 30 | target_link_libraries(lxdpdump 31 | xdp_event_logger 32 | "${LIBELF}" 33 | "${LIBZ}" 34 | "${LIBBCC}" 35 | "Folly::folly" 36 | "glog::glog" 37 | ) 38 | 39 | add_executable(xdpdump xdpdump_tool.cpp) 40 | target_link_libraries(xdpdump 41 | "-Wl,--start-group" 42 | "${LIBUNWIND}" 43 | "Folly::folly" 44 | "glog::glog" 45 | "${GFLAGS}" 46 | "${PTHREAD}" 47 | "${LIBDC}" 48 | "${DL}" 49 | "${EVENT_CORE}" 50 | "${LIBIBERTY}" 51 | iphelpers 52 | lxdpdump 53 | "-Wl,--end-group" 54 | ) 55 | -------------------------------------------------------------------------------- /tools/xdpdump/XdpDumpStructs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #pragma once 18 | #include 19 | 20 | namespace xdpdump { 21 | 22 | struct XdpDumpFilter { 23 | union { 24 | uint32_t src; 25 | uint32_t srcv6[4]; 26 | }; 27 | union { 28 | uint32_t dst; 29 | uint32_t dstv6[4]; 30 | }; 31 | uint16_t sport; 32 | uint16_t dport; 33 | uint8_t proto; 34 | bool ipv6; 35 | uint16_t offset; 36 | uint16_t offset_len; 37 | uint32_t pattern; 38 | std::string map_path; 39 | uint8_t flags; 40 | uint64_t count; 41 | bool mute; 42 | int32_t cpu; 43 | int32_t pages; 44 | }; 45 | 46 | extern "C" { 47 | struct XdpDumpOutput { 48 | union { 49 | uint32_t src; 50 | uint32_t srcv6[4]; 51 | }; 52 | union { 53 | uint32_t dst; 54 | uint32_t dstv6[4]; 55 | }; 56 | bool ipv6; 57 | uint16_t sport; 58 | uint16_t dport; 59 | uint8_t proto; 60 | uint16_t pkt_size; 61 | uint16_t data_len; 62 | }; 63 | } 64 | } // namespace xdpdump 65 | -------------------------------------------------------------------------------- /tools/xdpdump/XdpEventReader.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2018-present, Facebook, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation; version 2 of the License. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along 13 | * with this program; if not, write to the Free Software Foundation, Inc., 14 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | */ 16 | 17 | #include "tools/xdpdump/XdpEventReader.h" 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | namespace xdpdump { 25 | 26 | void XdpEventReader::handlePerfBufferEvent( 27 | int /* cpu */, 28 | const char* data, 29 | size_t /* size */) noexcept { 30 | auto info = eventLogger_->handlePerfEvent(data); 31 | if (queue_ != nullptr) { 32 | katran::PcapMsg pcap_msg( 33 | data + info.hdr_size, info.pkt_size, info.data_len); 34 | // best effort non blocking write. if writer thread is full we will lose 35 | // this packet 36 | auto res = queue_->write(std::move(pcap_msg)); 37 | if (!res) { 38 | // queue is full and we wasnt able to write into it. 39 | ++queueFull_; 40 | } 41 | } 42 | } 43 | 44 | } // namespace xdpdump 45 | --------------------------------------------------------------------------------