-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpip.go
63 lines (53 loc) · 2.04 KB
/
pip.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
package manager
import "fmt"
type ProbeIdentificationPair struct {
// UID - (optional) this field can be used to identify your probes when the same eBPF program is used on multiple
// hook points. Keep in mind that the pair (probe section, probe UID) needs to be unique
// system-wide for the kprobes and uprobes registration to work.
UID string
// EBPFFuncName - Name of the main eBPF function of your eBPF program.
EBPFFuncName string
}
func (pip ProbeIdentificationPair) String() string {
return fmt.Sprintf("{UID:%s EBPFFuncName:%s}", pip.UID, pip.EBPFFuncName)
}
// RenameProbeIdentificationPair - Renames the probe identification pair of a probe
func (p *Probe) RenameProbeIdentificationPair(newID ProbeIdentificationPair) error {
p.stateLock.Lock()
defer p.stateLock.Unlock()
if p.state >= paused {
return fmt.Errorf("couldn't rename ProbeIdentificationPair of %s with %s: %w", p.ProbeIdentificationPair, newID, ErrProbeRunning)
}
p.UID = newID.UID
return nil
}
// RenameProbeIdentificationPair - Renames a probe identification pair. This change will propagate to all the features in
// the manager that will try to select the probe by its old ProbeIdentificationPair.
func (m *Manager) RenameProbeIdentificationPair(oldID ProbeIdentificationPair, newID ProbeIdentificationPair) error {
m.stateLock.Lock()
defer m.stateLock.Unlock()
// sanity check: make sure the newID doesn't already exist
for _, mProbe := range m.Probes {
if mProbe.ProbeIdentificationPair == newID {
return ErrIdentificationPairInUse
}
}
if oldID.EBPFFuncName != newID.EBPFFuncName {
// edit the excluded sections
for i, excludedFuncName := range m.options.ExcludedFunctions {
if excludedFuncName == oldID.EBPFFuncName {
m.options.ExcludedFunctions[i] = newID.EBPFFuncName
}
}
}
// edit the probe selectors
for _, selector := range m.options.ActivatedProbes {
selector.EditProbeIdentificationPair(oldID, newID)
}
// edit the probe
p, ok := m.getProbe(oldID)
if !ok {
return ErrSymbolNotFound
}
return p.RenameProbeIdentificationPair(newID)
}