rbbcc 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rbbcc/bcc.rb +38 -2
- data/lib/rbbcc/clib.rb +1 -0
- data/lib/rbbcc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6795c09c9054d789de4ce10626404bc7f6e5f7cdb12296e2344b270f2a7fa2a7
|
|
4
|
+
data.tar.gz: e898c4bc91fcc3b7dff968a2daf44d667faf68c5ee9eef29b1eba4f14dc2d123
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d40bb0cc232b51f25cc6970580c00bcb52c13cf7423f5082f3bbb447b9ea5d5a59acb958a68df4b3a3639bf86ac8ee72a673313d009cdb18be9eec52dc3176a9
|
|
7
|
+
data.tar.gz: e9af3796aa61f7f76b0122e13b2ec6c0958c8d33edeb6c0d34a5813e0f38e7f1cbd46eb267290a3935b381d94815cb7b4479d5adfeee428c709124b7456e3fa4
|
data/Gemfile.lock
CHANGED
data/lib/rbbcc/bcc.rb
CHANGED
|
@@ -242,6 +242,7 @@ module RbBCC
|
|
|
242
242
|
@uprobe_fds = {}
|
|
243
243
|
@tracepoint_fds = {}
|
|
244
244
|
@raw_tracepoint_fds = {}
|
|
245
|
+
@lsm_fds = {}
|
|
245
246
|
|
|
246
247
|
if src_file
|
|
247
248
|
src_file = BCC._find_file(src_file)
|
|
@@ -433,6 +434,34 @@ module RbBCC
|
|
|
433
434
|
@tracepoint_fds.delete(tp)
|
|
434
435
|
end
|
|
435
436
|
|
|
437
|
+
def attach_lsm(fn_name: "")
|
|
438
|
+
if @lsm_fds.keys.include?(fn_name)
|
|
439
|
+
raise "LSM #{fn_name} has been attached"
|
|
440
|
+
end
|
|
441
|
+
|
|
442
|
+
fn = load_func(fn_name, BPF::LSM)
|
|
443
|
+
fd = Clib.bpf_attach_lsm(fn[:fd])
|
|
444
|
+
if fd < 0
|
|
445
|
+
raise SystemCallError.new("Failed to attach LSM #{fn_name}", Fiddle.last_error)
|
|
446
|
+
end
|
|
447
|
+
Util.debug "Attach: #{fn_name}"
|
|
448
|
+
@lsm_fds[fn_name] = fd
|
|
449
|
+
self
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
def detach_lsm(fn_name)
|
|
453
|
+
unless @lsm_fds.keys.include?(fn_name)
|
|
454
|
+
raise "LSM #{fn_name} is not attached"
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
begin
|
|
458
|
+
File.for_fd(@lsm_fds[fn_name]).close
|
|
459
|
+
rescue => e
|
|
460
|
+
warn "Closing fd failed: #{e.inspect}. Ignore and skip"
|
|
461
|
+
end
|
|
462
|
+
@lsm_fds.delete(fn_name)
|
|
463
|
+
end
|
|
464
|
+
|
|
436
465
|
def detach_kprobe_event(ev_name)
|
|
437
466
|
unless @kprobe_fds.keys.include?(ev_name)
|
|
438
467
|
raise "Event #{ev_name} not registered"
|
|
@@ -471,6 +500,10 @@ module RbBCC
|
|
|
471
500
|
@tracepoint_fds.size
|
|
472
501
|
end
|
|
473
502
|
|
|
503
|
+
def num_open_lsms
|
|
504
|
+
@lsm_fds.size
|
|
505
|
+
end
|
|
506
|
+
|
|
474
507
|
def tracefile
|
|
475
508
|
@tracefile ||= File.open("#{TRACEFS}/trace_pipe", "rb")
|
|
476
509
|
end
|
|
@@ -528,6 +561,10 @@ module RbBCC
|
|
|
528
561
|
detach_raw_tracepoint(k)
|
|
529
562
|
end
|
|
530
563
|
|
|
564
|
+
@lsm_fds.each do |k, v|
|
|
565
|
+
detach_lsm(k)
|
|
566
|
+
end
|
|
567
|
+
|
|
531
568
|
if @module
|
|
532
569
|
Clib.bpf_module_destroy(@module)
|
|
533
570
|
end
|
|
@@ -644,8 +681,7 @@ module RbBCC
|
|
|
644
681
|
fn_name: fn[:name]
|
|
645
682
|
)
|
|
646
683
|
elsif func_name.start_with?("lsm__")
|
|
647
|
-
|
|
648
|
-
load_func(func_name, BPF::LSM)
|
|
684
|
+
attach_lsm(fn_name: func_name)
|
|
649
685
|
end
|
|
650
686
|
end
|
|
651
687
|
end
|
data/lib/rbbcc/clib.rb
CHANGED
|
@@ -114,6 +114,7 @@ module RbBCC
|
|
|
114
114
|
extern 'int bpf_attach_tracepoint(int progfd, char *tp_category, char *tp_name)'
|
|
115
115
|
extern 'int bpf_detach_tracepoint(char *tp_category, char *tp_name)'
|
|
116
116
|
extern 'int bpf_attach_raw_tracepoint(int progfd, char *tp_name)'
|
|
117
|
+
extern 'int bpf_attach_lsm(int progfd)'
|
|
117
118
|
extern 'int bpf_open_perf_event(unsigned int, unsigned long, int, int)'
|
|
118
119
|
extern 'int bpf_close_perf_event_fd(int)'
|
|
119
120
|
extern 'int bpf_get_first_key(int, void *, int)'
|
data/lib/rbbcc/version.rb
CHANGED