|
|
@@ -344,8 +344,9 @@ func (t *Tracer) ebpf(ch chan<- Event) error {
|
|
|
func (t *Tracer) LinkEbpfProg() error {
|
|
|
klog.Infof("[start] Look eBPF specPrograms")
|
|
|
var (
|
|
|
- l link.Link
|
|
|
- err error
|
|
|
+ l link.Link
|
|
|
+ err error
|
|
|
+ lastErr error
|
|
|
)
|
|
|
for _, programSpec := range t.collectionSpec.Programs {
|
|
|
program := t.collection.Programs[programSpec.Name]
|
|
|
@@ -380,23 +381,41 @@ func (t *Tracer) LinkEbpfProg() error {
|
|
|
l, err = link.Kprobe(programSpec.AttachTo, program, nil)
|
|
|
}
|
|
|
if err != nil {
|
|
|
+ lastErr = err
|
|
|
t.Close()
|
|
|
- return fmt.Errorf("failed to link program: %w", err)
|
|
|
+ klog.Errorf("LinkEbpfProg failed to program[%s] link program: %s", programSpec.Name, err)
|
|
|
+ //return fmt.Errorf("failed to link program: %w", err)
|
|
|
+ } else {
|
|
|
+ t.links = append(t.links, l)
|
|
|
}
|
|
|
- t.links = append(t.links, l)
|
|
|
}
|
|
|
klog.Infof("[end] Look eBPF specPrograms")
|
|
|
+
|
|
|
+ if lastErr != nil {
|
|
|
+ return fmt.Errorf("failed to link program: %w", lastErr)
|
|
|
+ }
|
|
|
return nil
|
|
|
}
|
|
|
-func (t *Tracer) UnlinkEbpfProg() {
|
|
|
|
|
|
- for _, p := range t.uprobes {
|
|
|
- _ = p.Close()
|
|
|
+func (t *Tracer) UnlinkEbpfProg() error {
|
|
|
+ var (
|
|
|
+ lastErr error
|
|
|
+ err error
|
|
|
+ )
|
|
|
+ for pName, p := range t.uprobes {
|
|
|
+ if err = p.Close(); err != nil {
|
|
|
+ lastErr = err
|
|
|
+ klog.Errorf("UnlinkEbpfProg close program[%s] uprobe occurs error: %s", pName, err.Error())
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
for _, l := range t.links {
|
|
|
- _ = l.Close()
|
|
|
+ if err = l.Close(); err != nil {
|
|
|
+ lastErr = err
|
|
|
+ klog.Errorf("UnlinkEbpfProg close link occurs error: %s", err.Error())
|
|
|
+ }
|
|
|
}
|
|
|
+ return lastErr
|
|
|
}
|
|
|
|
|
|
func (t EventType) String() string {
|
|
|
@@ -482,13 +501,13 @@ type l7Event struct {
|
|
|
TraceStart uint32
|
|
|
TraceEnd uint32
|
|
|
EventCount uint32
|
|
|
- Sport uint16
|
|
|
- Dport uint16
|
|
|
- SAddr [16]byte
|
|
|
- DAddr [16]byte
|
|
|
- ComponentSport uint16
|
|
|
- ComponentDport uint16
|
|
|
- ComponentSAddr [16]byte
|
|
|
+ Sport uint16
|
|
|
+ Dport uint16
|
|
|
+ SAddr [16]byte
|
|
|
+ DAddr [16]byte
|
|
|
+ ComponentSport uint16
|
|
|
+ ComponentDport uint16
|
|
|
+ ComponentSAddr [16]byte
|
|
|
ComponentDAddr [16]byte
|
|
|
AssumedAppId HashByte
|
|
|
SpanId HashByte
|
|
|
@@ -710,23 +729,23 @@ func runEventsReader(name string, r *perf.Reader, ch chan<- Event, typ perfMapTy
|
|
|
|
|
|
payload := reader.Bytes()
|
|
|
req := &l7.RequestData{
|
|
|
- Protocol: l7.Protocol(v.Protocol),
|
|
|
- Status: l7.Status(v.Status),
|
|
|
- Duration: time.Duration(v.Duration),
|
|
|
- Method: l7.Method(v.Method),
|
|
|
- StatementId: v.StatementId,
|
|
|
- TraceId: v.TraceId,
|
|
|
- TraceStart: v.TraceStart,
|
|
|
- TraceEnd: v.TraceEnd,
|
|
|
- EventCount: v.EventCount,
|
|
|
- AssumedAppId: hex.EncodeToString(v.AssumedAppId[:]),
|
|
|
- SpanId: hex.EncodeToString(v.SpanId[:]),
|
|
|
- StartAt: v.StartAt,
|
|
|
- EndAt: v.EndtAt,
|
|
|
- ComponentSAddr: ipPort(v.ComponentSAddr,v.ComponentSport),
|
|
|
- ComponentDAddr: ipPort(v.ComponentDAddr,v.ComponentDport),
|
|
|
+ Protocol: l7.Protocol(v.Protocol),
|
|
|
+ Status: l7.Status(v.Status),
|
|
|
+ Duration: time.Duration(v.Duration),
|
|
|
+ Method: l7.Method(v.Method),
|
|
|
+ StatementId: v.StatementId,
|
|
|
+ TraceId: v.TraceId,
|
|
|
+ TraceStart: v.TraceStart,
|
|
|
+ TraceEnd: v.TraceEnd,
|
|
|
+ EventCount: v.EventCount,
|
|
|
+ AssumedAppId: hex.EncodeToString(v.AssumedAppId[:]),
|
|
|
+ SpanId: hex.EncodeToString(v.SpanId[:]),
|
|
|
+ StartAt: v.StartAt,
|
|
|
+ EndAt: v.EndtAt,
|
|
|
+ ComponentSAddr: ipPort(v.ComponentSAddr, v.ComponentSport),
|
|
|
+ ComponentDAddr: ipPort(v.ComponentDAddr, v.ComponentDport),
|
|
|
}
|
|
|
- if req.Protocol == l7.ProtocolHTTP{
|
|
|
+ if req.Protocol == l7.ProtocolHTTP {
|
|
|
klog.Infof("runEventsReader ComponentSAddr.String %s", req.ComponentSAddr.String())
|
|
|
klog.Infof("runEventsReader ComponentDAddr.String %s", req.ComponentDAddr.String())
|
|
|
}
|