Documentation
¶
Overview ¶
Package ateomnet provides shared networking configuration logic for Substrate runtime agents.
Index ¶
- Constants
- Variables
- func CleanupSandboxNetwork(network *SandboxNetwork) error
- func MustParseAddr(cidr string) *netlink.Addr
- func MustParseIP(s string) net.IP
- func MustParseMAC(s string) net.HardwareAddr
- func SandboxGatewayNetNSName(actorUID string) string
- type SandboxNetwork
- type SandboxNetworkConfig
- type SandboxSession
- type SessionHolder
Constants ¶
const ( ActorVethName = "eth0" ActorVethGateway = "169.254.17.1" ActorVethIP = "169.254.17.2" // ActorVethSubnet is the point-to-point /30 the actor veth lives on. ActorVethSubnet = "169.254.17.0/30" )
Variables ¶
var ( HostVethAddr = MustParseAddr(hostVethLocalAddress) ActorVethAddr = MustParseAddr(actorVethLocalAddress) ActorVethGwIP = MustParseIP(ActorVethGateway) )
Functions ¶
func CleanupSandboxNetwork ¶ added in v0.2.0
func CleanupSandboxNetwork(network *SandboxNetwork) error
CleanupSandboxNetwork closes namespace handles and removes their names.
func MustParseAddr ¶
MustParseAddr parses a CIDR string into a netlink.Addr, panicking on error.
func MustParseIP ¶
MustParseIP parses an IPv4 string into a net.IP, panicking on error.
func MustParseMAC ¶
func MustParseMAC(s string) net.HardwareAddr
MustParseMAC parses a MAC address string into a net.HardwareAddr, panicking on error.
func SandboxGatewayNetNSName ¶ added in v0.2.0
SandboxGatewayNetNSName names the namespace holding the veth peer and atunnel's sockets for one actor.
Types ¶
type SandboxNetwork ¶ added in v0.2.0
type SandboxNetwork struct {
// ActorUID is the Actor resource's UID. It names the namespaces, so a
// teardown can find them again.
ActorUID string
// RuntimeNetNS is what the sandbox runs in, whichever runtime that is: the
// micro-VM's tap lives here, and gVisor claims every interface here and
// moves their addresses into its own stack.
RuntimeNetNS netns.Handle
// GatewayNetNS holds the sandbox's default gateway, DNS relay, and atunnel
// sockets. This is local to the sandbox, not the external egress gateway.
// For microVMs it shares RuntimeNetNS.
//
// TODO: we hope gVisor can take that same single-namespace shape soon,
// once runsc can be given one interface rather than claiming every
// interface in the namespace it runs in.
GatewayNetNS netns.Handle
}
SandboxNetwork holds a sandbox's runtime and gateway namespaces.
func SetupSandboxNetwork ¶ added in v0.2.0
func SetupSandboxNetwork(ctx context.Context, cfg SandboxNetworkConfig) (_ *SandboxNetwork, retErr error)
SetupSandboxNetwork creates isolated networking with fixed sandbox addresses. gVisor uses a veth pair across runtime and gateway namespaces because it takes over every interface in its namespace. MicroVMs use a tap in one namespace. nftables at the sandbox's default gateway redirect outbound TCP to atunnel, preserving SO_ORIGINAL_DST. Traffic to the gateway address is not redirected, so DNS over UDP and TCP reaches the relay's own sockets.
type SandboxNetworkConfig ¶ added in v0.2.0
type SandboxNetworkConfig struct {
ActorUID string
// Veth separates gVisor's interfaces from the kernel-owned gateway.
// MicroVMs use a tap in a single namespace instead.
Veth bool
// EgressPort is where atunnel serves this actor. Every TCP connection the
// actor makes is redirected to it, whatever port it was aimed at.
EgressPort uint16
// DNSPort is where the DNS relay answers, on the sandbox's default gateway.
DNSPort uint16
}
SandboxNetworkConfig describes one actor's private networking.
type SandboxSession ¶ added in v0.2.0
type SandboxSession struct {
Network *SandboxNetwork
// contains filtered or unexported fields
}
SandboxSession owns a sandbox's network and serving sockets.
func ServeSandbox ¶ added in v0.2.0
func ServeSandbox(ctx context.Context, cfg SandboxNetworkConfig, egress egressServer, resolver dns.Server) (_ *SandboxSession, retErr error)
ServeSandbox builds a sandbox's network and serves egress and DNS from its gateway namespace. A nil server leaves that unserved, which fails closed.
func (*SandboxSession) Close ¶ added in v0.2.0
func (s *SandboxSession) Close(ctx context.Context) error
Close cancels the work in flight, closes the sockets, waits for the serving goroutines, then removes the namespaces. ctx bounds only the wait; the namespaces go either way, since leaving them wedges the next activation. Idempotent, and every step's error is returned.
type SessionHolder ¶ added in v0.2.0
type SessionHolder struct {
// contains filtered or unexported fields
}
SessionHolder is the one sandbox session a worker is serving, for the ateoms to share what is otherwise the same locking, replacement and dialing in both.
func (*SessionHolder) Close ¶ added in v0.2.0
func (h *SessionHolder) Close(ctx context.Context) error
Close releases the held session, if any.
func (*SessionHolder) Dialer ¶ added in v0.2.0
Dialer reaches whichever sandbox is held when the dial happens.
func (*SessionHolder) Replace ¶ added in v0.2.0
func (h *SessionHolder) Replace(ctx context.Context, next *SandboxSession) error
Replace closes whatever session is held and installs next. A previous actor's session can still be here if its teardown never ran, and overwriting it would leak both namespaces, their /run/netns mounts and the goroutines serving them.
func (*SessionHolder) Session ¶ added in v0.2.0
func (h *SessionHolder) Session() *SandboxSession
Session is what is held, or nil between activations.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dns answers an actor's DNS from its sandbox's gateway namespace and writes the resolv.conf that points the actor at it.
|
Package dns answers an actor's DNS from its sandbox's gateway namespace and writes the resolv.conf that points the actor at it. |
|
Package netns creates Linux network namespaces and runs code, opens sockets and dials inside them.
|
Package netns creates Linux network namespaces and runs code, opens sockets and dials inside them. |