hostnet

package
v0.6.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SysctlAllDisableIPv6     = "net.ipv6.conf.all.disable_ipv6"
	SysctlDefaultDisableIPv6 = "net.ipv6.conf.default.disable_ipv6"
)

The sysctls that turn IPv6 off in a network namespace. "all" also flips every interface already there (lo loses ::1); "default" is what an interface created or moved in later starts with, so a veth the CNI plugin adds after the write never gets a link-local address.

Variables

This section is empty.

Functions

func DisableIPv6InNetns added in v0.6.9

func DisableIPv6InNetns(path string) error

DisableIPv6InNetns turns IPv6 off inside the network namespace bind-mounted at path (all and default). Idempotent. A no-op when the host has no IPv6, and on platforms without network namespaces.

func DisableIPv6OnLink(name string) error

DisableIPv6OnLink turns IPv6 off on one host interface, so the host has no link-local address on it that a sandbox at the other end could reach. A no-op when the host has no IPv6. An interface that does not exist is an error: the caller just created it.

func EnsureForwardingSysctls

func EnsureForwardingSysctls() error

EnsureForwardingSysctls enables host forwarding/filter sysctls required for containerd native CNI networking (Phase 2). No-op on platforms without them.

func FlushConntrackForIP

func FlushConntrackForIP(ip string) error

FlushConntrackForIP drops conntrack entries for an IP on slot release (Phase 2).

func HostHasIPv6 added in v0.6.9

func HostHasIPv6() bool

HostHasIPv6 reports whether this kernel has IPv6. Without it no sandbox can have IPv6 either, and a runtime asked to set an IPv6 sysctl fails the create (runc cannot open the missing /proc/sys entry), so every caller below does nothing.

func NetnsIPv4Addrs added in v0.6.9

func NetnsIPv4Addrs(path string) ([]string, error)

NetnsIPv4Addrs returns the IPv4 addresses on the non-loopback interfaces of the network namespace bind-mounted at path: the address a workload started in that namespace comes up at. A namespace with no such address returns an empty list, not an error.

The containerd netns pool asks this of a warm slot that outlived a restart before it hands the slot out again, because a sandbox's rules go onto the slot's recorded address before its workload starts: a row whose namespace holds another address would put them on the wrong one.

func SandboxIPv6Sysctls added in v0.6.9

func SandboxIPv6Sysctls() map[string]string

SandboxIPv6Sysctls are the OCI (and Docker HostConfig) sysctls every sandbox is created with, so it starts with IPv6 off in its own network namespace before its first process runs. gVisor reads the "all" one from the spec too: runsc copies no IPv6 address or route into its own network stack when it is set. Nil when the host has no IPv6. A fresh map per call: callers merge it into a spec they own.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL