Documentation ¶
Overview ¶
Package dataplane defines implementations required to run a gateway dataplane.
Index ¶
- func NewStreamID() uint32
- type AtomicRoutingTable
- type DiagnosticsWriter
- type IPForwarder
- type IPForwarderMetrics
- type IngressMetrics
- type IngressServer
- type PathStatsPublisher
- type ReadConn
- type RoutingTable
- func (rt *RoutingTable) ClearSession(index int) error
- func (rt *RoutingTable) Close() 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
- func (rt *RoutingTable) SetSession(index int, session control.PktWriter) error
- 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) 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) io.Closer
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 }
IPForwarder reads packets from the reader, routes them according to a routing table and dispatches them to a session.
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 // IPPktInvalidPackets counts the number of packet parsing errors. If nil, the metric // is not reported. IPPktsInvalid metrics.Counter // IPPktsFragmented the number of fragmented packet. If nil, the metric is not reported. IPPktsFragmented 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 DeviceManager control.DeviceManager 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.
type PathStatsPublisher ¶
type RoutingTable ¶
type RoutingTable struct {
// 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(chains []*control.RoutingChain) *RoutingTable
NewRoutingTable creates a new routing table and initializes it with the given chains.
func (*RoutingTable) ClearSession ¶
func (rt *RoutingTable) ClearSession(index int) error
func (*RoutingTable) Close ¶
func (rt *RoutingTable) Close() 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`.
func (*RoutingTable) SetSession ¶
func (rt *RoutingTable) SetSession(index int, session control.PktWriter) error
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) SetPaths ¶
SetPaths sets the paths 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".