Skip to content

Commit

Permalink
linux/bpf_prog_load: support custom kernel builds
Browse files Browse the repository at this point in the history
for custom-built kernels, kernel.version may not
always contain the kernel version number
also support kernel versions with more than one
digits between dots
  • Loading branch information
vavrusa committed May 4, 2016
1 parent 9981190 commit 0da437f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions syscall/linux/syscalls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -787,9 +787,9 @@ if C.bpf then
if not version then
-- We have no better way to extract current kernel hex-string other
-- than parsing headers, compiling a helper function or reading /proc
local ver_str, count = S.sysctl('kernel.version'):match('%d.%d.%d'), 2
local ver_str, count = S.sysctl('kernel.osrelease'):match('%d+.%d+.%d+'), 2
version = 0
for i in ver_str:gmatch('%d') do -- Convert 'X.Y.Z' to 0xXXYYZZ
for i in ver_str:gmatch('%d+') do -- Convert 'X.Y.Z' to 0xXXYYZZ
version = bit.bor(version, bit.lshift(tonumber(i), 8*count))
count = count - 1
end
Expand Down

0 comments on commit 0da437f

Please sign in to comment.