Skip to content

Commit

Permalink
add bpf.o to craned rpm pack (#384)
Browse files Browse the repository at this point in the history
* fix wrong variable ref to BasicDevice

* add bpf.o to craned rpm pack

* fix: eBPF object installation prefix

---------

Co-authored-by: Nativu5 <44155313+Nativu5@users.noreply.github.com>
  • Loading branch information
wtr0504 and Nativu5 authored Dec 13, 2024
1 parent 5a61084 commit a7646cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,14 @@ install(FILES
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

# Install configuration files
if(ENABLE_BPF)
install(FILES
${CMAKE_BINARY_DIR}/src/Misc/BPF/cgroup_dev_bpf.o
DESTINATION /usr/local/lib64/bpf/
COMPONENT cranedc
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
endif()

install(FILES ${CMAKE_SOURCE_DIR}/etc/config.yaml
DESTINATION /etc/crane/
COMPONENT cranectldc
Expand Down
4 changes: 2 additions & 2 deletions src/Craned/CgroupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,8 @@ bool CgroupV2::SetDeviceAccess(const std::unordered_set<SlotId> &devices,

auto &bpf_devices = m_cgroup_bpf_devices;
for (const auto &[_, this_device] : Craned::g_this_node_device) {
if (!devices.contains(this_device->dev_id)) {
for (const auto &dev_meta : this_device->device_metas) {
if (!devices.contains(this_device->slot_id)) {
for (const auto &dev_meta : this_device->device_file_metas) {
short op_type = 0;
if (dev_meta.op_type == 'c') {
op_type |= BPF_DEVCG_DEV_CHAR;
Expand Down
2 changes: 1 addition & 1 deletion src/Craned/CgroupManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ enum class ControllerFile : uint64_t {
inline const char *kTaskCgPathPrefix = "Crane_Task_";
inline const char *RootCgroupFullPath = "/sys/fs/cgroup";
#ifdef CRANE_ENABLE_BPF
inline const char *BpfObjectFile = "/etc/crane/cgroup_dev_bpf.o";
inline const char *BpfObjectFile = "/usr/local/lib64/bpf/cgroup_dev_bpf.o";
inline const char *BpfDeviceMapFile = "/sys/fs/bpf/craned_dev_map";
inline const char *BpfMapName = "craned_dev_map";
inline const char *BpfProgramName = "craned_device_access";
Expand Down

0 comments on commit a7646cd

Please sign in to comment.