(state *specs.State)
| 305 | } |
| 306 | |
| 307 | func getNetNSPath(state *specs.State) (string, error) { |
| 308 | // If we have a network-namespace annotation we use it over the passed Pid. |
| 309 | netNsPath, netNsFound := state.Annotations[NetworkNamespace] |
| 310 | if netNsFound { |
| 311 | if _, err := os.Stat(netNsPath); err != nil { |
| 312 | return "", err |
| 313 | } |
| 314 | |
| 315 | return netNsPath, nil |
| 316 | } |
| 317 | |
| 318 | if state.Pid == 0 { |
| 319 | return "", errors.New("both state.Pid and the netNs annotation are unset") |
| 320 | } |
| 321 | |
| 322 | // We dont't have a networking namespace annotation, but we have a PID. |
| 323 | s := fmt.Sprintf("/proc/%d/ns/net", state.Pid) |
| 324 | if _, err := os.Stat(s); err != nil { |
| 325 | return "", err |
| 326 | } |
| 327 | return s, nil |
| 328 | } |
| 329 | |
| 330 | func getPortMapOpts(opts *handlerOpts) ([]cni.NamespaceOpts, error) { |
| 331 | if len(opts.ports) > 0 { |
no test coverage detected
searching dependent graphs…