Documentation
¶
Overview ¶
icx_network.go
Index ¶
- Constants
- func ToFullAddress(addrPort netip.AddrPort) *tcpip.FullAddress
- func Unmap4in6(addr netip.Addr) netip.Addr
- type ICXNetwork
- type IPTables
- type ProtocolHandler
- type TunDevice
- func (tun *TunDevice) AddAddr(addr netip.Prefix) error
- func (tun *TunDevice) BatchSize() int
- func (tun *TunDevice) Close() error
- func (tun *TunDevice) DelAddr(addr netip.Prefix) error
- func (tun *TunDevice) Events() <-chan tun.Event
- func (tun *TunDevice) File() *os.File
- func (tun *TunDevice) ForwardTo(ctx context.Context, upstream network.Network) error
- func (tun *TunDevice) ListenPacket(addr netip.AddrPort) (net.PacketConn, error)
- func (tun *TunDevice) LocalAddresses() ([]netip.Prefix, error)
- func (tun *TunDevice) MTU() (int, error)
- func (tun *TunDevice) Name() (string, error)
- func (tun *TunDevice) Network(resolveConf *network.ResolveConfig) *network.NetstackNetwork
- func (tun *TunDevice) Read(buf [][]byte, sizes []int, offset int) (int, error)
- func (tun *TunDevice) RegisterTCPStatsMetrics(reg prometheus.Registerer)
- func (tun *TunDevice) Write(buf [][]byte, offset int) (int, error)
- func (tun *TunDevice) WriteNotify()
Constants ¶
const IPv6MinMTU = 1280 // IPv6 minimum MTU, required for some PPPoE links.
const TunnelMTU = 1420
TunnelMTU is the MTU used for tunnel TUN devices. Sized to fit in a single QUIC datagram after PMTUD on a typical 1500-byte internet path: 1500 (Ethernet) - 20 (IP) - 8 (UDP) - ~26 (QUIC framing) - 1 (contextID) ≈ 1445. We use 1420 to leave headroom for path variance.
Variables ¶
This section is empty.
Functions ¶
func ToFullAddress ¶
func ToFullAddress(addrPort netip.AddrPort) *tcpip.FullAddress
func Unmap4in6 ¶
Unmap4in6 converts an IPv6 address to an IPv4 address if it is an IPv4-mapped IPv6 address. If the address is not an IPv4-mapped IPv6 address, it is returned unchanged. If the IPv4 address is zero, returns 127.0.0.1. It is following /96 embedding scheme from RFC 6052 (https://datatracker.ietf.org/doc/html/rfc6052#section-2.2).
Types ¶
type ICXNetwork ¶
TODO (dpeckett): nuke this at some point and merge the logic into the router.
func NewICXNetwork ¶
func NewICXNetwork(handler *icx.Handler, phy *l2pc.L2PacketConn, mtu int, resolveConf *network.ResolveConfig, pcapPath string) (*ICXNetwork, error)
NewICXNetwork creates a new ICXNetwork instance with the given handler, physical connection, MTU, and resolve configuration. If pcapPath is provided, it will create a packet sniffer that writes to the specified file. The handler must be configured in layer3 mode.
func (*ICXNetwork) Close ¶
func (net *ICXNetwork) Close() error
Close cleans up the network stack and closes the underlying resources.
func (*ICXNetwork) Start ¶
func (net *ICXNetwork) Start(ctx context.Context) error
Start copies packets to and from netstack and icx. Start runs the netstack <-> ICX datapath until ctx is cancelled or the underlying transport (phy) is closed. It blocks and should run in its own goroutine. The two pump loops (channel.Endpoint <-> engine <-> underlay) now live in the shared icx/vtep/netstack driver; this method just drives it.
type ProtocolHandler ¶
type ProtocolHandler func(stack.TransportEndpointID, *stack.PacketBuffer) bool
ProtocolHandler is a function that handles packets for a specific protocol.
func TCPForwarder ¶
func TCPForwarder(ctx context.Context, ipstack *stack.Stack, upstream network.Network) ProtocolHandler
TCPForwarder forwards TCP connections to an upstream network.
func UDPForwarder ¶
func UDPForwarder(ctx context.Context, ipstack *stack.Stack, upstream network.Network) ProtocolHandler
UDPForwarder forwards UDP packets to an upstream network.
type TunDevice ¶
type TunDevice struct {
// contains filtered or unexported fields
}
func NewTunDevice ¶
func (*TunDevice) ListenPacket ¶
ListenPacket creates an unconnected UDP PacketConn bound to the given overlay address inside the gvisor network stack.
func (*TunDevice) LocalAddresses ¶
LocalAddresses returns the list of local addresses assigned to the TUN device.
func (*TunDevice) Network ¶
func (tun *TunDevice) Network(resolveConf *network.ResolveConfig) *network.NetstackNetwork
Network returns the network abstraction for the TUN device.
func (*TunDevice) RegisterTCPStatsMetrics ¶
func (tun *TunDevice) RegisterTCPStatsMetrics(reg prometheus.Registerer)
RegisterTCPStatsMetrics registers netstack TCP stats as Prometheus gauges that are read at push/scrape time. Call once after creating the TunDevice.
func (*TunDevice) WriteNotify ¶
func (tun *TunDevice) WriteNotify()