Documentation ¶
Overview ¶
Package dataplane defines implementations required to run a gateway dataplane.
Index ¶
- func NewStreamID() uint32
- type AtomicRoutingTable
- func (t *AtomicRoutingTable) AddRoute(index int, pktWriter control.PktWriter) error
- func (t *AtomicRoutingTable) DelRoute(index int) error
- func (t *AtomicRoutingTable) RouteIPv4(packet layers.IPv4) control.PktWriter
- func (t *AtomicRoutingTable) RouteIPv6(packet layers.IPv6) control.PktWriter
- func (t *AtomicRoutingTable) SetRoutingTable(table control.RoutingTable)
- type DiagnosticsWriter
- type IPForwarder
- type IPForwarderMetrics
- type IngressMetrics
- type IngressServer
- type PathStatsPublisher
- type ReadConn
- type RoutingTable
- func (rt *RoutingTable) AddRoute(index int, session control.PktWriter) error
- func (rt *RoutingTable) DelRoute(index int) error
- func (rt *RoutingTable) DiagnosticsWrite(w io.Writer)
- func (rt *RoutingTable) RouteIPv4(pkt layers.IPv4) control.PktWriter
- func (rt *RoutingTable) RouteIPv6(pkt layers.IPv6) control.PktWriter
- type Session
- type SessionMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AtomicRoutingTable ¶
type AtomicRoutingTable struct {
// contains filtered or unexported fields
}
AtomicRoutingTable implements a routing table safe for concurrent use that can be swapped-out for a fresh table.
An AtomicRoutingTable{} is a valid configuration. A routing table in its initial state will always return nil for routing requests, and a SetRoute will be a no-op.
An AtomicRoutingTable should not be copied after use.
func (*AtomicRoutingTable) AddRoute ¶
func (t *AtomicRoutingTable) AddRoute(index int, pktWriter control.PktWriter) error
func (*AtomicRoutingTable) DelRoute ¶
func (t *AtomicRoutingTable) DelRoute(index int) error
func (*AtomicRoutingTable) RouteIPv4 ¶
func (t *AtomicRoutingTable) RouteIPv4(packet layers.IPv4) control.PktWriter
func (*AtomicRoutingTable) RouteIPv6 ¶
func (t *AtomicRoutingTable) RouteIPv6(packet layers.IPv6) control.PktWriter
func (*AtomicRoutingTable) SetRoutingTable ¶
func (t *AtomicRoutingTable) SetRoutingTable(table control.RoutingTable)
type DiagnosticsWriter ¶
DiagnosticsWriter writes to the stdout debug diagnostic information. TODO(karampok): switch to control.DiagnosticsWriter once there is this type.
type IPForwarder ¶
type IPForwarder struct { // Reader is the source of raw packets. It must not be nil. // // Each read should yield a whole packet. Reader io.Reader // RoutingTable is used to decide where packets should be sent. It must not be nil. RoutingTable control.RoutingTableReader // Metrics is used by the forwarder to report information about internal operation. // If a metric is not initialized, it is not reported. Metrics IPForwarderMetrics // Logger is used to display internal information. If nil, logging is disabled. Logger log.Logger }
IPForwarder reads packets from the reader, routes them according to a routing table and dispatches them to a session.
func (*IPForwarder) Run ¶
func (f *IPForwarder) Run() error
Run forwards packets from the reader based on the routing table.
type IPForwarderMetrics ¶
type IPForwarderMetrics struct { // IPPktBytesLocalRecv counts the IP packet bytes received from the local network. If nil, the // metric is not reported. IPPktBytesLocalRecv metrics.Counter // IPPktsLocalRecv counts the number of IP packets received from the local network. If nil, // the metric is not reported. IPPktsLocalRecv metrics.Counter // IPPktsNoRoute counts the number of IP packets received from the local network and that were // discarded because no routing entry was found. If nil, the metric is not reported. IPPktsNoRoute metrics.Counter // MetricInvalidPackets counts the number of packet parsing errors. If nil, the metric // is not reported. IPPktsInvalid metrics.Counter // ReceiveLocalErrors counts the number of read errors encountered on the raw packets source. // If nil, the metric is not reported. ReceiveLocalErrors metrics.Counter }
IPForwarderMetrics is used by the forwarder to report information about internal operation.
type IngressMetrics ¶
type IngressMetrics struct { // IPPktBytesRecv is the total IP packets bytes received. IPPktBytesRecv metrics.Counter // IPPktBytesRecv is the total IP packets count received. IPPktsRecv metrics.Counter // IPPktBytesLocalSent is the total IP packets bytes sent to the local network. IPPktBytesLocalSent metrics.Counter // IPPktsLocalSent is the total IP packets counbt sent to the local network. IPPktsLocalSent metrics.Counter // FrameBytesRecv is the total frames bytes received. FrameBytesRecv metrics.Counter // FramesRecv is the total frames count received. FramesRecv metrics.Counter // FramesDiscarded is the total number of discarded frames. FramesDiscarded metrics.Counter // SendLocalError is the error count when sending IP packets to the local network. SendLocalError metrics.Counter // ReceiveExternalError is the error count when reading frames from the external network. ReceiveExternalError metrics.Counter }
IngressMetrics are used to report traffic and error statistics for ingress traffic.
type IngressServer ¶
type IngressServer struct { Conn ReadConn TUN io.Writer Metrics IngressMetrics // contains filtered or unexported fields }
IngressServer reads new encapsulated packets, classifies the packet by source ISD-AS -> source host Addr -> Sess Id and hands it off to the appropriate Worker, starting a new one if none currently exists.
func (*IngressServer) Run ¶
func (d *IngressServer) Run() error
type PathStatsPublisher ¶
type RoutingTable ¶
type RoutingTable struct { // RouteExporter is informed of remote network prefixes that are reachable/unreachable. // If nil, routes are not exported. RouteExporter control.RouteExporter // contains filtered or unexported fields }
RoutingTable contains the data-plane routing table for the gateway. The same routing table is used for both IPv4 and IPv6 traffic.
func NewRoutingTable ¶
func NewRoutingTable(exporter control.RouteExporter, chains []*control.RoutingChain) *RoutingTable
NewRoutingTable creates a new routing table and initializes it with the given chains.
func (*RoutingTable) AddRoute ¶
func (rt *RoutingTable) AddRoute(index int, session control.PktWriter) error
func (*RoutingTable) DelRoute ¶
func (rt *RoutingTable) DelRoute(index int) error
func (*RoutingTable) DiagnosticsWrite ¶
func (rt *RoutingTable) DiagnosticsWrite(w io.Writer)
func (*RoutingTable) RouteIPv4 ¶
func (rt *RoutingTable) RouteIPv4(pkt layers.IPv4) control.PktWriter
RouteIPv4 returns the session the IPv4 packet should be routed on. It returns after doing a longest prefix match on the destination IP address. Once the longest prefix match is found, the matching traffic class for the prefix with lowest index is found. Finally, the associated Session for the match is returned. If no routing prefix is matched, or no traffic class is matched, routing will return `nil`.
func (*RoutingTable) RouteIPv6 ¶
func (rt *RoutingTable) RouteIPv6(pkt layers.IPv6) control.PktWriter
RouteIPv6 returns the session the IPv6 packet should be routed on. It returns after doing a longest prefix match on the destination IP address. Once the longest prefix match is found, the matching traffic class for the prefix with lowest index is found. Finally, the associated Session for the match is returned. If no routing prefix is matched, or no traffic class is matched, routing will return `nil`.
type Session ¶
type Session struct { SessionID uint8 GatewayAddr net.UDPAddr DataPlaneConn net.PacketConn PathStatsPublisher PathStatsPublisher Metrics SessionMetrics // contains filtered or unexported fields }
func (*Session) Close ¶
func (s *Session) Close()
Close signals that the session should close up its internal Connections. Close returns as soon as forwarding goroutines are signaled to shut down (never blocks).
func (*Session) SetPath ¶
SetPath sets the path for subsequent packets encapsulated by the session. Packets that were written up to this point will still be sent via the old path. There are two reasons for that:
1. New path may have smaller MTU causing the already buffered frame not to fit in.
2. Paths can have different latencies, meaning that switching to new path could cause packets to be delivered out of order. Using new sender with new stream ID causes creation of new reassemby queue on the remote side, thus avoiding the reordering issues.
type SessionMetrics ¶
type SessionMetrics struct { // IPPktsSent is the IP packets count sent. IPPktsSent metrics.Counter // IPPktBytesSent is the IP packet bytes sent. IPPktBytesSent metrics.Counter // FramesSent is the frames count sent. FramesSent metrics.Counter // FrameBytesSent is the frame bytes sent. FrameBytesSent metrics.Counter // SendExternalError is the error count when sending frames to the external network. SendExternalErrors metrics.Counter }
SessionMetrics report traffic and error counters for a session. They must be instantiated with the labels "remote_isd_as" and "policy_id".