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)
| 110 | // WithDetachedNetNSIfAny executes fn in [DetachedNetNS] if RootlessKit is running with --detach-netns mode. |
| 111 | // Otherwise it just executes fn in the current netns. |
| 112 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…