MCPcopy Create free account
hub / github.com/containerd/nerdctl / WithDetachedNetNSIfAny

Function WithDetachedNetNSIfAny

pkg/rootlessutil/rootlessutil_linux.go:112–121  ·  view source on GitHub ↗

WithDetachedNetNSIfAny executes fn in [DetachedNetNS] if RootlessKit is running with --detach-netns mode. Otherwise it just executes fn in the current netns.

(fn func() error)

Source from the content-addressed store, hash-verified

110// WithDetachedNetNSIfAny executes fn in [DetachedNetNS] if RootlessKit is running with --detach-netns mode.
111// Otherwise it just executes fn in the current netns.
112func WithDetachedNetNSIfAny(fn func() error) error {
113 netns, err := DetachedNetNS()
114 if err != nil {
115 return err
116 }
117 if netns == "" {
118 return fn()
119 }
120 return ns.WithNetNSPath(netns, func(_ ns.NetNS) error { return fn() })
121}

Callers

nothing calls this directly

Calls 1

DetachedNetNSFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…