diff --git a/omnibus/package-scripts/agent-rpm/prerm b/omnibus/package-scripts/agent-rpm/prerm index 44a8c5398ca53c..520cb64c33e012 100755 --- a/omnibus/package-scripts/agent-rpm/prerm +++ b/omnibus/package-scripts/agent-rpm/prerm @@ -115,11 +115,6 @@ remove_sysprobe_secagent_files() if [ -d "$INSTALL_DIR/run" ]; then rmdir "$INSTALL_DIR/run" 2>/dev/null || true fi - - # Remove any unpacked BTF files - find "$INSTALL_DIR/embedded/share/system-probe/ebpf/co-re/btf" -name "*.btf*" -type f -delete || true - # And remove empty directories - find "$INSTALL_DIR/embedded/share/system-probe/ebpf/co-re" -type d -empty -delete || true } remove_remote_config_db() diff --git a/pkg/ebpf/c/bpf_metadata.h b/pkg/ebpf/c/bpf_metadata.h deleted file mode 100644 index ad7162404feca2..00000000000000 --- a/pkg/ebpf/c/bpf_metadata.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This header file is included in kconfig.h and ktypes.h, which should make - * this metadata available to all object files. - */ - -#ifndef __BPF_METADATA_H__ -#define __BPF_METADATA_H__ - -#ifndef __CGO__ // Do not include metadata in CGo builds, as it causes duplicate symbols -#if defined(__x86_64__) || defined(__TARGET_ARCH_x86) -char __dd_metadata_arch[] __attribute__((section("dd_metadata"), used)) = ""; -#elif defined(__aarch64__) || defined(__TARGET_ARCH_arm64) -char __dd_metadata_arch[] __attribute__((section("dd_metadata"), used)) = ""; -#else -char __dd_metadata_arch[] __attribute__((section("dd_metadata"), used)) = ""; -#endif -#endif - -#endif diff --git a/pkg/ebpf/c/kconfig.h b/pkg/ebpf/c/kconfig.h index a5a186d9404530..c93f500eb7d09c 100644 --- a/pkg/ebpf/c/kconfig.h +++ b/pkg/ebpf/c/kconfig.h @@ -1,8 +1,6 @@ #ifndef __KCONFIG_H #define __KCONFIG_H -#include "bpf_metadata.h" - #include // include asm/compiler.h to fix `error: expected string literal in 'asm'` compilation error coming from mte-kasan.h // this was fixed in https://github.com/torvalds/linux/commit/b859ebedd1e730bbda69142fca87af4e712649a1 diff --git a/pkg/ebpf/c/ktypes.h b/pkg/ebpf/c/ktypes.h index 0daf39816bc366..de243a94a5a9a9 100644 --- a/pkg/ebpf/c/ktypes.h +++ b/pkg/ebpf/c/ktypes.h @@ -1,8 +1,6 @@ #ifndef __KTYPES_H__ #define __KTYPES_H__ -#include "bpf_metadata.h" - #ifdef COMPILE_CORE #include "vmlinux.h" #else diff --git a/tasks/libs/common/utils.py b/tasks/libs/common/utils.py index 3ab39b06f57e83..9a477f51aafe9d 100644 --- a/tasks/libs/common/utils.py +++ b/tasks/libs/common/utils.py @@ -261,7 +261,6 @@ def get_build_flags( env['CGO_LDFLAGS'] = os.environ.get('CGO_LDFLAGS', '') + ' -Wl,--allow-multiple-definition' extra_cgo_flags = " -Werror -Wno-deprecated-declarations" - extra_cgo_flags += " -D__CGO__" # Some C files include definitions that can cause duplicate symbols if included in CGo code (bpf_metadata.h) mainly if rtloader_headers: extra_cgo_flags += f" -I{rtloader_headers}" if rtloader_common_headers: diff --git a/test/new-e2e/tests/agent-platform/common/agent_behaviour.go b/test/new-e2e/tests/agent-platform/common/agent_behaviour.go index dfb29e58a47074..4ea8eae34c3c97 100644 --- a/test/new-e2e/tests/agent-platform/common/agent_behaviour.go +++ b/test/new-e2e/tests/agent-platform/common/agent_behaviour.go @@ -15,11 +15,10 @@ import ( componentos "github.com/DataDog/test-infra-definitions/components/os" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - agentclient "github.com/DataDog/datadog-agent/test/new-e2e/pkg/utils/e2e/client/agentclient" boundport "github.com/DataDog/datadog-agent/test/new-e2e/tests/agent-platform/common/bound-port" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // CheckAgentBehaviour runs test to check the agent is behaving as expected @@ -320,53 +319,3 @@ func CheckCWSBehaviour(t *testing.T, client *TestClient) { require.True(tt, result, "system-probe and security-agent should communicate") }) } - -// CheckSystemProbeBehavior runs tests to check the agent behave correctly when system-probe is enabled -func CheckSystemProbeBehavior(t *testing.T, client *TestClient) { - t.Run("enable system-probe and restarts", func(tt *testing.T) { - err := client.SetConfig(client.Helper.GetConfigFolder()+"system-probe.yaml", "system_probe_config.enabled", "true") - require.NoError(tt, err) - - err = client.SetConfig(client.Helper.GetConfigFolder()+"system-probe.yaml", "system_probe_config.enabled", "true") - require.NoError(tt, err) - - _, err = client.SvcManager.Restart(client.Helper.GetServiceName()) - require.NoError(tt, err, "datadog-agent should restart after CWS is enabled") - }) - - t.Run("system-probe is running", func(tt *testing.T) { - var err error - require.Eventually(tt, func() bool { - return AgentProcessIsRunning(client, "system-probe") - }, 1*time.Minute, 500*time.Millisecond, "system-probe should be running ", err) - }) - - t.Run("ebpf programs are unpacked and valid", func(tt *testing.T) { - ebpfPath := "/opt/datadog-agent/embedded/share/system-probe/ebpf" - output, err := client.Host.Execute(fmt.Sprintf("find %s -name '*.o'", ebpfPath)) - require.NoError(tt, err) - files := strings.Split(strings.TrimSpace(output), "\n") - require.Greater(tt, len(files), 0, "ebpf object files should be present") - - _, err = client.Host.Execute("command -v readelf") - if err != nil { - tt.Skip("readelf is not available on the host") - return - } - - hostArch, err := client.Host.Execute("uname -m") - require.NoError(tt, err) - hostArch = strings.TrimSpace(hostArch) - if hostArch == "aarch64" { - hostArch = "arm64" - } - archMetadata := fmt.Sprintf("", hostArch) - - for _, file := range files { - file = strings.TrimSpace(file) - ddMetadata, err := client.Host.Execute(fmt.Sprintf("readelf -p dd_metadata %s", file)) - require.NoError(tt, err, "readelf should not error, file is %s", file) - require.Contains(tt, ddMetadata, archMetadata, "invalid arch metadata") - } - }) -} diff --git a/test/new-e2e/tests/agent-platform/install-script/install_script_test.go b/test/new-e2e/tests/agent-platform/install-script/install_script_test.go index 56ab93a12a7c66..89fc4a9ba9b38a 100644 --- a/test/new-e2e/tests/agent-platform/install-script/install_script_test.go +++ b/test/new-e2e/tests/agent-platform/install-script/install_script_test.go @@ -136,11 +136,8 @@ func (is *installScriptSuite) AgentTest(flavor string) { common.CheckAgentPython(is.T(), client, common.ExpectedPythonVersion3) common.CheckApmEnabled(is.T(), client) common.CheckApmDisabled(is.T(), client) - if flavor == "datadog-agent" { - common.CheckSystemProbeBehavior(is.T(), client) - if is.cwsSupported { - common.CheckCWSBehaviour(is.T(), client) - } + if flavor == "datadog-agent" && is.cwsSupported { + common.CheckCWSBehaviour(is.T(), client) } common.CheckInstallationInstallScript(is.T(), client) is.testUninstall(client, flavor) diff --git a/test/new-e2e/tests/agent-platform/step-by-step/step_by_step_test.go b/test/new-e2e/tests/agent-platform/step-by-step/step_by_step_test.go index 6a7dd091427ec2..9e8a690024ed60 100644 --- a/test/new-e2e/tests/agent-platform/step-by-step/step_by_step_test.go +++ b/test/new-e2e/tests/agent-platform/step-by-step/step_by_step_test.go @@ -160,11 +160,8 @@ func (is *stepByStepSuite) CheckStepByStepAgentInstallation(VMclient *common.Tes } common.CheckApmEnabled(is.T(), VMclient) common.CheckApmDisabled(is.T(), VMclient) - if *flavorName == "datadog-agent" { - common.CheckSystemProbeBehavior(is.T(), VMclient) - if is.cwsSupported { - common.CheckCWSBehaviour(is.T(), VMclient) - } + if *flavorName == "datadog-agent" && is.cwsSupported { + common.CheckCWSBehaviour(is.T(), VMclient) } is.T().Run("remove the agent", func(tt *testing.T) {