-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
paths.go
69 lines (59 loc) · 2.45 KB
/
paths.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Cilium
package loader
import (
"path/filepath"
"github.com/vishvananda/netlink"
datapath "github.com/cilium/cilium/pkg/datapath/types"
)
// bpffsDevicesDir returns the path to the 'devices' directory on bpffs, usually
// /sys/fs/bpf/cilium/devices. It does not ensure the directory exists.
//
// base is typically set to /sys/fs/bpf/cilium, but can be a temp directory
// during tests.
func bpffsDevicesDir(base string) string {
return filepath.Join(base, "devices")
}
// bpffsDeviceDir returns the path to the per-device directory on bpffs, usually
// /sys/fs/bpf/cilium/devices/<device>. It does not ensure the directory exists.
//
// base is typically set to /sys/fs/bpf/cilium, but can be a temp directory
// during tests.
func bpffsDeviceDir(base string, device netlink.Link) string {
return filepath.Join(bpffsDevicesDir(base), device.Attrs().Name)
}
// bpffsDeviceLinksDir returns the bpffs path to the per-device links directory,
// usually /sys/fs/bpf/cilium/devices/<device>/links. It does not ensure the
// directory exists.
//
// base is typically set to /sys/fs/bpf/cilium, but can be a temp directory
// during tests.
func bpffsDeviceLinksDir(base string, device netlink.Link) string {
return filepath.Join(bpffsDeviceDir(base, device), "links")
}
// bpffsEndpointsDir returns the path to the 'endpoints' directory on bpffs, usually
// /sys/fs/bpf/cilium/endpoints. It does not ensure the directory exists.
//
// base is typically set to /sys/fs/bpf/cilium, but can be a temp directory
// during tests.
func bpffsEndpointsDir(base string) string {
return filepath.Join(base, "endpoints")
}
// bpffsEndpointDir returns the path to the per-endpoint directory on bpffs,
// usually /sys/fs/bpf/cilium/endpoints/<endpoint-id>. It does not ensure the
// directory exists.
//
// base is typically set to /sys/fs/bpf/cilium, but can be a temp directory
// during tests.
func bpffsEndpointDir(base string, ep datapath.Endpoint) string {
return filepath.Join(bpffsEndpointsDir(base), ep.StringID())
}
// bpffsEndpointLinksDir returns the bpffs path to the per-endpoint links directory,
// usually /sys/fs/bpf/cilium/endpoints/<endpoint-id>/links. It does not ensure the
// directory exists.
//
// base is typically set to /sys/fs/bpf/cilium, but can be a temp directory
// during tests.
func bpffsEndpointLinksDir(base string, ep datapath.Endpoint) string {
return filepath.Join(bpffsEndpointDir(base, ep), "links")
}