Skip to content

Commit

Permalink
Fix program info hash algorithm (#2829)
Browse files Browse the repository at this point in the history
* backup

* backup2

* fix

* fix

* fix

* fix

* fix

* code cleanup

* revert expected files

* remove regression test

* code cleanup

* remove dead code

* cr comments

* Apply suggestions from code review

Co-authored-by: Dave Thaler <[email protected]>

* cr comments

* fix build

---------

Co-authored-by: Dave Thaler <[email protected]>
  • Loading branch information
saxena-anurag and dthaler authored Sep 11, 2023
1 parent b0c099b commit 88b6f67
Show file tree
Hide file tree
Showing 9 changed files with 396 additions and 150 deletions.
28 changes: 17 additions & 11 deletions libs/execution_context/ebpf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,15 @@ ebpf_core_resolve_helper(
goto Done;
}

return_value = ebpf_program_set_program_info_hash(program);
if (return_value != EBPF_SUCCESS) {
goto Done;
}

Done:
if (return_value != EBPF_SUCCESS && program != NULL) {
ebpf_program_clear_helper_function_ids(program);
}
EBPF_OBJECT_RELEASE_REFERENCE((ebpf_core_object_t*)program);
EBPF_RETURN_RESULT(return_value);
}
Expand Down Expand Up @@ -423,17 +431,15 @@ _ebpf_core_protocol_resolve_helper(
goto Done;
}

if (count_of_helpers == 0) {
goto Done;
}

request_helper_ids = (uint32_t*)ebpf_allocate_with_tag(count_of_helpers * sizeof(uint32_t), EBPF_POOL_TAG_CORE);
if (request_helper_ids == NULL) {
return_value = EBPF_NO_MEMORY;
goto Done;
}
for (helper_index = 0; helper_index < count_of_helpers; helper_index++) {
request_helper_ids[helper_index] = request->helper_id[helper_index];
if (count_of_helpers != 0) {
request_helper_ids = (uint32_t*)ebpf_allocate_with_tag(count_of_helpers * sizeof(uint32_t), EBPF_POOL_TAG_CORE);
if (request_helper_ids == NULL) {
return_value = EBPF_NO_MEMORY;
goto Done;
}
for (helper_index = 0; helper_index < count_of_helpers; helper_index++) {
request_helper_ids[helper_index] = request->helper_id[helper_index];
}
}

return_value =
Expand Down
33 changes: 15 additions & 18 deletions libs/execution_context/ebpf_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,26 +1155,23 @@ _ebpf_native_resolve_helpers_for_program(
uint16_t helper_count = program->entry->helper_count;
helper_function_entry_t* helpers = program->entry->helpers;

if (helper_count == 0) {
// No helpers called by this program.
EBPF_RETURN_RESULT(EBPF_SUCCESS);
}

helper_ids = ebpf_allocate_with_tag(helper_count * sizeof(uint32_t), EBPF_POOL_TAG_NATIVE);
if (helper_ids == NULL) {
result = EBPF_NO_MEMORY;
goto Done;
}
if (helper_count > 0) {
helper_ids = ebpf_allocate_with_tag(helper_count * sizeof(uint32_t), EBPF_POOL_TAG_NATIVE);
if (helper_ids == NULL) {
result = EBPF_NO_MEMORY;
goto Done;
}

helper_addresses = ebpf_allocate_with_tag(helper_count * sizeof(helper_function_address), EBPF_POOL_TAG_NATIVE);
if (helper_addresses == NULL) {
result = EBPF_NO_MEMORY;
goto Done;
}
helper_addresses = ebpf_allocate_with_tag(helper_count * sizeof(helper_function_address), EBPF_POOL_TAG_NATIVE);
if (helper_addresses == NULL) {
result = EBPF_NO_MEMORY;
goto Done;
}

// Iterate over the helper indices to get all the helper ids.
for (uint16_t i = 0; i < helper_count; i++) {
helper_ids[i] = helpers[i].helper_id;
// Iterate over the helper indices to get all the helper ids.
for (uint16_t i = 0; i < helper_count; i++) {
helper_ids[i] = helpers[i].helper_id;
}
}

result = ebpf_core_resolve_helper(program->handle, helper_count, helper_ids, (uint64_t*)helper_addresses);
Expand Down
Loading

0 comments on commit 88b6f67

Please sign in to comment.