Skip to content

link: link.Tracepoint fails for tracepoint groups containing '-' (hyphen) #1854

@AryanBakliwal

Description

@AryanBakliwal

Describe the bug

When trying to attach an eBPF program to a tracepoint whose group contains a hyphen (e.g. xhci-hcd), link.Tracepoint fails with:

opening tracepoint: invalid tracefs group: "xhci-hcd"

This happens because the validIdentifier function currently rejects hyphens (-), even though they are valid in tracefs event groups (for example, USB tracepoints use xhci-hcd).
This prevents attaching to valid tracepoints that exist in the kernel.

Expected behavior

The tracepoint should attach successfully, since xhci-hcd is a valid group under /sys/kernel/tracing/events/.

How to reproduce

Build a simple Go program that tries to attach to a tracepoint with a - in the group:

tp, err := link.Tracepoint("xhci-hcd", "xhci_setup_device", objs.XhciSetupDevice, nil)
if err != nil {
	log.Fatalf("opening tracepoint: %s", err)
}
defer tp.Close()

and run the program.

Version information

github.com/cilium/ebpf v0.19.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions