Class: OsCtld::Devices::V2::BpfLink

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/devices/v2/bpf_link.rb

Overview

Encapsulates BPF program link to a cgroup

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prog_name, pool_name, cgroup_path) ⇒ BpfLink

Returns a new instance of BpfLink.

Parameters:

  • prog_name (String)
  • pool_name (String)
  • cgroup_path (String)


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_pathString (readonly)

Returns:

  • (String)


25
26
27
# File 'lib/osctld/devices/v2/bpf_link.rb', line 25

def cgroup_path
  @cgroup_path
end

#nameString (readonly)

Returns:

  • (String)


28
29
30
# File 'lib/osctld/devices/v2/bpf_link.rb', line 28

def name
  @name
end

#pathString (readonly)

Pin file path

Returns:

  • (String)


32
33
34
# File 'lib/osctld/devices/v2/bpf_link.rb', line 32

def path
  @path
end

#pool_nameString (readonly)

Returns:

  • (String)


22
23
24
# File 'lib/osctld/devices/v2/bpf_link.rb', line 22

def pool_name
  @pool_name
end

#prog_nameString (readonly)

Returns:

  • (String)


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

Parameters:

  • pool_name (String)
  • name (String)

    link file name

Returns:



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