2021-05-26 00:11:13 +03:00
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
#include <mutex>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "api_service.h"
|
|
|
|
#include "rpc_interface_h.h"
|
|
|
|
#include "svc_common.h"
|
|
|
|
|
|
|
|
ebpf_result_t
|
2021-06-08 00:22:04 +03:00
|
|
|
ebpf_server_verify_and_load_program(
|
2021-05-26 00:11:13 +03:00
|
|
|
/* [ref][in] */ ebpf_program_load_info* info,
|
|
|
|
/* [ref][out] */ uint32_t* logs_size,
|
2021-05-26 01:36:19 +03:00
|
|
|
/* [ref][size_is][size_is][out] */ char** logs)
|
2021-05-26 00:11:13 +03:00
|
|
|
{
|
2021-06-08 00:22:04 +03:00
|
|
|
ebpf_result_t result;
|
|
|
|
|
|
|
|
if (info->byte_code_size == 0) {
|
|
|
|
return EBPF_INVALID_ARGUMENT;
|
|
|
|
}
|
|
|
|
|
2021-08-31 06:15:09 +03:00
|
|
|
// Set the handle of program being verified in thread-local storage.
|
2021-09-14 18:25:56 +03:00
|
|
|
set_program_under_verification(reinterpret_cast<ebpf_handle_t>(info->program_handle));
|
2021-08-31 06:15:09 +03:00
|
|
|
|
2021-06-08 00:22:04 +03:00
|
|
|
result = ebpf_verify_and_load_program(
|
|
|
|
&info->program_type,
|
2021-09-14 18:25:56 +03:00
|
|
|
reinterpret_cast<ebpf_handle_t>(info->program_handle),
|
2021-06-08 00:22:04 +03:00
|
|
|
info->execution_context,
|
|
|
|
info->execution_type,
|
|
|
|
info->map_count,
|
|
|
|
info->handle_map,
|
|
|
|
info->byte_code_size,
|
|
|
|
info->byte_code,
|
|
|
|
const_cast<const char**>(logs),
|
|
|
|
logs_size);
|
2021-05-26 00:11:13 +03:00
|
|
|
|
2021-06-08 00:22:04 +03:00
|
|
|
ebpf_clear_thread_local_storage();
|
|
|
|
return result;
|
2021-05-26 00:11:13 +03:00
|
|
|
}
|