Class: OsCtld::Devices::V2::BpfLink
- Inherits:
-
Object
- Object
- OsCtld::Devices::V2::BpfLink
- Defined in:
- lib/osctld/devices/v2/bpf_link.rb
Overview
Encapsulates BPF program link to a cgroup
Instance Attribute Summary collapse
- #cgroup_path ⇒ String readonly
- #name ⇒ String readonly
-
#path ⇒ String
readonly
Pin file path.
- #pool_name ⇒ String readonly
- #prog_name ⇒ String readonly
Class Method Summary collapse
-
.from_name(pool_name, name) ⇒ Devices::V2::BpfLink
Create link instance from file name.
Instance Method Summary collapse
-
#initialize(prog_name, pool_name, cgroup_path) ⇒ BpfLink
constructor
A new instance of BpfLink.
Constructor Details
#initialize(prog_name, pool_name, cgroup_path) ⇒ BpfLink
Returns a new instance of BpfLink.
37 38 39 40 41 42 43 |
# File 'lib/osctld/devices/v2/bpf_link.rb', line 37 def initialize(prog_name, pool_name, cgroup_path) @prog_name = prog_name @pool_name = pool_name @cgroup_path = cgroup_path @name = "devcg-#{prog_name}-on-#{OsCtl::Lib::StringEscape.escape_path(cgroup_path)}" @path = BpfFs.link_pin_path(pool_name, @name) end |
Instance Attribute Details
#cgroup_path ⇒ String (readonly)
25 26 27 |
# File 'lib/osctld/devices/v2/bpf_link.rb', line 25 def cgroup_path @cgroup_path end |
#name ⇒ String (readonly)
28 29 30 |
# File 'lib/osctld/devices/v2/bpf_link.rb', line 28 def name @name end |
#path ⇒ String (readonly)
Pin file path
32 33 34 |
# File 'lib/osctld/devices/v2/bpf_link.rb', line 32 def path @path end |
#pool_name ⇒ String (readonly)
22 23 24 |
# File 'lib/osctld/devices/v2/bpf_link.rb', line 22 def pool_name @pool_name end |
#prog_name ⇒ String (readonly)
19 20 21 |
# File 'lib/osctld/devices/v2/bpf_link.rb', line 19 def prog_name @prog_name end |
Class Method Details
.from_name(pool_name, name) ⇒ Devices::V2::BpfLink
Create link instance from file name
10 11 12 13 14 15 16 |
# File 'lib/osctld/devices/v2/bpf_link.rb', line 10 def self.from_name(pool_name, name) if /\Adevcg-([^\-]+)-on-([^\Z]+)\Z/ !~ name raise ArgumentError, "#{name}.inspect is not valid link name" end new(::Regexp.last_match(1), pool_name, OsCtl::Lib::StringEscape.unescape_path(::Regexp.last_match(2))) end |