-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FreeBSD has the CNI plugins ported: https://www.freshports.org/net/containernetworking-plugins/. This allows us to enable CNI networking for FreeBSD containers. This change adapts the existing linux codebase to work on freebsd: - containerutil: use nullfs instead of bind mounts for resolv.conf, etc. - ocihook: freebsd's bridge plugin uses jail names in contrast to linux's network namespace usages - container creation: configure runj runtime to create vnet jails by default Signed-off-by: Artem Khramov <akhramov@pm.me>
- Loading branch information
Showing
13 changed files
with
173 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...erutil/container_network_manager_linux.go → ...nerutil/container_network_manager_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build linux || freebsd | ||
|
||
/* | ||
Copyright The containerd Authors. | ||
|
2 changes: 1 addition & 1 deletion
2
...erutil/container_network_manager_other.go → .../container_network_manager_unsupported.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//go:build !freebsd | ||
|
||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package ocihook | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
func getNetNSPath(state *specs.State) (string, error) { | ||
// If we have a network-namespace annotation we use it over the passed Pid. | ||
netNsPath, netNsFound := state.Annotations[NetworkNamespace] | ||
if netNsFound { | ||
if _, err := os.Stat(netNsPath); err != nil { | ||
return "", err | ||
} | ||
|
||
return netNsPath, nil | ||
} | ||
|
||
if state.Pid == 0 && !netNsFound { | ||
return "", errors.New("both state.Pid and the netNs annotation are unset") | ||
} | ||
|
||
// We dont't have a networking namespace annotation, but we have a PID. | ||
s := fmt.Sprintf("/proc/%d/ns/net", state.Pid) | ||
if _, err := os.Stat(s); err != nil { | ||
return "", err | ||
} | ||
return s, nil | ||
} |