diff --git a/include/bpf2c.h b/include/bpf2c.h index 8caa89bae9..a88fe1035e 100644 --- a/include/bpf2c.h +++ b/include/bpf2c.h @@ -108,6 +108,23 @@ extern "C" helper_function_t address; } btf_resolved_function_data_t; + /** + * @brief Stable map definition embedded in native module metadata. + * + * New native map properties must be added to map_entry_t instead of this structure. + */ + typedef struct _ebpf_native_map_definition + { + ebpf_map_type_t type; + uint32_t key_size; + uint32_t value_size; + uint32_t max_entries; + uint32_t inner_map_idx; + ebpf_pin_type_t pinning; + uint32_t id; + uint32_t inner_id; + } ebpf_native_map_definition_t; + /** * @brief Map entry. * This structure contains the address of the map and the map definition. The address is written into the entry @@ -121,8 +138,9 @@ extern "C" uint64_t zero_marker[2]; ebpf_native_module_header_t header; - ebpf_map_definition_in_file_t definition; + ebpf_native_map_definition_t definition; const char* name; + uint32_t map_flags; } map_entry_t; typedef struct _map_data @@ -311,7 +329,7 @@ extern "C" EBPF_NATIVE_BTF_RESOLVED_FUNCTION_DATA_CURRENT_VERSION_TOTAL_SIZE} #define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION 1 -#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_entry_t, name) +#define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE EBPF_SIZE_INCLUDING_FIELD(map_entry_t, map_flags) #define EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_TOTAL_SIZE sizeof(map_entry_t) #define EBPF_NATIVE_MAP_ENTRY_HEADER \ {EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION, \ diff --git a/include/ebpf_core_structs.h b/include/ebpf_core_structs.h index ffc0b3a1ec..d1caf96c0c 100644 --- a/include/ebpf_core_structs.h +++ b/include/ebpf_core_structs.h @@ -17,9 +17,20 @@ /** * @brief eBPF Map Information */ +typedef struct _ebpf_map_info_definition +{ + ebpf_map_type_t type; + uint32_t key_size; + uint32_t value_size; + uint32_t max_entries; + ebpf_id_t inner_map_id; + ebpf_pin_type_t pinning; +} ebpf_map_info_definition_t; + typedef struct _ebpf_map_info { - ebpf_map_definition_in_memory_t definition; + // This definition must remain ABI-compatible with clients built before map_flags was added. + ebpf_map_info_definition_t definition; _Field_z_ char* pin_path; } ebpf_map_info_t; diff --git a/include/ebpf_structs.h b/include/ebpf_structs.h index 8bf09a2fcf..1ab181f6e7 100644 --- a/include/ebpf_structs.h +++ b/include/ebpf_structs.h @@ -106,6 +106,9 @@ static const char* const _ebpf_pin_type_names[] = { typedef uint32_t ebpf_id_t; #define EBPF_ID_NONE 0 +/// Do not enforce max_entries limit on hash maps. +#define BPF_F_NO_MAX_ENTRIES 1 + /** * @brief eBPF Map Definition as it is stored in memory. */ @@ -117,6 +120,7 @@ typedef struct _ebpf_map_definition_in_memory uint32_t max_entries; ///< Maximum number of entries allowed in the map. ebpf_id_t inner_map_id; ebpf_pin_type_t pinning; + uint32_t map_flags; ///< Map flags (e.g., BPF_F_NO_MAX_ENTRIES). } ebpf_map_definition_in_memory_t; /** @@ -142,6 +146,7 @@ typedef struct _ebpf_map_definition_in_file /** For a map of map, inner_id is the id of the inner map template. */ uint32_t inner_id; + uint32_t map_flags; ///< Map creation flags. } ebpf_map_definition_in_file_t; typedef enum diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 5ac107290e..d484a8fd0a 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -94,7 +94,7 @@ typedef struct uint32_t key_size; ///< Size in bytes of keys. uint32_t value_size; ///< Size in bytes of values. uint32_t max_entries; ///< Maximum number of entries in the map. - uint32_t map_flags; ///< Not supported, must be zero. + uint32_t map_flags; ///< Map flags. Supported: BPF_F_NO_MAX_ENTRIES. uint32_t inner_map_fd; ///< File descriptor of inner map. uint32_t numa_node; ///< Not supported, must be zero. char map_name[SYS_BPF_OBJ_NAME_LEN]; ///< Map name. diff --git a/libs/api/Verifier.cpp b/libs/api/Verifier.cpp index dbdc402048..9901143f8e 100644 --- a/libs/api/Verifier.cpp +++ b/libs/api/Verifier.cpp @@ -172,23 +172,24 @@ typedef struct _section_offset_to_map string map_name; } section_offset_to_map_t; -static ebpf_pin_type_t -_get_pin_type_for_btf_map(const libbtf::btf_type_data& btf_data, libbtf::btf_type_id id) +static uint32_t +_get_uint_value_for_btf_map( + const libbtf::btf_type_data& btf_data, libbtf::btf_type_id id, const char* member_name, uint32_t default_value) { auto map_struct = btf_data.get_kind_type(id); for (const auto& member : map_struct.members) { - if (member.name == "pinning") { + if (member.name == member_name) { // This should use value_from_BTF__uint from btf_parser.cpp, but it's static. - auto pinning_type_id = member.type; + auto value_type_id = member.type; // Dereference the pointer type. - pinning_type_id = btf_data.dereference_pointer(pinning_type_id); + value_type_id = btf_data.dereference_pointer(value_type_id); // Get the array type. - auto pinning_type = btf_data.get_kind_type(pinning_type_id); + auto value_type = btf_data.get_kind_type(value_type_id); // Value is encoded as the number of elements in the array. - return static_cast(pinning_type.count_of_elements); + return value_type.count_of_elements; } } - return LIBBPF_PIN_NONE; + return default_value; } /** @@ -284,7 +285,9 @@ _parse_btf_map_info_and_populate_cache(const ELFIO::elfio& reader, const vector< int btf_type_id = btf_map_descriptor.original_fd; int btf_inner_type_id = btf_map_descriptor.inner_map_fd; - auto pin_type = _get_pin_type_for_btf_map(btf_data.value(), btf_type_id); + auto pin_type = static_cast( + _get_uint_value_for_btf_map(btf_data.value(), btf_type_id, "pinning", LIBBPF_PIN_NONE)); + auto map_flags = _get_uint_value_for_btf_map(btf_data.value(), btf_type_id, "map_flags", 0); cache_map_handle( ebpf_handle_invalid, map_idx_to_original_fd(idx), @@ -293,6 +296,7 @@ _parse_btf_map_info_and_populate_cache(const ELFIO::elfio& reader, const vector< btf_map_descriptor.key_size, btf_map_descriptor.value_size, btf_map_descriptor.max_entries, + map_flags, (uint32_t)ebpf_fd_invalid, btf_inner_type_id, entry.section_offset, @@ -308,7 +312,9 @@ _parse_btf_map_info_and_populate_cache(const ELFIO::elfio& reader, const vector< int btf_type_id = btf_map_descriptor.original_fd; int btf_inner_type_id = btf_map_descriptor.inner_map_fd; - auto pin_type = _get_pin_type_for_btf_map(btf_data.value(), btf_type_id); + auto pin_type = static_cast( + _get_uint_value_for_btf_map(btf_data.value(), btf_type_id, "pinning", LIBBPF_PIN_NONE)); + auto map_flags = _get_uint_value_for_btf_map(btf_data.value(), btf_type_id, "map_flags", 0); cache_map_handle( ebpf_handle_invalid, map_idx_to_original_fd(idx), @@ -317,6 +323,7 @@ _parse_btf_map_info_and_populate_cache(const ELFIO::elfio& reader, const vector< btf_map_descriptor.key_size, btf_map_descriptor.value_size, btf_map_descriptor.max_entries, + map_flags, (uint32_t)ebpf_fd_invalid, btf_inner_type_id, MAXSIZE_T, diff --git a/libs/api/ebpf_api.cpp b/libs/api/ebpf_api.cpp index a62ed93137..846afea4f9 100644 --- a/libs/api/ebpf_api.cpp +++ b/libs/api/ebpf_api.cpp @@ -10,6 +10,7 @@ #include "bpf2c.h" #include "device_helper.hpp" #include "ebpf_api.h" +#include "ebpf_native_structs.h" #include "ebpf_protocol.h" #include "ebpf_ring_buffer_record.h" #include "ebpf_serialize.h" @@ -377,7 +378,8 @@ ebpf_map_create( ebpf_assert(map_fd); - if (opts && (opts->map_flags != 0 || opts->numa_node != 0 || opts->map_ifindex != 0)) { + if (opts && + ((opts->map_flags & ~(uint32_t)BPF_F_NO_MAX_ENTRIES) != 0 || opts->numa_node != 0 || opts->map_ifindex != 0)) { result = EBPF_INVALID_ARGUMENT; goto Exit; } @@ -388,6 +390,7 @@ ebpf_map_create( map_definition.key_size = key_size; map_definition.value_size = value_size; map_definition.max_entries = max_entries; + map_definition.map_flags = opts ? opts->map_flags : 0; // bpf_map_create_opts has inner_map_fd defined as __u32, so it cannot be set to // ebpf_fd_invalid (-1). Hence treat inner_map_fd = 0 as ebpf_fd_invalid. @@ -2531,6 +2534,7 @@ initialize_map(_Out_ ebpf_map_t* map, _In_ const map_cache_t& map_cache) noexcep map->map_definition.value_size = map_cache.verifier_map_descriptor.value_size; map->map_definition.max_entries = map_cache.verifier_map_descriptor.max_entries; map->map_definition.pinning = map_cache.pinning; + map->map_definition.map_flags = map_cache.map_flags; map->map_id = map_cache.id; map->map_definition.inner_map_id = map_cache.inner_id; map->inner_map_original_fd = map_cache.verifier_map_descriptor.inner_map_fd; @@ -2571,6 +2575,7 @@ _initialize_ebpf_maps_native( ebpf_assert(map->map_definition.key_size == info.key_size); ebpf_assert(map->map_definition.value_size == info.value_size); ebpf_assert(map->map_definition.max_entries == info.max_entries); + ebpf_assert(map->map_definition.map_flags == info.map_flags); map->map_definition.inner_map_id = info.inner_map_id; map->map_fd = _create_file_descriptor_for_handle(map_handles[i]); @@ -3056,16 +3061,27 @@ _ebpf_pe_get_map_definitions( map_offset += 8; } if (pe_context->object != nullptr) { - for (int map_index = 0; map_offset + sizeof(map_entry_t) <= section_header.Misc.VirtualSize; - map_offset += sizeof(map_entry_t), map_index++) { - map_entry_t* entry = (map_entry_t*)(buffer->buf + map_offset); - if (entry->zero_marker[0] != 0 || entry->zero_marker[1] != 0) { + for (int map_index = 0; + map_offset + EBPF_OFFSET_OF(map_entry_t, header) + sizeof(ebpf_native_module_header_t) <= + section_header.Misc.VirtualSize; + map_index++) { + const map_entry_t* source_entry = (const map_entry_t*)(buffer->buf + map_offset); + if (source_entry->zero_marker[0] != 0 || source_entry->zero_marker[1] != 0) { // bpf2c generates a section that has map names longer than sizeof(map_entry_t) // at the end of the section. This entry seems to be a map name string, so we've // reached the end of the maps. break; } + map_entry_t normalized_entry = {}; + if (source_entry->header.total_size > section_header.Misc.VirtualSize - map_offset || + !ebpf_native_map_entry_to_current(&normalized_entry, source_entry)) { + pe_context->result = EBPF_INVALID_OBJECT; + goto Error; + } + map_offset += (uint32_t)source_entry->header.total_size; + const map_entry_t* entry = &normalized_entry; + map = (ebpf_map_t*)ebpf_allocate_with_tag(sizeof(ebpf_map_t), EBPF_POOL_TAG_DEFAULT); if (map == nullptr) { goto Error; @@ -3079,6 +3095,7 @@ _ebpf_pe_get_map_definitions( map->map_definition.max_entries = entry->definition.max_entries; map->map_definition.pinning = entry->definition.pinning; map->map_definition.inner_map_id = entry->definition.inner_id; + map->map_definition.map_flags = entry->map_flags; map->inner_map_original_fd = map_idx_to_original_fd(entry->definition.inner_map_idx); map->pinned = false; map->reused = false; @@ -3586,7 +3603,8 @@ _ebpf_validate_map(_In_ const ebpf_map_t* map, fd_t original_map_fd) NO_EXCEPT_T } if (info.type != map->map_definition.type || info.key_size != map->map_definition.key_size || - info.value_size != map->map_definition.value_size || info.max_entries != map->map_definition.max_entries) { + info.value_size != map->map_definition.value_size || info.max_entries != map->map_definition.max_entries || + info.map_flags != map->map_definition.map_flags) { result = EBPF_INVALID_ARGUMENT; goto Exit; } diff --git a/libs/api/windows_platform.cpp b/libs/api/windows_platform.cpp index 486f814e11..0e69ec9eb5 100644 --- a/libs/api/windows_platform.cpp +++ b/libs/api/windows_platform.cpp @@ -57,6 +57,7 @@ _parse_maps_section_windows( s.key_size, s.value_size, s.max_entries, + s.map_flags, inner_map_original_fd, s.inner_id, section_offset, diff --git a/libs/api_common/api_common.hpp b/libs/api_common/api_common.hpp index f19ea0fa05..ddfb00df33 100644 --- a/libs/api_common/api_common.hpp +++ b/libs/api_common/api_common.hpp @@ -68,17 +68,18 @@ typedef struct _map_cache prevail::EbpfMapDescriptor verifier_map_descriptor; ebpf_pin_type_t pinning; uint32_t inner_id; + uint32_t map_flags; _map_cache() : handle(0), id(EBPF_ID_NONE), section_offset(0), verifier_map_descriptor(), pinning(LIBBPF_PIN_NONE), - inner_id(EBPF_ID_NONE) + inner_id(EBPF_ID_NONE), map_flags(0) { } _map_cache( ebpf_handle_t handle, size_t section_offset, prevail::EbpfMapDescriptor descriptor, ebpf_pin_type_t pinning) : handle(handle), id(EBPF_ID_NONE), section_offset(section_offset), verifier_map_descriptor(descriptor), - pinning(pinning), inner_id(EBPF_ID_NONE) + pinning(pinning), inner_id(EBPF_ID_NONE), map_flags(0) { } @@ -90,11 +91,12 @@ typedef struct _map_cache unsigned int key_size, unsigned int value_size, unsigned int max_entries, + uint32_t _map_flags, fd_t inner_map_original_fd, unsigned int _inner_id, size_t section_offset, ebpf_pin_type_t pinning) - : handle(handle), section_offset(section_offset), pinning(pinning) + : handle(handle), section_offset(section_offset), pinning(pinning), map_flags(_map_flags) { verifier_map_descriptor.original_fd = original_fd; verifier_map_descriptor.type = type; @@ -125,6 +127,7 @@ cache_map_handle( uint32_t key_size, uint32_t value_size, uint32_t max_entries, + uint32_t map_flags, uint32_t inner_map_original_fd, uint32_t inner_id, size_t section_offset, diff --git a/libs/api_common/map_descriptors.cpp b/libs/api_common/map_descriptors.cpp index 887c92240e..9db9641d75 100644 --- a/libs/api_common/map_descriptors.cpp +++ b/libs/api_common/map_descriptors.cpp @@ -98,6 +98,7 @@ cache_map_original_file_descriptor_with_handle( uint32_t key_size, uint32_t value_size, uint32_t max_entries, + uint32_t map_flags, uint32_t inner_map_original_fd, uint32_t inner_id, ebpf_handle_t handle, @@ -111,6 +112,7 @@ cache_map_original_file_descriptor_with_handle( key_size, value_size, max_entries, + map_flags, inner_map_original_fd, inner_id, section_offset, @@ -126,6 +128,7 @@ cache_map_handle( uint32_t key_size, uint32_t value_size, uint32_t max_entries, + uint32_t map_flags, uint32_t inner_map_original_fd, uint32_t inner_id, size_t section_offset, @@ -139,6 +142,7 @@ cache_map_handle( key_size, value_size, max_entries, + map_flags, inner_map_original_fd, (inner_id ? inner_id : EBPF_ID_NONE), section_offset, diff --git a/libs/api_common/map_descriptors.hpp b/libs/api_common/map_descriptors.hpp index 7b9485f05f..7c61bab540 100644 --- a/libs/api_common/map_descriptors.hpp +++ b/libs/api_common/map_descriptors.hpp @@ -25,6 +25,7 @@ cache_map_original_file_descriptor_with_handle( uint32_t key_size, uint32_t value_size, uint32_t max_entries, + uint32_t map_flags, uint32_t inner_map_original_fd, uint32_t inner_id, ebpf_handle_t handle, diff --git a/libs/execution_context/ebpf_maps.c b/libs/execution_context/ebpf_maps.c index 97453dd8d1..916a87386a 100644 --- a/libs/execution_context/ebpf_maps.c +++ b/libs/execution_context/ebpf_maps.c @@ -1274,8 +1274,17 @@ _create_hash_map( if (inner_map_handle != ebpf_handle_invalid) { return EBPF_INVALID_ARGUMENT; } + bool no_max_entries = (map_definition->map_flags & BPF_F_NO_MAX_ENTRIES) != 0; return _create_hash_map_internal( - sizeof(ebpf_core_map_t), map_definition, 0, 0, false, NULL, NULL, EBPF_HASH_TABLE_NOTIFICATION_TYPE_NONE, map); + sizeof(ebpf_core_map_t), + map_definition, + 0, + 0, + !no_max_entries, + NULL, + NULL, + EBPF_HASH_TABLE_NOTIFICATION_TYPE_NONE, + map); } static void @@ -1344,12 +1353,13 @@ _create_object_hash_map( *map = NULL; + bool no_max_entries = (map_definition->map_flags & BPF_F_NO_MAX_ENTRIES) != 0; result = _create_hash_map_internal( sizeof(ebpf_core_object_map_t), map_definition, actual_value_size, 0, - false, + !no_max_entries, NULL, NULL, EBPF_HASH_TABLE_NOTIFICATION_TYPE_NONE, @@ -2227,12 +2237,13 @@ _create_lpm_map( goto Exit; } + bool no_max_entries = (map_definition->map_flags & BPF_F_NO_MAX_ENTRIES) != 0; result = _create_hash_map_internal( lpm_data_size, map_definition, 0, 0, - false, + !no_max_entries, _lpm_extract, NULL, EBPF_HASH_TABLE_NOTIFICATION_TYPE_NONE, @@ -3793,6 +3804,21 @@ ebpf_map_create( goto Exit; } + // Validate map_flags. Only BPF_F_NO_MAX_ENTRIES is supported, and only for hash-based map types. + if (ebpf_map_definition->map_flags != 0) { + if (ebpf_map_definition->map_flags & ~(uint32_t)BPF_F_NO_MAX_ENTRIES) { + result = EBPF_INVALID_ARGUMENT; + goto Exit; + } + if (ebpf_map_definition->map_flags & BPF_F_NO_MAX_ENTRIES) { + if (type != BPF_MAP_TYPE_HASH && type != BPF_MAP_TYPE_PERCPU_HASH && type != BPF_MAP_TYPE_HASH_OF_MAPS && + type != BPF_MAP_TYPE_LPM_TRIE) { + result = EBPF_INVALID_ARGUMENT; + goto Exit; + } + } + } + const ebpf_map_metadata_table_properties_t* properties = _ebpf_map_metadata_table_query(type); if (properties == NULL) { @@ -4202,7 +4228,7 @@ ebpf_map_get_info( info->key_size = map->ebpf_map_definition.key_size; info->value_size = map->original_value_size; info->max_entries = map->ebpf_map_definition.max_entries; - info->map_flags = 0; + info->map_flags = map->ebpf_map_definition.map_flags; if (info->type == BPF_MAP_TYPE_ARRAY_OF_MAPS || info->type == BPF_MAP_TYPE_HASH_OF_MAPS) { ebpf_core_object_map_t* object_map = EBPF_FROM_FIELD(ebpf_core_object_map_t, core_map, map); info->inner_map_id = object_map->core_map.ebpf_map_definition.inner_map_id diff --git a/libs/execution_context/ebpf_native.c b/libs/execution_context/ebpf_native.c index 3df6a05ae1..3bf52bcefe 100644 --- a/libs/execution_context/ebpf_native.c +++ b/libs/execution_context/ebpf_native.c @@ -9,6 +9,7 @@ #include "ebpf_hash_table.h" #include "ebpf_maps.h" #include "ebpf_native.h" +#include "ebpf_native_structs.h" #include "ebpf_object.h" #include "ebpf_program.h" #include "ebpf_protocol.h" @@ -371,9 +372,10 @@ _ebpf_validate_native_program_entry_array( static bool _ebpf_validate_native_map_entry(_In_ const map_entry_t* native_map_entry) { + map_entry_t normalized_map_entry = {0}; + return ( - (native_map_entry != NULL) && ebpf_validate_object_header_native_map_entry(&native_map_entry->header) && - (native_map_entry->name != NULL)); + ebpf_native_map_entry_to_current(&normalized_map_entry, native_map_entry) && normalized_map_entry.name != NULL); } static bool @@ -1255,8 +1257,11 @@ _ebpf_native_initialize_maps( for (uint32_t i = 0; i < map_count; i++) { // Copy the map_entry_t from native module to ebpf_native_map_t. - map_entry_t* map_entry = (map_entry_t*)ARRAY_ELEMENT_INDEX(maps, i, map_entry_size); - memcpy(&native_maps[i].entry, map_entry, map_entry_size); + const void* map_entry = ARRAY_ELEMENT_INDEX(maps, i, map_entry_size); + if (!ebpf_native_map_entry_to_current(&native_maps[i].entry, map_entry)) { + result = EBPF_INVALID_ARGUMENT; + goto Done; + } map_entry_t* entry = &native_maps[i].entry; if (entry->definition.pinning != LIBBPF_PIN_NONE && entry->definition.pinning != LIBBPF_PIN_BY_NAME) { @@ -1299,14 +1304,14 @@ _ebpf_native_initialize_maps( // Populate inner map fd. for (uint32_t i = 0; i < map_count; i++) { - ebpf_map_definition_in_file_t* definition = &(native_maps[i].entry.definition); + ebpf_native_map_definition_t* definition = &(native_maps[i].entry.definition); int32_t inner_map_original_id = -1; if (_ebpf_native_is_map_in_map(&native_maps[i])) { if (definition->inner_map_idx != 0) { inner_map_original_id = definition->inner_map_idx + ORIGINAL_ID_OFFSET; } else if (definition->inner_id != 0) { for (uint32_t j = 0; j < map_count; j++) { - ebpf_map_definition_in_file_t* inner_definition = &(native_maps[j].entry.definition); + ebpf_native_map_definition_t* inner_definition = &(native_maps[j].entry.definition); if (inner_definition->id == definition->inner_id && i != j) { inner_map_original_id = j + ORIGINAL_ID_OFFSET; break; @@ -1341,7 +1346,8 @@ _ebpf_native_validate_map(_In_ const ebpf_native_map_t* map, ebpf_handle_t origi } if (info.type != map->entry.definition.type || info.key_size != map->entry.definition.key_size || - info.value_size != map->entry.definition.value_size || info.max_entries != map->entry.definition.max_entries) { + info.value_size != map->entry.definition.value_size || info.max_entries != map->entry.definition.max_entries || + info.map_flags != map->entry.map_flags) { result = EBPF_INVALID_ARGUMENT; goto Exit; } @@ -1654,6 +1660,7 @@ _ebpf_native_create_maps(_Inout_ ebpf_native_module_instance_t* instance) map_definition.key_size = native_map->entry.definition.key_size; map_definition.value_size = native_map->entry.definition.value_size; map_definition.max_entries = native_map->entry.definition.max_entries; + map_definition.map_flags = native_map->entry.map_flags; result = ebpf_core_create_map(&map_name, &map_definition, inner_map_handle, &native_map->handle); if (result != EBPF_SUCCESS) { diff --git a/libs/execution_context/unit/execution_context_unit_test.cpp b/libs/execution_context/unit/execution_context_unit_test.cpp index a986cedead..bc3d679032 100644 --- a/libs/execution_context/unit/execution_context_unit_test.cpp +++ b/libs/execution_context/unit/execution_context_unit_test.cpp @@ -3,13 +3,16 @@ #define EBPF_FILE_ID EBPF_FILE_ID_EXECUTION_CONTEXT_UNIT_TESTS +#include "bpf2c.h" #include "catch_wrapper.hpp" #include "ebpf_async.h" #include "ebpf_core.h" #include "ebpf_maps.h" +#include "ebpf_native_structs.h" #include "ebpf_object.h" #include "ebpf_program.h" #include "ebpf_ring_buffer.h" +#include "ebpf_shared_framework.h" #include "execution_context_unit_test_jit.h" #include "helpers.h" #include "test_helper.hpp" @@ -75,7 +78,7 @@ _test_crud_operations(ebpf_map_type_t map_type) case BPF_MAP_TYPE_HASH: is_array = false; supports_find_and_delete = true; - behavior_on_max_entries = MAP_BEHAVIOR_INSERT; + behavior_on_max_entries = MAP_BEHAVIOR_FAIL; run_at_dpc = false; error_on_full = EBPF_OUT_OF_SPACE; break; @@ -88,7 +91,7 @@ _test_crud_operations(ebpf_map_type_t map_type) case BPF_MAP_TYPE_PERCPU_HASH: is_array = false; supports_find_and_delete = true; - behavior_on_max_entries = MAP_BEHAVIOR_INSERT; + behavior_on_max_entries = MAP_BEHAVIOR_FAIL; run_at_dpc = true; error_on_full = EBPF_OUT_OF_SPACE; break; @@ -326,6 +329,99 @@ MAP_TEST(BPF_MAP_TYPE_PERCPU_ARRAY); MAP_TEST(BPF_MAP_TYPE_LRU_HASH); MAP_TEST(BPF_MAP_TYPE_LRU_PERCPU_HASH); +TEST_CASE("map_no_max_entries_flag", "[execution_context]") +{ + _ebpf_core_initializer core; + core.initialize(); + + // Create a hash map with BPF_F_NO_MAX_ENTRIES flag - should allow inserts beyond max_entries. + ebpf_map_definition_in_memory_t map_definition{ + BPF_MAP_TYPE_HASH, + sizeof(uint32_t), + sizeof(uint64_t), + _test_map_size, + 0, + LIBBPF_PIN_NONE, + BPF_F_NO_MAX_ENTRIES}; + map_ptr map; + { + ebpf_map_t* local_map; + cxplat_utf8_string_t map_name = {0}; + REQUIRE( + ebpf_map_create(&map_name, &map_definition, (uintptr_t)ebpf_handle_invalid, &local_map) == EBPF_SUCCESS); + map.reset(local_map); + } + std::vector value(ebpf_map_get_definition(map.get())->value_size); + + // Fill the map to max_entries. + for (uint32_t key = 0; key < _test_map_size; key++) { + *reinterpret_cast(value.data()) = static_cast(key) * static_cast(key); + REQUIRE( + ebpf_map_update_entry( + map.get(), + sizeof(key), + reinterpret_cast(&key), + value.size(), + value.data(), + EBPF_ANY, + 0) == EBPF_SUCCESS); + } + + // Insert beyond max_entries should succeed with BPF_F_NO_MAX_ENTRIES. + uint32_t extra_key = _test_map_size; + *reinterpret_cast(value.data()) = 0xdeadbeef; + REQUIRE( + ebpf_map_update_entry( + map.get(), + sizeof(extra_key), + reinterpret_cast(&extra_key), + value.size(), + value.data(), + EBPF_ANY, + 0) == EBPF_SUCCESS); + + // Verify the extra entry is present. + REQUIRE( + ebpf_map_find_entry( + map.get(), + sizeof(extra_key), + reinterpret_cast(&extra_key), + value.size(), + value.data(), + 0) == EBPF_SUCCESS); + REQUIRE(*reinterpret_cast(value.data()) == 0xdeadbeef); +} + +TEST_CASE("map_no_max_entries_flag_invalid_for_array", "[execution_context][negative]") +{ + _ebpf_core_initializer core; + core.initialize(); + + // BPF_F_NO_MAX_ENTRIES should be rejected for array maps. + ebpf_map_definition_in_memory_t map_definition{ + BPF_MAP_TYPE_ARRAY, sizeof(uint32_t), sizeof(uint64_t), 10, 0, LIBBPF_PIN_NONE, BPF_F_NO_MAX_ENTRIES}; + ebpf_map_t* local_map; + cxplat_utf8_string_t map_name = {0}; + REQUIRE( + ebpf_map_create(&map_name, &map_definition, (uintptr_t)ebpf_handle_invalid, &local_map) == + EBPF_INVALID_ARGUMENT); +} + +TEST_CASE("map_invalid_flags_rejected", "[execution_context][negative]") +{ + _ebpf_core_initializer core; + core.initialize(); + + // Unknown flags should be rejected. + ebpf_map_definition_in_memory_t map_definition{ + BPF_MAP_TYPE_HASH, sizeof(uint32_t), sizeof(uint64_t), 10, 0, LIBBPF_PIN_NONE, (1U << 14)}; + ebpf_map_t* local_map; + cxplat_utf8_string_t map_name = {0}; + REQUIRE( + ebpf_map_create(&map_name, &map_definition, (uintptr_t)ebpf_handle_invalid, &local_map) == + EBPF_INVALID_ARGUMENT); +} + TEST_CASE("map_create_invalid", "[execution_context][negative]") { _ebpf_core_initializer core; @@ -510,21 +606,21 @@ TEST_CASE("map_crud_operations_lpm_trie_32", "[execution_context]") CHECK(return_value == correct_value); } + lpm_trie_32_key_t extra_key = {32, 192, 168, 15, 1}; { // Insert a new key. - lpm_trie_32_key_t key = {32, 192, 168, 15, 1}; - std::string key_string = _ip32_prefix_string(key.prefix_length, key.value); + std::string key_string = _ip32_prefix_string(extra_key.prefix_length, extra_key.value); CAPTURE(key_string); key_string.resize(max_string); REQUIRE( ebpf_map_update_entry( map.get(), 0, - reinterpret_cast(&key), + reinterpret_cast(&extra_key), 0, reinterpret_cast(key_string.c_str()), EBPF_ANY, - EBPF_MAP_FLAG_HELPER) == EBPF_SUCCESS); + EBPF_MAP_FLAG_HELPER) == EBPF_OUT_OF_SPACE); } // Re-insert the same keys (to test update) @@ -549,6 +645,72 @@ TEST_CASE("map_crud_operations_lpm_trie_32", "[execution_context]") ebpf_map_delete_entry(map.get(), 0, reinterpret_cast(&key), EBPF_MAP_FLAG_HELPER) == EBPF_SUCCESS); } + + // LPM lookup falls back to less-specific prefixes, so check the rejected key after removing those entries. + char* return_value = nullptr; + REQUIRE( + ebpf_map_find_entry( + map.get(), + 0, + reinterpret_cast(&extra_key), + 0, + reinterpret_cast(&return_value), + EBPF_MAP_FLAG_HELPER) == EBPF_KEY_NOT_FOUND); +} + +TEST_CASE("map_lpm_trie_no_max_entries_flag", "[execution_context]") +{ + _ebpf_core_initializer core; + core.initialize(); + + ebpf_map_definition_in_memory_t map_definition{ + BPF_MAP_TYPE_LPM_TRIE, + sizeof(lpm_trie_32_key_t), + sizeof(uint64_t), + 1, + 0, + LIBBPF_PIN_NONE, + BPF_F_NO_MAX_ENTRIES}; + map_ptr map; + { + ebpf_map_t* local_map; + cxplat_utf8_string_t map_name = {0}; + REQUIRE( + ebpf_map_create(&map_name, &map_definition, (uintptr_t)ebpf_handle_invalid, &local_map) == EBPF_SUCCESS); + map.reset(local_map); + } + + std::vector keys{ + {32, {192, 168, 15, 1}}, + {32, {192, 168, 15, 2}}, + {32, {192, 168, 15, 3}}, + }; + + for (size_t index = 0; index < keys.size(); index++) { + uint64_t value = index + 1; + REQUIRE( + ebpf_map_update_entry( + map.get(), + 0, + reinterpret_cast(&keys[index]), + 0, + reinterpret_cast(&value), + EBPF_ANY, + EBPF_MAP_FLAG_HELPER) == EBPF_SUCCESS); + } + + for (size_t index = 0; index < keys.size(); index++) { + uint8_t* return_value = nullptr; + REQUIRE( + ebpf_map_find_entry( + map.get(), + 0, + reinterpret_cast(&keys[index]), + 0, + reinterpret_cast(&return_value), + EBPF_MAP_FLAG_HELPER) == EBPF_SUCCESS); + REQUIRE(*reinterpret_cast(return_value) == index + 1); + } } TEST_CASE("map_crud_operations_lpm_trie_32", "[execution_context][negative]") @@ -846,9 +1008,10 @@ TEST_CASE("map_crud_operations_lpm_trie_128", "[execution_context]") EBPF_ANY, EBPF_MAP_FLAG_HELPER) == EBPF_SUCCESS); } + auto extra_lpm_pair = _lpm_128_prefix_pair(33, 0xBB); { - // Add a new entry to the map, it should succeed. - auto lpm_pair = _lpm_128_prefix_pair(33, 0xBB); + // Add a new entry to the full map, it should fail. + auto& lpm_pair = extra_lpm_pair; std::string key_string = lpm_pair.second; CAPTURE(key_string); REQUIRE( @@ -859,7 +1022,7 @@ TEST_CASE("map_crud_operations_lpm_trie_128", "[execution_context]") 0, reinterpret_cast(lpm_pair.second.c_str()), EBPF_ANY, - EBPF_MAP_FLAG_HELPER) == EBPF_SUCCESS); + EBPF_MAP_FLAG_HELPER) == EBPF_OUT_OF_SPACE); } // Delete all the keys we originally inserted. @@ -869,6 +1032,17 @@ TEST_CASE("map_crud_operations_lpm_trie_128", "[execution_context]") ebpf_map_delete_entry(map.get(), 0, reinterpret_cast(&key), EBPF_MAP_FLAG_HELPER) == EBPF_SUCCESS); } + + // LPM lookup falls back to less-specific prefixes, so check the rejected key after removing those entries. + char* return_value = nullptr; + REQUIRE( + ebpf_map_find_entry( + map.get(), + 0, + reinterpret_cast(&extra_lpm_pair.first), + 0, + reinterpret_cast(&return_value), + EBPF_MAP_FLAG_HELPER) == EBPF_KEY_NOT_FOUND); } TEST_CASE("map_crud_operations_queue", "[execution_context]") @@ -2830,3 +3004,37 @@ TEST_CASE("INVALID_GENERAL_HELPER_PROGRAM_DATA", "[execution_context][negative]" // https://github.com/microsoft/ebpf-for-windows/issues/1139 // EBPF_OPERATION_LOAD_NATIVE_MODULE // EBPF_OPERATION_LOAD_NATIVE_PROGRAMS + +TEST_CASE("native map entry header layouts", "[execution_context]") +{ + STATIC_REQUIRE(EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION == 1); + STATIC_REQUIRE(EBPF_OFFSET_OF(ebpf_native_map_entry_legacy_t, name) == EBPF_OFFSET_OF(map_entry_t, name)); + STATIC_REQUIRE(EBPF_OFFSET_OF(map_entry_t, map_flags) > EBPF_OFFSET_OF(map_entry_t, name)); + + ebpf_native_map_entry_legacy_t legacy_entry = { + {0, 0}, + {EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION, + EBPF_NATIVE_MAP_ENTRY_LEGACY_SIZE, + EBPF_NATIVE_MAP_ENTRY_LEGACY_TOTAL_SIZE}, + {BPF_MAP_TYPE_HASH, 4, 8, 16, 0, LIBBPF_PIN_NONE, 1, 0}, + "legacy_map"}; + map_entry_t normalized_entry = {}; + REQUIRE(ebpf_native_map_entry_to_current(&normalized_entry, &legacy_entry)); + REQUIRE(normalized_entry.header.version == EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION); + REQUIRE(normalized_entry.definition.type == legacy_entry.definition.type); + REQUIRE(normalized_entry.name == legacy_entry.name); + REQUIRE(normalized_entry.map_flags == 0); + + map_entry_t current_entry = { + {0, 0}, + EBPF_NATIVE_MAP_ENTRY_HEADER, + {BPF_MAP_TYPE_HASH, 4, 8, 16, 0, LIBBPF_PIN_NONE, 1, 0}, + "current_map", + BPF_F_NO_MAX_ENTRIES}; + REQUIRE(ebpf_native_map_entry_to_current(&normalized_entry, ¤t_entry)); + REQUIRE(normalized_entry.name == current_entry.name); + REQUIRE(normalized_entry.map_flags == BPF_F_NO_MAX_ENTRIES); + + legacy_entry.header.size++; + REQUIRE_FALSE(ebpf_native_map_entry_to_current(&normalized_entry, &legacy_entry)); +} diff --git a/libs/ioctl_spec/EbpfProtocol.3d b/libs/ioctl_spec/EbpfProtocol.3d index 41cff336bc..da64b30795 100644 --- a/libs/ioctl_spec/EbpfProtocol.3d +++ b/libs/ioctl_spec/EbpfProtocol.3d @@ -72,7 +72,7 @@ // Byte offset of variable-length data from start of message. // Must match offsetof() on the C struct (x64 MSVC, default packing). #define CREATE_PROGRAM_DATA_OFFSET 28 -#define CREATE_MAP_DATA_OFFSET 40 +#define CREATE_MAP_DATA_OFFSET 48 #define LOAD_CODE_CODE_OFFSET 20 #define FIND_ELEMENT_KEY_OFFSET 17 #define MAP_UPDATE_DATA_OFFSET 20 @@ -127,16 +127,18 @@ where (MessageLength >= CREATE_PROGRAM_DATA_OFFSET) EBPF_OPERATION_CREATE_MAP (id=3) Body layout after 8-byte header: - ebpf_map_definition_in_memory_t (24 bytes, offset 8) - ebpf_handle_t inner_map_handle (8 bytes, offset 32) - uint8_t data[] (variable, offset 40 - map name) + ebpf_map_definition_in_memory_t (28 bytes, offset 8) + 4 bytes padding (offset 36) + ebpf_handle_t inner_map_handle (8 bytes, offset 40) + uint8_t data[] (variable, offset 48 - map name) Validates: minimum length for fixed fields, variable data region. */ typedef struct _CREATE_MAP_BODY (UINT16 MessageLength) where (MessageLength >= CREATE_MAP_DATA_OFFSET) { - UINT8 MapDefinition[24]; + UINT8 MapDefinition[28]; + UINT8 Padding[4]; UINT8 InnerMapHandle[8]; UINT8 Data[:byte-size (UINT32)(MessageLength - CREATE_MAP_DATA_OFFSET)]; } CREATE_MAP_BODY; diff --git a/libs/ioctl_spec/ebpf_protocol_layout_check.h b/libs/ioctl_spec/ebpf_protocol_layout_check.h index 091bfd3b69..0b68e769d4 100644 --- a/libs/ioctl_spec/ebpf_protocol_layout_check.h +++ b/libs/ioctl_spec/ebpf_protocol_layout_check.h @@ -3,10 +3,10 @@ #pragma once -#include - #include "ebpf_protocol.h" +#include + static_assert(sizeof(ebpf_operation_header_t) == 8, "ebpf_operation_header_t must remain 8 bytes"); static_assert(sizeof(ebpf_operation_id_t) == sizeof(uint32_t), "ebpf_operation_id_t must remain 4 bytes"); static_assert(sizeof(ebpf_code_type_t) == sizeof(uint32_t), "ebpf_code_type_t must remain 4 bytes"); @@ -23,7 +23,8 @@ static_assert( #endif static_assert( - offsetof(ebpf_operation_create_map_request_t, data) == 40, "ebpf_operation_create_map_request_t.data offset mismatch"); + offsetof(ebpf_operation_create_map_request_t, data) == 48, + "ebpf_operation_create_map_request_t.data offset mismatch"); static_assert( offsetof(ebpf_operation_map_find_element_request_t, key) == 17, "ebpf_operation_map_find_element_request_t.key offset mismatch"); @@ -46,7 +47,8 @@ static_assert( offsetof(ebpf_operation_get_pinned_object_request_t, path) == 8, "ebpf_operation_get_pinned_object_request_t.path offset mismatch"); static_assert( - offsetof(ebpf_operation_link_program_request_t, data) == 32, "ebpf_operation_link_program_request_t.data offset mismatch"); + offsetof(ebpf_operation_link_program_request_t, data) == 32, + "ebpf_operation_link_program_request_t.data offset mismatch"); static_assert( offsetof(ebpf_operation_unlink_program_request_t, data) == 41, "ebpf_operation_unlink_program_request_t.data offset mismatch"); diff --git a/libs/ioctl_spec/generated/EbpfProtocol.c b/libs/ioctl_spec/generated/EbpfProtocol.c index 5e58f81050..72ac112c9d 100644 --- a/libs/ioctl_spec/generated/EbpfProtocol.c +++ b/libs/ioctl_spec/generated/EbpfProtocol.c @@ -406,7 +406,7 @@ ValidateCreateMapBody( { /* Validating field MapDefinition */ BOOLEAN - hasEnoughBytes0 = (uint64_t)(uint32_t)(uint8_t)24U <= + hasEnoughBytes0 = (uint64_t)(uint32_t)(uint8_t)28U <= (InputLength - positionAfternone1); uint64_t positionAfterCreateMapBody0; if (!hasEnoughBytes0) @@ -419,7 +419,7 @@ ValidateCreateMapBody( { uint8_t *truncatedInput = Input; uint64_t truncatedInputLength = - positionAfternone1 + (uint64_t)(uint32_t)(uint8_t)24U; + positionAfternone1 + (uint64_t)(uint32_t)(uint8_t)28U; uint64_t result = positionAfternone1; while (TRUE) { @@ -497,9 +497,9 @@ ValidateCreateMapBody( } else { - /* Validating field InnerMapHandle */ + /* Validating field Padding */ BOOLEAN - hasEnoughBytes0 = (uint64_t)(uint32_t)(uint8_t)8U <= + hasEnoughBytes0 = (uint64_t)(uint32_t)(uint8_t)4U <= (InputLength - positionAfterMapDefinition); uint64_t positionAfterCreateMapBody0; if (!hasEnoughBytes0) @@ -513,7 +513,7 @@ ValidateCreateMapBody( uint8_t *truncatedInput = Input; uint64_t truncatedInputLength = positionAfterMapDefinition + - (uint64_t)(uint32_t)(uint8_t)8U; + (uint64_t)(uint32_t)(uint8_t)4U; uint64_t result = positionAfterMapDefinition; while (TRUE) { @@ -552,7 +552,7 @@ ValidateCreateMapBody( else { Err("_CREATE_MAP_BODY", - "InnerMapHandle.element", + "Padding.element", EverParseErrorReasonOfResult( positionAfterCreateMapBody), Ctxt, @@ -572,53 +572,47 @@ ValidateCreateMapBody( uint64_t res = result; positionAfterCreateMapBody0 = res; } - uint64_t positionAfterInnerMapHandle; + uint64_t positionAfterPadding; if (EverParseIsSuccess(positionAfterCreateMapBody0)) { - positionAfterInnerMapHandle = positionAfterCreateMapBody0; + positionAfterPadding = positionAfterCreateMapBody0; } else { Err("_CREATE_MAP_BODY", - "InnerMapHandle", + "Padding", EverParseErrorReasonOfResult( positionAfterCreateMapBody0), Ctxt, Input, positionAfterMapDefinition); - positionAfterInnerMapHandle = positionAfterCreateMapBody0; + positionAfterPadding = positionAfterCreateMapBody0; } - if (EverParseIsError(positionAfterInnerMapHandle)) + if (EverParseIsError(positionAfterPadding)) { - positionAfterCreateMapBody = positionAfterInnerMapHandle; + positionAfterCreateMapBody = positionAfterPadding; } else { - /* Validating field Data */ + /* Validating field InnerMapHandle */ BOOLEAN - hasEnoughBytes = - (uint64_t)(uint32_t)( - MessageLength - - (uint16_t)EBPFPROTOCOL____CREATE_MAP_DATA_OFFSET) <= - (InputLength - positionAfterInnerMapHandle); + hasEnoughBytes0 = (uint64_t)(uint32_t)(uint8_t)8U <= + (InputLength - positionAfterPadding); uint64_t positionAfterCreateMapBody0; - if (!hasEnoughBytes) + if (!hasEnoughBytes0) { positionAfterCreateMapBody0 = EverParseSetValidatorErrorPos( EVERPARSE_VALIDATOR_ERROR_NOT_ENOUGH_DATA, - positionAfterInnerMapHandle); + positionAfterPadding); } else { uint8_t *truncatedInput = Input; uint64_t truncatedInputLength = - positionAfterInnerMapHandle + - (uint64_t)(uint32_t)( - MessageLength - - (uint16_t) - EBPFPROTOCOL____CREATE_MAP_DATA_OFFSET); - uint64_t result = positionAfterInnerMapHandle; + positionAfterPadding + + (uint64_t)(uint32_t)(uint8_t)8U; + uint64_t result = positionAfterPadding; while (TRUE) { uint64_t position = *&result; @@ -657,7 +651,7 @@ ValidateCreateMapBody( else { Err("_CREATE_MAP_BODY", - "Data.element", + "InnerMapHandle.element", EverParseErrorReasonOfResult( positionAfterCreateMapBody), Ctxt, @@ -677,23 +671,133 @@ ValidateCreateMapBody( uint64_t res = result; positionAfterCreateMapBody0 = res; } + uint64_t positionAfterInnerMapHandle; if (EverParseIsSuccess(positionAfterCreateMapBody0)) { - positionAfterCreateMapBody = + positionAfterInnerMapHandle = positionAfterCreateMapBody0; } else { Err("_CREATE_MAP_BODY", - "Data", + "InnerMapHandle", EverParseErrorReasonOfResult( positionAfterCreateMapBody0), Ctxt, Input, - positionAfterInnerMapHandle); - positionAfterCreateMapBody = + positionAfterPadding); + positionAfterInnerMapHandle = positionAfterCreateMapBody0; } + if (EverParseIsError(positionAfterInnerMapHandle)) + { + positionAfterCreateMapBody = + positionAfterInnerMapHandle; + } + else + { + /* Validating field Data */ + BOOLEAN + hasEnoughBytes = + (uint64_t)(uint32_t)( + MessageLength - + (uint16_t) + EBPFPROTOCOL____CREATE_MAP_DATA_OFFSET) <= + (InputLength - positionAfterInnerMapHandle); + uint64_t positionAfterCreateMapBody0; + if (!hasEnoughBytes) + { + positionAfterCreateMapBody0 = + EverParseSetValidatorErrorPos( + EVERPARSE_VALIDATOR_ERROR_NOT_ENOUGH_DATA, + positionAfterInnerMapHandle); + } + else + { + uint8_t *truncatedInput = Input; + uint64_t truncatedInputLength = + positionAfterInnerMapHandle + + (uint64_t)(uint32_t)( + MessageLength - + (uint16_t) + EBPFPROTOCOL____CREATE_MAP_DATA_OFFSET); + uint64_t result = positionAfterInnerMapHandle; + while (TRUE) + { + uint64_t position = *&result; + BOOLEAN ite; + if (!((uint64_t)1U <= + (truncatedInputLength - position))) + { + ite = TRUE; + } + else + { + /* Checking that we have enough space for a + * UINT8, i.e., 1 byte */ + BOOLEAN hasBytes = + (uint64_t)1U <= + (truncatedInputLength - position); + uint64_t positionAfterCreateMapBody; + if (hasBytes) + { + positionAfterCreateMapBody = + position + (uint64_t)1U; + } + else + { + positionAfterCreateMapBody = + EverParseSetValidatorErrorPos( + EVERPARSE_VALIDATOR_ERROR_NOT_ENOUGH_DATA, + position); + } + uint64_t res; + if (EverParseIsSuccess( + positionAfterCreateMapBody)) + { + res = positionAfterCreateMapBody; + } + else + { + Err("_CREATE_MAP_BODY", + "Data.element", + EverParseErrorReasonOfResult( + positionAfterCreateMapBody), + Ctxt, + truncatedInput, + position); + res = positionAfterCreateMapBody; + } + uint64_t result1 = res; + result = result1; + ite = EverParseIsError(result1); + } + if (ite) + { + break; + } + } + uint64_t res = result; + positionAfterCreateMapBody0 = res; + } + if (EverParseIsSuccess(positionAfterCreateMapBody0)) + { + positionAfterCreateMapBody = + positionAfterCreateMapBody0; + } + else + { + Err("_CREATE_MAP_BODY", + "Data", + EverParseErrorReasonOfResult( + positionAfterCreateMapBody0), + Ctxt, + Input, + positionAfterInnerMapHandle); + positionAfterCreateMapBody = + positionAfterCreateMapBody0; + } + } } } } diff --git a/libs/ioctl_spec/generated/EbpfProtocol.h b/libs/ioctl_spec/generated/EbpfProtocol.h index 667b76ee2b..80dde9f4d0 100644 --- a/libs/ioctl_spec/generated/EbpfProtocol.h +++ b/libs/ioctl_spec/generated/EbpfProtocol.h @@ -61,7 +61,7 @@ extern "C" #define EBPFPROTOCOL____CREATE_PROGRAM_DATA_OFFSET ((uint8_t)28U) -#define EBPFPROTOCOL____CREATE_MAP_DATA_OFFSET ((uint8_t)40U) +#define EBPFPROTOCOL____CREATE_MAP_DATA_OFFSET ((uint8_t)48U) #define EBPFPROTOCOL____LOAD_CODE_CODE_OFFSET ((uint8_t)20U) diff --git a/libs/runtime/unit/platform_unit_test.cpp b/libs/runtime/unit/platform_unit_test.cpp index 5c300a755b..9f1a4c3444 100644 --- a/libs/runtime/unit/platform_unit_test.cpp +++ b/libs/runtime/unit/platform_unit_test.cpp @@ -1627,6 +1627,11 @@ TEST_CASE("serialize_map_test", "[platform]") _test_helper test_helper; test_helper.initialize(); + STATIC_REQUIRE(sizeof(ebpf_map_info_definition_t) == 24); + STATIC_REQUIRE(EBPF_OFFSET_OF(ebpf_map_info_t, pin_path) == 24); + STATIC_REQUIRE(sizeof(ebpf_map_info_t) == 24 + sizeof(char*)); + STATIC_REQUIRE(EBPF_OFFSET_OF(ebpf_serialized_map_info_t, pin_path) == 30); + const int map_count = 10; ebpf_map_info_internal_t internal_map_info_array[map_count] = {}; std::string pin_path_prefix = "\\ebpf\\map\\"; @@ -1648,6 +1653,7 @@ TEST_CASE("serialize_map_test", "[platform]") map_info->definition.key_size = i + 1; map_info->definition.value_size = (i + 1) * (i + 1); map_info->definition.max_entries = (i + 1) * 128; + map_info->definition.map_flags = BPF_F_NO_MAX_ENTRIES; map_info->pin_path.length = pin_paths[i].size(); map_info->pin_path.value = const_cast(reinterpret_cast(pin_paths[i].c_str())); @@ -1677,6 +1683,10 @@ TEST_CASE("serialize_map_test", "[platform]") &serialized_length, &required_length) == EBPF_SUCCESS); + REQUIRE( + reinterpret_cast(unique_buffer.get())->definition.map_flags == + BPF_F_NO_MAX_ENTRIES); + // Deserialize. REQUIRE( ebpf_deserialize_map_info_array(serialized_length, unique_buffer.get(), map_count, &map_info_array) == @@ -1686,8 +1696,12 @@ TEST_CASE("serialize_map_test", "[platform]") for (int i = 0; i < map_count; i++) { ebpf_map_info_internal_t* input_map_info = &internal_map_info_array[i]; ebpf_map_info_t* map_info = &map_info_array[i]; - REQUIRE( - memcmp(&map_info->definition, &input_map_info->definition, sizeof(ebpf_map_definition_in_memory_t)) == 0); + REQUIRE(map_info->definition.type == input_map_info->definition.type); + REQUIRE(map_info->definition.key_size == input_map_info->definition.key_size); + REQUIRE(map_info->definition.value_size == input_map_info->definition.value_size); + REQUIRE(map_info->definition.max_entries == input_map_info->definition.max_entries); + REQUIRE(map_info->definition.inner_map_id == input_map_info->definition.inner_map_id); + REQUIRE(map_info->definition.pinning == input_map_info->definition.pinning); REQUIRE(strnlen_s(map_info->pin_path, EBPF_MAX_PIN_PATH_LENGTH) == input_map_info->pin_path.length); REQUIRE(memcmp(map_info->pin_path, input_map_info->pin_path.value, input_map_info->pin_path.length) == 0); } diff --git a/libs/service/api_service.cpp b/libs/service/api_service.cpp index 80a91858aa..1762d87897 100644 --- a/libs/service/api_service.cpp +++ b/libs/service/api_service.cpp @@ -310,6 +310,7 @@ _query_and_cache_map_descriptors( descriptor.key_size, descriptor.value_size, descriptor.max_entries, + 0, handle_map[i].inner_map_original_fd, handle_map[i].inner_id, reinterpret_cast(handle_map[i].handle), @@ -660,11 +661,8 @@ _ebpf_is_proof_of_verification_required() { uint32_t proof_of_verification_value = 0; ebpf_store_key_t parameters_key = nullptr; - ebpf_result_t reg_result = ebpf_open_registry_key( - ebpf_store_hklm_root_key, - EBPF_PARAMETERS_REGISTRY_PATH, - KEY_READ, - ¶meters_key); + ebpf_result_t reg_result = + ebpf_open_registry_key(ebpf_store_hklm_root_key, EBPF_PARAMETERS_REGISTRY_PATH, KEY_READ, ¶meters_key); if (reg_result == EBPF_FILE_NOT_FOUND) { // Key not present — feature not opted into, verification not required. return false; @@ -674,9 +672,7 @@ _ebpf_is_proof_of_verification_required() return true; } reg_result = ebpf_read_registry_value_dword( - parameters_key, - EBPF_PROOF_OF_VERIFICATION_REGISTRY_VALUE, - &proof_of_verification_value); + parameters_key, EBPF_PROOF_OF_VERIFICATION_REGISTRY_VALUE, &proof_of_verification_value); ebpf_close_registry_key(parameters_key); if (reg_result == EBPF_FILE_NOT_FOUND) { // Value not present — feature not opted into, verification not required. diff --git a/libs/shared/ebpf_native_structs.h b/libs/shared/ebpf_native_structs.h new file mode 100644 index 0000000000..336a40acc1 --- /dev/null +++ b/libs/shared/ebpf_native_structs.h @@ -0,0 +1,28 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +#pragma once + +#include "bpf2c.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct _ebpf_native_map_entry_legacy + { + uint64_t zero_marker[2]; + ebpf_native_module_header_t header; + ebpf_native_map_definition_t definition; + const char* name; + } ebpf_native_map_entry_legacy_t; + +#define EBPF_NATIVE_MAP_ENTRY_LEGACY_SIZE EBPF_SIZE_INCLUDING_FIELD(ebpf_native_map_entry_legacy_t, name) +#define EBPF_NATIVE_MAP_ENTRY_LEGACY_TOTAL_SIZE sizeof(ebpf_native_map_entry_legacy_t) + + _Success_(return) bool ebpf_native_map_entry_to_current(_Out_ map_entry_t* destination, _In_ const void* source); + +#ifdef __cplusplus +} +#endif diff --git a/libs/shared/ebpf_serialize.c b/libs/shared/ebpf_serialize.c index ddfc7a32b9..a9c0d95951 100644 --- a/libs/shared/ebpf_serialize.c +++ b/libs/shared/ebpf_serialize.c @@ -198,8 +198,13 @@ ebpf_deserialize_map_info_array( source = (ebpf_serialized_map_info_t*)current; destination = &out_map_info[map_index]; - // Copy the map definition part. - destination->definition = source->definition; + // Copy the stable public definition. + destination->definition.type = source->definition.type; + destination->definition.key_size = source->definition.key_size; + destination->definition.value_size = source->definition.value_size; + destination->definition.max_entries = source->definition.max_entries; + destination->definition.inner_map_id = source->definition.inner_map_id; + destination->definition.pinning = source->definition.pinning; // Advance the input buffer current pointer. current += EBPF_OFFSET_OF(ebpf_serialized_map_info_t, pin_path); diff --git a/libs/shared/kernel/shared_kernel.vcxproj b/libs/shared/kernel/shared_kernel.vcxproj index 18c6ca6d25..8ad6c9bdc3 100644 --- a/libs/shared/kernel/shared_kernel.vcxproj +++ b/libs/shared/kernel/shared_kernel.vcxproj @@ -14,6 +14,7 @@ + diff --git a/libs/shared/kernel/shared_kernel.vcxproj.filters b/libs/shared/kernel/shared_kernel.vcxproj.filters index 16ff30f3a9..7f773a6162 100644 --- a/libs/shared/kernel/shared_kernel.vcxproj.filters +++ b/libs/shared/kernel/shared_kernel.vcxproj.filters @@ -27,6 +27,9 @@ + + Header Files + Header Files diff --git a/libs/shared/shared_common.c b/libs/shared/shared_common.c index e74aff581a..4857d0882d 100644 --- a/libs/shared/shared_common.c +++ b/libs/shared/shared_common.c @@ -2,6 +2,7 @@ // SPDX-License-Identifier: MIT #include "bpf2c.h" +#include "ebpf_native_structs.h" #include "ebpf_program_types.h" #include "ebpf_serialize.h" #include "ebpf_shared_framework.h" @@ -107,8 +108,9 @@ size_t _ebpf_native_helper_function_entry_supported_size[] = {EBPF_NATIVE_HELPER #define EBPF_NATIVE_HELPER_FUNCTION_DATA_SIZE_0 EBPF_SIZE_INCLUDING_FIELD(helper_function_data_t, tail_call) size_t _ebpf_native_helper_function_data_supported_size[] = {EBPF_NATIVE_HELPER_FUNCTION_DATA_SIZE_0}; -#define EBPF_NATIVE_MAP_ENTRY_SIZE_0 EBPF_SIZE_INCLUDING_FIELD(map_entry_t, name) -size_t _ebpf_native_map_entry_supported_size[] = {EBPF_NATIVE_MAP_ENTRY_SIZE_0}; +#define EBPF_NATIVE_MAP_ENTRY_SIZE_0 EBPF_NATIVE_MAP_ENTRY_LEGACY_SIZE +#define EBPF_NATIVE_MAP_ENTRY_SIZE_1 EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE +size_t _ebpf_native_map_entry_supported_size[] = {EBPF_NATIVE_MAP_ENTRY_SIZE_0, EBPF_NATIVE_MAP_ENTRY_SIZE_1}; #define EBPF_NATIVE_MAP_DATA_SIZE_0 EBPF_SIZE_INCLUDING_FIELD(map_data_t, address) #define EBPF_NATIVE_MAP_DATA_SIZE_1 EBPF_SIZE_INCLUDING_FIELD(map_data_t, array_data) @@ -387,9 +389,43 @@ ebpf_validate_object_header_native_helper_function_entry( bool ebpf_validate_object_header_native_map_entry(_In_ const ebpf_extension_header_t* native_map_entry_header) { + if (native_map_entry_header == NULL) { + return false; + } + return ( - (native_map_entry_header != NULL) && - _ebpf_validate_extension_object_header(EBPF_NATIVE_MAP_ENTRY, native_map_entry_header)); + _ebpf_validate_extension_object_header(EBPF_NATIVE_MAP_ENTRY, native_map_entry_header) && + ((native_map_entry_header->size == EBPF_NATIVE_MAP_ENTRY_LEGACY_SIZE && + native_map_entry_header->total_size == EBPF_NATIVE_MAP_ENTRY_LEGACY_TOTAL_SIZE) || + (native_map_entry_header->size == EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE && + native_map_entry_header->total_size == EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_TOTAL_SIZE))); +} + +_Success_(return) bool ebpf_native_map_entry_to_current(_Out_ map_entry_t* destination, _In_ const void* source) +{ + const ebpf_native_map_entry_legacy_t* legacy_entry = (const ebpf_native_map_entry_legacy_t*)source; + + if (destination == NULL || source == NULL || !ebpf_validate_object_header_native_map_entry(&legacy_entry->header)) { + return false; + } + + memset(destination, 0, sizeof(*destination)); + switch (legacy_entry->header.size) { + case EBPF_NATIVE_MAP_ENTRY_LEGACY_SIZE: + destination->zero_marker[0] = legacy_entry->zero_marker[0]; + destination->zero_marker[1] = legacy_entry->zero_marker[1]; + destination->definition = legacy_entry->definition; + destination->name = legacy_entry->name; + break; + case EBPF_NATIVE_MAP_ENTRY_CURRENT_VERSION_SIZE: + *destination = *(const map_entry_t*)source; + break; + default: + return false; + } + + destination->header = (ebpf_native_module_header_t)EBPF_NATIVE_MAP_ENTRY_HEADER; + return true; } bool diff --git a/libs/shared/user/shared_user.vcxproj b/libs/shared/user/shared_user.vcxproj index 3946e4d148..585fce00a5 100644 --- a/libs/shared/user/shared_user.vcxproj +++ b/libs/shared/user/shared_user.vcxproj @@ -7,6 +7,7 @@ + diff --git a/libs/shared/user/shared_user.vcxproj.filters b/libs/shared/user/shared_user.vcxproj.filters index 16ff30f3a9..7f773a6162 100644 --- a/libs/shared/user/shared_user.vcxproj.filters +++ b/libs/shared/user/shared_user.vcxproj.filters @@ -27,6 +27,9 @@ + + Header Files + Header Files diff --git a/tests/bpf2c_tests/elf_bpf.cpp b/tests/bpf2c_tests/elf_bpf.cpp index fcb98d66da..9b576ebc20 100644 --- a/tests/bpf2c_tests/elf_bpf.cpp +++ b/tests/bpf2c_tests/elf_bpf.cpp @@ -251,6 +251,8 @@ DECLARE_TEST("map_in_map_btf", _test_mode::Verify) DECLARE_TEST("map_in_map_legacy_id", _test_mode::Verify) DECLARE_TEST("map_annotation_collision", _test_mode::Verify) DECLARE_TEST("map_in_map_legacy_idx", _test_mode::Verify) +DECLARE_TEST("map_max_entries", _test_mode::Verify) +DECLARE_TEST("map_no_max_entries", _test_mode::Verify) DECLARE_TEST("map_reuse", _test_mode::Verify) DECLARE_TEST("map_sequential_lookup", _test_mode::Verify) DECLARE_TEST("map_reuse_2", _test_mode::Verify) diff --git a/tests/bpf2c_tests/expected/ambiguous_array_map_dll.c b/tests/bpf2c_tests/expected/ambiguous_array_map_dll.c index 8803b2c6d1..76f91553f6 100644 --- a/tests/bpf2c_tests/expected/ambiguous_array_map_dll.c +++ b/tests/bpf2c_tests/expected/ambiguous_array_map_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_a"}, + "map_a", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_b"}, + "map_b", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/ambiguous_array_map_raw.c b/tests/bpf2c_tests/expected/ambiguous_array_map_raw.c index 6f5f78c313..71961ae9c8 100644 --- a/tests/bpf2c_tests/expected/ambiguous_array_map_raw.c +++ b/tests/bpf2c_tests/expected/ambiguous_array_map_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_a"}, + "map_a", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_b"}, + "map_b", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/ambiguous_array_map_sys.c b/tests/bpf2c_tests/expected/ambiguous_array_map_sys.c index 62776049c0..683f43e3fc 100644 --- a/tests/bpf2c_tests/expected/ambiguous_array_map_sys.c +++ b/tests/bpf2c_tests/expected/ambiguous_array_map_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_a"}, + "map_a", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_b"}, + "map_b", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_dll.c b/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_dll.c index be2eb46981..1dec188eaa 100644 --- a/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_dll.c +++ b/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_raw.c b/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_raw.c index 07edeee363..0ce713637d 100644 --- a/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_raw.c +++ b/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_sys.c b/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_sys.c index b0148c2b9c..701573a835 100644 --- a/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_sys.c +++ b/tests/bpf2c_tests/expected/atomic_instruction_fetch_add_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bad_map_name_dll.c b/tests/bpf2c_tests/expected/bad_map_name_dll.c index 39ee0db3c1..f8c6348bf5 100644 --- a/tests/bpf2c_tests/expected/bad_map_name_dll.c +++ b/tests/bpf2c_tests/expected/bad_map_name_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 8, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 8, // Identifier for a map template. + 0, // The id of the inner map template. }, - "this_map_has_a_name_that_is_longer_than_what_the_ebpfcore_driver_can_support"}, + "this_map_has_a_name_that_is_longer_than_what_the_ebpfcore_driver_can_support", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bad_map_name_raw.c b/tests/bpf2c_tests/expected/bad_map_name_raw.c index 527b0e8edb..6baeb8e2ed 100644 --- a/tests/bpf2c_tests/expected/bad_map_name_raw.c +++ b/tests/bpf2c_tests/expected/bad_map_name_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 8, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 8, // Identifier for a map template. + 0, // The id of the inner map template. }, - "this_map_has_a_name_that_is_longer_than_what_the_ebpfcore_driver_can_support"}, + "this_map_has_a_name_that_is_longer_than_what_the_ebpfcore_driver_can_support", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bad_map_name_sys.c b/tests/bpf2c_tests/expected/bad_map_name_sys.c index 352869d161..260d2dae27 100644 --- a/tests/bpf2c_tests/expected/bad_map_name_sys.c +++ b/tests/bpf2c_tests/expected/bad_map_name_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 8, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 8, // Identifier for a map template. + 0, // The id of the inner map template. }, - "this_map_has_a_name_that_is_longer_than_what_the_ebpfcore_driver_can_support"}, + "this_map_has_a_name_that_is_longer_than_what_the_ebpfcore_driver_can_support", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bind_policy_dll.c b/tests/bpf2c_tests/expected/bind_policy_dll.c index 8c51b1d93f..995bb9da16 100644 --- a/tests/bpf2c_tests/expected/bind_policy_dll.c +++ b/tests/bpf2c_tests/expected/bind_policy_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 16, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 100, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 21, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 16, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 100, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 21, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_policy_map"}, + "bind_policy_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bind_policy_raw.c b/tests/bpf2c_tests/expected/bind_policy_raw.c index dbf2b9851c..cc6709cab1 100644 --- a/tests/bpf2c_tests/expected/bind_policy_raw.c +++ b/tests/bpf2c_tests/expected/bind_policy_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 16, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 100, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 21, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 16, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 100, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 21, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_policy_map"}, + "bind_policy_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bind_policy_sys.c b/tests/bpf2c_tests/expected/bind_policy_sys.c index 678375ad4c..835c0e2fee 100644 --- a/tests/bpf2c_tests/expected/bind_policy_sys.c +++ b/tests/bpf2c_tests/expected/bind_policy_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 16, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 100, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 21, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 16, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 100, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 21, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_policy_map"}, + "bind_policy_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_dll.c b/tests/bpf2c_tests/expected/bindmonitor_dll.c index 7db28c5563..44770f2ca8 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_dll.c +++ b/tests/bpf2c_tests/expected/bindmonitor_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "limits_map"}, + "limits_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 23, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -98,7 +102,9 @@ static map_entry_t _maps[] = { 29, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_dll.c b/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_dll.c index ed81d2a1fd..7fb2fa4818 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_dll.c +++ b/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_tail_call_map"}, + "bind_tail_call_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_raw.c b/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_raw.c index c43143f26d..f2e707e777 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_raw.c +++ b/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_tail_call_map"}, + "bind_tail_call_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_sys.c b/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_sys.c index e023501bbf..f18820fca1 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_sys.c +++ b/tests/bpf2c_tests/expected/bindmonitor_mt_tailcall_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_tail_call_map"}, + "bind_tail_call_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_dll.c b/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_dll.c index b9e09b3681..a18502d16a 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_dll.c +++ b/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_raw.c b/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_raw.c index ef74a1aec9..13eb333b28 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_raw.c +++ b/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_sys.c b/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_sys.c index 15bffbf076..27567d6eb1 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_sys.c +++ b/tests/bpf2c_tests/expected/bindmonitor_perf_event_array_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_raw.c b/tests/bpf2c_tests/expected/bindmonitor_raw.c index 5ce2f44cb0..4d185186cc 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_raw.c +++ b/tests/bpf2c_tests/expected/bindmonitor_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "limits_map"}, + "limits_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 23, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -68,7 +72,9 @@ static map_entry_t _maps[] = { 29, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_ringbuf_dll.c b/tests/bpf2c_tests/expected/bindmonitor_ringbuf_dll.c index 26df31f2d7..29a10c3930 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_ringbuf_dll.c +++ b/tests/bpf2c_tests/expected/bindmonitor_ringbuf_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_ringbuf_raw.c b/tests/bpf2c_tests/expected/bindmonitor_ringbuf_raw.c index d5b069804e..0d9d370734 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_ringbuf_raw.c +++ b/tests/bpf2c_tests/expected/bindmonitor_ringbuf_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_ringbuf_sys.c b/tests/bpf2c_tests/expected/bindmonitor_ringbuf_sys.c index 56714843c2..2a66f34382 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_ringbuf_sys.c +++ b/tests/bpf2c_tests/expected/bindmonitor_ringbuf_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_sys.c b/tests/bpf2c_tests/expected/bindmonitor_sys.c index 73d84c920a..2103068d2f 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_sys.c +++ b/tests/bpf2c_tests/expected/bindmonitor_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "limits_map"}, + "limits_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 23, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -223,7 +227,9 @@ static map_entry_t _maps[] = { 29, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_tailcall_dll.c b/tests/bpf2c_tests/expected/bindmonitor_tailcall_dll.c index 0ea6a7feb8..0d7b779510 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_tailcall_dll.c +++ b/tests/bpf2c_tests/expected/bindmonitor_tailcall_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "limits_map"}, + "limits_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -98,13 +102,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "prog_array_map"}, + "prog_array_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -116,13 +122,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "dummy_map"}, + "dummy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -134,13 +142,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 10, // The id of the inner map template. }, - "dummy_outer_map"}, + "dummy_outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -152,25 +162,29 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "dummy_outer_idx_map"}, + "dummy_outer_idx_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "dummy_inner_map"}, + "dummy_inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_tailcall_raw.c b/tests/bpf2c_tests/expected/bindmonitor_tailcall_raw.c index 3f76c29a83..c1382c058d 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_tailcall_raw.c +++ b/tests/bpf2c_tests/expected/bindmonitor_tailcall_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "limits_map"}, + "limits_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -68,13 +72,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "prog_array_map"}, + "prog_array_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -86,13 +92,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "dummy_map"}, + "dummy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -104,13 +112,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 10, // The id of the inner map template. }, - "dummy_outer_map"}, + "dummy_outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -122,25 +132,29 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "dummy_outer_idx_map"}, + "dummy_outer_idx_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "dummy_inner_map"}, + "dummy_inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bindmonitor_tailcall_sys.c b/tests/bpf2c_tests/expected/bindmonitor_tailcall_sys.c index 11b4b4beca..2757ce0ae3 100644 --- a/tests/bpf2c_tests/expected/bindmonitor_tailcall_sys.c +++ b/tests/bpf2c_tests/expected/bindmonitor_tailcall_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "process_map"}, + "process_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "limits_map"}, + "limits_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -223,13 +227,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "prog_array_map"}, + "prog_array_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -241,13 +247,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "dummy_map"}, + "dummy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -259,13 +267,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 10, // The id of the inner map template. }, - "dummy_outer_map"}, + "dummy_outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -277,25 +287,29 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "dummy_outer_idx_map"}, + "dummy_outer_idx_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "dummy_inner_map"}, + "dummy_inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bpf2bpf_loop_dll.c b/tests/bpf2c_tests/expected/bpf2bpf_loop_dll.c index 13b4fd4b86..a64d53ab6c 100644 --- a/tests/bpf2c_tests/expected/bpf2bpf_loop_dll.c +++ b/tests/bpf2c_tests/expected/bpf2bpf_loop_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bpf2bpf_loop_map"}, + "bpf2bpf_loop_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bpf2bpf_loop_raw.c b/tests/bpf2c_tests/expected/bpf2bpf_loop_raw.c index d3846731c9..7d31d17265 100644 --- a/tests/bpf2c_tests/expected/bpf2bpf_loop_raw.c +++ b/tests/bpf2c_tests/expected/bpf2bpf_loop_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bpf2bpf_loop_map"}, + "bpf2bpf_loop_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bpf2bpf_loop_sys.c b/tests/bpf2c_tests/expected/bpf2bpf_loop_sys.c index c43efa8db2..2685453ceb 100644 --- a/tests/bpf2c_tests/expected/bpf2bpf_loop_sys.c +++ b/tests/bpf2c_tests/expected/bpf2bpf_loop_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bpf2bpf_loop_map"}, + "bpf2bpf_loop_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bpf_call_dll.c b/tests/bpf2c_tests/expected/bpf_call_dll.c index feba42fa0d..30652fb477 100644 --- a/tests/bpf2c_tests/expected/bpf_call_dll.c +++ b/tests/bpf2c_tests/expected/bpf_call_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 9, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bpf_call_raw.c b/tests/bpf2c_tests/expected/bpf_call_raw.c index 7bd2999f04..c82ed34710 100644 --- a/tests/bpf2c_tests/expected/bpf_call_raw.c +++ b/tests/bpf2c_tests/expected/bpf_call_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 9, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/bpf_call_sys.c b/tests/bpf2c_tests/expected/bpf_call_sys.c index 7728571b6a..2f196614fc 100644 --- a/tests/bpf2c_tests/expected/bpf_call_sys.c +++ b/tests/bpf2c_tests/expected/bpf_call_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 9, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/callgraph_bpf2bpf_dll.c b/tests/bpf2c_tests/expected/callgraph_bpf2bpf_dll.c index 194d0672a2..f4c7039093 100644 --- a/tests/bpf2c_tests/expected/callgraph_bpf2bpf_dll.c +++ b/tests/bpf2c_tests/expected/callgraph_bpf2bpf_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_count_map"}, + "bind_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/callgraph_bpf2bpf_raw.c b/tests/bpf2c_tests/expected/callgraph_bpf2bpf_raw.c index d8a7ff5bf6..416ca836a1 100644 --- a/tests/bpf2c_tests/expected/callgraph_bpf2bpf_raw.c +++ b/tests/bpf2c_tests/expected/callgraph_bpf2bpf_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_count_map"}, + "bind_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/callgraph_bpf2bpf_sys.c b/tests/bpf2c_tests/expected/callgraph_bpf2bpf_sys.c index b337f6acae..25a392db0c 100644 --- a/tests/bpf2c_tests/expected/callgraph_bpf2bpf_sys.c +++ b/tests/bpf2c_tests/expected/callgraph_bpf2bpf_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_count_map"}, + "bind_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_connect_authorization6_dll.c b/tests/bpf2c_tests/expected/cgroup_connect_authorization6_dll.c index 6a6e8a9b1c..55f022df72 100644 --- a/tests/bpf2c_tests/expected/cgroup_connect_authorization6_dll.c +++ b/tests/bpf2c_tests/expected/cgroup_connect_authorization6_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect_authorization6_count_map"}, + "connect_authorization6_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_connect_authorization6_raw.c b/tests/bpf2c_tests/expected/cgroup_connect_authorization6_raw.c index 0e3008de00..3bba10ebd9 100644 --- a/tests/bpf2c_tests/expected/cgroup_connect_authorization6_raw.c +++ b/tests/bpf2c_tests/expected/cgroup_connect_authorization6_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect_authorization6_count_map"}, + "connect_authorization6_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_connect_authorization6_sys.c b/tests/bpf2c_tests/expected/cgroup_connect_authorization6_sys.c index 8eae01f284..d588d0c837 100644 --- a/tests/bpf2c_tests/expected/cgroup_connect_authorization6_sys.c +++ b/tests/bpf2c_tests/expected/cgroup_connect_authorization6_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect_authorization6_count_map"}, + "connect_authorization6_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_count_connect4_dll.c b/tests/bpf2c_tests/expected/cgroup_count_connect4_dll.c index f258079c08..fe078018ce 100644 --- a/tests/bpf2c_tests/expected/cgroup_count_connect4_dll.c +++ b/tests/bpf2c_tests/expected/cgroup_count_connect4_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect4_count_map"}, + "connect4_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_count_connect4_raw.c b/tests/bpf2c_tests/expected/cgroup_count_connect4_raw.c index 31b93ecfe5..73669a60ed 100644 --- a/tests/bpf2c_tests/expected/cgroup_count_connect4_raw.c +++ b/tests/bpf2c_tests/expected/cgroup_count_connect4_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect4_count_map"}, + "connect4_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_count_connect4_sys.c b/tests/bpf2c_tests/expected/cgroup_count_connect4_sys.c index 0b63f31a12..67bb22448c 100644 --- a/tests/bpf2c_tests/expected/cgroup_count_connect4_sys.c +++ b/tests/bpf2c_tests/expected/cgroup_count_connect4_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect4_count_map"}, + "connect4_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_count_connect6_dll.c b/tests/bpf2c_tests/expected/cgroup_count_connect6_dll.c index c4201f543f..d3b9f2dc7f 100644 --- a/tests/bpf2c_tests/expected/cgroup_count_connect6_dll.c +++ b/tests/bpf2c_tests/expected/cgroup_count_connect6_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect6_count_map"}, + "connect6_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_count_connect6_raw.c b/tests/bpf2c_tests/expected/cgroup_count_connect6_raw.c index 43d7a16cc6..93f6b38043 100644 --- a/tests/bpf2c_tests/expected/cgroup_count_connect6_raw.c +++ b/tests/bpf2c_tests/expected/cgroup_count_connect6_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect6_count_map"}, + "connect6_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_count_connect6_sys.c b/tests/bpf2c_tests/expected/cgroup_count_connect6_sys.c index 805c28e735..cc07f7abe4 100644 --- a/tests/bpf2c_tests/expected/cgroup_count_connect6_sys.c +++ b/tests/bpf2c_tests/expected/cgroup_count_connect6_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 2, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 11, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 2, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 11, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connect6_count_map"}, + "connect6_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr2_dll.c b/tests/bpf2c_tests/expected/cgroup_sock_addr2_dll.c index a3b263aab5..51fae88b18 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr2_dll.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr2_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "policy_map"}, + "policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -80,25 +82,29 @@ static map_entry_t _maps[] = { 30, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 24, // Size in bytes of a map key. - 28, // Size in bytes of a map value. - 100, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 32, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 24, // Size in bytes of a map key. + 28, // Size in bytes of a map value. + 100, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 32, // Identifier for a map template. + 0, // The id of the inner map template. }, - "authorization_policy_map"}, + "authorization_policy_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr2_raw.c b/tests/bpf2c_tests/expected/cgroup_sock_addr2_raw.c index d4c395fe09..2a3b054e73 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr2_raw.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr2_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "policy_map"}, + "policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -50,25 +52,29 @@ static map_entry_t _maps[] = { 30, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 24, // Size in bytes of a map key. - 28, // Size in bytes of a map value. - 100, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 32, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 24, // Size in bytes of a map key. + 28, // Size in bytes of a map value. + 100, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 32, // Identifier for a map template. + 0, // The id of the inner map template. }, - "authorization_policy_map"}, + "authorization_policy_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr2_sys.c b/tests/bpf2c_tests/expected/cgroup_sock_addr2_sys.c index 40bdaf35bc..7a4b611f4a 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr2_sys.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr2_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "policy_map"}, + "policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -205,25 +207,29 @@ static map_entry_t _maps[] = { 30, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 24, // Size in bytes of a map key. - 28, // Size in bytes of a map value. - 100, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 32, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 24, // Size in bytes of a map key. + 28, // Size in bytes of a map value. + 100, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 32, // Identifier for a map template. + 0, // The id of the inner map template. }, - "authorization_policy_map"}, + "authorization_policy_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_dll.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_dll.c index e5e355ddf0..697ef53e2a 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_dll.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_dll.c @@ -48,39 +48,43 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 256, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 17, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 256, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 17, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_verdict_map"}, + "bind_verdict_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 24, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 24, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_invocation_count_map"}, + "bind_invocation_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_raw.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_raw.c index 6d2ef65163..6a2830f42a 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_raw.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_raw.c @@ -18,39 +18,43 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 256, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 17, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 256, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 17, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_verdict_map"}, + "bind_verdict_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 24, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 24, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_invocation_count_map"}, + "bind_invocation_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_sys.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_sys.c index d28cd2146f..9755c66478 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_sys.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_bind_sys.c @@ -173,39 +173,43 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 256, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 17, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 256, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 17, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_verdict_map"}, + "bind_verdict_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 24, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 24, // Identifier for a map template. + 0, // The id of the inner map template. }, - "bind_invocation_count_map"}, + "bind_invocation_count_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_dll.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_dll.c index f5b2ac53bf..a998b2e918 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_dll.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_dll.c @@ -48,75 +48,83 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 19, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 19, // Identifier for a map template. + 0, // The id of the inner map template. }, - "egress_connection_policy_map"}, + "egress_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 21, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 21, // Identifier for a map template. + 0, // The id of the inner map template. }, - "ingress_connection_policy_map"}, + "ingress_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 23, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 23, // Identifier for a map template. + 0, // The id of the inner map template. }, - "listen_connection_policy_map"}, + "listen_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1000, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 28, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1000, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 28, // Identifier for a map template. + 0, // The id of the inner map template. }, - "socket_cookie_map"}, + "socket_cookie_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_dll.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_dll.c index 8491e8e81b..7fc89ba91f 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_dll.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_dll.c @@ -48,57 +48,63 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 32, // Size in bytes of a map value. - 1000, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 32, // Size in bytes of a map value. + 1000, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "network_context_map"}, + "network_context_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 18, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 18, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connection_count_map"}, + "connection_count_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 32, // Size in bytes of a map value. - 4, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 28, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 32, // Size in bytes of a map value. + 4, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 28, // Identifier for a map template. + 0, // The id of the inner map template. }, - "sock_addr_helper_results_map"}, + "sock_addr_helper_results_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_raw.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_raw.c index 9ee2336980..33ecc9227f 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_raw.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_raw.c @@ -18,57 +18,63 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 32, // Size in bytes of a map value. - 1000, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 32, // Size in bytes of a map value. + 1000, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "network_context_map"}, + "network_context_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 18, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 18, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connection_count_map"}, + "connection_count_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 32, // Size in bytes of a map value. - 4, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 28, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 32, // Size in bytes of a map value. + 4, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 28, // Identifier for a map template. + 0, // The id of the inner map template. }, - "sock_addr_helper_results_map"}, + "sock_addr_helper_results_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_sys.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_sys.c index 0ad83177f8..31367490c5 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_sys.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_helpers_sys.c @@ -173,57 +173,63 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 32, // Size in bytes of a map value. - 1000, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 32, // Size in bytes of a map value. + 1000, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "network_context_map"}, + "network_context_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 18, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 18, // Identifier for a map template. + 0, // The id of the inner map template. }, - "connection_count_map"}, + "connection_count_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 32, // Size in bytes of a map value. - 4, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 28, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 32, // Size in bytes of a map value. + 4, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 28, // Identifier for a map template. + 0, // The id of the inner map template. }, - "sock_addr_helper_results_map"}, + "sock_addr_helper_results_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_raw.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_raw.c index 7dbaa168de..fdc9fa1594 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_raw.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_raw.c @@ -18,75 +18,83 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 19, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 19, // Identifier for a map template. + 0, // The id of the inner map template. }, - "egress_connection_policy_map"}, + "egress_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 21, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 21, // Identifier for a map template. + 0, // The id of the inner map template. }, - "ingress_connection_policy_map"}, + "ingress_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 23, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 23, // Identifier for a map template. + 0, // The id of the inner map template. }, - "listen_connection_policy_map"}, + "listen_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1000, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 28, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1000, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 28, // Identifier for a map template. + 0, // The id of the inner map template. }, - "socket_cookie_map"}, + "socket_cookie_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/cgroup_sock_addr_sys.c b/tests/bpf2c_tests/expected/cgroup_sock_addr_sys.c index fe949ce2eb..a656e64ed4 100644 --- a/tests/bpf2c_tests/expected/cgroup_sock_addr_sys.c +++ b/tests/bpf2c_tests/expected/cgroup_sock_addr_sys.c @@ -173,75 +173,83 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 19, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 19, // Identifier for a map template. + 0, // The id of the inner map template. }, - "egress_connection_policy_map"}, + "egress_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 21, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 21, // Identifier for a map template. + 0, // The id of the inner map template. }, - "ingress_connection_policy_map"}, + "ingress_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 23, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 23, // Identifier for a map template. + 0, // The id of the inner map template. }, - "listen_connection_policy_map"}, + "listen_connection_policy_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 56, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1000, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 28, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 56, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1000, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 28, // Identifier for a map template. + 0, // The id of the inner map template. }, - "socket_cookie_map"}, + "socket_cookie_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/custom_map_basic_dll.c b/tests/bpf2c_tests/expected/custom_map_basic_dll.c index 57ca08b861..568da9cb83 100644 --- a/tests/bpf2c_tests/expected/custom_map_basic_dll.c +++ b/tests/bpf2c_tests/expected/custom_map_basic_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "array_map"}, + "array_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_SAMPLE_HASH_MAP, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 0, // The id of the inner map template. }, - "sample_hash_map"}, + "sample_hash_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -98,13 +102,15 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "config_map"}, + "config_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -116,25 +122,29 @@ static map_entry_t _maps[] = { 18, // Identifier for a map template. 0, // The id of the inner map template. }, - "result_map"}, + "result_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 20, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 20, // Identifier for a map template. + 0, // The id of the inner map template. }, - "result_value_map"}, + "result_value_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/custom_map_basic_raw.c b/tests/bpf2c_tests/expected/custom_map_basic_raw.c index 22099403ab..d9adf6f17a 100644 --- a/tests/bpf2c_tests/expected/custom_map_basic_raw.c +++ b/tests/bpf2c_tests/expected/custom_map_basic_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "array_map"}, + "array_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_SAMPLE_HASH_MAP, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 0, // The id of the inner map template. }, - "sample_hash_map"}, + "sample_hash_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -68,13 +72,15 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "config_map"}, + "config_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -86,25 +92,29 @@ static map_entry_t _maps[] = { 18, // Identifier for a map template. 0, // The id of the inner map template. }, - "result_map"}, + "result_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 20, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 20, // Identifier for a map template. + 0, // The id of the inner map template. }, - "result_value_map"}, + "result_value_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/custom_map_basic_sys.c b/tests/bpf2c_tests/expected/custom_map_basic_sys.c index e46729665d..7aba066691 100644 --- a/tests/bpf2c_tests/expected/custom_map_basic_sys.c +++ b/tests/bpf2c_tests/expected/custom_map_basic_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "array_map"}, + "array_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_SAMPLE_HASH_MAP, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 0, // The id of the inner map template. }, - "sample_hash_map"}, + "sample_hash_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -223,13 +227,15 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "config_map"}, + "config_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -241,25 +247,29 @@ static map_entry_t _maps[] = { 18, // Identifier for a map template. 0, // The id of the inner map template. }, - "result_map"}, + "result_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 20, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 20, // Identifier for a map template. + 0, // The id of the inner map template. }, - "result_value_map"}, + "result_value_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/custom_map_invalid_dll.c b/tests/bpf2c_tests/expected/custom_map_invalid_dll.c index 76d673068b..4ba2fa25a8 100644 --- a/tests/bpf2c_tests/expected/custom_map_invalid_dll.c +++ b/tests/bpf2c_tests/expected/custom_map_invalid_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_SAMPLE_HASH_MAP, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "sample_array_map"}, + "sample_array_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/custom_map_invalid_raw.c b/tests/bpf2c_tests/expected/custom_map_invalid_raw.c index 7fdd6db215..e4d2b5b2c6 100644 --- a/tests/bpf2c_tests/expected/custom_map_invalid_raw.c +++ b/tests/bpf2c_tests/expected/custom_map_invalid_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_SAMPLE_HASH_MAP, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "sample_array_map"}, + "sample_array_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/custom_map_invalid_sys.c b/tests/bpf2c_tests/expected/custom_map_invalid_sys.c index 5df5b3f32f..11928569b3 100644 --- a/tests/bpf2c_tests/expected/custom_map_invalid_sys.c +++ b/tests/bpf2c_tests/expected/custom_map_invalid_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_SAMPLE_HASH_MAP, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "sample_array_map"}, + "sample_array_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/divide_by_zero_dll.c b/tests/bpf2c_tests/expected/divide_by_zero_dll.c index 53c57064cd..d15a75c2d1 100644 --- a/tests/bpf2c_tests/expected/divide_by_zero_dll.c +++ b/tests/bpf2c_tests/expected/divide_by_zero_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/divide_by_zero_raw.c b/tests/bpf2c_tests/expected/divide_by_zero_raw.c index f356550684..27b9e500f9 100644 --- a/tests/bpf2c_tests/expected/divide_by_zero_raw.c +++ b/tests/bpf2c_tests/expected/divide_by_zero_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/divide_by_zero_sys.c b/tests/bpf2c_tests/expected/divide_by_zero_sys.c index a72f6aa755..bd776f8078 100644 --- a/tests/bpf2c_tests/expected/divide_by_zero_sys.c +++ b/tests/bpf2c_tests/expected/divide_by_zero_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/droppacket_dll.c b/tests/bpf2c_tests/expected/droppacket_dll.c index ec40623e5a..d18f49f53e 100644 --- a/tests/bpf2c_tests/expected/droppacket_dll.c +++ b/tests/bpf2c_tests/expected/droppacket_dll.c @@ -48,39 +48,43 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "interface_index_map"}, + "interface_index_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "dropped_packet_map"}, + "dropped_packet_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/droppacket_raw.c b/tests/bpf2c_tests/expected/droppacket_raw.c index 135067083a..2a2a3767e0 100644 --- a/tests/bpf2c_tests/expected/droppacket_raw.c +++ b/tests/bpf2c_tests/expected/droppacket_raw.c @@ -18,39 +18,43 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "interface_index_map"}, + "interface_index_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "dropped_packet_map"}, + "dropped_packet_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/droppacket_sys.c b/tests/bpf2c_tests/expected/droppacket_sys.c index ebc827bf6b..3e4bfc417f 100644 --- a/tests/bpf2c_tests/expected/droppacket_sys.c +++ b/tests/bpf2c_tests/expected/droppacket_sys.c @@ -173,39 +173,43 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 10, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 4, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 10, // Identifier for a map template. + 0, // The id of the inner map template. }, - "interface_index_map"}, + "interface_index_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 8, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "dropped_packet_map"}, + "dropped_packet_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/global_vars_and_map_dll.c b/tests/bpf2c_tests/expected/global_vars_and_map_dll.c index a7e6b002dd..384800a46c 100644 --- a/tests/bpf2c_tests/expected/global_vars_and_map_dll.c +++ b/tests/bpf2c_tests/expected/global_vars_and_map_dll.c @@ -48,27 +48,29 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 24, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 13, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 24, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. }, - "some_config_map"}, + "some_config_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 29, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.bss"}, + "global_.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/global_vars_and_map_raw.c b/tests/bpf2c_tests/expected/global_vars_and_map_raw.c index b15b8a8f1e..58b80e9b96 100644 --- a/tests/bpf2c_tests/expected/global_vars_and_map_raw.c +++ b/tests/bpf2c_tests/expected/global_vars_and_map_raw.c @@ -18,27 +18,29 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 24, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 13, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 24, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. }, - "some_config_map"}, + "some_config_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 29, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.bss"}, + "global_.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/global_vars_and_map_sys.c b/tests/bpf2c_tests/expected/global_vars_and_map_sys.c index 8c2845e5d9..56cda97968 100644 --- a/tests/bpf2c_tests/expected/global_vars_and_map_sys.c +++ b/tests/bpf2c_tests/expected/global_vars_and_map_sys.c @@ -173,27 +173,29 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_HASH, // Type of map. - 4, // Size in bytes of a map key. - 24, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 13, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 24, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. }, - "some_config_map"}, + "some_config_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 29, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.bss"}, + "global_.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/global_vars_dll.c b/tests/bpf2c_tests/expected/global_vars_dll.c index a596fd4c8e..4f8b41f2d7 100644 --- a/tests/bpf2c_tests/expected/global_vars_dll.c +++ b/tests/bpf2c_tests/expected/global_vars_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.rodata"}, + "global_.rodata", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 24, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.data"}, + "global_.data", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -98,7 +102,9 @@ static map_entry_t _maps[] = { 23, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.bss"}, + "global_.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/global_vars_raw.c b/tests/bpf2c_tests/expected/global_vars_raw.c index 7d45220813..d38f625ff8 100644 --- a/tests/bpf2c_tests/expected/global_vars_raw.c +++ b/tests/bpf2c_tests/expected/global_vars_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.rodata"}, + "global_.rodata", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 24, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.data"}, + "global_.data", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -68,7 +72,9 @@ static map_entry_t _maps[] = { 23, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.bss"}, + "global_.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/global_vars_sys.c b/tests/bpf2c_tests/expected/global_vars_sys.c index e92e8157af..ebdb55e941 100644 --- a/tests/bpf2c_tests/expected/global_vars_sys.c +++ b/tests/bpf2c_tests/expected/global_vars_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.rodata"}, + "global_.rodata", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 24, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.data"}, + "global_.data", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -223,7 +227,9 @@ static map_entry_t _maps[] = { 23, // Identifier for a map template. 0, // The id of the inner map template. }, - "global_.bss"}, + "global_.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/hash_of_map_dll.c b/tests/bpf2c_tests/expected/hash_of_map_dll.c index bf873abd89..72bbc75a1f 100644 --- a/tests/bpf2c_tests/expected/hash_of_map_dll.c +++ b/tests/bpf2c_tests/expected/hash_of_map_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 8, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/hash_of_map_raw.c b/tests/bpf2c_tests/expected/hash_of_map_raw.c index a18f352e2c..791aa3f30c 100644 --- a/tests/bpf2c_tests/expected/hash_of_map_raw.c +++ b/tests/bpf2c_tests/expected/hash_of_map_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 8, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/hash_of_map_sys.c b/tests/bpf2c_tests/expected/hash_of_map_sys.c index 82e87a7a00..6b14b266e7 100644 --- a/tests/bpf2c_tests/expected/hash_of_map_sys.c +++ b/tests/bpf2c_tests/expected/hash_of_map_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 8, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/inner_map_dll.c b/tests/bpf2c_tests/expected/inner_map_dll.c index d1dd9e6981..1493c9ae54 100644 --- a/tests/bpf2c_tests/expected/inner_map_dll.c +++ b/tests/bpf2c_tests/expected/inner_map_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 25, // Identifier for a map template. 21, // The id of the inner map template. }, - "outer_map2"}, + "outer_map2", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -98,13 +102,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -116,7 +122,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "__anonymous_1"}, + "__anonymous_1", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/inner_map_raw.c b/tests/bpf2c_tests/expected/inner_map_raw.c index a666766dfb..24c8d925e2 100644 --- a/tests/bpf2c_tests/expected/inner_map_raw.c +++ b/tests/bpf2c_tests/expected/inner_map_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 25, // Identifier for a map template. 21, // The id of the inner map template. }, - "outer_map2"}, + "outer_map2", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -68,13 +72,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -86,7 +92,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "__anonymous_1"}, + "__anonymous_1", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/inner_map_sys.c b/tests/bpf2c_tests/expected/inner_map_sys.c index e285270211..7428117ba7 100644 --- a/tests/bpf2c_tests/expected/inner_map_sys.c +++ b/tests/bpf2c_tests/expected/inner_map_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 25, // Identifier for a map template. 21, // The id of the inner map template. }, - "outer_map2"}, + "outer_map2", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -223,13 +227,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -241,7 +247,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "__anonymous_1"}, + "__anonymous_1", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/lru_map_test_dll.c b/tests/bpf2c_tests/expected/lru_map_test_dll.c index acade9008f..4f8c421590 100644 --- a/tests/bpf2c_tests/expected/lru_map_test_dll.c +++ b/tests/bpf2c_tests/expected/lru_map_test_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_HASH, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "lru_map"}, + "lru_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/lru_map_test_raw.c b/tests/bpf2c_tests/expected/lru_map_test_raw.c index 269ea95cd6..ce0a76308a 100644 --- a/tests/bpf2c_tests/expected/lru_map_test_raw.c +++ b/tests/bpf2c_tests/expected/lru_map_test_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_HASH, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "lru_map"}, + "lru_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/lru_map_test_sys.c b/tests/bpf2c_tests/expected/lru_map_test_sys.c index 0b5666c7e4..9e1988f3da 100644 --- a/tests/bpf2c_tests/expected/lru_map_test_sys.c +++ b/tests/bpf2c_tests/expected/lru_map_test_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_HASH, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "lru_map"}, + "lru_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_annotation_collision_dll.c b/tests/bpf2c_tests/expected/map_annotation_collision_dll.c index 4c10234c41..de7ce02870 100644 --- a/tests/bpf2c_tests/expected/map_annotation_collision_dll.c +++ b/tests/bpf2c_tests/expected/map_annotation_collision_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "hash_map"}, + "hash_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 19, // Identifier for a map template. 0, // The id of the inner map template. }, - "array_map"}, + "array_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_annotation_collision_raw.c b/tests/bpf2c_tests/expected/map_annotation_collision_raw.c index e04923038c..56fa4acc55 100644 --- a/tests/bpf2c_tests/expected/map_annotation_collision_raw.c +++ b/tests/bpf2c_tests/expected/map_annotation_collision_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "hash_map"}, + "hash_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 19, // Identifier for a map template. 0, // The id of the inner map template. }, - "array_map"}, + "array_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_annotation_collision_sys.c b/tests/bpf2c_tests/expected/map_annotation_collision_sys.c index 9c3fa32d49..a1304935d0 100644 --- a/tests/bpf2c_tests/expected/map_annotation_collision_sys.c +++ b/tests/bpf2c_tests/expected/map_annotation_collision_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "hash_map"}, + "hash_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 19, // Identifier for a map template. 0, // The id of the inner map template. }, - "array_map"}, + "array_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_dll.c b/tests/bpf2c_tests/expected/map_dll.c index b019132176..05f45339c3 100644 --- a/tests/bpf2c_tests/expected/map_dll.c +++ b/tests/bpf2c_tests/expected/map_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "HASH_map"}, + "HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERCPU_HASH, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "PERCPU_HASH_map"}, + "PERCPU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -98,13 +102,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "ARRAY_map"}, + "ARRAY_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERCPU_ARRAY, // Type of map. @@ -116,13 +122,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "PERCPU_ARRAY_map"}, + "PERCPU_ARRAY_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_HASH, // Type of map. @@ -134,13 +142,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "LRU_HASH_map"}, + "LRU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_PERCPU_HASH, // Type of map. @@ -152,13 +162,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "LRU_PERCPU_HASH_map"}, + "LRU_PERCPU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_QUEUE, // Type of map. @@ -170,13 +182,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "QUEUE_map"}, + "QUEUE_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_STACK, // Type of map. @@ -188,7 +202,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "STACK_map"}, + "STACK_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_btf_dll.c b/tests/bpf2c_tests/expected/map_in_map_btf_dll.c index 73221406e9..9f2026b274 100644 --- a/tests/bpf2c_tests/expected/map_in_map_btf_dll.c +++ b/tests/bpf2c_tests/expected/map_in_map_btf_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 8, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_btf_raw.c b/tests/bpf2c_tests/expected/map_in_map_btf_raw.c index 9500d36355..f917200b27 100644 --- a/tests/bpf2c_tests/expected/map_in_map_btf_raw.c +++ b/tests/bpf2c_tests/expected/map_in_map_btf_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 8, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_btf_sys.c b/tests/bpf2c_tests/expected/map_in_map_btf_sys.c index 799a535774..6d7514c361 100644 --- a/tests/bpf2c_tests/expected/map_in_map_btf_sys.c +++ b/tests/bpf2c_tests/expected/map_in_map_btf_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 14, // Identifier for a map template. 8, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_legacy_id_dll.c b/tests/bpf2c_tests/expected/map_in_map_legacy_id_dll.c index 6552506743..0245752f49 100644 --- a/tests/bpf2c_tests/expected/map_in_map_legacy_id_dll.c +++ b/tests/bpf2c_tests/expected/map_in_map_legacy_id_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 10, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_legacy_id_raw.c b/tests/bpf2c_tests/expected/map_in_map_legacy_id_raw.c index 84b40638c1..51187ca853 100644 --- a/tests/bpf2c_tests/expected/map_in_map_legacy_id_raw.c +++ b/tests/bpf2c_tests/expected/map_in_map_legacy_id_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 10, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_legacy_id_sys.c b/tests/bpf2c_tests/expected/map_in_map_legacy_id_sys.c index 42e1e42ee7..709ae82513 100644 --- a/tests/bpf2c_tests/expected/map_in_map_legacy_id_sys.c +++ b/tests/bpf2c_tests/expected/map_in_map_legacy_id_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 10, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_legacy_idx_dll.c b/tests/bpf2c_tests/expected/map_in_map_legacy_idx_dll.c index 923d4e39be..0bd832b914 100644 --- a/tests/bpf2c_tests/expected/map_in_map_legacy_idx_dll.c +++ b/tests/bpf2c_tests/expected/map_in_map_legacy_idx_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_legacy_idx_raw.c b/tests/bpf2c_tests/expected/map_in_map_legacy_idx_raw.c index d80183bfbe..cfc7eb54cc 100644 --- a/tests/bpf2c_tests/expected/map_in_map_legacy_idx_raw.c +++ b/tests/bpf2c_tests/expected/map_in_map_legacy_idx_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_in_map_legacy_idx_sys.c b/tests/bpf2c_tests/expected/map_in_map_legacy_idx_sys.c index 42a1f6368d..97850b69e1 100644 --- a/tests/bpf2c_tests/expected/map_in_map_legacy_idx_sys.c +++ b/tests/bpf2c_tests/expected/map_in_map_legacy_idx_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_max_entries_dll.c b/tests/bpf2c_tests/expected/map_max_entries_dll.c new file mode 100644 index 0000000000..a489c7c680 --- /dev/null +++ b/tests/bpf2c_tests/expected/map_max_entries_dll.c @@ -0,0 +1,246 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_max_entries.o + +#include "bpf2c.h" + +#include +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers. +#include + +#define metadata_table map_max_entries##_metadata_table +extern metadata_table_t metadata_table; + +bool APIENTRY +DllMain(_In_ HMODULE hModule, unsigned int ul_reason_for_call, _In_ void* lpReserved) +{ + UNREFERENCED_PARAMETER(hModule); + UNREFERENCED_PARAMETER(lpReserved); + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +__declspec(dllexport) metadata_table_t* +get_metadata_table() +{ + return &metadata_table; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "max_entries_map", // Map name. + 0, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 17 "sample/undocked/map_max_entries.c" +{ +#line 17 "sample/undocked/map_max_entries.c" + // Prologue. +#line 17 "sample/undocked/map_max_entries.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r0 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r1 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r2 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r3 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r4 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r5 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r10 = 0; + +#line 17 "sample/undocked/map_max_entries.c" + r1 = (uintptr_t)context; +#line 17 "sample/undocked/map_max_entries.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 17 "sample/undocked/map_max_entries.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 19 "sample/undocked/map_max_entries.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + if (r3 > r2) { +#line 19 "sample/undocked/map_max_entries.c" + goto label_1; +#line 19 "sample/undocked/map_max_entries.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 23 "sample/undocked/map_max_entries.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 23 "sample/undocked/map_max_entries.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 26 "sample/undocked/map_max_entries.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 26 "sample/undocked/map_max_entries.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 26 "sample/undocked/map_max_entries.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 27 "sample/undocked/map_max_entries.c" + return r0; +#line 17 "sample/undocked/map_max_entries.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_max_entries, + "sample~1", + "sample_ext", + "map_max_entries", + map_max_entries_maps, + 1, + map_max_entries_helpers, + 1, + 20, + &map_max_entries_program_type_guid, + &map_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_max_entries_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_max_entries_legacy_dll.c b/tests/bpf2c_tests/expected/map_max_entries_legacy_dll.c new file mode 100644 index 0000000000..291320b563 --- /dev/null +++ b/tests/bpf2c_tests/expected/map_max_entries_legacy_dll.c @@ -0,0 +1,246 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_max_entries_legacy.o + +#include "bpf2c.h" + +#include +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers. +#include + +#define metadata_table map_max_entries_legacy##_metadata_table +extern metadata_table_t metadata_table; + +bool APIENTRY +DllMain(_In_ HMODULE hModule, unsigned int ul_reason_for_call, _In_ void* lpReserved) +{ + UNREFERENCED_PARAMETER(hModule); + UNREFERENCED_PARAMETER(lpReserved); + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +__declspec(dllexport) metadata_table_t* +get_metadata_table() +{ + return &metadata_table; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 0, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "max_entries_map", // Map name. + 0, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 18 "sample/undocked/map_max_entries_legacy.c" +{ +#line 18 "sample/undocked/map_max_entries_legacy.c" + // Prologue. +#line 18 "sample/undocked/map_max_entries_legacy.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r0 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r1 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r2 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r3 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r4 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r5 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r10 = 0; + +#line 18 "sample/undocked/map_max_entries_legacy.c" + r1 = (uintptr_t)context; +#line 18 "sample/undocked/map_max_entries_legacy.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 18 "sample/undocked/map_max_entries_legacy.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 20 "sample/undocked/map_max_entries_legacy.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + if (r3 > r2) { +#line 20 "sample/undocked/map_max_entries_legacy.c" + goto label_1; +#line 20 "sample/undocked/map_max_entries_legacy.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_max_entries_legacy.c" + return r0; +#line 18 "sample/undocked/map_max_entries_legacy.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_max_entries, + "sample~1", + "sample_ext", + "map_max_entries", + map_max_entries_maps, + 1, + map_max_entries_helpers, + 1, + 20, + &map_max_entries_program_type_guid, + &map_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_max_entries_legacy_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_max_entries_legacy_raw.c b/tests/bpf2c_tests/expected/map_max_entries_legacy_raw.c new file mode 100644 index 0000000000..70aea9c113 --- /dev/null +++ b/tests/bpf2c_tests/expected/map_max_entries_legacy_raw.c @@ -0,0 +1,216 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_max_entries_legacy.o + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 0, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "max_entries_map", // Map name. + 0, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 18 "sample/undocked/map_max_entries_legacy.c" +{ +#line 18 "sample/undocked/map_max_entries_legacy.c" + // Prologue. +#line 18 "sample/undocked/map_max_entries_legacy.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r0 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r1 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r2 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r3 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r4 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r5 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r10 = 0; + +#line 18 "sample/undocked/map_max_entries_legacy.c" + r1 = (uintptr_t)context; +#line 18 "sample/undocked/map_max_entries_legacy.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 18 "sample/undocked/map_max_entries_legacy.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 20 "sample/undocked/map_max_entries_legacy.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + if (r3 > r2) { +#line 20 "sample/undocked/map_max_entries_legacy.c" + goto label_1; +#line 20 "sample/undocked/map_max_entries_legacy.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_max_entries_legacy.c" + return r0; +#line 18 "sample/undocked/map_max_entries_legacy.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_max_entries, + "sample~1", + "sample_ext", + "map_max_entries", + map_max_entries_maps, + 1, + map_max_entries_helpers, + 1, + 20, + &map_max_entries_program_type_guid, + &map_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_max_entries_legacy_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_max_entries_legacy_sys.c b/tests/bpf2c_tests/expected/map_max_entries_legacy_sys.c new file mode 100644 index 0000000000..6d8d0f633d --- /dev/null +++ b/tests/bpf2c_tests/expected/map_max_entries_legacy_sys.c @@ -0,0 +1,371 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_max_entries_legacy.o + +#define NO_CRT +#include "bpf2c.h" + +#include +#include +#include + +DRIVER_INITIALIZE DriverEntry; +DRIVER_UNLOAD DriverUnload; +RTL_QUERY_REGISTRY_ROUTINE static _bpf2c_query_registry_routine; + +#define metadata_table map_max_entries_legacy##_metadata_table + +static GUID _bpf2c_npi_id = {/* c847aac8-a6f2-4b53-aea3-f4a94b9a80cb */ + 0xc847aac8, + 0xa6f2, + 0x4b53, + {0xae, 0xa3, 0xf4, 0xa9, 0x4b, 0x9a, 0x80, 0xcb}}; +static NPI_MODULEID _bpf2c_module_id = {sizeof(_bpf2c_module_id), MIT_GUID, {0}}; +static HANDLE _bpf2c_nmr_client_handle; +static HANDLE _bpf2c_nmr_provider_handle; +extern metadata_table_t metadata_table; + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance); + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context); + +static const NPI_CLIENT_CHARACTERISTICS _bpf2c_npi_client_characteristics = { + 0, // Version + sizeof(NPI_CLIENT_CHARACTERISTICS), // Length + _bpf2c_npi_client_attach_provider, + _bpf2c_npi_client_detach_provider, + NULL, + {0, // Version + sizeof(NPI_REGISTRATION_INSTANCE), // Length + &_bpf2c_npi_id, + &_bpf2c_module_id, + 0, + NULL}}; + +static NTSTATUS +_bpf2c_query_npi_module_id( + _In_ const wchar_t* value_name, + unsigned long value_type, + _In_ const void* value_data, + unsigned long value_length, + _Inout_ void* context, + _Inout_ void* entry_context) +{ + UNREFERENCED_PARAMETER(value_name); + UNREFERENCED_PARAMETER(context); + UNREFERENCED_PARAMETER(entry_context); + + if (value_type != REG_BINARY) { + return STATUS_INVALID_PARAMETER; + } + if (value_length != sizeof(_bpf2c_module_id.Guid)) { + return STATUS_INVALID_PARAMETER; + } + + memcpy(&_bpf2c_module_id.Guid, value_data, value_length); + return STATUS_SUCCESS; +} + +NTSTATUS +DriverEntry(_In_ DRIVER_OBJECT* driver_object, _In_ UNICODE_STRING* registry_path) +{ + NTSTATUS status; + RTL_QUERY_REGISTRY_TABLE query_table[] = { + { + NULL, // Query routine + RTL_QUERY_REGISTRY_SUBKEY, // Flags + L"Parameters", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + { + _bpf2c_query_npi_module_id, // Query routine + RTL_QUERY_REGISTRY_REQUIRED, // Flags + L"NpiModuleId", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + {0}}; + + status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, registry_path->Buffer, query_table, NULL, NULL); + if (!NT_SUCCESS(status)) { + goto Exit; + } + + status = NmrRegisterClient(&_bpf2c_npi_client_characteristics, NULL, &_bpf2c_nmr_client_handle); + +Exit: + if (NT_SUCCESS(status)) { + driver_object->DriverUnload = DriverUnload; + } + + return status; +} + +void +DriverUnload(_In_ DRIVER_OBJECT* driver_object) +{ + NTSTATUS status = NmrDeregisterClient(_bpf2c_nmr_client_handle); + if (status == STATUS_PENDING) { + NmrWaitForClientDeregisterComplete(_bpf2c_nmr_client_handle); + } + UNREFERENCED_PARAMETER(driver_object); +} + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance) +{ + NTSTATUS status = STATUS_SUCCESS; + void* provider_binding_context = NULL; + void* provider_dispatch_table = NULL; + + UNREFERENCED_PARAMETER(client_context); + UNREFERENCED_PARAMETER(provider_registration_instance); + + if (_bpf2c_nmr_provider_handle != NULL) { + return STATUS_INVALID_PARAMETER; + } + + status = NmrClientAttachProvider( + nmr_binding_handle, client_context, &metadata_table, &provider_binding_context, &provider_dispatch_table); + if (status != STATUS_SUCCESS) { + goto Done; + } + _bpf2c_nmr_provider_handle = nmr_binding_handle; + +Done: + return status; +} + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context) +{ + _bpf2c_nmr_provider_handle = NULL; + UNREFERENCED_PARAMETER(client_binding_context); + return STATUS_SUCCESS; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 0, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "max_entries_map", // Map name. + 0, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 18 "sample/undocked/map_max_entries_legacy.c" +{ +#line 18 "sample/undocked/map_max_entries_legacy.c" + // Prologue. +#line 18 "sample/undocked/map_max_entries_legacy.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r0 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r1 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r2 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r3 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r4 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r5 = 0; +#line 18 "sample/undocked/map_max_entries_legacy.c" + register uint64_t r10 = 0; + +#line 18 "sample/undocked/map_max_entries_legacy.c" + r1 = (uintptr_t)context; +#line 18 "sample/undocked/map_max_entries_legacy.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 18 "sample/undocked/map_max_entries_legacy.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 20 "sample/undocked/map_max_entries_legacy.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 20 "sample/undocked/map_max_entries_legacy.c" + if (r3 > r2) { +#line 20 "sample/undocked/map_max_entries_legacy.c" + goto label_1; +#line 20 "sample/undocked/map_max_entries_legacy.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_max_entries_legacy.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 24 "sample/undocked/map_max_entries_legacy.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 27 "sample/undocked/map_max_entries_legacy.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_max_entries_legacy.c" + return r0; +#line 18 "sample/undocked/map_max_entries_legacy.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_max_entries, + "sample~1", + "sample_ext", + "map_max_entries", + map_max_entries_maps, + 1, + map_max_entries_helpers, + 1, + 20, + &map_max_entries_program_type_guid, + &map_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_max_entries_legacy_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_max_entries_raw.c b/tests/bpf2c_tests/expected/map_max_entries_raw.c new file mode 100644 index 0000000000..2edff4102c --- /dev/null +++ b/tests/bpf2c_tests/expected/map_max_entries_raw.c @@ -0,0 +1,216 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_max_entries.o + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "max_entries_map", // Map name. + 0, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 17 "sample/undocked/map_max_entries.c" +{ +#line 17 "sample/undocked/map_max_entries.c" + // Prologue. +#line 17 "sample/undocked/map_max_entries.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r0 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r1 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r2 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r3 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r4 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r5 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r10 = 0; + +#line 17 "sample/undocked/map_max_entries.c" + r1 = (uintptr_t)context; +#line 17 "sample/undocked/map_max_entries.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 17 "sample/undocked/map_max_entries.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 19 "sample/undocked/map_max_entries.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + if (r3 > r2) { +#line 19 "sample/undocked/map_max_entries.c" + goto label_1; +#line 19 "sample/undocked/map_max_entries.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 23 "sample/undocked/map_max_entries.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 23 "sample/undocked/map_max_entries.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 26 "sample/undocked/map_max_entries.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 26 "sample/undocked/map_max_entries.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 26 "sample/undocked/map_max_entries.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 27 "sample/undocked/map_max_entries.c" + return r0; +#line 17 "sample/undocked/map_max_entries.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_max_entries, + "sample~1", + "sample_ext", + "map_max_entries", + map_max_entries_maps, + 1, + map_max_entries_helpers, + 1, + 20, + &map_max_entries_program_type_guid, + &map_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_max_entries_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_max_entries_sys.c b/tests/bpf2c_tests/expected/map_max_entries_sys.c new file mode 100644 index 0000000000..c75d09f530 --- /dev/null +++ b/tests/bpf2c_tests/expected/map_max_entries_sys.c @@ -0,0 +1,371 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_max_entries.o + +#define NO_CRT +#include "bpf2c.h" + +#include +#include +#include + +DRIVER_INITIALIZE DriverEntry; +DRIVER_UNLOAD DriverUnload; +RTL_QUERY_REGISTRY_ROUTINE static _bpf2c_query_registry_routine; + +#define metadata_table map_max_entries##_metadata_table + +static GUID _bpf2c_npi_id = {/* c847aac8-a6f2-4b53-aea3-f4a94b9a80cb */ + 0xc847aac8, + 0xa6f2, + 0x4b53, + {0xae, 0xa3, 0xf4, 0xa9, 0x4b, 0x9a, 0x80, 0xcb}}; +static NPI_MODULEID _bpf2c_module_id = {sizeof(_bpf2c_module_id), MIT_GUID, {0}}; +static HANDLE _bpf2c_nmr_client_handle; +static HANDLE _bpf2c_nmr_provider_handle; +extern metadata_table_t metadata_table; + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance); + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context); + +static const NPI_CLIENT_CHARACTERISTICS _bpf2c_npi_client_characteristics = { + 0, // Version + sizeof(NPI_CLIENT_CHARACTERISTICS), // Length + _bpf2c_npi_client_attach_provider, + _bpf2c_npi_client_detach_provider, + NULL, + {0, // Version + sizeof(NPI_REGISTRATION_INSTANCE), // Length + &_bpf2c_npi_id, + &_bpf2c_module_id, + 0, + NULL}}; + +static NTSTATUS +_bpf2c_query_npi_module_id( + _In_ const wchar_t* value_name, + unsigned long value_type, + _In_ const void* value_data, + unsigned long value_length, + _Inout_ void* context, + _Inout_ void* entry_context) +{ + UNREFERENCED_PARAMETER(value_name); + UNREFERENCED_PARAMETER(context); + UNREFERENCED_PARAMETER(entry_context); + + if (value_type != REG_BINARY) { + return STATUS_INVALID_PARAMETER; + } + if (value_length != sizeof(_bpf2c_module_id.Guid)) { + return STATUS_INVALID_PARAMETER; + } + + memcpy(&_bpf2c_module_id.Guid, value_data, value_length); + return STATUS_SUCCESS; +} + +NTSTATUS +DriverEntry(_In_ DRIVER_OBJECT* driver_object, _In_ UNICODE_STRING* registry_path) +{ + NTSTATUS status; + RTL_QUERY_REGISTRY_TABLE query_table[] = { + { + NULL, // Query routine + RTL_QUERY_REGISTRY_SUBKEY, // Flags + L"Parameters", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + { + _bpf2c_query_npi_module_id, // Query routine + RTL_QUERY_REGISTRY_REQUIRED, // Flags + L"NpiModuleId", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + {0}}; + + status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, registry_path->Buffer, query_table, NULL, NULL); + if (!NT_SUCCESS(status)) { + goto Exit; + } + + status = NmrRegisterClient(&_bpf2c_npi_client_characteristics, NULL, &_bpf2c_nmr_client_handle); + +Exit: + if (NT_SUCCESS(status)) { + driver_object->DriverUnload = DriverUnload; + } + + return status; +} + +void +DriverUnload(_In_ DRIVER_OBJECT* driver_object) +{ + NTSTATUS status = NmrDeregisterClient(_bpf2c_nmr_client_handle); + if (status == STATUS_PENDING) { + NmrWaitForClientDeregisterComplete(_bpf2c_nmr_client_handle); + } + UNREFERENCED_PARAMETER(driver_object); +} + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance) +{ + NTSTATUS status = STATUS_SUCCESS; + void* provider_binding_context = NULL; + void* provider_dispatch_table = NULL; + + UNREFERENCED_PARAMETER(client_context); + UNREFERENCED_PARAMETER(provider_registration_instance); + + if (_bpf2c_nmr_provider_handle != NULL) { + return STATUS_INVALID_PARAMETER; + } + + status = NmrClientAttachProvider( + nmr_binding_handle, client_context, &metadata_table, &provider_binding_context, &provider_dispatch_table); + if (status != STATUS_SUCCESS) { + goto Done; + } + _bpf2c_nmr_provider_handle = nmr_binding_handle; + +Done: + return status; +} + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context) +{ + _bpf2c_nmr_provider_handle = NULL; + UNREFERENCED_PARAMETER(client_binding_context); + return STATUS_SUCCESS; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "max_entries_map", // Map name. + 0, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 17 "sample/undocked/map_max_entries.c" +{ +#line 17 "sample/undocked/map_max_entries.c" + // Prologue. +#line 17 "sample/undocked/map_max_entries.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r0 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r1 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r2 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r3 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r4 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r5 = 0; +#line 17 "sample/undocked/map_max_entries.c" + register uint64_t r10 = 0; + +#line 17 "sample/undocked/map_max_entries.c" + r1 = (uintptr_t)context; +#line 17 "sample/undocked/map_max_entries.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 17 "sample/undocked/map_max_entries.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 19 "sample/undocked/map_max_entries.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 19 "sample/undocked/map_max_entries.c" + if (r3 > r2) { +#line 19 "sample/undocked/map_max_entries.c" + goto label_1; +#line 19 "sample/undocked/map_max_entries.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 24 "sample/undocked/map_max_entries.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 23 "sample/undocked/map_max_entries.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 23 "sample/undocked/map_max_entries.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 23 "sample/undocked/map_max_entries.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 26 "sample/undocked/map_max_entries.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 26 "sample/undocked/map_max_entries.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 26 "sample/undocked/map_max_entries.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 27 "sample/undocked/map_max_entries.c" + return r0; +#line 17 "sample/undocked/map_max_entries.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_max_entries, + "sample~1", + "sample_ext", + "map_max_entries", + map_max_entries_maps, + 1, + map_max_entries_helpers, + 1, + 20, + &map_max_entries_program_type_guid, + &map_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_max_entries_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_no_max_entries_dll.c b/tests/bpf2c_tests/expected/map_no_max_entries_dll.c new file mode 100644 index 0000000000..bcaf272be3 --- /dev/null +++ b/tests/bpf2c_tests/expected/map_no_max_entries_dll.c @@ -0,0 +1,246 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_no_max_entries.o + +#include "bpf2c.h" + +#include +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers. +#include + +#define metadata_table map_no_max_entries##_metadata_table +extern metadata_table_t metadata_table; + +bool APIENTRY +DllMain(_In_ HMODULE hModule, unsigned int ul_reason_for_call, _In_ void* lpReserved) +{ + UNREFERENCED_PARAMETER(hModule); + UNREFERENCED_PARAMETER(lpReserved); + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +__declspec(dllexport) metadata_table_t* +get_metadata_table() +{ + return &metadata_table; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "no_max_entries_map", // Map name. + 1, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_no_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_no_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_no_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_no_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_no_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 19 "sample/undocked/map_no_max_entries.c" +{ +#line 19 "sample/undocked/map_no_max_entries.c" + // Prologue. +#line 19 "sample/undocked/map_no_max_entries.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r0 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r1 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r2 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r3 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r4 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r5 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r10 = 0; + +#line 19 "sample/undocked/map_no_max_entries.c" + r1 = (uintptr_t)context; +#line 19 "sample/undocked/map_no_max_entries.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 19 "sample/undocked/map_no_max_entries.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 21 "sample/undocked/map_no_max_entries.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + if (r3 > r2) { +#line 21 "sample/undocked/map_no_max_entries.c" + goto label_1; +#line 21 "sample/undocked/map_no_max_entries.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 25 "sample/undocked/map_no_max_entries.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 25 "sample/undocked/map_no_max_entries.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 28 "sample/undocked/map_no_max_entries.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_no_max_entries.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 28 "sample/undocked/map_no_max_entries.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 29 "sample/undocked/map_no_max_entries.c" + return r0; +#line 19 "sample/undocked/map_no_max_entries.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_no_max_entries, + "sample~1", + "sample_ext", + "map_no_max_entries", + map_no_max_entries_maps, + 1, + map_no_max_entries_helpers, + 1, + 20, + &map_no_max_entries_program_type_guid, + &map_no_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_no_max_entries_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_no_max_entries_legacy_dll.c b/tests/bpf2c_tests/expected/map_no_max_entries_legacy_dll.c new file mode 100644 index 0000000000..54b18f4e2a --- /dev/null +++ b/tests/bpf2c_tests/expected/map_no_max_entries_legacy_dll.c @@ -0,0 +1,246 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_no_max_entries_legacy.o + +#include "bpf2c.h" + +#include +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers. +#include + +#define metadata_table map_no_max_entries_legacy##_metadata_table +extern metadata_table_t metadata_table; + +bool APIENTRY +DllMain(_In_ HMODULE hModule, unsigned int ul_reason_for_call, _In_ void* lpReserved) +{ + UNREFERENCED_PARAMETER(hModule); + UNREFERENCED_PARAMETER(lpReserved); + switch (ul_reason_for_call) { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +__declspec(dllexport) metadata_table_t* +get_metadata_table() +{ + return &metadata_table; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 0, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "no_max_entries_map", // Map name. + 1, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_no_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_no_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_no_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_no_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_no_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 19 "sample/undocked/map_no_max_entries_legacy.c" +{ +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + // Prologue. +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r0 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r1 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r2 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r3 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r4 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r5 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r10 = 0; + +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r1 = (uintptr_t)context; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + if (r3 > r2) { +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + goto label_1; +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 29 "sample/undocked/map_no_max_entries_legacy.c" + return r0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_no_max_entries, + "sample~1", + "sample_ext", + "map_no_max_entries", + map_no_max_entries_maps, + 1, + map_no_max_entries_helpers, + 1, + 20, + &map_no_max_entries_program_type_guid, + &map_no_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_no_max_entries_legacy_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_no_max_entries_legacy_raw.c b/tests/bpf2c_tests/expected/map_no_max_entries_legacy_raw.c new file mode 100644 index 0000000000..20417aa8af --- /dev/null +++ b/tests/bpf2c_tests/expected/map_no_max_entries_legacy_raw.c @@ -0,0 +1,216 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_no_max_entries_legacy.o + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 0, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "no_max_entries_map", // Map name. + 1, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_no_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_no_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_no_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_no_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_no_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 19 "sample/undocked/map_no_max_entries_legacy.c" +{ +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + // Prologue. +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r0 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r1 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r2 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r3 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r4 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r5 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r10 = 0; + +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r1 = (uintptr_t)context; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + if (r3 > r2) { +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + goto label_1; +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 29 "sample/undocked/map_no_max_entries_legacy.c" + return r0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_no_max_entries, + "sample~1", + "sample_ext", + "map_no_max_entries", + map_no_max_entries_maps, + 1, + map_no_max_entries_helpers, + 1, + 20, + &map_no_max_entries_program_type_guid, + &map_no_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_no_max_entries_legacy_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_no_max_entries_legacy_sys.c b/tests/bpf2c_tests/expected/map_no_max_entries_legacy_sys.c new file mode 100644 index 0000000000..33b32e1626 --- /dev/null +++ b/tests/bpf2c_tests/expected/map_no_max_entries_legacy_sys.c @@ -0,0 +1,371 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_no_max_entries_legacy.o + +#define NO_CRT +#include "bpf2c.h" + +#include +#include +#include + +DRIVER_INITIALIZE DriverEntry; +DRIVER_UNLOAD DriverUnload; +RTL_QUERY_REGISTRY_ROUTINE static _bpf2c_query_registry_routine; + +#define metadata_table map_no_max_entries_legacy##_metadata_table + +static GUID _bpf2c_npi_id = {/* c847aac8-a6f2-4b53-aea3-f4a94b9a80cb */ + 0xc847aac8, + 0xa6f2, + 0x4b53, + {0xae, 0xa3, 0xf4, 0xa9, 0x4b, 0x9a, 0x80, 0xcb}}; +static NPI_MODULEID _bpf2c_module_id = {sizeof(_bpf2c_module_id), MIT_GUID, {0}}; +static HANDLE _bpf2c_nmr_client_handle; +static HANDLE _bpf2c_nmr_provider_handle; +extern metadata_table_t metadata_table; + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance); + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context); + +static const NPI_CLIENT_CHARACTERISTICS _bpf2c_npi_client_characteristics = { + 0, // Version + sizeof(NPI_CLIENT_CHARACTERISTICS), // Length + _bpf2c_npi_client_attach_provider, + _bpf2c_npi_client_detach_provider, + NULL, + {0, // Version + sizeof(NPI_REGISTRATION_INSTANCE), // Length + &_bpf2c_npi_id, + &_bpf2c_module_id, + 0, + NULL}}; + +static NTSTATUS +_bpf2c_query_npi_module_id( + _In_ const wchar_t* value_name, + unsigned long value_type, + _In_ const void* value_data, + unsigned long value_length, + _Inout_ void* context, + _Inout_ void* entry_context) +{ + UNREFERENCED_PARAMETER(value_name); + UNREFERENCED_PARAMETER(context); + UNREFERENCED_PARAMETER(entry_context); + + if (value_type != REG_BINARY) { + return STATUS_INVALID_PARAMETER; + } + if (value_length != sizeof(_bpf2c_module_id.Guid)) { + return STATUS_INVALID_PARAMETER; + } + + memcpy(&_bpf2c_module_id.Guid, value_data, value_length); + return STATUS_SUCCESS; +} + +NTSTATUS +DriverEntry(_In_ DRIVER_OBJECT* driver_object, _In_ UNICODE_STRING* registry_path) +{ + NTSTATUS status; + RTL_QUERY_REGISTRY_TABLE query_table[] = { + { + NULL, // Query routine + RTL_QUERY_REGISTRY_SUBKEY, // Flags + L"Parameters", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + { + _bpf2c_query_npi_module_id, // Query routine + RTL_QUERY_REGISTRY_REQUIRED, // Flags + L"NpiModuleId", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + {0}}; + + status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, registry_path->Buffer, query_table, NULL, NULL); + if (!NT_SUCCESS(status)) { + goto Exit; + } + + status = NmrRegisterClient(&_bpf2c_npi_client_characteristics, NULL, &_bpf2c_nmr_client_handle); + +Exit: + if (NT_SUCCESS(status)) { + driver_object->DriverUnload = DriverUnload; + } + + return status; +} + +void +DriverUnload(_In_ DRIVER_OBJECT* driver_object) +{ + NTSTATUS status = NmrDeregisterClient(_bpf2c_nmr_client_handle); + if (status == STATUS_PENDING) { + NmrWaitForClientDeregisterComplete(_bpf2c_nmr_client_handle); + } + UNREFERENCED_PARAMETER(driver_object); +} + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance) +{ + NTSTATUS status = STATUS_SUCCESS; + void* provider_binding_context = NULL; + void* provider_dispatch_table = NULL; + + UNREFERENCED_PARAMETER(client_context); + UNREFERENCED_PARAMETER(provider_registration_instance); + + if (_bpf2c_nmr_provider_handle != NULL) { + return STATUS_INVALID_PARAMETER; + } + + status = NmrClientAttachProvider( + nmr_binding_handle, client_context, &metadata_table, &provider_binding_context, &provider_dispatch_table); + if (status != STATUS_SUCCESS) { + goto Done; + } + _bpf2c_nmr_provider_handle = nmr_binding_handle; + +Done: + return status; +} + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context) +{ + _bpf2c_nmr_provider_handle = NULL; + UNREFERENCED_PARAMETER(client_binding_context); + return STATUS_SUCCESS; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 0, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "no_max_entries_map", // Map name. + 1, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_no_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_no_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_no_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_no_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_no_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 19 "sample/undocked/map_no_max_entries_legacy.c" +{ +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + // Prologue. +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r0 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r1 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r2 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r3 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r4 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r5 = 0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + register uint64_t r10 = 0; + +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r1 = (uintptr_t)context; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 19 "sample/undocked/map_no_max_entries_legacy.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + if (r3 > r2) { +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + goto label_1; +#line 21 "sample/undocked/map_no_max_entries_legacy.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries_legacy.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 25 "sample/undocked/map_no_max_entries_legacy.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 28 "sample/undocked/map_no_max_entries_legacy.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 29 "sample/undocked/map_no_max_entries_legacy.c" + return r0; +#line 19 "sample/undocked/map_no_max_entries_legacy.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_no_max_entries, + "sample~1", + "sample_ext", + "map_no_max_entries", + map_no_max_entries_maps, + 1, + map_no_max_entries_helpers, + 1, + 20, + &map_no_max_entries_program_type_guid, + &map_no_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_no_max_entries_legacy_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_no_max_entries_raw.c b/tests/bpf2c_tests/expected/map_no_max_entries_raw.c new file mode 100644 index 0000000000..b8d11f984f --- /dev/null +++ b/tests/bpf2c_tests/expected/map_no_max_entries_raw.c @@ -0,0 +1,216 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_no_max_entries.o + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "no_max_entries_map", // Map name. + 1, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_no_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_no_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_no_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_no_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_no_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 19 "sample/undocked/map_no_max_entries.c" +{ +#line 19 "sample/undocked/map_no_max_entries.c" + // Prologue. +#line 19 "sample/undocked/map_no_max_entries.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r0 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r1 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r2 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r3 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r4 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r5 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r10 = 0; + +#line 19 "sample/undocked/map_no_max_entries.c" + r1 = (uintptr_t)context; +#line 19 "sample/undocked/map_no_max_entries.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 19 "sample/undocked/map_no_max_entries.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 21 "sample/undocked/map_no_max_entries.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + if (r3 > r2) { +#line 21 "sample/undocked/map_no_max_entries.c" + goto label_1; +#line 21 "sample/undocked/map_no_max_entries.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 25 "sample/undocked/map_no_max_entries.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 25 "sample/undocked/map_no_max_entries.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 28 "sample/undocked/map_no_max_entries.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_no_max_entries.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 28 "sample/undocked/map_no_max_entries.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 29 "sample/undocked/map_no_max_entries.c" + return r0; +#line 19 "sample/undocked/map_no_max_entries.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_no_max_entries, + "sample~1", + "sample_ext", + "map_no_max_entries", + map_no_max_entries_maps, + 1, + map_no_max_entries_helpers, + 1, + 20, + &map_no_max_entries_program_type_guid, + &map_no_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_no_max_entries_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_no_max_entries_sys.c b/tests/bpf2c_tests/expected/map_no_max_entries_sys.c new file mode 100644 index 0000000000..0a0585cbb7 --- /dev/null +++ b/tests/bpf2c_tests/expected/map_no_max_entries_sys.c @@ -0,0 +1,371 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Do not alter this generated file. +// This file was generated from map_no_max_entries.o + +#define NO_CRT +#include "bpf2c.h" + +#include +#include +#include + +DRIVER_INITIALIZE DriverEntry; +DRIVER_UNLOAD DriverUnload; +RTL_QUERY_REGISTRY_ROUTINE static _bpf2c_query_registry_routine; + +#define metadata_table map_no_max_entries##_metadata_table + +static GUID _bpf2c_npi_id = {/* c847aac8-a6f2-4b53-aea3-f4a94b9a80cb */ + 0xc847aac8, + 0xa6f2, + 0x4b53, + {0xae, 0xa3, 0xf4, 0xa9, 0x4b, 0x9a, 0x80, 0xcb}}; +static NPI_MODULEID _bpf2c_module_id = {sizeof(_bpf2c_module_id), MIT_GUID, {0}}; +static HANDLE _bpf2c_nmr_client_handle; +static HANDLE _bpf2c_nmr_provider_handle; +extern metadata_table_t metadata_table; + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance); + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context); + +static const NPI_CLIENT_CHARACTERISTICS _bpf2c_npi_client_characteristics = { + 0, // Version + sizeof(NPI_CLIENT_CHARACTERISTICS), // Length + _bpf2c_npi_client_attach_provider, + _bpf2c_npi_client_detach_provider, + NULL, + {0, // Version + sizeof(NPI_REGISTRATION_INSTANCE), // Length + &_bpf2c_npi_id, + &_bpf2c_module_id, + 0, + NULL}}; + +static NTSTATUS +_bpf2c_query_npi_module_id( + _In_ const wchar_t* value_name, + unsigned long value_type, + _In_ const void* value_data, + unsigned long value_length, + _Inout_ void* context, + _Inout_ void* entry_context) +{ + UNREFERENCED_PARAMETER(value_name); + UNREFERENCED_PARAMETER(context); + UNREFERENCED_PARAMETER(entry_context); + + if (value_type != REG_BINARY) { + return STATUS_INVALID_PARAMETER; + } + if (value_length != sizeof(_bpf2c_module_id.Guid)) { + return STATUS_INVALID_PARAMETER; + } + + memcpy(&_bpf2c_module_id.Guid, value_data, value_length); + return STATUS_SUCCESS; +} + +NTSTATUS +DriverEntry(_In_ DRIVER_OBJECT* driver_object, _In_ UNICODE_STRING* registry_path) +{ + NTSTATUS status; + RTL_QUERY_REGISTRY_TABLE query_table[] = { + { + NULL, // Query routine + RTL_QUERY_REGISTRY_SUBKEY, // Flags + L"Parameters", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + { + _bpf2c_query_npi_module_id, // Query routine + RTL_QUERY_REGISTRY_REQUIRED, // Flags + L"NpiModuleId", // Name + NULL, // Entry context + REG_NONE, // Default type + NULL, // Default data + 0, // Default length + }, + {0}}; + + status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, registry_path->Buffer, query_table, NULL, NULL); + if (!NT_SUCCESS(status)) { + goto Exit; + } + + status = NmrRegisterClient(&_bpf2c_npi_client_characteristics, NULL, &_bpf2c_nmr_client_handle); + +Exit: + if (NT_SUCCESS(status)) { + driver_object->DriverUnload = DriverUnload; + } + + return status; +} + +void +DriverUnload(_In_ DRIVER_OBJECT* driver_object) +{ + NTSTATUS status = NmrDeregisterClient(_bpf2c_nmr_client_handle); + if (status == STATUS_PENDING) { + NmrWaitForClientDeregisterComplete(_bpf2c_nmr_client_handle); + } + UNREFERENCED_PARAMETER(driver_object); +} + +static NTSTATUS +_bpf2c_npi_client_attach_provider( + _In_ HANDLE nmr_binding_handle, + _In_ void* client_context, + _In_ const NPI_REGISTRATION_INSTANCE* provider_registration_instance) +{ + NTSTATUS status = STATUS_SUCCESS; + void* provider_binding_context = NULL; + void* provider_dispatch_table = NULL; + + UNREFERENCED_PARAMETER(client_context); + UNREFERENCED_PARAMETER(provider_registration_instance); + + if (_bpf2c_nmr_provider_handle != NULL) { + return STATUS_INVALID_PARAMETER; + } + + status = NmrClientAttachProvider( + nmr_binding_handle, client_context, &metadata_table, &provider_binding_context, &provider_dispatch_table); + if (status != STATUS_SUCCESS) { + goto Done; + } + _bpf2c_nmr_provider_handle = nmr_binding_handle; + +Done: + return status; +} + +static NTSTATUS +_bpf2c_npi_client_detach_provider(_In_ void* client_binding_context) +{ + _bpf2c_nmr_provider_handle = NULL; + UNREFERENCED_PARAMETER(client_binding_context); + return STATUS_SUCCESS; +} + +#include "bpf2c.h" + +static void +_get_hash(_Outptr_result_buffer_maybenull_(*size) const uint8_t** hash, _Out_ size_t* size) +{ + *hash = NULL; + *size = 0; +} + +#pragma data_seg(push, "maps") +static map_entry_t _maps[] = { + { + {0, 0}, + { + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. + }, + { + BPF_MAP_TYPE_HASH, // Type of map. + 4, // Size in bytes of a map key. + 8, // Size in bytes of a map value. + 2, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 13, // Identifier for a map template. + 0, // The id of the inner map template. + }, + "no_max_entries_map", // Map name. + 1, // Map creation flags. + }, +}; +#pragma data_seg(pop) + +static void +_get_maps(_Outptr_result_buffer_maybenull_(*count) map_entry_t** maps, _Out_ size_t* count) +{ + *maps = _maps; + *count = 1; +} + +static void +_get_global_variable_sections( + _Outptr_result_buffer_maybenull_(*count) global_variable_section_info_t** global_variable_sections, + _Out_ size_t* count) +{ + *global_variable_sections = NULL; + *count = 0; +} + +static helper_function_entry_t map_no_max_entries_helpers[] = { + { + {1, 40, 40}, // Version header. + 2, + "helper_id_2", + }, +}; + +static GUID map_no_max_entries_program_type_guid = { + 0xf788ef4a, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static GUID map_no_max_entries_attach_type_guid = { + 0xf788ef4b, 0x207d, 0x4dc3, {0x85, 0xcf, 0x0f, 0x2e, 0xa1, 0x07, 0x21, 0x3c}}; +static uint16_t map_no_max_entries_maps[] = { + 0, +}; + +#pragma code_seg(push, "sample~1") +static uint64_t +map_no_max_entries(void* context, const program_runtime_context_t* runtime_context) +#line 19 "sample/undocked/map_no_max_entries.c" +{ +#line 19 "sample/undocked/map_no_max_entries.c" + // Prologue. +#line 19 "sample/undocked/map_no_max_entries.c" + uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r0 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r1 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r2 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r3 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r4 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r5 = 0; +#line 19 "sample/undocked/map_no_max_entries.c" + register uint64_t r10 = 0; + +#line 19 "sample/undocked/map_no_max_entries.c" + r1 = (uintptr_t)context; +#line 19 "sample/undocked/map_no_max_entries.c" + r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); + + // EBPF_OP_LDDW pc=0 dst=r0 src=r0 offset=0 imm=-1 +#line 19 "sample/undocked/map_no_max_entries.c" + r0 = (uint64_t)4294967295; + // EBPF_OP_LDXDW pc=2 dst=r2 src=r1 offset=8 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + READ_ONCE_64(r2, r1, OFFSET(8)); + // EBPF_OP_LDXDW pc=3 dst=r1 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + READ_ONCE_64(r1, r1, OFFSET(0)); + // EBPF_OP_MOV64_REG pc=4 dst=r3 src=r1 offset=0 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + r3 = r1; + // EBPF_OP_ADD64_IMM pc=5 dst=r3 src=r0 offset=0 imm=4 +#line 21 "sample/undocked/map_no_max_entries.c" + r3 += IMMEDIATE(4); + // EBPF_OP_JGT_REG pc=6 dst=r3 src=r2 offset=12 imm=0 +#line 21 "sample/undocked/map_no_max_entries.c" + if (r3 > r2) { +#line 21 "sample/undocked/map_no_max_entries.c" + goto label_1; +#line 21 "sample/undocked/map_no_max_entries.c" + } + // EBPF_OP_LDXW pc=7 dst=r1 src=r1 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + READ_ONCE_32(r1, r1, OFFSET(0)); + // EBPF_OP_STXW pc=8 dst=r10 src=r1 offset=-4 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-4)); + // EBPF_OP_MUL64_REG pc=9 dst=r1 src=r1 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + r1 *= r1; + // EBPF_OP_STXDW pc=10 dst=r10 src=r1 offset=-16 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + WRITE_ONCE_64(r10, (uint64_t)r1, OFFSET(-16)); + // EBPF_OP_MOV64_REG pc=11 dst=r2 src=r10 offset=0 imm=0 +#line 26 "sample/undocked/map_no_max_entries.c" + r2 = r10; + // EBPF_OP_ADD64_IMM pc=12 dst=r2 src=r0 offset=0 imm=-4 +#line 25 "sample/undocked/map_no_max_entries.c" + r2 += IMMEDIATE(-4); + // EBPF_OP_MOV64_REG pc=13 dst=r3 src=r10 offset=0 imm=0 +#line 25 "sample/undocked/map_no_max_entries.c" + r3 = r10; + // EBPF_OP_ADD64_IMM pc=14 dst=r3 src=r0 offset=0 imm=-16 +#line 25 "sample/undocked/map_no_max_entries.c" + r3 += IMMEDIATE(-16); + // EBPF_OP_LDDW pc=15 dst=r1 src=r1 offset=0 imm=1 +#line 28 "sample/undocked/map_no_max_entries.c" + r1 = POINTER(runtime_context->map_data[0].address); + // EBPF_OP_MOV64_IMM pc=17 dst=r4 src=r0 offset=0 imm=0 +#line 28 "sample/undocked/map_no_max_entries.c" + r4 = IMMEDIATE(0); + // EBPF_OP_CALL pc=18 dst=r0 src=r0 offset=0 imm=2 +#line 28 "sample/undocked/map_no_max_entries.c" + r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); +label_1: + // EBPF_OP_EXIT pc=19 dst=r0 src=r0 offset=0 imm=0 +#line 29 "sample/undocked/map_no_max_entries.c" + return r0; +#line 19 "sample/undocked/map_no_max_entries.c" +} +#pragma code_seg(pop) +#line __LINE__ __FILE__ + +#pragma data_seg(push, "programs") +static program_entry_t _programs[] = { + { + 0, + {1, 154, 160}, // Version header. + map_no_max_entries, + "sample~1", + "sample_ext", + "map_no_max_entries", + map_no_max_entries_maps, + 1, + map_no_max_entries_helpers, + 1, + 20, + &map_no_max_entries_program_type_guid, + &map_no_max_entries_attach_type_guid, + }, +}; +#pragma data_seg(pop) + +static void +_get_programs(_Outptr_result_buffer_(*count) program_entry_t** programs, _Out_ size_t* count) +{ + *programs = _programs; + *count = 1; +} + +static void +_get_version(_Out_ bpf2c_version_t* version) +{ + version->major = 1; + version->minor = 6; + version->revision = 0; +} + +static void +_get_map_initial_values(_Outptr_result_buffer_(*count) map_initial_values_t** map_initial_values, _Out_ size_t* count) +{ + *map_initial_values = NULL; + *count = 0; +} + +metadata_table_t map_no_max_entries_metadata_table = { + sizeof(metadata_table_t), + _get_programs, + _get_maps, + _get_hash, + _get_version, + _get_map_initial_values, + _get_global_variable_sections, +}; diff --git a/tests/bpf2c_tests/expected/map_raw.c b/tests/bpf2c_tests/expected/map_raw.c index 86c5ed9d8f..2e0c169222 100644 --- a/tests/bpf2c_tests/expected/map_raw.c +++ b/tests/bpf2c_tests/expected/map_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "HASH_map"}, + "HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERCPU_HASH, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "PERCPU_HASH_map"}, + "PERCPU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -68,13 +72,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "ARRAY_map"}, + "ARRAY_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERCPU_ARRAY, // Type of map. @@ -86,13 +92,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "PERCPU_ARRAY_map"}, + "PERCPU_ARRAY_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_HASH, // Type of map. @@ -104,13 +112,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "LRU_HASH_map"}, + "LRU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_PERCPU_HASH, // Type of map. @@ -122,13 +132,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "LRU_PERCPU_HASH_map"}, + "LRU_PERCPU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_QUEUE, // Type of map. @@ -140,13 +152,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "QUEUE_map"}, + "QUEUE_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_STACK, // Type of map. @@ -158,7 +172,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "STACK_map"}, + "STACK_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_reuse_2_dll.c b/tests/bpf2c_tests/expected/map_reuse_2_dll.c index 251cde53f7..31cf8da891 100644 --- a/tests/bpf2c_tests/expected/map_reuse_2_dll.c +++ b/tests/bpf2c_tests/expected/map_reuse_2_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 1, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 17, // Identifier for a map template. 0, // The id of the inner map template. }, - "port_map"}, + "port_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -98,7 +102,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) @@ -143,129 +149,129 @@ static uint16_t lookup_update_maps[] = { #pragma code_seg(push, "sample~1") static uint64_t lookup_update(void* context, const program_runtime_context_t* runtime_context) -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" { -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" // Prologue. -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r0 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r1 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r2 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r3 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r4 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r5 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r6 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r10 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r1 = (uintptr_t)context; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); // EBPF_OP_MOV64_IMM pc=0 dst=r6 src=r0 offset=0 imm=0 -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r6 = IMMEDIATE(0); // EBPF_OP_STXW pc=1 dst=r10 src=r6 offset=-4 imm=0 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-4)); // EBPF_OP_MOV64_REG pc=2 dst=r2 src=r10 offset=0 imm=0 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=3 dst=r2 src=r0 offset=0 imm=-4 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-4); // EBPF_OP_LDDW pc=4 dst=r1 src=r1 offset=0 imm=2 -#line 55 "sample/undocked/map_reuse_2.c" +#line 56 "sample/undocked/map_reuse_2.c" r1 = POINTER(runtime_context->map_data[0].address); // EBPF_OP_CALL pc=6 dst=r0 src=r0 offset=0 imm=1 -#line 55 "sample/undocked/map_reuse_2.c" +#line 56 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); // EBPF_OP_JEQ_IMM pc=7 dst=r0 src=r0 offset=20 imm=0 -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" if (r0 == IMMEDIATE(0)) { -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" goto label_2; -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" } // EBPF_OP_STXW pc=8 dst=r10 src=r6 offset=-8 imm=0 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-8)); // EBPF_OP_MOV64_REG pc=9 dst=r2 src=r10 offset=0 imm=0 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=10 dst=r2 src=r0 offset=0 imm=-8 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-8); // EBPF_OP_MOV64_REG pc=11 dst=r1 src=r0 offset=0 imm=0 -#line 58 "sample/undocked/map_reuse_2.c" +#line 59 "sample/undocked/map_reuse_2.c" r1 = r0; // EBPF_OP_CALL pc=12 dst=r0 src=r0 offset=0 imm=1 -#line 58 "sample/undocked/map_reuse_2.c" +#line 59 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); // EBPF_OP_JNE_IMM pc=13 dst=r0 src=r0 offset=1 imm=0 -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" if (r0 != IMMEDIATE(0)) { -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" goto label_1; -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" } // EBPF_OP_JA pc=14 dst=r0 src=r0 offset=13 imm=0 -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" goto label_2; label_1: // EBPF_OP_STXW pc=15 dst=r10 src=r6 offset=-12 imm=0 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-12)); // EBPF_OP_LDXW pc=16 dst=r1 src=r0 offset=0 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" READ_ONCE_32(r1, r0, OFFSET(0)); // EBPF_OP_STXW pc=17 dst=r10 src=r1 offset=-16 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-16)); // EBPF_OP_MOV64_REG pc=18 dst=r2 src=r10 offset=0 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=19 dst=r2 src=r0 offset=0 imm=-12 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-12); // EBPF_OP_MOV64_REG pc=20 dst=r3 src=r10 offset=0 imm=0 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r3 = r10; // EBPF_OP_ADD64_IMM pc=21 dst=r3 src=r0 offset=0 imm=-16 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r3 += IMMEDIATE(-16); // EBPF_OP_LDDW pc=22 dst=r1 src=r1 offset=0 imm=3 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r1 = POINTER(runtime_context->map_data[1].address); // EBPF_OP_MOV64_IMM pc=24 dst=r4 src=r0 offset=0 imm=0 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r4 = IMMEDIATE(0); // EBPF_OP_MOV64_REG pc=25 dst=r6 src=r0 offset=0 imm=0 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r6 = r0; // EBPF_OP_CALL pc=26 dst=r0 src=r0 offset=0 imm=2 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[1].address(r1, r2, r3, r4, r5, context); // EBPF_OP_LDXW pc=27 dst=r6 src=r6 offset=0 imm=0 -#line 65 "sample/undocked/map_reuse_2.c" +#line 66 "sample/undocked/map_reuse_2.c" READ_ONCE_32(r6, r6, OFFSET(0)); label_2: // EBPF_OP_MOV64_REG pc=28 dst=r0 src=r6 offset=0 imm=0 -#line 69 "sample/undocked/map_reuse_2.c" +#line 70 "sample/undocked/map_reuse_2.c" r0 = r6; // EBPF_OP_EXIT pc=29 dst=r0 src=r0 offset=0 imm=0 -#line 69 "sample/undocked/map_reuse_2.c" +#line 70 "sample/undocked/map_reuse_2.c" return r0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" } #pragma code_seg(pop) #line __LINE__ __FILE__ diff --git a/tests/bpf2c_tests/expected/map_reuse_2_raw.c b/tests/bpf2c_tests/expected/map_reuse_2_raw.c index 919421f367..a44b635149 100644 --- a/tests/bpf2c_tests/expected/map_reuse_2_raw.c +++ b/tests/bpf2c_tests/expected/map_reuse_2_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 1, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 17, // Identifier for a map template. 0, // The id of the inner map template. }, - "port_map"}, + "port_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -68,7 +72,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) @@ -113,129 +119,129 @@ static uint16_t lookup_update_maps[] = { #pragma code_seg(push, "sample~1") static uint64_t lookup_update(void* context, const program_runtime_context_t* runtime_context) -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" { -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" // Prologue. -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r0 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r1 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r2 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r3 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r4 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r5 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r6 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r10 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r1 = (uintptr_t)context; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); // EBPF_OP_MOV64_IMM pc=0 dst=r6 src=r0 offset=0 imm=0 -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r6 = IMMEDIATE(0); // EBPF_OP_STXW pc=1 dst=r10 src=r6 offset=-4 imm=0 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-4)); // EBPF_OP_MOV64_REG pc=2 dst=r2 src=r10 offset=0 imm=0 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=3 dst=r2 src=r0 offset=0 imm=-4 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-4); // EBPF_OP_LDDW pc=4 dst=r1 src=r1 offset=0 imm=2 -#line 55 "sample/undocked/map_reuse_2.c" +#line 56 "sample/undocked/map_reuse_2.c" r1 = POINTER(runtime_context->map_data[0].address); // EBPF_OP_CALL pc=6 dst=r0 src=r0 offset=0 imm=1 -#line 55 "sample/undocked/map_reuse_2.c" +#line 56 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); // EBPF_OP_JEQ_IMM pc=7 dst=r0 src=r0 offset=20 imm=0 -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" if (r0 == IMMEDIATE(0)) { -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" goto label_2; -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" } // EBPF_OP_STXW pc=8 dst=r10 src=r6 offset=-8 imm=0 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-8)); // EBPF_OP_MOV64_REG pc=9 dst=r2 src=r10 offset=0 imm=0 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=10 dst=r2 src=r0 offset=0 imm=-8 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-8); // EBPF_OP_MOV64_REG pc=11 dst=r1 src=r0 offset=0 imm=0 -#line 58 "sample/undocked/map_reuse_2.c" +#line 59 "sample/undocked/map_reuse_2.c" r1 = r0; // EBPF_OP_CALL pc=12 dst=r0 src=r0 offset=0 imm=1 -#line 58 "sample/undocked/map_reuse_2.c" +#line 59 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); // EBPF_OP_JNE_IMM pc=13 dst=r0 src=r0 offset=1 imm=0 -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" if (r0 != IMMEDIATE(0)) { -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" goto label_1; -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" } // EBPF_OP_JA pc=14 dst=r0 src=r0 offset=13 imm=0 -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" goto label_2; label_1: // EBPF_OP_STXW pc=15 dst=r10 src=r6 offset=-12 imm=0 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-12)); // EBPF_OP_LDXW pc=16 dst=r1 src=r0 offset=0 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" READ_ONCE_32(r1, r0, OFFSET(0)); // EBPF_OP_STXW pc=17 dst=r10 src=r1 offset=-16 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-16)); // EBPF_OP_MOV64_REG pc=18 dst=r2 src=r10 offset=0 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=19 dst=r2 src=r0 offset=0 imm=-12 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-12); // EBPF_OP_MOV64_REG pc=20 dst=r3 src=r10 offset=0 imm=0 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r3 = r10; // EBPF_OP_ADD64_IMM pc=21 dst=r3 src=r0 offset=0 imm=-16 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r3 += IMMEDIATE(-16); // EBPF_OP_LDDW pc=22 dst=r1 src=r1 offset=0 imm=3 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r1 = POINTER(runtime_context->map_data[1].address); // EBPF_OP_MOV64_IMM pc=24 dst=r4 src=r0 offset=0 imm=0 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r4 = IMMEDIATE(0); // EBPF_OP_MOV64_REG pc=25 dst=r6 src=r0 offset=0 imm=0 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r6 = r0; // EBPF_OP_CALL pc=26 dst=r0 src=r0 offset=0 imm=2 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[1].address(r1, r2, r3, r4, r5, context); // EBPF_OP_LDXW pc=27 dst=r6 src=r6 offset=0 imm=0 -#line 65 "sample/undocked/map_reuse_2.c" +#line 66 "sample/undocked/map_reuse_2.c" READ_ONCE_32(r6, r6, OFFSET(0)); label_2: // EBPF_OP_MOV64_REG pc=28 dst=r0 src=r6 offset=0 imm=0 -#line 69 "sample/undocked/map_reuse_2.c" +#line 70 "sample/undocked/map_reuse_2.c" r0 = r6; // EBPF_OP_EXIT pc=29 dst=r0 src=r0 offset=0 imm=0 -#line 69 "sample/undocked/map_reuse_2.c" +#line 70 "sample/undocked/map_reuse_2.c" return r0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" } #pragma code_seg(pop) #line __LINE__ __FILE__ diff --git a/tests/bpf2c_tests/expected/map_reuse_2_sys.c b/tests/bpf2c_tests/expected/map_reuse_2_sys.c index bc3f635949..1c3bb0ba7e 100644 --- a/tests/bpf2c_tests/expected/map_reuse_2_sys.c +++ b/tests/bpf2c_tests/expected/map_reuse_2_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 1, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 17, // Identifier for a map template. 0, // The id of the inner map template. }, - "port_map"}, + "port_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -223,7 +227,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) @@ -268,129 +274,129 @@ static uint16_t lookup_update_maps[] = { #pragma code_seg(push, "sample~1") static uint64_t lookup_update(void* context, const program_runtime_context_t* runtime_context) -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" { -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" // Prologue. -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" uint64_t stack[(UBPF_STACK_SIZE + 7) / 8]; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r0 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r1 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r2 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r3 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r4 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r5 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r6 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" register uint64_t r10 = 0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r1 = (uintptr_t)context; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r10 = (uintptr_t)((uint8_t*)stack + sizeof(stack)); // EBPF_OP_MOV64_IMM pc=0 dst=r6 src=r0 offset=0 imm=0 -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" r6 = IMMEDIATE(0); // EBPF_OP_STXW pc=1 dst=r10 src=r6 offset=-4 imm=0 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-4)); // EBPF_OP_MOV64_REG pc=2 dst=r2 src=r10 offset=0 imm=0 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=3 dst=r2 src=r0 offset=0 imm=-4 -#line 52 "sample/undocked/map_reuse_2.c" +#line 53 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-4); // EBPF_OP_LDDW pc=4 dst=r1 src=r1 offset=0 imm=2 -#line 55 "sample/undocked/map_reuse_2.c" +#line 56 "sample/undocked/map_reuse_2.c" r1 = POINTER(runtime_context->map_data[0].address); // EBPF_OP_CALL pc=6 dst=r0 src=r0 offset=0 imm=1 -#line 55 "sample/undocked/map_reuse_2.c" +#line 56 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); // EBPF_OP_JEQ_IMM pc=7 dst=r0 src=r0 offset=20 imm=0 -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" if (r0 == IMMEDIATE(0)) { -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" goto label_2; -#line 56 "sample/undocked/map_reuse_2.c" +#line 57 "sample/undocked/map_reuse_2.c" } // EBPF_OP_STXW pc=8 dst=r10 src=r6 offset=-8 imm=0 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-8)); // EBPF_OP_MOV64_REG pc=9 dst=r2 src=r10 offset=0 imm=0 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=10 dst=r2 src=r0 offset=0 imm=-8 -#line 57 "sample/undocked/map_reuse_2.c" +#line 58 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-8); // EBPF_OP_MOV64_REG pc=11 dst=r1 src=r0 offset=0 imm=0 -#line 58 "sample/undocked/map_reuse_2.c" +#line 59 "sample/undocked/map_reuse_2.c" r1 = r0; // EBPF_OP_CALL pc=12 dst=r0 src=r0 offset=0 imm=1 -#line 58 "sample/undocked/map_reuse_2.c" +#line 59 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[0].address(r1, r2, r3, r4, r5, context); // EBPF_OP_JNE_IMM pc=13 dst=r0 src=r0 offset=1 imm=0 -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" if (r0 != IMMEDIATE(0)) { -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" goto label_1; -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" } // EBPF_OP_JA pc=14 dst=r0 src=r0 offset=13 imm=0 -#line 59 "sample/undocked/map_reuse_2.c" +#line 60 "sample/undocked/map_reuse_2.c" goto label_2; label_1: // EBPF_OP_STXW pc=15 dst=r10 src=r6 offset=-12 imm=0 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r6, OFFSET(-12)); // EBPF_OP_LDXW pc=16 dst=r1 src=r0 offset=0 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" READ_ONCE_32(r1, r0, OFFSET(0)); // EBPF_OP_STXW pc=17 dst=r10 src=r1 offset=-16 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" WRITE_ONCE_32(r10, (uint32_t)r1, OFFSET(-16)); // EBPF_OP_MOV64_REG pc=18 dst=r2 src=r10 offset=0 imm=0 -#line 62 "sample/undocked/map_reuse_2.c" +#line 63 "sample/undocked/map_reuse_2.c" r2 = r10; // EBPF_OP_ADD64_IMM pc=19 dst=r2 src=r0 offset=0 imm=-12 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r2 += IMMEDIATE(-12); // EBPF_OP_MOV64_REG pc=20 dst=r3 src=r10 offset=0 imm=0 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r3 = r10; // EBPF_OP_ADD64_IMM pc=21 dst=r3 src=r0 offset=0 imm=-16 -#line 61 "sample/undocked/map_reuse_2.c" +#line 62 "sample/undocked/map_reuse_2.c" r3 += IMMEDIATE(-16); // EBPF_OP_LDDW pc=22 dst=r1 src=r1 offset=0 imm=3 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r1 = POINTER(runtime_context->map_data[1].address); // EBPF_OP_MOV64_IMM pc=24 dst=r4 src=r0 offset=0 imm=0 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r4 = IMMEDIATE(0); // EBPF_OP_MOV64_REG pc=25 dst=r6 src=r0 offset=0 imm=0 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r6 = r0; // EBPF_OP_CALL pc=26 dst=r0 src=r0 offset=0 imm=2 -#line 63 "sample/undocked/map_reuse_2.c" +#line 64 "sample/undocked/map_reuse_2.c" r0 = runtime_context->helper_data[1].address(r1, r2, r3, r4, r5, context); // EBPF_OP_LDXW pc=27 dst=r6 src=r6 offset=0 imm=0 -#line 65 "sample/undocked/map_reuse_2.c" +#line 66 "sample/undocked/map_reuse_2.c" READ_ONCE_32(r6, r6, OFFSET(0)); label_2: // EBPF_OP_MOV64_REG pc=28 dst=r0 src=r6 offset=0 imm=0 -#line 69 "sample/undocked/map_reuse_2.c" +#line 70 "sample/undocked/map_reuse_2.c" r0 = r6; // EBPF_OP_EXIT pc=29 dst=r0 src=r0 offset=0 imm=0 -#line 69 "sample/undocked/map_reuse_2.c" +#line 70 "sample/undocked/map_reuse_2.c" return r0; -#line 50 "sample/undocked/map_reuse_2.c" +#line 51 "sample/undocked/map_reuse_2.c" } #pragma code_seg(pop) #line __LINE__ __FILE__ diff --git a/tests/bpf2c_tests/expected/map_reuse_dll.c b/tests/bpf2c_tests/expected/map_reuse_dll.c index 6e325a6259..1c6935d78e 100644 --- a/tests/bpf2c_tests/expected/map_reuse_dll.c +++ b/tests/bpf2c_tests/expected/map_reuse_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,13 +82,15 @@ static map_entry_t _maps[] = { 17, // Identifier for a map template. 0, // The id of the inner map template. }, - "port_map"}, + "port_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -98,7 +102,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_reuse_raw.c b/tests/bpf2c_tests/expected/map_reuse_raw.c index b733000588..6f29a83e72 100644 --- a/tests/bpf2c_tests/expected/map_reuse_raw.c +++ b/tests/bpf2c_tests/expected/map_reuse_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,13 +52,15 @@ static map_entry_t _maps[] = { 17, // Identifier for a map template. 0, // The id of the inner map template. }, - "port_map"}, + "port_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -68,7 +72,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_reuse_sys.c b/tests/bpf2c_tests/expected/map_reuse_sys.c index 906778c67a..ab935c3996 100644 --- a/tests/bpf2c_tests/expected/map_reuse_sys.c +++ b/tests/bpf2c_tests/expected/map_reuse_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH_OF_MAPS, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 15, // Identifier for a map template. 11, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 17, // Identifier for a map template. 0, // The id of the inner map template. }, - "port_map"}, + "port_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -223,7 +227,9 @@ static map_entry_t _maps[] = { 11, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_sequential_lookup_dll.c b/tests/bpf2c_tests/expected/map_sequential_lookup_dll.c index 5863685605..8acb0ec216 100644 --- a/tests/bpf2c_tests/expected/map_sequential_lookup_dll.c +++ b/tests/bpf2c_tests/expected/map_sequential_lookup_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "stats_map"}, + "stats_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_sequential_lookup_raw.c b/tests/bpf2c_tests/expected/map_sequential_lookup_raw.c index 6240c403df..82e2c80033 100644 --- a/tests/bpf2c_tests/expected/map_sequential_lookup_raw.c +++ b/tests/bpf2c_tests/expected/map_sequential_lookup_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "stats_map"}, + "stats_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_sequential_lookup_sys.c b/tests/bpf2c_tests/expected/map_sequential_lookup_sys.c index 7df2b9a424..cc37ae94dc 100644 --- a/tests/bpf2c_tests/expected/map_sequential_lookup_sys.c +++ b/tests/bpf2c_tests/expected/map_sequential_lookup_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "stats_map"}, + "stats_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_synchronized_update_dll.c b/tests/bpf2c_tests/expected/map_synchronized_update_dll.c index 1061458ea3..bf66bae7ea 100644 --- a/tests/bpf2c_tests/expected/map_synchronized_update_dll.c +++ b/tests/bpf2c_tests/expected/map_synchronized_update_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_1"}, + "map_1", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,25 +82,29 @@ static map_entry_t _maps[] = { 12, // Identifier for a map template. 0, // The id of the inner map template. }, - "failure_stats"}, + "failure_stats", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. 4, // Size in bytes of a map key. 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. + 2, // Maximum number of entries allowed in the map. 0, // Inner map index. LIBBPF_PIN_NONE, // Pinning type for the map. 14, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_2"}, + "map_2", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_synchronized_update_raw.c b/tests/bpf2c_tests/expected/map_synchronized_update_raw.c index 2d9fc295de..24deb09199 100644 --- a/tests/bpf2c_tests/expected/map_synchronized_update_raw.c +++ b/tests/bpf2c_tests/expected/map_synchronized_update_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_1"}, + "map_1", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,25 +52,29 @@ static map_entry_t _maps[] = { 12, // Identifier for a map template. 0, // The id of the inner map template. }, - "failure_stats"}, + "failure_stats", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. 4, // Size in bytes of a map key. 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. + 2, // Maximum number of entries allowed in the map. 0, // Inner map index. LIBBPF_PIN_NONE, // Pinning type for the map. 14, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_2"}, + "map_2", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_synchronized_update_sys.c b/tests/bpf2c_tests/expected/map_synchronized_update_sys.c index 330e9f431e..d371d79388 100644 --- a/tests/bpf2c_tests/expected/map_synchronized_update_sys.c +++ b/tests/bpf2c_tests/expected/map_synchronized_update_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 8, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_1"}, + "map_1", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,25 +207,29 @@ static map_entry_t _maps[] = { 12, // Identifier for a map template. 0, // The id of the inner map template. }, - "failure_stats"}, + "failure_stats", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. 4, // Size in bytes of a map key. 4, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. + 2, // Maximum number of entries allowed in the map. 0, // Inner map index. LIBBPF_PIN_NONE, // Pinning type for the map. 14, // Identifier for a map template. 0, // The id of the inner map template. }, - "map_2"}, + "map_2", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/map_sys.c b/tests/bpf2c_tests/expected/map_sys.c index 0661651d93..70d694d6fe 100644 --- a/tests/bpf2c_tests/expected/map_sys.c +++ b/tests/bpf2c_tests/expected/map_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "HASH_map"}, + "HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERCPU_HASH, // Type of map. @@ -205,13 +207,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "PERCPU_HASH_map"}, + "PERCPU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -223,13 +227,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "ARRAY_map"}, + "ARRAY_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERCPU_ARRAY, // Type of map. @@ -241,13 +247,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "PERCPU_ARRAY_map"}, + "PERCPU_ARRAY_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_HASH, // Type of map. @@ -259,13 +267,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "LRU_HASH_map"}, + "LRU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_LRU_PERCPU_HASH, // Type of map. @@ -277,13 +287,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "LRU_PERCPU_HASH_map"}, + "LRU_PERCPU_HASH_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_QUEUE, // Type of map. @@ -295,13 +307,15 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "QUEUE_map"}, + "QUEUE_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_STACK, // Type of map. @@ -313,7 +327,9 @@ static map_entry_t _maps[] = { 0, // Identifier for a map template. 0, // The id of the inner map template. }, - "STACK_map"}, + "STACK_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/perf_event_burst_dll.c b/tests/bpf2c_tests/expected/perf_event_burst_dll.c index 619d3465f1..db623be551 100644 --- a/tests/bpf2c_tests/expected/perf_event_burst_dll.c +++ b/tests/bpf2c_tests/expected/perf_event_burst_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "burst_test_map"}, + "burst_test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/perf_event_burst_raw.c b/tests/bpf2c_tests/expected/perf_event_burst_raw.c index 584a481dde..ae6a493916 100644 --- a/tests/bpf2c_tests/expected/perf_event_burst_raw.c +++ b/tests/bpf2c_tests/expected/perf_event_burst_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "burst_test_map"}, + "burst_test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/perf_event_burst_sys.c b/tests/bpf2c_tests/expected/perf_event_burst_sys.c index 5ef253c957..ec2141d003 100644 --- a/tests/bpf2c_tests/expected/perf_event_burst_sys.c +++ b/tests/bpf2c_tests/expected/perf_event_burst_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "burst_test_map"}, + "burst_test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/perf_event_cpu_target_dll.c b/tests/bpf2c_tests/expected/perf_event_cpu_target_dll.c index 0475bc889f..012114724b 100644 --- a/tests/bpf2c_tests/expected/perf_event_cpu_target_dll.c +++ b/tests/bpf2c_tests/expected/perf_event_cpu_target_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "cpu_target_map"}, + "cpu_target_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/perf_event_cpu_target_raw.c b/tests/bpf2c_tests/expected/perf_event_cpu_target_raw.c index 5cdd9ff4d3..cff5ba1549 100644 --- a/tests/bpf2c_tests/expected/perf_event_cpu_target_raw.c +++ b/tests/bpf2c_tests/expected/perf_event_cpu_target_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "cpu_target_map"}, + "cpu_target_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/perf_event_cpu_target_sys.c b/tests/bpf2c_tests/expected/perf_event_cpu_target_sys.c index b09edca9ec..f159a69b21 100644 --- a/tests/bpf2c_tests/expected/perf_event_cpu_target_sys.c +++ b/tests/bpf2c_tests/expected/perf_event_cpu_target_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "cpu_target_map"}, + "cpu_target_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/pidtgid_dll.c b/tests/bpf2c_tests/expected/pidtgid_dll.c index 58596858a4..851c64f7e3 100644 --- a/tests/bpf2c_tests/expected/pidtgid_dll.c +++ b/tests/bpf2c_tests/expected/pidtgid_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 12, // Identifier for a map template. 0, // The id of the inner map template. }, - "pidtgid_map"}, + "pidtgid_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 31, // Identifier for a map template. 0, // The id of the inner map template. }, - "pidtgid.bss"}, + "pidtgid.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/pidtgid_raw.c b/tests/bpf2c_tests/expected/pidtgid_raw.c index 2b38e132a8..ebc7582c71 100644 --- a/tests/bpf2c_tests/expected/pidtgid_raw.c +++ b/tests/bpf2c_tests/expected/pidtgid_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 12, // Identifier for a map template. 0, // The id of the inner map template. }, - "pidtgid_map"}, + "pidtgid_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 31, // Identifier for a map template. 0, // The id of the inner map template. }, - "pidtgid.bss"}, + "pidtgid.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/pidtgid_sys.c b/tests/bpf2c_tests/expected/pidtgid_sys.c index ef39787a75..9d7bae2b07 100644 --- a/tests/bpf2c_tests/expected/pidtgid_sys.c +++ b/tests/bpf2c_tests/expected/pidtgid_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 12, // Identifier for a map template. 0, // The id of the inner map template. }, - "pidtgid_map"}, + "pidtgid_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 31, // Identifier for a map template. 0, // The id of the inner map template. }, - "pidtgid.bss"}, + "pidtgid.bss", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/process_start_key_dll.c b/tests/bpf2c_tests/expected/process_start_key_dll.c index fad0122876..032212e107 100644 --- a/tests/bpf2c_tests/expected/process_start_key_dll.c +++ b/tests/bpf2c_tests/expected/process_start_key_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 16, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 16, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "process_start_key_map"}, + "process_start_key_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/process_start_key_raw.c b/tests/bpf2c_tests/expected/process_start_key_raw.c index 8dd38a67a3..e298eb70b3 100644 --- a/tests/bpf2c_tests/expected/process_start_key_raw.c +++ b/tests/bpf2c_tests/expected/process_start_key_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 16, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 16, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "process_start_key_map"}, + "process_start_key_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/process_start_key_sys.c b/tests/bpf2c_tests/expected/process_start_key_sys.c index c3f4ea5a19..620ad572e8 100644 --- a/tests/bpf2c_tests/expected/process_start_key_sys.c +++ b/tests/bpf2c_tests/expected/process_start_key_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 16, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 16, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "process_start_key_map"}, + "process_start_key_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/sockops_dll.c b/tests/bpf2c_tests/expected/sockops_dll.c index 5b7f5ac991..587c0f95d0 100644 --- a/tests/bpf2c_tests/expected/sockops_dll.c +++ b/tests/bpf2c_tests/expected/sockops_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "connection_map"}, + "connection_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/sockops_flow_id_dll.c b/tests/bpf2c_tests/expected/sockops_flow_id_dll.c index cc69e00bd7..be6e2eda78 100644 --- a/tests/bpf2c_tests/expected/sockops_flow_id_dll.c +++ b/tests/bpf2c_tests/expected/sockops_flow_id_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "flow_id_map"}, + "flow_id_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 0, // The id of the inner map template. }, - "flow_id_audit_map"}, + "flow_id_audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/sockops_flow_id_raw.c b/tests/bpf2c_tests/expected/sockops_flow_id_raw.c index f93b00064f..ecce0e45bb 100644 --- a/tests/bpf2c_tests/expected/sockops_flow_id_raw.c +++ b/tests/bpf2c_tests/expected/sockops_flow_id_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "flow_id_map"}, + "flow_id_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 0, // The id of the inner map template. }, - "flow_id_audit_map"}, + "flow_id_audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/sockops_flow_id_sys.c b/tests/bpf2c_tests/expected/sockops_flow_id_sys.c index 5b5ea7a34d..db66f706a8 100644 --- a/tests/bpf2c_tests/expected/sockops_flow_id_sys.c +++ b/tests/bpf2c_tests/expected/sockops_flow_id_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "flow_id_map"}, + "flow_id_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 0, // The id of the inner map template. }, - "flow_id_audit_map"}, + "flow_id_audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/sockops_raw.c b/tests/bpf2c_tests/expected/sockops_raw.c index 7db3222e0a..d0aa975e45 100644 --- a/tests/bpf2c_tests/expected/sockops_raw.c +++ b/tests/bpf2c_tests/expected/sockops_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "connection_map"}, + "connection_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/sockops_sys.c b/tests/bpf2c_tests/expected/sockops_sys.c index e60384540d..4621c304e1 100644 --- a/tests/bpf2c_tests/expected/sockops_sys.c +++ b/tests/bpf2c_tests/expected/sockops_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_HASH, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "connection_map"}, + "connection_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_RINGBUF, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 0, // The id of the inner map template. }, - "audit_map"}, + "audit_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_bad_dll.c b/tests/bpf2c_tests/expected/tail_call_bad_dll.c index 4daf2a4141..93ac75d9c7 100644 --- a/tests/bpf2c_tests/expected/tail_call_bad_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_bad_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_bad_raw.c b/tests/bpf2c_tests/expected/tail_call_bad_raw.c index 6e94ea721d..95520295cb 100644 --- a/tests/bpf2c_tests/expected/tail_call_bad_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_bad_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_bad_sys.c b/tests/bpf2c_tests/expected/tail_call_bad_sys.c index e94cd87a2b..a577cef23b 100644 --- a/tests/bpf2c_tests/expected/tail_call_bad_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_bad_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_dll.c b/tests/bpf2c_tests/expected/tail_call_dll.c index ea7dacf536..f0e0de466f 100644 --- a/tests/bpf2c_tests/expected/tail_call_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_map_dll.c b/tests/bpf2c_tests/expected/tail_call_map_dll.c index 04341bb298..4031b8d911 100644 --- a/tests/bpf2c_tests/expected/tail_call_map_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_map_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 21, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_map_raw.c b/tests/bpf2c_tests/expected/tail_call_map_raw.c index 20c95ea3aa..b627a26479 100644 --- a/tests/bpf2c_tests/expected/tail_call_map_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_map_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 21, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_map_sys.c b/tests/bpf2c_tests/expected/tail_call_map_sys.c index 049a49b712..3c0aa1f3a5 100644 --- a/tests/bpf2c_tests/expected/tail_call_map_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_map_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 21, // Identifier for a map template. 0, // The id of the inner map template. }, - "inner_map"}, + "inner_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY_OF_MAPS, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 27, // Identifier for a map template. 21, // The id of the inner map template. }, - "outer_map"}, + "outer_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_max_exceed_dll.c b/tests/bpf2c_tests/expected/tail_call_max_exceed_dll.c index 3458ca2b4a..09d464b18c 100644 --- a/tests/bpf2c_tests/expected/tail_call_max_exceed_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_max_exceed_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_tail_call_map"}, + "bind_tail_call_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_max_exceed_raw.c b/tests/bpf2c_tests/expected/tail_call_max_exceed_raw.c index 4932c7aded..ef93166c09 100644 --- a/tests/bpf2c_tests/expected/tail_call_max_exceed_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_max_exceed_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_tail_call_map"}, + "bind_tail_call_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_max_exceed_sys.c b/tests/bpf2c_tests/expected/tail_call_max_exceed_sys.c index d5b9ca03da..53717ed130 100644 --- a/tests/bpf2c_tests/expected/tail_call_max_exceed_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_max_exceed_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "bind_tail_call_map"}, + "bind_tail_call_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_multiple_dll.c b/tests/bpf2c_tests/expected/tail_call_multiple_dll.c index d53d6be4aa..b874a522f4 100644 --- a/tests/bpf2c_tests/expected/tail_call_multiple_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_multiple_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_multiple_raw.c b/tests/bpf2c_tests/expected/tail_call_multiple_raw.c index bc1b685261..936b2473db 100644 --- a/tests/bpf2c_tests/expected/tail_call_multiple_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_multiple_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_multiple_sys.c b/tests/bpf2c_tests/expected/tail_call_multiple_sys.c index e47ff66bb5..65c6dc13ef 100644 --- a/tests/bpf2c_tests/expected/tail_call_multiple_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_multiple_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_raw.c b/tests/bpf2c_tests/expected/tail_call_raw.c index add4c3f44c..04a1d8c5ce 100644 --- a/tests/bpf2c_tests/expected/tail_call_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_recursive_dll.c b/tests/bpf2c_tests/expected/tail_call_recursive_dll.c index 4f395fe368..63fad9a502 100644 --- a/tests/bpf2c_tests/expected/tail_call_recursive_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_recursive_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 20, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_recursive_raw.c b/tests/bpf2c_tests/expected/tail_call_recursive_raw.c index eaba33fb43..b561f30ea8 100644 --- a/tests/bpf2c_tests/expected/tail_call_recursive_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_recursive_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 20, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_recursive_sys.c b/tests/bpf2c_tests/expected/tail_call_recursive_sys.c index 4fc26f886d..09fd6d13d0 100644 --- a/tests/bpf2c_tests/expected/tail_call_recursive_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_recursive_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 20, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 26, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_same_section_dll.c b/tests/bpf2c_tests/expected/tail_call_same_section_dll.c index 275c1ef794..1072c814d8 100644 --- a/tests/bpf2c_tests/expected/tail_call_same_section_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_same_section_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_same_section_raw.c b/tests/bpf2c_tests/expected/tail_call_same_section_raw.c index d8c91a934a..5fc2606802 100644 --- a/tests/bpf2c_tests/expected/tail_call_same_section_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_same_section_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_same_section_sys.c b/tests/bpf2c_tests/expected/tail_call_same_section_sys.c index c20d65fa47..22bf955da1 100644 --- a/tests/bpf2c_tests/expected/tail_call_same_section_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_same_section_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_sequential_dll.c b/tests/bpf2c_tests/expected/tail_call_sequential_dll.c index 6c812de4ad..6d33d61e25 100644 --- a/tests/bpf2c_tests/expected/tail_call_sequential_dll.c +++ b/tests/bpf2c_tests/expected/tail_call_sequential_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 22, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 28, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_sequential_raw.c b/tests/bpf2c_tests/expected/tail_call_sequential_raw.c index 8eb05566dd..5f151df5b7 100644 --- a/tests/bpf2c_tests/expected/tail_call_sequential_raw.c +++ b/tests/bpf2c_tests/expected/tail_call_sequential_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 22, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 28, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_sequential_sys.c b/tests/bpf2c_tests/expected/tail_call_sequential_sys.c index da52f572d5..3224fbfb22 100644 --- a/tests/bpf2c_tests/expected/tail_call_sequential_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_sequential_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 22, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 28, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/tail_call_sys.c b/tests/bpf2c_tests/expected/tail_call_sys.c index 01499fc3ff..31207d9e59 100644 --- a/tests/bpf2c_tests/expected/tail_call_sys.c +++ b/tests/bpf2c_tests/expected/tail_call_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PROG_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "map"}, + "map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "canary"}, + "canary", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_invalid_redirect_map_dll.c b/tests/bpf2c_tests/expected/test_invalid_redirect_map_dll.c index 63afaa01a1..545d754717 100644 --- a/tests/bpf2c_tests/expected/test_invalid_redirect_map_dll.c +++ b/tests/bpf2c_tests/expected/test_invalid_redirect_map_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "redirect_map"}, + "redirect_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_invalid_redirect_map_raw.c b/tests/bpf2c_tests/expected/test_invalid_redirect_map_raw.c index ed8e2654a7..a4a45500d8 100644 --- a/tests/bpf2c_tests/expected/test_invalid_redirect_map_raw.c +++ b/tests/bpf2c_tests/expected/test_invalid_redirect_map_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "redirect_map"}, + "redirect_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_invalid_redirect_map_sys.c b/tests/bpf2c_tests/expected/test_invalid_redirect_map_sys.c index 758cc67113..3f46823049 100644 --- a/tests/bpf2c_tests/expected/test_invalid_redirect_map_sys.c +++ b/tests/bpf2c_tests/expected/test_invalid_redirect_map_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "redirect_map"}, + "redirect_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_ebpf_dll.c b/tests/bpf2c_tests/expected/test_sample_ebpf_dll.c index 189307e8d8..74c0bf6788 100644 --- a/tests/bpf2c_tests/expected/test_sample_ebpf_dll.c +++ b/tests/bpf2c_tests/expected/test_sample_ebpf_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_ebpf_raw.c b/tests/bpf2c_tests/expected/test_sample_ebpf_raw.c index 41cfe006a8..c3aa6b76c7 100644 --- a/tests/bpf2c_tests/expected/test_sample_ebpf_raw.c +++ b/tests/bpf2c_tests/expected/test_sample_ebpf_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_ebpf_sys.c b/tests/bpf2c_tests/expected/test_sample_ebpf_sys.c index 05a804488e..be2a10a33a 100644 --- a/tests/bpf2c_tests/expected/test_sample_ebpf_sys.c +++ b/tests/bpf2c_tests/expected/test_sample_ebpf_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_implicit_helpers_dll.c b/tests/bpf2c_tests/expected/test_sample_implicit_helpers_dll.c index 32118b90c3..b3d1f8732d 100644 --- a/tests/bpf2c_tests/expected/test_sample_implicit_helpers_dll.c +++ b/tests/bpf2c_tests/expected/test_sample_implicit_helpers_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,13 +62,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -80,7 +82,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "output_map"}, + "output_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_implicit_helpers_raw.c b/tests/bpf2c_tests/expected/test_sample_implicit_helpers_raw.c index 8d25092788..f52c8e998c 100644 --- a/tests/bpf2c_tests/expected/test_sample_implicit_helpers_raw.c +++ b/tests/bpf2c_tests/expected/test_sample_implicit_helpers_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,13 +32,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -50,7 +52,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "output_map"}, + "output_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_implicit_helpers_sys.c b/tests/bpf2c_tests/expected/test_sample_implicit_helpers_sys.c index 2072ab82ab..b997b8c82b 100644 --- a/tests/bpf2c_tests/expected/test_sample_implicit_helpers_sys.c +++ b/tests/bpf2c_tests/expected/test_sample_implicit_helpers_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,13 +187,15 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -205,7 +207,9 @@ static map_entry_t _maps[] = { 16, // Identifier for a map template. 0, // The id of the inner map template. }, - "output_map"}, + "output_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_perf_event_array_dll.c b/tests/bpf2c_tests/expected/test_sample_perf_event_array_dll.c index 198cac61d7..366c8c5978 100644 --- a/tests/bpf2c_tests/expected/test_sample_perf_event_array_dll.c +++ b/tests/bpf2c_tests/expected/test_sample_perf_event_array_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_perf_event_array_raw.c b/tests/bpf2c_tests/expected/test_sample_perf_event_array_raw.c index b6640a6b51..30d539eafe 100644 --- a/tests/bpf2c_tests/expected/test_sample_perf_event_array_raw.c +++ b/tests/bpf2c_tests/expected/test_sample_perf_event_array_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_perf_event_array_sys.c b/tests/bpf2c_tests/expected/test_sample_perf_event_array_sys.c index 9365d11aa5..5977560072 100644 --- a/tests/bpf2c_tests/expected/test_sample_perf_event_array_sys.c +++ b/tests/bpf2c_tests/expected/test_sample_perf_event_array_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_PERF_EVENT_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 7, // Identifier for a map template. 0, // The id of the inner map template. }, - "test_map"}, + "test_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_redirect_map_dll.c b/tests/bpf2c_tests/expected/test_sample_redirect_map_dll.c index f903652e6d..0accd59244 100644 --- a/tests/bpf2c_tests/expected/test_sample_redirect_map_dll.c +++ b/tests/bpf2c_tests/expected/test_sample_redirect_map_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "redirect_map"}, + "redirect_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_redirect_map_raw.c b/tests/bpf2c_tests/expected/test_sample_redirect_map_raw.c index 6eb9557d6b..f79332d36d 100644 --- a/tests/bpf2c_tests/expected/test_sample_redirect_map_raw.c +++ b/tests/bpf2c_tests/expected/test_sample_redirect_map_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "redirect_map"}, + "redirect_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_sample_redirect_map_sys.c b/tests/bpf2c_tests/expected/test_sample_redirect_map_sys.c index c2dbeb1e0e..89e32f0170 100644 --- a/tests/bpf2c_tests/expected/test_sample_redirect_map_sys.c +++ b/tests/bpf2c_tests/expected/test_sample_redirect_map_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 10, // Identifier for a map template. 0, // The id of the inner map template. }, - "redirect_map"}, + "redirect_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_utility_helpers_dll.c b/tests/bpf2c_tests/expected/test_utility_helpers_dll.c index 24639afa8e..2fff71b039 100644 --- a/tests/bpf2c_tests/expected/test_utility_helpers_dll.c +++ b/tests/bpf2c_tests/expected/test_utility_helpers_dll.c @@ -49,8 +49,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -62,7 +62,9 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "utility_map"}, + "utility_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_utility_helpers_raw.c b/tests/bpf2c_tests/expected/test_utility_helpers_raw.c index 4034af6fbe..556ae5ff10 100644 --- a/tests/bpf2c_tests/expected/test_utility_helpers_raw.c +++ b/tests/bpf2c_tests/expected/test_utility_helpers_raw.c @@ -19,8 +19,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -32,7 +32,9 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "utility_map"}, + "utility_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/test_utility_helpers_sys.c b/tests/bpf2c_tests/expected/test_utility_helpers_sys.c index d0e49019bd..d1fb28daa4 100644 --- a/tests/bpf2c_tests/expected/test_utility_helpers_sys.c +++ b/tests/bpf2c_tests/expected/test_utility_helpers_sys.c @@ -174,8 +174,8 @@ static map_entry_t _maps[] = { {0, 0}, { 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { BPF_MAP_TYPE_ARRAY, // Type of map. @@ -187,7 +187,9 @@ static map_entry_t _maps[] = { 13, // Identifier for a map template. 0, // The id of the inner map template. }, - "utility_map"}, + "utility_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/thread_start_time_dll.c b/tests/bpf2c_tests/expected/thread_start_time_dll.c index 9423f22d88..7a3fd56128 100644 --- a/tests/bpf2c_tests/expected/thread_start_time_dll.c +++ b/tests/bpf2c_tests/expected/thread_start_time_dll.c @@ -48,21 +48,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 16, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 16, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "thread_start_time_map"}, + "thread_start_time_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/thread_start_time_raw.c b/tests/bpf2c_tests/expected/thread_start_time_raw.c index 5824ac6254..02dd611f0a 100644 --- a/tests/bpf2c_tests/expected/thread_start_time_raw.c +++ b/tests/bpf2c_tests/expected/thread_start_time_raw.c @@ -18,21 +18,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 16, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 16, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "thread_start_time_map"}, + "thread_start_time_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/bpf2c_tests/expected/thread_start_time_sys.c b/tests/bpf2c_tests/expected/thread_start_time_sys.c index f5a57e2d78..eb3060c3c5 100644 --- a/tests/bpf2c_tests/expected/thread_start_time_sys.c +++ b/tests/bpf2c_tests/expected/thread_start_time_sys.c @@ -173,21 +173,23 @@ static map_entry_t _maps[] = { { {0, 0}, { - 1, // Current Version. - 80, // Struct size up to the last field. - 80, // Total struct size including padding. + 1, // Current Version. + 84, // Struct size up to the last field. + 88, // Total struct size including padding. }, { - BPF_MAP_TYPE_ARRAY, // Type of map. - 4, // Size in bytes of a map key. - 16, // Size in bytes of a map value. - 1, // Maximum number of entries allowed in the map. - 0, // Inner map index. - LIBBPF_PIN_NONE, // Pinning type for the map. - 15, // Identifier for a map template. - 0, // The id of the inner map template. + BPF_MAP_TYPE_ARRAY, // Type of map. + 4, // Size in bytes of a map key. + 16, // Size in bytes of a map value. + 1, // Maximum number of entries allowed in the map. + 0, // Inner map index. + LIBBPF_PIN_NONE, // Pinning type for the map. + 15, // Identifier for a map template. + 0, // The id of the inner map template. }, - "thread_start_time_map"}, + "thread_start_time_map", // Map name. + 0, // Map creation flags. + }, }; #pragma data_seg(pop) diff --git a/tests/end_to_end/end_to_end.cpp b/tests/end_to_end/end_to_end.cpp index 5eb337d602..4a70e7f6d9 100644 --- a/tests/end_to_end/end_to_end.cpp +++ b/tests/end_to_end/end_to_end.cpp @@ -2458,7 +2458,7 @@ _map_reuse_2_test(ebpf_execution_type_t execution_type) int inner_map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, nullptr, sizeof(__u32), sizeof(__u32), 1, nullptr); REQUIRE(inner_map_fd > 0); - bpf_map_create_opts opts = {.inner_map_fd = (uint32_t)inner_map_fd}; + bpf_map_create_opts opts = {.inner_map_fd = (uint32_t)inner_map_fd, .map_flags = BPF_F_NO_MAX_ENTRIES}; int outer_map_fd = bpf_map_create(BPF_MAP_TYPE_HASH_OF_MAPS, nullptr, sizeof(__u32), sizeof(fd_t), 1, &opts); REQUIRE(outer_map_fd > 0); @@ -2514,6 +2514,43 @@ _map_reuse_2_test(ebpf_execution_type_t execution_type) DECLARE_JIT_TEST_CASES("map_reuse_2", "[end_to_end]", _map_reuse_2_test); +static void +_map_reuse_map_flags_invalid_test(ebpf_execution_type_t execution_type) +{ + _test_helper_end_to_end test_helper; + test_helper.initialize(); + program_info_provider_t sample_program_info; + REQUIRE(sample_program_info.initialize(EBPF_PROGRAM_TYPE_SAMPLE) == EBPF_SUCCESS); + + int inner_map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, nullptr, sizeof(__u32), sizeof(__u32), 1, nullptr); + REQUIRE(inner_map_fd > 0); + + // The program's outer map has BPF_F_NO_MAX_ENTRIES, but this pinned map does not. + bpf_map_create_opts opts = {.inner_map_fd = (uint32_t)inner_map_fd}; + int outer_map_fd = bpf_map_create(BPF_MAP_TYPE_HASH_OF_MAPS, nullptr, sizeof(__u32), sizeof(fd_t), 1, &opts); + REQUIRE(outer_map_fd > 0); + REQUIRE(bpf_obj_pin(outer_map_fd, "/ebpf/global/outer_map") == 0); + + int port_map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, nullptr, sizeof(__u32), sizeof(__u32), 1, nullptr); + REQUIRE(port_map_fd > 0); + REQUIRE(bpf_obj_pin(port_map_fd, "/ebpf/global/port_map") == 0); + + bpf_object_ptr object; + fd_t program_fd; + const char* file_name = (execution_type == EBPF_EXECUTION_NATIVE ? "map_reuse_2_um.dll" : "map_reuse_2.o"); + REQUIRE( + ebpf_program_load(file_name, BPF_PROG_TYPE_SAMPLE, execution_type, &object, &program_fd, nullptr) == -EINVAL); + + Platform::_close(outer_map_fd); + Platform::_close(inner_map_fd); + Platform::_close(port_map_fd); + + REQUIRE(ebpf_object_unpin("/ebpf/global/outer_map") == EBPF_SUCCESS); + REQUIRE(ebpf_object_unpin("/ebpf/global/port_map") == EBPF_SUCCESS); +} + +DECLARE_JIT_TEST_CASES("map_reuse_map_flags_invalid", "[end_to_end][map_reuse]", _map_reuse_map_flags_invalid_test); + static void _map_reuse_3_test(ebpf_execution_type_t execution_type) { @@ -2528,7 +2565,7 @@ _map_reuse_3_test(ebpf_execution_type_t execution_type) int inner_map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, nullptr, sizeof(__u32), sizeof(__u32), 1, nullptr); REQUIRE(inner_map_fd > 0); - bpf_map_create_opts opts = {.inner_map_fd = (uint32_t)inner_map_fd}; + bpf_map_create_opts opts = {.inner_map_fd = (uint32_t)inner_map_fd, .map_flags = BPF_F_NO_MAX_ENTRIES}; int outer_map_fd = bpf_map_create(BPF_MAP_TYPE_HASH_OF_MAPS, nullptr, sizeof(__u32), sizeof(fd_t), 1, &opts); REQUIRE(outer_map_fd > 0); @@ -3500,8 +3537,9 @@ TEST_CASE("multiple_map_insert", "[close_cleanup]") } void -test_no_limit_map_entries(ebpf_map_type_t type, bool max_entries_limited) +test_map_entries_limit(ebpf_map_type_t type, bool no_max_entries) { + CAPTURE(type, no_max_entries); uint32_t max_entries = 2; fd_t inner_map_fd = ebpf_fd_invalid; fd_t map_fd = ebpf_fd_invalid; @@ -3522,24 +3560,31 @@ test_no_limit_map_entries(ebpf_map_type_t type, bool max_entries_limited) } lpm_trie_key_t; lpm_trie_key_t trie_key = {0}; + bpf_map_create_opts opts = {sizeof(opts)}; + opts.map_flags = no_max_entries ? BPF_F_NO_MAX_ENTRIES : 0; if (IS_NESTED_MAP(type)) { // First create and pin the maps manually. inner_map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, nullptr, sizeof(int32_t), sizeof(int32_t), 1, nullptr); REQUIRE(inner_map_fd > 0); - bpf_map_create_opts opts = {.inner_map_fd = (uint32_t)inner_map_fd}; + opts.inner_map_fd = (uint32_t)inner_map_fd; key_size = sizeof(int32_t); value_size = sizeof(fd_t); - map_fd = bpf_map_create(BPF_MAP_TYPE_HASH_OF_MAPS, nullptr, key_size, value_size, 1, &opts); + map_fd = bpf_map_create(BPF_MAP_TYPE_HASH_OF_MAPS, nullptr, key_size, value_size, max_entries, &opts); REQUIRE(map_fd > 0); } else { key_size = IS_LPM_MAP(type) ? sizeof(lpm_trie_key_t) : sizeof(int32_t); value_size = sizeof(int32_t); - map_fd = bpf_map_create(type, nullptr, key_size, value_size, max_entries, nullptr); + map_fd = bpf_map_create(type, nullptr, key_size, value_size, max_entries, &opts); REQUIRE(map_fd > 0); } + bpf_map_info map_info{}; + uint32_t map_info_size = sizeof(map_info); + REQUIRE(bpf_obj_get_info_by_fd(map_fd, &map_info, &map_info_size) == 0); + REQUIRE(map_info.map_flags == opts.map_flags); + // Update value_size for percpu maps for read / update operations. if (IS_PERCPU_MAP(type)) { value_size = EBPF_PAD_8(value_size) * static_cast(libbpf_num_possible_cpus()); @@ -3575,12 +3620,16 @@ test_no_limit_map_entries(ebpf_map_type_t type, bool max_entries_limited) } // In case of LRU_HASH, the insert will succeed, but the oldest entry will be removed. - int expected_error = (!max_entries_limited || IS_LRU_MAP(type)) ? 0 : -ENOSPC; + int expected_error = (no_max_entries || IS_LRU_MAP(type)) ? 0 : -ENOSPC; key = compute_key(&max_entries); - REQUIRE(bpf_map_update_elem(map_fd, key, value, 0) == (max_entries_limited ? expected_error : 0)); + REQUIRE(bpf_map_update_elem(map_fd, key, value, 0) == expected_error); + + std::vector lookup_value(value_size); + int lookup_result = bpf_map_lookup_elem(map_fd, key, lookup_value.data()); + REQUIRE((lookup_result == 0) == (expected_error == 0)); // In case of LRU_HASH, check that the number of entries is still `max_entries`. - if (IS_LRU_MAP(type) && max_entries_limited) { + if (IS_LRU_MAP(type)) { uint32_t entries_count = 0; lpm_trie_key_t local_key = {0}; void* old_key = nullptr; @@ -3600,21 +3649,13 @@ TEST_CASE("test_map_entries_limit", "[end_to_end]") _test_helper_end_to_end test_helper; test_helper.initialize(); - // The below hash table based map types do not have a limit on the number of entries. - // 1. BPF_MAP_TYPE_HASH - // 2. BPF_MAP_TYPE_PERCPU_HASH - // 3. BPF_MAP_TYPE_HASH_OF_MAPS - // 4. BPF_MAP_TYPE_LPM_TRIE - test_no_limit_map_entries(BPF_MAP_TYPE_HASH, false); - test_no_limit_map_entries(BPF_MAP_TYPE_PERCPU_HASH, false); - test_no_limit_map_entries(BPF_MAP_TYPE_HASH_OF_MAPS, false); - test_no_limit_map_entries(BPF_MAP_TYPE_LPM_TRIE, false); - - // The below hash table based map types have a limit on the number of entries. - // 1. BPF_MAP_TYPE_LRU_HASH - // 2. BPF_MAP_TYPE_LRU_PERCPU_HASH - test_no_limit_map_entries(BPF_MAP_TYPE_LRU_HASH, true); - test_no_limit_map_entries(BPF_MAP_TYPE_LRU_PERCPU_HASH, true); + for (auto type : {BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_PERCPU_HASH, BPF_MAP_TYPE_HASH_OF_MAPS, BPF_MAP_TYPE_LPM_TRIE}) { + test_map_entries_limit(type, false); + test_map_entries_limit(type, true); + } + + test_map_entries_limit(BPF_MAP_TYPE_LRU_HASH, false); + test_map_entries_limit(BPF_MAP_TYPE_LRU_PERCPU_HASH, false); } static void diff --git a/tests/sample/undocked/map_max_entries.c b/tests/sample/undocked/map_max_entries.c new file mode 100644 index 0000000000..2eca19faca --- /dev/null +++ b/tests/sample/undocked/map_max_entries.c @@ -0,0 +1,27 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Sample eBPF program demonstrating the default bounded hash map behavior. + +#include "bpf_helpers.h" +#include "sample_ext_helpers.h" + +struct +{ + __uint(type, BPF_MAP_TYPE_HASH); + __type(key, uint32_t); + __type(value, uint64_t); + __uint(max_entries, 2); +} max_entries_map SEC(".maps"); + +SEC("sample_ext") int map_max_entries(sample_program_context_t* ctx) +{ + if (ctx->data_start + sizeof(uint32_t) > ctx->data_end) { + return -1; + } + + uint32_t key = *(uint32_t*)ctx->data_start; + uint64_t value = (uint64_t)key * (uint64_t)key; + + return bpf_map_update_elem(&max_entries_map, &key, &value, 0); +} \ No newline at end of file diff --git a/tests/sample/undocked/map_max_entries_legacy.c b/tests/sample/undocked/map_max_entries_legacy.c new file mode 100644 index 0000000000..7871229580 --- /dev/null +++ b/tests/sample/undocked/map_max_entries_legacy.c @@ -0,0 +1,28 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Sample eBPF program demonstrating the default bounded hash map behavior +// using the legacy map definition format. + +#include "bpf_helpers.h" +#include "sample_ext_helpers.h" + +SEC("maps") +struct _ebpf_map_definition_in_file max_entries_map = { + .type = BPF_MAP_TYPE_HASH, + .key_size = sizeof(uint32_t), + .value_size = sizeof(uint64_t), + .max_entries = 2, +}; + +SEC("sample_ext") int map_max_entries(sample_program_context_t* ctx) +{ + if (ctx->data_start + sizeof(uint32_t) > ctx->data_end) { + return -1; + } + + uint32_t key = *(uint32_t*)ctx->data_start; + uint64_t value = (uint64_t)key * (uint64_t)key; + + return bpf_map_update_elem(&max_entries_map, &key, &value, 0); +} diff --git a/tests/sample/undocked/map_no_max_entries.c b/tests/sample/undocked/map_no_max_entries.c new file mode 100644 index 0000000000..7cba922ee2 --- /dev/null +++ b/tests/sample/undocked/map_no_max_entries.c @@ -0,0 +1,29 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Sample eBPF program demonstrating use of BPF_F_NO_MAX_ENTRIES to create a +// hash map without a maximum entry limit. + +#include "bpf_helpers.h" +#include "sample_ext_helpers.h" + +struct +{ + __uint(type, BPF_MAP_TYPE_HASH); + __type(key, uint32_t); + __type(value, uint64_t); + __uint(max_entries, 2); + __uint(map_flags, BPF_F_NO_MAX_ENTRIES); +} no_max_entries_map SEC(".maps"); + +SEC("sample_ext") int map_no_max_entries(sample_program_context_t* ctx) +{ + if (ctx->data_start + sizeof(uint32_t) > ctx->data_end) { + return -1; + } + + uint32_t key = *(uint32_t*)ctx->data_start; + uint64_t value = (uint64_t)key * (uint64_t)key; + + return bpf_map_update_elem(&no_max_entries_map, &key, &value, 0); +} diff --git a/tests/sample/undocked/map_no_max_entries_legacy.c b/tests/sample/undocked/map_no_max_entries_legacy.c new file mode 100644 index 0000000000..746e2b7038 --- /dev/null +++ b/tests/sample/undocked/map_no_max_entries_legacy.c @@ -0,0 +1,29 @@ +// Copyright (c) eBPF for Windows contributors +// SPDX-License-Identifier: MIT + +// Sample eBPF program demonstrating BPF_F_NO_MAX_ENTRIES using the legacy map +// definition format. + +#include "bpf_helpers.h" +#include "sample_ext_helpers.h" + +SEC("maps") +struct _ebpf_map_definition_in_file no_max_entries_map = { + .type = BPF_MAP_TYPE_HASH, + .key_size = sizeof(uint32_t), + .value_size = sizeof(uint64_t), + .max_entries = 2, + .map_flags = BPF_F_NO_MAX_ENTRIES, +}; + +SEC("sample_ext") int map_no_max_entries(sample_program_context_t* ctx) +{ + if (ctx->data_start + sizeof(uint32_t) > ctx->data_end) { + return -1; + } + + uint32_t key = *(uint32_t*)ctx->data_start; + uint64_t value = (uint64_t)key * (uint64_t)key; + + return bpf_map_update_elem(&no_max_entries_map, &key, &value, 0); +} diff --git a/tests/sample/undocked/map_reuse_2.c b/tests/sample/undocked/map_reuse_2.c index 5266bcde7f..1a953c2b17 100644 --- a/tests/sample/undocked/map_reuse_2.c +++ b/tests/sample/undocked/map_reuse_2.c @@ -34,6 +34,7 @@ struct __type(key, uint32_t); __uint(max_entries, 1); __type(value, uint32_t); + __uint(map_flags, BPF_F_NO_MAX_ENTRIES); __uint(pinning, LIBBPF_PIN_BY_NAME); __array(values, inner_map); } outer_map SEC(".maps"); diff --git a/tests/sample/undocked/map_synchronized_update.c b/tests/sample/undocked/map_synchronized_update.c index d34ce0aa7b..197a9f4ba5 100644 --- a/tests/sample/undocked/map_synchronized_update.c +++ b/tests/sample/undocked/map_synchronized_update.c @@ -26,7 +26,7 @@ struct __uint(type, BPF_MAP_TYPE_HASH); __type(key, uint32_t); __type(value, uint32_t); - __uint(max_entries, 1); + __uint(max_entries, 2); } map_2 SEC(".maps"); // Stats map to track failures when the inner map lookup fails. diff --git a/tests/unit/libbpf_test.cpp b/tests/unit/libbpf_test.cpp index e17e8f4732..3154f9b4c5 100644 --- a/tests/unit/libbpf_test.cpp +++ b/tests/unit/libbpf_test.cpp @@ -782,6 +782,169 @@ _test_libbpf_map(ebpf_execution_type_t execution_type) DECLARE_ALL_TEST_CASES("libbpf map", "[libbpf]", _test_libbpf_map); +static void +_test_map_max_entries_program( + ebpf_execution_type_t execution_type, bool no_max_entries, const char* object_name_override = nullptr) +{ + _test_helper_end_to_end test_helper; + test_helper.initialize(); + + single_instance_hook_t hook(EBPF_PROGRAM_TYPE_SAMPLE, EBPF_ATTACH_TYPE_SAMPLE); + REQUIRE(hook.initialize() == EBPF_SUCCESS); + program_info_provider_t sample_program_info; + REQUIRE(sample_program_info.initialize(EBPF_PROGRAM_TYPE_SAMPLE) == EBPF_SUCCESS); + + const char* object_name = + object_name_override ? object_name_override : (no_max_entries ? "map_no_max_entries" : "map_max_entries"); + std::string file_name = std::string(object_name) + (execution_type == EBPF_EXECUTION_NATIVE ? "_um.dll" : ".o"); + bpf_object_ptr object(bpf_object__open(file_name.c_str())); + REQUIRE(object != nullptr); + REQUIRE(ebpf_object_set_execution_type(object.get(), execution_type) == EBPF_SUCCESS); + REQUIRE(bpf_object__load(object.get()) == 0); + + const char* program_name = no_max_entries ? "map_no_max_entries" : "map_max_entries"; + const char* map_name = no_max_entries ? "no_max_entries_map" : "max_entries_map"; + bpf_program* program = bpf_object__find_program_by_name(object.get(), program_name); + REQUIRE(program != nullptr); + bpf_map* map = bpf_object__find_map_by_name(object.get(), map_name); + REQUIRE(map != nullptr); + REQUIRE(bpf_map__max_entries(map) == 2); + + int map_fd = bpf_map__fd(map); + REQUIRE(map_fd >= 0); + bpf_map_info map_info{}; + uint32_t map_info_size = sizeof(map_info); + REQUIRE(bpf_obj_get_info_by_fd(map_fd, &map_info, &map_info_size) == 0); + REQUIRE(map_info.map_flags == (no_max_entries ? BPF_F_NO_MAX_ENTRIES : 0U)); + + // Fill the map from user mode. + for (uint32_t key = 0; key < bpf_map__max_entries(map); key++) { + uint64_t value = (uint64_t)key * key; + REQUIRE(bpf_map_update_elem(map_fd, &key, &value, BPF_ANY) == 0); + } + + // A new key beyond max_entries succeeds only for the opted-in map. + uint32_t user_key = bpf_map__max_entries(map); + uint64_t user_value = (uint64_t)user_key * user_key; + int update_result = bpf_map_update_elem(map_fd, &user_key, &user_value, BPF_ANY); + REQUIRE((update_result == 0) == no_max_entries); + uint64_t found_value = 0; + int lookup_result = bpf_map_lookup_elem(map_fd, &user_key, &found_value); + REQUIRE((lookup_result == 0) == no_max_entries); + if (no_max_entries) { + REQUIRE(found_value == user_value); + } + + bpf_link_ptr link(bpf_program__attach(program)); + REQUIRE(link != nullptr); + + // The BPF program attempts to insert another distinct key beyond max_entries. + INITIALIZE_SAMPLE_CONTEXT + uint32_t program_key = bpf_map__max_entries(map) + 1; + ctx->data_start = reinterpret_cast(&program_key); + ctx->data_end = ctx->data_start + sizeof(program_key); + uint32_t program_result = 0; + REQUIRE(hook.fire(ctx, &program_result) == EBPF_SUCCESS); + REQUIRE((program_result == 0) == no_max_entries); + + found_value = 0; + lookup_result = bpf_map_lookup_elem(map_fd, &program_key, &found_value); + REQUIRE((lookup_result == 0) == no_max_entries); + if (no_max_entries) { + REQUIRE(found_value == (uint64_t)program_key * program_key); + } +} + +static void +_test_map_no_max_entries_program(ebpf_execution_type_t execution_type) +{ + _test_map_max_entries_program(execution_type, true); +} + +static void +_test_map_bounded_entries_program(ebpf_execution_type_t execution_type) +{ + _test_map_max_entries_program(execution_type, false); +} + +static void +_test_legacy_map_no_max_entries_program(ebpf_execution_type_t execution_type) +{ + _test_map_max_entries_program(execution_type, true, "map_no_max_entries_legacy"); +} + +static void +_test_legacy_map_bounded_entries_program(ebpf_execution_type_t execution_type) +{ + _test_map_max_entries_program(execution_type, false, "map_max_entries_legacy"); +} + +DECLARE_JIT_TEST_CASES( + "libbpf map no max entries program", "[libbpf][map_no_max_entries]", _test_map_no_max_entries_program); +DECLARE_JIT_TEST_CASES( + "libbpf map bounded entries program", "[libbpf][map_no_max_entries]", _test_map_bounded_entries_program); +DECLARE_JIT_TEST_CASES( + "libbpf legacy map no max entries program", + "[libbpf][map_no_max_entries][legacy_map]", + _test_legacy_map_no_max_entries_program); +DECLARE_JIT_TEST_CASES( + "libbpf legacy map bounded entries program", + "[libbpf][map_no_max_entries][legacy_map]", + _test_legacy_map_bounded_entries_program); + +TEST_CASE("libbpf map_no_max_entries_flag", "[libbpf]") +{ + _test_helper_libbpf test_helper; + test_helper.initialize(); + + // Create hash map with BPF_F_NO_MAX_ENTRIES - should allow inserts beyond max_entries. + uint32_t max_entries = 4; + bpf_map_create_opts opts = {sizeof(opts)}; + opts.map_flags = BPF_F_NO_MAX_ENTRIES; + int map_fd = bpf_map_create(BPF_MAP_TYPE_HASH, "unbounded", sizeof(uint32_t), sizeof(uint64_t), max_entries, &opts); + REQUIRE(map_fd >= 0); + + // Fill the map to max_entries. + for (uint32_t key = 0; key < max_entries; key++) { + uint64_t value = static_cast(key) * key; + REQUIRE(bpf_map_update_elem(map_fd, &key, &value, 0) == 0); + } + + // Insert beyond max_entries should succeed. + uint32_t extra_key = max_entries; + uint64_t extra_value = 0xdeadbeef; + REQUIRE(bpf_map_update_elem(map_fd, &extra_key, &extra_value, 0) == 0); + + // Verify the extra entry. + uint64_t lookup_value = 0; + REQUIRE(bpf_map_lookup_elem(map_fd, &extra_key, &lookup_value) == 0); + REQUIRE(lookup_value == 0xdeadbeef); + + Platform::_close(map_fd); + + // Create hash map WITHOUT the flag - should enforce max_entries. + int bounded_fd = + bpf_map_create(BPF_MAP_TYPE_HASH, "bounded", sizeof(uint32_t), sizeof(uint64_t), max_entries, NULL); + REQUIRE(bounded_fd >= 0); + + // Fill the map. + for (uint32_t key = 0; key < max_entries; key++) { + uint64_t value = static_cast(key) * key; + REQUIRE(bpf_map_update_elem(bounded_fd, &key, &value, 0) == 0); + } + + // Insert beyond max_entries should fail. + extra_key = max_entries; + REQUIRE(bpf_map_update_elem(bounded_fd, &extra_key, &extra_value, 0) < 0); + + Platform::_close(bounded_fd); + + // BPF_F_NO_MAX_ENTRIES on array maps should fail. + opts.map_flags = BPF_F_NO_MAX_ENTRIES; + int array_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, "bad_array", sizeof(uint32_t), sizeof(uint64_t), 10, &opts); + REQUIRE(array_fd < 0); +} + TEST_CASE("libbpf create queue", "[libbpf]") { _test_helper_libbpf test_helper; diff --git a/tools/bpf2c/bpf_code_generator.cpp b/tools/bpf2c/bpf_code_generator.cpp index f31d34d01f..411add05e7 100644 --- a/tools/bpf2c/bpf_code_generator.cpp +++ b/tools/bpf2c/bpf_code_generator.cpp @@ -621,6 +621,21 @@ vector_of(const ELFIO::section& sec) return {(T*)data, (T*)(data + size)}; } +static uint32_t +get_uint_value_for_btf_map( + const libbtf::btf_type_data& btf_data, libbtf::btf_type_id id, const char* member_name, uint32_t default_value) +{ + auto map_struct = btf_data.get_kind_type(id); + for (const auto& member : map_struct.members) { + if (member.name == member_name) { + // This should use value_from_BTF__uint from btf_parser.cpp, but it's static. + auto value_type_id = btf_data.dereference_pointer(member.type); + return btf_data.get_kind_type(value_type_id).count_of_elements; + } + } + return default_value; +} + // Parse a BTF maps section. void bpf_code_generator::parse_btf_maps_section(const unsafe_string& name) @@ -697,20 +712,13 @@ bpf_code_generator::parse_btf_maps_section(const unsafe_string& name) map_definition.max_entries = map_descriptor.max_entries; map_definition.id = map_descriptor.original_fd; map_definition.inner_id = map_descriptor.inner_map_fd != -1 ? map_descriptor.inner_map_fd : 0; + map_definition.map_flags = + get_uint_value_for_btf_map(btf_data.value(), map_descriptor.original_fd, "map_flags", 0); + map_definition.pinning = static_cast( + get_uint_value_for_btf_map(btf_data.value(), map_descriptor.original_fd, "pinning", LIBBPF_PIN_NONE)); - // Get pinning data from the BTF data. auto map_struct = btf_data->get_kind_type(map_descriptor.original_fd); for (const auto& member : map_struct.members) { - if (member.name == "pinning") { - // This should use value_from_BTF__uint from btf_parser.cpp, but it's static. - auto pinning_type_id = member.type; - // Dereference the pointer type. - pinning_type_id = btf_data->dereference_pointer(pinning_type_id); - // Get the array type. - auto pinning_type = btf_data->get_kind_type(pinning_type_id); - // Value is encoded as the number of elements in the array. - map_definition.pinning = static_cast(pinning_type.count_of_elements); - } // "values" is a variable length array of pointers to values. // Compute the offset of the values array and resize the vector // to hold the initial values. @@ -2232,6 +2240,8 @@ bpf_code_generator::emit_c_code(std::ostream& output_stream) width = std::max(width, std::log10((size_t)entry.definition.id)); width = std::max(width, std::log10((size_t)entry.definition.inner_id)); + width = std::max(width, (double)name.quoted().size()); + width = std::max(width, std::log10((size_t)entry.definition.map_flags)); auto stream_width = static_cast(std::floor(width) + 1); stream_width += 2; // Add space for the trailing ", " @@ -2271,7 +2281,11 @@ bpf_code_generator::emit_c_code(std::ostream& output_stream) << std::to_string(entry.definition.inner_id) + "," << "// The id of the inner map template." << std::endl; output_stream << INDENT " }," << std::endl; - output_stream << INDENT " " << name.quoted() << "}," << std::endl; + output_stream << INDENT " " << std::left << std::setw(stream_width) << name.quoted() + "," << "// Map name." + << std::endl; + output_stream << INDENT " " << std::left << std::setw(stream_width) + << std::to_string(entry.definition.map_flags) + "," << "// Map creation flags." << std::endl; + output_stream << INDENT "}," << std::endl; } output_stream << "};" << std::endl; output_stream << "#pragma data_seg(pop)" << std::endl;