blob: adbda3ee3cbef4c42638178d0b9b7d9032a23eac [file] [log] [blame]
# Copyright 2018 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//common-mk/generate-dbus-adaptors.gni")
import("//common-mk/install_seccomp_policy.gni")
import("//common-mk/pkg_config.gni")
import("//common-mk/proto_library.gni")
group("all") {
deps = [
":install_dbus_config",
":install_init_config",
":install_seccomp_policy",
":install_setuid_restriction",
":libpatchpanel",
":libpatchpanel-util",
":patchpaneld",
"//patchpanel/bpf:patchpanel_ebpf",
"//patchpanel/iptables:install_iptables_start_scripts",
]
if (use.fuzzer) {
deps += [
":broadcast_forwarder_fuzzer",
":counters_service_fuzzer",
":datapath_fuzzer",
":dns_query_fuzzer",
":dns_util_fuzzer",
":firewall_fuzzer",
":multicast_forwarder_fuzzer",
":ndproxy_fuzzer",
":net_util_fuzzer",
]
}
if (use.test) {
deps += [ ":patchpanel_testrunner" ]
}
}
# Install the D-Bus config.
install_config("install_dbus_config") {
sources = [
"dbus/org.chromium.Patchpanel.conf",
"dbus/org.chromium.SocketService.conf",
]
install_path = "dbus_system_d"
}
# Install the init config.
install_config("install_init_config") {
sources = [ "init/patchpanel.conf" ]
install_path = "upstart"
}
# Install the seccomp config.
install_seccomp_policy("install_seccomp_policy") {
sources = [ "seccomp/" + getenv("ARCH") + "/iptables-seccomp.policy" ]
install_path = "seccomp_policy"
install_compiled_bpf = true
}
# Install the setuid restriction config.
install_config("install_setuid_restriction") {
sources = [ "setuid_restrictions/patchpaneld_uid_allowlist.txt" ]
install_path = "/usr/share/cros/startup/process_management_policies"
}
pkg_config("target_defaults") {
cflags = [ "-Wconversion" ]
pkg_deps = [
"libbrillo",
"libchrome",
"libmetrics",
"libminijail",
"libnet-base",
"libnetfilter_conntrack",
"libshill-client",
"re2",
"system_api",
"vboot_host",
]
if (use.fuzzer) {
pkg_deps += [ "protobuf" ]
} else {
pkg_deps += [ "protobuf-lite" ]
}
}
proto_library("patchpanel_ipc_protos") {
proto_in_dir = "."
proto_out_dir = "include/patchpanel"
sources = [ "${proto_in_dir}/ipc.proto" ]
}
# Generate the D-Bus C++ binding.
generate_dbus_adaptors("patchpanel_dbus_adaptors") {
sources = [ "dbus_bindings/org.chromium.patchpanel.xml" ]
dbus_adaptors_out_dir = "include/patchpanel/dbus_adaptors"
dbus_service_config = "dbus_bindings/patchpanel-dbus-service-config.json"
}
generate_dbus_adaptors("socketservice_dbus_adaptors") {
sources = [ "dbus_bindings/org.chromium.socketservice.xml" ]
dbus_adaptors_out_dir = "include/socketservice/dbus_adaptors"
dbus_service_config = "dbus_bindings/socketservice-dbus-service-config.json"
}
source_set("util_sources") {
sources = [
"address_manager.cc",
"dns/dns_query.cc",
"dns/dns_response.cc",
"dns/dns_util.cc",
"dns/io_buffer.cc",
"mac_address_generator.cc",
"message_dispatcher.cc",
"net_util.cc",
"subnet.cc",
"subnet_pool.cc",
]
configs += [
":target_defaults",
"//common-mk:pic",
]
}
shared_library("libpatchpanel-util") {
deps = [ ":util_sources" ]
install_path = "lib"
}
static_library("libpatchpanel") {
# NIC hotplug is temporarily disabled while being stabilized.
nic_hotplug = false
sources = [
"adb_proxy.cc",
"arc_service.cc",
"broadcast_forwarder.cc",
"clat_service.cc",
"connmark_updater.cc",
"conntrack_monitor.cc",
"counters_service.cc",
"crostini_service.cc",
"datapath.cc",
"dhcp_server_controller.cc",
"downstream_network_info.cc",
"downstream_network_service.cc",
"firewall.cc",
"guest_ipv6_service.cc",
"iptables.cc",
"lifeline_fd_service.cc",
"manager.cc",
"minijailed_process_runner.cc",
"multicast_counters_service.cc",
"multicast_forwarder.cc",
"multicast_metrics.cc",
"multicast_proxy.cc",
"ndproxy.cc",
"network/address_service.cc",
"network/network_applier.cc",
"network/routing_policy_service.cc",
"network/routing_table.cc",
"network/routing_table_entry.cc",
"network_monitor_service.cc",
"patchpanel_adaptor.cc",
"patchpanel_daemon.cc",
"proto_utils.cc",
"qos_service.cc",
"routing_service.cc",
"rtnl_client.cc",
"shill_client.cc",
"socket_daemon.cc",
"socket_service_adaptor.cc",
"subprocess_controller.cc",
"system.cc",
"vm_concierge_client.cc",
]
configs += [ ":target_defaults" ]
cflags = [ "-Wconversion" ]
defines = [
"USE_ARCVM=${use.arcvm}",
"USE_ARCVM_NIC_HOTPLUG=${nic_hotplug}",
]
# Workaround for b/266863330: disable PCH when the user generates
# compilation database for an editor.
if (!use.compdb_only && !use.compilation_database) {
precompiled_header = "pch/pch.h"
precompiled_source = "pch/pch.h"
}
all_dependent_pkg_deps = [
"protobuf",
"system_api",
]
deps = [
":patchpanel_dbus_adaptors",
":patchpanel_ipc_protos",
":socketservice_dbus_adaptors",
":util_sources",
]
}
executable("patchpaneld") {
sources = [ "main.cc" ]
configs += [ ":target_defaults" ]
deps = [ ":libpatchpanel" ]
install_path = "bin"
}
if (use.fuzzer) {
pkg_config("fuzzing_config") {
pkg_deps = [ "libchrome-test" ]
}
executable("broadcast_forwarder_fuzzer") {
sources = [ "broadcast_forwarder_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
executable("counters_service_fuzzer") {
sources = [ "counters_service_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
executable("datapath_fuzzer") {
sources = [ "datapath_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
executable("dns_query_fuzzer") {
sources = [ "dns/dns_query_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
executable("dns_util_fuzzer") {
sources = [ "dns/dns_util_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
executable("firewall_fuzzer") {
sources = [ "firewall_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
executable("multicast_forwarder_fuzzer") {
sources = [ "multicast_forwarder_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
"//common-mk:test",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
pkg_deps = [ "libchrome-test" ]
}
executable("ndproxy_fuzzer") {
sources = [ "ndproxy_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
executable("net_util_fuzzer") {
sources = [ "net_util_fuzzer.cc" ]
configs += [
"//common-mk/common_fuzzer",
":target_defaults",
":fuzzing_config",
]
deps = [ ":libpatchpanel" ]
}
}
if (use.test) {
pkg_config("test_config") {
pkg_deps = [ "libchrome-test" ]
}
executable("patchpanel_testrunner") {
run_test = true
sources = [
"address_manager_test.cc",
"arc_service_test.cc",
"clat_service_test.cc",
"connmark_updater_test.cc",
"conntrack_monitor_test.cc",
"counters_service_test.cc",
"crostini_service_test.cc",
"datapath_test.cc",
"dhcp_server_controller_test.cc",
"dns/dns_query_test.cc",
"dns/dns_response_test.cc",
"downstream_network_info_test.cc",
"downstream_network_service_test.cc",
"firewall_test.cc",
"guest_ipv6_service_test.cc",
"lifeline_fd_service_test.cc",
"mac_address_generator_test.cc",
"manager_test.cc",
"minijailed_process_runner_test.cc",
"mock_connmark_updater.cc",
"mock_conntrack_monitor.cc",
"mock_counters_service.cc",
"mock_datapath.cc",
"mock_guest_ipv6_service.cc",
"mock_lifeline_fd_service.cc",
"mock_multicast_counters_service.cc",
"mock_process_runner.cc",
"mock_routing_service.cc",
"mock_rtnl_client.cc",
"mock_system.cc",
"mock_vm_concierge_client.cc",
"multicast_counters_service_test.cc",
"multicast_metrics_test.cc",
"ndproxy_test.cc",
"net_util_test.cc",
"network/address_service_test.cc",
"network/mock_address_service.cc",
"network/mock_network_applier.cc",
"network/mock_routing_policy_service.cc",
"network/mock_routing_table.cc",
"network/network_applier_test.cc",
"network/routing_policy_service_test.cc",
"network/routing_table_test.cc",
"network_monitor_service_test.cc",
"noop_subprocess_controller.cc",
"proto_utils_test.cc",
"qos_service_test.cc",
"routing_service_test.cc",
"shill_client_test.cc",
"socket_service_adaptor_test.cc",
"subnet_pool_test.cc",
"subnet_test.cc",
"subprocess_controller_test.cc",
"system_test.cc",
"testrunner.cc",
"vm_concierge_client_test.cc",
]
configs += [
"//common-mk:test",
":target_defaults",
":test_config",
]
# Workaround for b/266863330: disable PCH when the user generates
# compilation database for an editor.
if (!use.compdb_only && !use.compilation_database) {
precompiled_header = "pch/pch_test.h"
precompiled_source = "pch/pch_test.h"
}
defines = [ "UNIT_TEST" ]
deps = [
":libpatchpanel",
"//common-mk/testrunner",
]
pkg_deps = [ "libnet-base-test" ]
}
}