Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up order of includes #2015

Merged
merged 18 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update sort
Signed-off-by: Dave Thaler <dthaler@microsoft.com>
  • Loading branch information
dthaler committed Feb 3, 2023
commit abb3b57dc4d2fcee3f6d96c79202705a5eaf022c
21 changes: 12 additions & 9 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ BinPackParameters: false
BreakBeforeBraces: Mozilla
#
# Special include file sort ordering rules.
# Priority indicates the "group" (where groups are separated by a blank line).
# SortPriority indicates the order within a group when we need to override alphabetical
# order due to Windows header dependencies.
SortIncludes: 'true'
IncludeBlocks: Regroup
IncludeIsMainRegex: "UNUSED$"
IncludeCategories:
- Regex: '^"'
Priority: 1
# winsock2.h must be before in6addr.h or windows.h
- Regex: '^<[Ww]insock2.h>'
Priority: 2
Expand All @@ -36,18 +37,20 @@ IncludeCategories:
# windows.h must be before ElfWrapper.h or netsh.h
- Regex: '^<[Ww]indows.h>'
Priority: 2
SortPriority: 2
SortPriority: 3
# ws2def.h and ws2ipdef.h must be before iphlpapi.h
- Regex: '^<(ws2def|ws2ipdef).h>'
Priority: 2
SortPriority: 2
- Regex: '^<ElfWrapper.h>'
Priority: 2
SortPriority: 3
- Regex: '^(<|")ElfWrapper.h'
Priority: 2
SortPriority: 4
# ntifs.h must be before ntddk.h
- Regex: '^<ntifs.h>'
- Regex: '^<ntifs.h'
Priority: 2
SortPriority: 3
SortPriority: 4
- Regex: '^"'
Priority: 1
- Regex: '^<'
Priority: 2
SortPriority: 4
SortPriority: 5
7 changes: 5 additions & 2 deletions ebpfapi/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT

// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
/**
* @file
* @brief Defines the entry point for the DLL application.
*/
#include "api_internal.h"
#include "framework.h"

bool use_ebpf_store = true;

Expand Down
18 changes: 0 additions & 18 deletions ebpfapi/pch.h

This file was deleted.

1 change: 0 additions & 1 deletion ebpfapi/rpc_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// the behavior of other Windows headers.
#include <winsock2.h>
#include <windows.h>

#include <ctype.h>
#include <iostream>
#include <sddl.h>
Expand Down
2 changes: 1 addition & 1 deletion include/bpf/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ bpf_prog_load(

#else
#pragma warning(push)
#include "libbpf/src/bpf.h"
#include "bpf_legacy.h"
#include "libbpf/src/bpf.h"
#pragma warning(pop)
#endif
2 changes: 1 addition & 1 deletion include/bpf_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// this version of bpf_helpers.h is already cross-platform.

// Include platform-specific definitions.
#include "ebpf_structs.h"
#include "bpf_helpers_platform.h"
#include "ebpf_structs.h"

// If we're compiling an actual eBPF program, then include
// libbpf's bpf_helpers.h for the rest of the platform-agnostic
Expand Down
5 changes: 3 additions & 2 deletions include/linux/bpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
//! This file should be thought of as platform/bpf.h not Linux-specific per se.
//! It is needed under this path though since the Libbpf bpf.h includes it as such.

#include <stdint.h>
#include "ebpf_structs.h"

#include <stdint.h>

#ifdef _MSC_VER
// This file is being included by a user-mode Windows application.
#include "ebpf_program_types.h"
#include "ebpf_api.h"
#include "ebpf_program_types.h"
#define LIBBPF_API
#include "libbpf/src/libbpf_common.h"
#undef LIBBPF_DEPRECATED
Expand Down
2 changes: 1 addition & 1 deletion include/user/ebpf_registry_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#pragma once

#include "ebpf_platform.h"
#include "ebpf_api.h"
#include "ebpf_platform.h"
#include "platform.h"

#define __return_type uint32_t
Expand Down
4 changes: 2 additions & 2 deletions libs/api/Verifier.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT

#include "Verifier.h"
#include "api_common.hpp"
#include "api_internal.h"
#include "ebpf_api.h"
#include "ebpf_platform.h"
#include "ebpf_program_types.h"
#include "ebpf_verifier_wrapper.hpp"
#include "elfio_wrapper.hpp"
#include "ElfWrapper.h"
#include "platform.hpp"
#include "windows_platform.hpp"
#include "windows_platform_common.hpp"
#include "Verifier.h"

#include <ElfWrapper.h>
#include <filesystem>
#include <iostream>
#include <sstream>
Expand Down
6 changes: 3 additions & 3 deletions libs/api/bpf_syscall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT
#include "bpf.h"
#include "libbpf.h"

#include <linux/bpf.h>

#define CHECK_SIZE(last_field_name) \
Expand Down Expand Up @@ -58,8 +59,7 @@ bpf(int cmd, union bpf_attr* attr, unsigned int size)
return bpf_obj_get((const char*)attr->pathname);
case BPF_PROG_ATTACH: {
CHECK_SIZE(attach_flags);
return bpf_prog_attach(
attr->attach_bpf_fd, attr->target_fd, attr->attach_type, attr->attach_flags);
return bpf_prog_attach(attr->attach_bpf_fd, attr->target_fd, attr->attach_type, attr->attach_flags);
}
case BPF_PROG_DETACH: {
CHECK_SIZE(attach_type);
Expand Down Expand Up @@ -123,4 +123,4 @@ bpf(int cmd, union bpf_attr* attr, unsigned int size)
errno = EINVAL;
return -1;
}
}
}
3 changes: 1 addition & 2 deletions libs/api/ebpf_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
#include "map_descriptors.hpp"
#define _PEPARSE_WINDOWS_CONFLICTS
#include "pe-parse/parse.h"

#include "rpc_client.h"
extern "C"
{
#include "ubpf.h"
}
#include "utilities.hpp"
#include "Verifier.h"
#include "utilities.hpp"
#include "windows_platform_common.hpp"

#include <codecvt>
Expand Down
3 changes: 2 additions & 1 deletion libs/api/rpc_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#pragma once

#include <rpc.h>
#include "rpc_interface_h.h"

#include <rpc.h>

RPC_STATUS
initialize_rpc_binding(void);

Expand Down
2 changes: 1 addition & 1 deletion libs/api/windows_platform.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT

#include "api_common.hpp"
#include "api_internal.h"
#include "crab_verifier_wrapper.hpp"
#include "api_common.hpp"
#include "ebpf_api.h"
#include "helpers.hpp"
#include "map_descriptors.hpp"
Expand Down
2 changes: 1 addition & 1 deletion libs/api_common/windows_platform_common.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT

#include "api_internal.h"
#include "api_common.hpp"
#include "api_internal.h"
#include "crab_verifier_wrapper.hpp"
#include "device_helper.hpp"
#include "ebpf_api.h"
Expand Down
2 changes: 1 addition & 1 deletion libs/api_common/windows_program_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#pragma once

#include "crab_verifier_wrapper.hpp"
#include "ebpf_program_types.h"
#include "ebpf_nethooks.h"
#include "ebpf_program_types.h"
#include "net_ebpf_ext_program_info.h"
#include "sample_ext_helpers.h"
#include "sample_ext_program_info.h"
Expand Down
16 changes: 8 additions & 8 deletions libs/ebpfnetsh/links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
// SPDX-License-Identifier: MIT

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#include <iostream>
#include <iomanip>
#include <netsh.h>
#include <string>
#include <vector>
#include "bpf/bpf.h"
#include "bpf/libbpf.h"
#include "ebpf_api.h"
#include "ebpf_windows.h"
#include "platform.h"
#include "links.h"
#include "platform.h"
#include "tokens.h"

#include <windows.h>
#include <iomanip>
#include <iostream>
#include <netsh.h>
#include <string>
#include <vector>

DWORD
handle_ebpf_show_links(
LPCWSTR machine, LPWSTR* argv, DWORD current_index, DWORD argc, DWORD flags, LPCVOID data, BOOL* done)
Expand Down
4 changes: 2 additions & 2 deletions libs/ebpfnetsh/maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include "bpf/libbpf.h"
#include "ebpf_api.h"
#include "ebpf_windows.h"
#include "platform.h"
#include "maps.h"
#include "platform.h"
#include "tokens.h"

#include <iostream>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion libs/ebpfnetsh/pins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
#include "platform.h"
#include "tokens.h"

#include <iostream>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion libs/execution_context/ebpf_core.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT

#include <errno.h>
#include "ebpf_async.h"
#include "ebpf_core.h"
#include "ebpf_epoch.h"
Expand All @@ -15,6 +14,8 @@
#include "ebpf_serialize.h"
#include "ebpf_state.h"

#include <errno.h>

GUID ebpf_program_information_extension_interface_id;
GUID ebpf_hook_extension_interface_id;

Expand Down
2 changes: 1 addition & 1 deletion libs/execution_context/ebpf_maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#pragma once

#include "ebpf_core_structs.h"
#include "bpf_helpers.h"
#include "ebpf_core_structs.h"
#include "ebpf_platform.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion libs/execution_context/ebpf_native.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#pragma once

#include "bpf2c.h"
#include "ebpf_core_structs.h"
#include "ebpf_maps.h"
#include "bpf2c.h"

#ifdef __cplusplus
extern "C"
Expand Down
8 changes: 4 additions & 4 deletions libs/execution_context/unit/execution_context_unit_test.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MIT

#include <set>

#include <optional>
#include "catch_wrapper.hpp"
#include "ebpf_async.h"
#include "ebpf_ring_buffer.h"
#include "ebpf_core.h"
#include "ebpf_maps.h"
#include "ebpf_object.h"
#include "ebpf_program.h"
#include "ebpf_ring_buffer.h"
#include "helpers.h"

#include <optional>
#include <set>

#define PAGE_SIZE 4096

typedef class _ebpf_async_wrapper
Expand Down
1 change: 1 addition & 0 deletions libs/platform/ebpf_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ebpf_structs.h"
#include "ebpf_windows.h"
#include "framework.h"

#include <TraceLoggingProvider.h>
#include <winmeta.h>

Expand Down
2 changes: 1 addition & 1 deletion libs/platform/kernel/framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <ntintsafe.h>
#pragma warning(pop)
#include <ntifs.h> // Must be before ntddk.h
#include <ntddk.h>
#include <netioddk.h>
#include <ntddk.h>
#include <stdint.h>
#include <wdm.h>

Expand Down
3 changes: 1 addition & 2 deletions libs/platform/unit/platform_unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@
// headers.
#include <winsock2.h>
#include <Windows.h>

#include <chrono>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <sddl.h>
#include <thread>

extern ebpf_helper_function_prototype_t* ebpf_core_helper_function_prototype;
extern uint32_t ebpf_core_helper_functions_count;
Expand Down
2 changes: 1 addition & 1 deletion libs/platform/user/ebpf_handle_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ebpf_handle_table_terminate()
}

_Must_inspect_result_ ebpf_result_t
ebpf_handle_create(_Out_ ebpf_handle_t* handle, _Inout_ ebpf_base_object_t* object)
ebpf_handle_create(_Out_ ebpf_handle_t* handle, _Inout_ ebpf_base_object_t* object)
{
EBPF_LOG_ENTRY();
ebpf_handle_t new_handle;
Expand Down
Loading