MCPcopy
hub / github.com/cilium/ebpf / ExampleAttachNetNs

Function ExampleAttachNetNs

link/netns_test.go:49–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49func ExampleAttachNetNs() {
50 prog, err := createSkLookupProgram()
51 if err != nil {
52 panic(err)
53 }
54 defer prog.Close()
55
56 // This can be a path to another netns as well.
57 netns, err := os.Open("/proc/self/ns/net")
58 if err != nil {
59 panic(err)
60 }
61 defer netns.Close()
62
63 link, err := AttachNetNs(int(netns.Fd()), prog)
64 if err != nil {
65 panic(err)
66 }
67
68 // The socket lookup program is now active until Close().
69 link.Close()
70}

Callers

nothing calls this directly

Calls 4

createSkLookupProgramFunction · 0.85
AttachNetNsFunction · 0.85
OpenMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…