netstack

package
v0.0.0-...-ff2c174 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: Apache-2.0, MIT Imports: 42 Imported by: 0

Documentation

Overview

Package netstack provides an implementation of the socket.Socket interface that is backed by a tcpip.Endpoint.

It does not depend on any particular endpoint implementation, and thus can be used to expose certain endpoints to the sentry while leaving others out, for example, TCP endpoints and Unix-domain endpoints.

Lock ordering: netstack => mm: ioSequenceReadWriter copies user memory inside tcpip.Endpoint.Write(). Netstack is allowed to (and does) hold locks during this operation.

Index

Constants

View Source
const DefaultTTL = 64

DefaultTTL is linux's default TTL. All network protocols in all stacks used with this package must have this value set as their default TTL.

Variables

View Source
var Metrics = tcpip.Stats{
	UnknownProtocolRcvdPackets: mustCreateMetric("/netstack/unknown_protocol_received_packets", "Number of packets received by netstack that were for an unknown or unsupported protocol."),
	MalformedRcvdPackets:       mustCreateMetric("/netstack/malformed_received_packets", "Number of packets received by netstack that were deemed malformed."),
	DroppedPackets:             mustCreateMetric("/netstack/dropped_packets", "Number of packets dropped by netstack due to full queues."),
	ICMP: tcpip.ICMPStats{
		V4: tcpip.ICMPv4Stats{
			PacketsSent: tcpip.ICMPv4SentPacketStats{
				ICMPv4PacketStats: tcpip.ICMPv4PacketStats{
					EchoRequest:    mustCreateMetric("/netstack/icmp/v4/packets_sent/echo_request", "Number of ICMPv4 echo request packets sent by netstack."),
					EchoReply:      mustCreateMetric("/netstack/icmp/v4/packets_sent/echo_reply", "Number of ICMPv4 echo reply packets sent by netstack."),
					DstUnreachable: mustCreateMetric("/netstack/icmp/v4/packets_sent/dst_unreachable", "Number of ICMPv4 destination unreachable packets sent by netstack."),
					SrcQuench:      mustCreateMetric("/netstack/icmp/v4/packets_sent/src_quench", "Number of ICMPv4 source quench packets sent by netstack."),
					Redirect:       mustCreateMetric("/netstack/icmp/v4/packets_sent/redirect", "Number of ICMPv4 redirect packets sent by netstack."),
					TimeExceeded:   mustCreateMetric("/netstack/icmp/v4/packets_sent/time_exceeded", "Number of ICMPv4 time exceeded packets sent by netstack."),
					ParamProblem:   mustCreateMetric("/netstack/icmp/v4/packets_sent/param_problem", "Number of ICMPv4 parameter problem packets sent by netstack."),
					Timestamp:      mustCreateMetric("/netstack/icmp/v4/packets_sent/timestamp", "Number of ICMPv4 timestamp packets sent by netstack."),
					TimestampReply: mustCreateMetric("/netstack/icmp/v4/packets_sent/timestamp_reply", "Number of ICMPv4 timestamp reply packets sent by netstack."),
					InfoRequest:    mustCreateMetric("/netstack/icmp/v4/packets_sent/info_request", "Number of ICMPv4 information request packets sent by netstack."),
					InfoReply:      mustCreateMetric("/netstack/icmp/v4/packets_sent/info_reply", "Number of ICMPv4 information reply packets sent by netstack."),
				},
				Dropped:     mustCreateMetric("/netstack/icmp/v4/packets_sent/dropped", "Number of ICMPv4 packets dropped by netstack due to link layer errors."),
				RateLimited: mustCreateMetric("/netstack/icmp/v4/packets_sent/rate_limited", "Number of ICMPv4 packets dropped by netstack due to rate limit being exceeded."),
			},
			PacketsReceived: tcpip.ICMPv4ReceivedPacketStats{
				ICMPv4PacketStats: tcpip.ICMPv4PacketStats{
					EchoRequest:    mustCreateMetric("/netstack/icmp/v4/packets_received/echo_request", "Number of ICMPv4 echo request packets received by netstack."),
					EchoReply:      mustCreateMetric("/netstack/icmp/v4/packets_received/echo_reply", "Number of ICMPv4 echo reply packets received by netstack."),
					DstUnreachable: mustCreateMetric("/netstack/icmp/v4/packets_received/dst_unreachable", "Number of ICMPv4 destination unreachable packets received by netstack."),
					SrcQuench:      mustCreateMetric("/netstack/icmp/v4/packets_received/src_quench", "Number of ICMPv4 source quench packets received by netstack."),
					Redirect:       mustCreateMetric("/netstack/icmp/v4/packets_received/redirect", "Number of ICMPv4 redirect packets received by netstack."),
					TimeExceeded:   mustCreateMetric("/netstack/icmp/v4/packets_received/time_exceeded", "Number of ICMPv4 time exceeded packets received by netstack."),
					ParamProblem:   mustCreateMetric("/netstack/icmp/v4/packets_received/param_problem", "Number of ICMPv4 parameter problem packets received by netstack."),
					Timestamp:      mustCreateMetric("/netstack/icmp/v4/packets_received/timestamp", "Number of ICMPv4 timestamp packets received by netstack."),
					TimestampReply: mustCreateMetric("/netstack/icmp/v4/packets_received/timestamp_reply", "Number of ICMPv4 timestamp reply packets received by netstack."),
					InfoRequest:    mustCreateMetric("/netstack/icmp/v4/packets_received/info_request", "Number of ICMPv4 information request packets received by netstack."),
					InfoReply:      mustCreateMetric("/netstack/icmp/v4/packets_received/info_reply", "Number of ICMPv4 information reply packets received by netstack."),
				},
				Invalid: mustCreateMetric("/netstack/icmp/v4/packets_received/invalid", "Number of ICMPv4 packets received that the transport layer could not parse."),
			},
		},
		V6: tcpip.ICMPv6Stats{
			PacketsSent: tcpip.ICMPv6SentPacketStats{
				ICMPv6PacketStats: tcpip.ICMPv6PacketStats{
					EchoRequest:             mustCreateMetric("/netstack/icmp/v6/packets_sent/echo_request", "Number of ICMPv6 echo request packets sent by netstack."),
					EchoReply:               mustCreateMetric("/netstack/icmp/v6/packets_sent/echo_reply", "Number of ICMPv6 echo reply packets sent by netstack."),
					DstUnreachable:          mustCreateMetric("/netstack/icmp/v6/packets_sent/dst_unreachable", "Number of ICMPv6 destination unreachable packets sent by netstack."),
					PacketTooBig:            mustCreateMetric("/netstack/icmp/v6/packets_sent/packet_too_big", "Number of ICMPv6 packet too big packets sent by netstack."),
					TimeExceeded:            mustCreateMetric("/netstack/icmp/v6/packets_sent/time_exceeded", "Number of ICMPv6 time exceeded packets sent by netstack."),
					ParamProblem:            mustCreateMetric("/netstack/icmp/v6/packets_sent/param_problem", "Number of ICMPv6 parameter problem packets sent by netstack."),
					RouterSolicit:           mustCreateMetric("/netstack/icmp/v6/packets_sent/router_solicit", "Number of ICMPv6 router solicit packets sent by netstack."),
					RouterAdvert:            mustCreateMetric("/netstack/icmp/v6/packets_sent/router_advert", "Number of ICMPv6 router advert packets sent by netstack."),
					NeighborSolicit:         mustCreateMetric("/netstack/icmp/v6/packets_sent/neighbor_solicit", "Number of ICMPv6 neighbor solicit packets sent by netstack."),
					NeighborAdvert:          mustCreateMetric("/netstack/icmp/v6/packets_sent/neighbor_advert", "Number of ICMPv6 neighbor advert packets sent by netstack."),
					RedirectMsg:             mustCreateMetric("/netstack/icmp/v6/packets_sent/redirect_msg", "Number of ICMPv6 redirect message packets sent by netstack."),
					MulticastListenerQuery:  mustCreateMetric("/netstack/icmp/v6/packets_sent/multicast_listener_query", "Number of ICMPv6 multicast listener query packets sent by netstack."),
					MulticastListenerReport: mustCreateMetric("/netstack/icmp/v6/packets_sent/multicast_listener_report", "Number of ICMPv6 multicast listener report packets sent by netstack."),
					MulticastListenerDone:   mustCreateMetric("/netstack/icmp/v6/packets_sent/multicast_listener_done", "Number of ICMPv6 multicast listener done packets sent by netstack."),
				},
				Dropped:     mustCreateMetric("/netstack/icmp/v6/packets_sent/dropped", "Number of ICMPv6 packets dropped by netstack due to link layer errors."),
				RateLimited: mustCreateMetric("/netstack/icmp/v6/packets_sent/rate_limited", "Number of ICMPv6 packets dropped by netstack due to rate limit being exceeded."),
			},
			PacketsReceived: tcpip.ICMPv6ReceivedPacketStats{
				ICMPv6PacketStats: tcpip.ICMPv6PacketStats{
					EchoRequest:             mustCreateMetric("/netstack/icmp/v6/packets_received/echo_request", "Number of ICMPv6 echo request packets received by netstack."),
					EchoReply:               mustCreateMetric("/netstack/icmp/v6/packets_received/echo_reply", "Number of ICMPv6 echo reply packets received by netstack."),
					DstUnreachable:          mustCreateMetric("/netstack/icmp/v6/packets_received/dst_unreachable", "Number of ICMPv6 destination unreachable packets received by netstack."),
					PacketTooBig:            mustCreateMetric("/netstack/icmp/v6/packets_received/packet_too_big", "Number of ICMPv6 packet too big packets received by netstack."),
					TimeExceeded:            mustCreateMetric("/netstack/icmp/v6/packets_received/time_exceeded", "Number of ICMPv6 time exceeded packets received by netstack."),
					ParamProblem:            mustCreateMetric("/netstack/icmp/v6/packets_received/param_problem", "Number of ICMPv6 parameter problem packets received by netstack."),
					RouterSolicit:           mustCreateMetric("/netstack/icmp/v6/packets_received/router_solicit", "Number of ICMPv6 router solicit packets received by netstack."),
					RouterAdvert:            mustCreateMetric("/netstack/icmp/v6/packets_received/router_advert", "Number of ICMPv6 router advert packets received by netstack."),
					NeighborSolicit:         mustCreateMetric("/netstack/icmp/v6/packets_received/neighbor_solicit", "Number of ICMPv6 neighbor solicit packets received by netstack."),
					NeighborAdvert:          mustCreateMetric("/netstack/icmp/v6/packets_received/neighbor_advert", "Number of ICMPv6 neighbor advert packets received by netstack."),
					RedirectMsg:             mustCreateMetric("/netstack/icmp/v6/packets_received/redirect_msg", "Number of ICMPv6 redirect message packets received by netstack."),
					MulticastListenerQuery:  mustCreateMetric("/netstack/icmp/v6/packets_received/multicast_listener_query", "Number of ICMPv6 multicast listener query packets received by netstack."),
					MulticastListenerReport: mustCreateMetric("/netstack/icmp/v6/packets_received/multicast_listener_report", "Number of ICMPv6 multicast listener report packets sent by netstack."),
					MulticastListenerDone:   mustCreateMetric("/netstack/icmp/v6/packets_received/multicast_listener_done", "Number of ICMPv6 multicast listener done packets sent by netstack."),
				},
				Unrecognized:                   mustCreateMetric("/netstack/icmp/v6/packets_received/unrecognized", "Number of ICMPv6 packets received that the transport layer does not know how to parse."),
				Invalid:                        mustCreateMetric("/netstack/icmp/v6/packets_received/invalid", "Number of ICMPv6 packets received that the transport layer could not parse."),
				RouterOnlyPacketsDroppedByHost: mustCreateMetric("/netstack/icmp/v6/packets_received/router_only_packets_dropped_by_host", "Number of ICMPv6 packets dropped due to being router-specific packets."),
			},
		},
	},
	IGMP: tcpip.IGMPStats{
		PacketsSent: tcpip.IGMPSentPacketStats{
			IGMPPacketStats: tcpip.IGMPPacketStats{
				MembershipQuery:    mustCreateMetric("/netstack/igmp/packets_sent/membership_query", "Number of IGMP Membership Query messages sent by netstack."),
				V1MembershipReport: mustCreateMetric("/netstack/igmp/packets_sent/v1_membership_report", "Number of IGMPv1 Membership Report messages sent by netstack."),
				V2MembershipReport: mustCreateMetric("/netstack/igmp/packets_sent/v2_membership_report", "Number of IGMPv2 Membership Report messages sent by netstack."),
				LeaveGroup:         mustCreateMetric("/netstack/igmp/packets_sent/leave_group", "Number of IGMP Leave Group messages sent by netstack."),
			},
			Dropped: mustCreateMetric("/netstack/igmp/packets_sent/dropped", "Number of IGMP packets dropped by netstack due to link layer errors."),
		},
		PacketsReceived: tcpip.IGMPReceivedPacketStats{
			IGMPPacketStats: tcpip.IGMPPacketStats{
				MembershipQuery:    mustCreateMetric("/netstack/igmp/packets_received/membership_query", "Number of IGMP Membership Query messages received by netstack."),
				V1MembershipReport: mustCreateMetric("/netstack/igmp/packets_received/v1_membership_report", "Number of IGMPv1 Membership Report messages received by netstack."),
				V2MembershipReport: mustCreateMetric("/netstack/igmp/packets_received/v2_membership_report", "Number of IGMPv2 Membership Report messages received by netstack."),
				LeaveGroup:         mustCreateMetric("/netstack/igmp/packets_received/leave_group", "Number of IGMP Leave Group messages received by netstack."),
			},
			Invalid:        mustCreateMetric("/netstack/igmp/packets_received/invalid", "Number of IGMP packets received by netstack that could not be parsed."),
			ChecksumErrors: mustCreateMetric("/netstack/igmp/packets_received/checksum_errors", "Number of received IGMP packets with bad checksums."),
			Unrecognized:   mustCreateMetric("/netstack/igmp/packets_received/unrecognized", "Number of unrecognized IGMP packets received by netstack."),
		},
	},
	IP: tcpip.IPStats{
		PacketsReceived:                     mustCreateMetric("/netstack/ip/packets_received", "Number of IP packets received from the link layer in nic.DeliverNetworkPacket."),
		DisabledPacketsReceived:             mustCreateMetric("/netstack/ip/disabled_packets_received", "Number of IP packets received from the link layer when the IP layer is disabled."),
		InvalidDestinationAddressesReceived: mustCreateMetric("/netstack/ip/invalid_addresses_received", "Number of IP packets received with an unknown or invalid destination address."),
		InvalidSourceAddressesReceived:      mustCreateMetric("/netstack/ip/invalid_source_addresses_received", "Number of IP packets received with an unknown or invalid source address."),
		PacketsDelivered:                    mustCreateMetric("/netstack/ip/packets_delivered", "Number of incoming IP packets that are successfully delivered to the transport layer via HandlePacket."),
		PacketsSent:                         mustCreateMetric("/netstack/ip/packets_sent", "Number of IP packets sent via WritePacket."),
		OutgoingPacketErrors:                mustCreateMetric("/netstack/ip/outgoing_packet_errors", "Number of IP packets which failed to write to a link-layer endpoint."),
		MalformedPacketsReceived:            mustCreateMetric("/netstack/ip/malformed_packets_received", "Number of IP packets which failed IP header validation checks."),
		MalformedFragmentsReceived:          mustCreateMetric("/netstack/ip/malformed_fragments_received", "Number of IP fragments which failed IP fragment validation checks."),
		IPTablesPreroutingDropped:           mustCreateMetric("/netstack/ip/iptables/prerouting_dropped", "Number of IP packets dropped in the Prerouting chain."),
		IPTablesInputDropped:                mustCreateMetric("/netstack/ip/iptables/input_dropped", "Number of IP packets dropped in the Input chain."),
		IPTablesOutputDropped:               mustCreateMetric("/netstack/ip/iptables/output_dropped", "Number of IP packets dropped in the Output chain."),
		OptionTimestampReceived:             mustCreateMetric("/netstack/ip/options/timestamp_received", "Number of timestamp options found in received IP packets."),
		OptionRecordRouteReceived:           mustCreateMetric("/netstack/ip/options/record_route_received", "Number of record route options found in received IP packets."),
		OptionRouterAlertReceived:           mustCreateMetric("/netstack/ip/options/router_alert_received", "Number of router alert options found in received IP packets."),
		OptionUnknownReceived:               mustCreateMetric("/netstack/ip/options/unknown_received", "Number of unknown options found in received IP packets."),
		Forwarding: tcpip.IPForwardingStats{
			Unrouteable:          mustCreateMetric("/netstack/ip/forwarding/unrouteable", "Number of IP packets received which couldn't be routed and thus were not forwarded."),
			ExhaustedTTL:         mustCreateMetric("/netstack/ip/forwarding/exhausted_ttl", "Number of IP packets received which could not be forwarded due to an exhausted TTL."),
			LinkLocalSource:      mustCreateMetric("/netstack/ip/forwarding/link_local_source_address", "Number of IP packets received which could not be forwarded due to a link-local source address."),
			LinkLocalDestination: mustCreateMetric("/netstack/ip/forwarding/link_local_destination_address", "Number of IP packets received which could not be forwarded due to a link-local destination address."),
			Errors:               mustCreateMetric("/netstack/ip/forwarding/errors", "Number of IP packets which couldn't be forwarded."),
		},
	},
	ARP: tcpip.ARPStats{
		PacketsReceived:                                 mustCreateMetric("/netstack/arp/packets_received", "Number of ARP packets received from the link layer."),
		DisabledPacketsReceived:                         mustCreateMetric("/netstack/arp/disabled_packets_received", "Number of ARP packets received from the link layer when the ARP layer is disabled."),
		MalformedPacketsReceived:                        mustCreateMetric("/netstack/arp/malformed_packets_received", "Number of ARP packets which failed ARP header validation checks."),
		RequestsReceived:                                mustCreateMetric("/netstack/arp/requests_received", "Number of ARP requests received."),
		RequestsReceivedUnknownTargetAddress:            mustCreateMetric("/netstack/arp/requests_received_unknown_addr", "Number of ARP requests received with an unknown target address."),
		OutgoingRequestInterfaceHasNoLocalAddressErrors: mustCreateMetric("/netstack/arp/outgoing_requests_iface_has_no_addr", "Number of failed attempts to send an ARP request with an interface that has no network address."),
		OutgoingRequestBadLocalAddressErrors:            mustCreateMetric("/netstack/arp/outgoing_requests_invalid_local_addr", "Number of failed attempts to send an ARP request with a provided local address that is invalid."),
		OutgoingRequestsDropped:                         mustCreateMetric("/netstack/arp/outgoing_requests_dropped", "Number of ARP requests which failed to write to a link-layer endpoint."),
		OutgoingRequestsSent:                            mustCreateMetric("/netstack/arp/outgoing_requests_sent", "Number of ARP requests sent."),
		RepliesReceived:                                 mustCreateMetric("/netstack/arp/replies_received", "Number of ARP replies received."),
		OutgoingRepliesDropped:                          mustCreateMetric("/netstack/arp/outgoing_replies_dropped", "Number of ARP replies which failed to write to a link-layer endpoint."),
		OutgoingRepliesSent:                             mustCreateMetric("/netstack/arp/outgoing_replies_sent", "Number of ARP replies sent."),
	},
	TCP: tcpip.TCPStats{
		ActiveConnectionOpenings:           mustCreateMetric("/netstack/tcp/active_connection_openings", "Number of connections opened successfully via Connect."),
		PassiveConnectionOpenings:          mustCreateMetric("/netstack/tcp/passive_connection_openings", "Number of connections opened successfully via Listen."),
		CurrentEstablished:                 mustCreateGauge("/netstack/tcp/current_established", "Number of connections in ESTABLISHED state now."),
		CurrentConnected:                   mustCreateGauge("/netstack/tcp/current_open", "Number of connections that are in connected state."),
		EstablishedResets:                  mustCreateMetric("/netstack/tcp/established_resets", "Number of times TCP connections have made a direct transition to the CLOSED state from either the ESTABLISHED state or the CLOSE-WAIT state"),
		EstablishedClosed:                  mustCreateMetric("/netstack/tcp/established_closed", "Number of times established TCP connections made a transition to CLOSED state."),
		EstablishedTimedout:                mustCreateMetric("/netstack/tcp/established_timedout", "Number of times  an established connection was reset because of keep-alive time out."),
		ListenOverflowSynDrop:              mustCreateMetric("/netstack/tcp/listen_overflow_syn_drop", "Number of times the listen queue overflowed and a SYN was dropped."),
		ListenOverflowAckDrop:              mustCreateMetric("/netstack/tcp/listen_overflow_ack_drop", "Number of times the listen queue overflowed and the final ACK in the handshake was dropped."),
		ListenOverflowSynCookieSent:        mustCreateMetric("/netstack/tcp/listen_overflow_syn_cookie_sent", "Number of times a SYN cookie was sent."),
		ListenOverflowSynCookieRcvd:        mustCreateMetric("/netstack/tcp/listen_overflow_syn_cookie_rcvd", "Number of times a SYN cookie was received."),
		ListenOverflowInvalidSynCookieRcvd: mustCreateMetric("/netstack/tcp/listen_overflow_invalid_syn_cookie_rcvd", "Number of times an invalid SYN cookie was received."),
		FailedConnectionAttempts:           mustCreateMetric("/netstack/tcp/failed_connection_attempts", "Number of calls to Connect or Listen (active and passive openings, respectively) that end in an error."),
		ValidSegmentsReceived:              mustCreateMetric("/netstack/tcp/valid_segments_received", "Number of TCP segments received that the transport layer successfully parsed."),
		InvalidSegmentsReceived:            mustCreateMetric("/netstack/tcp/invalid_segments_received", "Number of TCP segments received that the transport layer could not parse."),
		SegmentsSent:                       mustCreateMetric("/netstack/tcp/segments_sent", "Number of TCP segments sent."),
		SegmentSendErrors:                  mustCreateMetric("/netstack/tcp/segment_send_errors", "Number of TCP segments failed to be sent."),
		ResetsSent:                         mustCreateMetric("/netstack/tcp/resets_sent", "Number of TCP resets sent."),
		ResetsReceived:                     mustCreateMetric("/netstack/tcp/resets_received", "Number of TCP resets received."),
		Retransmits:                        mustCreateMetric("/netstack/tcp/retransmits", "Number of TCP segments retransmitted."),
		FastRecovery:                       mustCreateMetric("/netstack/tcp/fast_recovery", "Number of times fast recovery was used to recover from packet loss."),
		SACKRecovery:                       mustCreateMetric("/netstack/tcp/sack_recovery", "Number of times SACK recovery was used to recover from packet loss."),
		TLPRecovery:                        mustCreateMetric("/netstack/tcp/tlp_recovery", "Number of times tail loss probe triggers recovery from tail loss."),
		SlowStartRetransmits:               mustCreateMetric("/netstack/tcp/slow_start_retransmits", "Number of segments retransmitted in slow start mode."),
		FastRetransmit:                     mustCreateMetric("/netstack/tcp/fast_retransmit", "Number of TCP segments which were fast retransmitted."),
		Timeouts:                           mustCreateMetric("/netstack/tcp/timeouts", "Number of times RTO expired."),
		ChecksumErrors:                     mustCreateMetric("/netstack/tcp/checksum_errors", "Number of segments dropped due to bad checksums."),
		FailedPortReservations:             mustCreateMetric("/netstack/tcp/failed_port_reservations", "Number of time TCP failed to reserve a port."),
	},
	UDP: tcpip.UDPStats{
		PacketsReceived:          mustCreateMetric("/netstack/udp/packets_received", "Number of UDP datagrams received via HandlePacket."),
		UnknownPortErrors:        mustCreateMetric("/netstack/udp/unknown_port_errors", "Number of incoming UDP datagrams dropped because they did not have a known destination port."),
		ReceiveBufferErrors:      mustCreateMetric("/netstack/udp/receive_buffer_errors", "Number of incoming UDP datagrams dropped due to the receiving buffer being in an invalid state."),
		MalformedPacketsReceived: mustCreateMetric("/netstack/udp/malformed_packets_received", "Number of incoming UDP datagrams dropped due to the UDP header being in a malformed state."),
		PacketsSent:              mustCreateMetric("/netstack/udp/packets_sent", "Number of UDP datagrams sent."),
		PacketSendErrors:         mustCreateMetric("/netstack/udp/packet_send_errors", "Number of UDP datagrams failed to be sent."),
		ChecksumErrors:           mustCreateMetric("/netstack/udp/checksum_errors", "Number of UDP datagrams dropped due to bad checksums."),
	},
}

Metrics contains metrics exported by netstack.

Functions

func ConvertShutdown

func ConvertShutdown(how int) (tcpip.ShutdownFlags, *syserr.Error)

ConvertShutdown converts Linux shutdown flags into tcpip shutdown flags.

func GetSockOpt

func GetSockOpt(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, family int, skType linux.SockType, level, name int, outPtr hostarch.Addr, outLen int) (marshal.Marshallable, *syserr.Error)

GetSockOpt can be used to implement the linux syscall getsockopt(2) for sockets backed by a commonEndpoint.

func Ioctl

func Ioctl(ctx context.Context, ep commonEndpoint, io usermem.IO, args arch.SyscallArguments) (uintptr, error)

Ioctl performs a socket ioctl.

func LinuxToTUNFlags

func LinuxToTUNFlags(flags uint16) (tun.Flags, error)

LinuxToTUNFlags converts Linux TUN flags to a tun.Flags.

func New

func New(t *kernel.Task, family int, skType linux.SockType, protocol int, queue *waiter.Queue, endpoint tcpip.Endpoint) (*fs.File, *syserr.Error)

New creates a new endpoint socket.

func NewVFS2

func NewVFS2(t *kernel.Task, family int, skType linux.SockType, protocol int, queue *waiter.Queue, endpoint tcpip.Endpoint) (*vfs.FileDescription, *syserr.Error)

NewVFS2 creates a new endpoint socket.

func SetSockOpt

func SetSockOpt(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, level int, name int, optVal []byte) *syserr.Error

SetSockOpt can be used to implement the linux syscall setsockopt(2) for sockets backed by a commonEndpoint.

func TUNFlagsToLinux

func TUNFlagsToLinux(flags tun.Flags) uint16

TUNFlagsToLinux converts a tun.Flags to Linux TUN flags.

Types

type SocketOperations

type SocketOperations struct {
	fsutil.FilePipeSeek             `state:"nosave"`
	fsutil.FileNotDirReaddir        `state:"nosave"`
	fsutil.FileNoopFlush            `state:"nosave"`
	fsutil.FileNoFsync              `state:"nosave"`
	fsutil.FileNoMMap               `state:"nosave"`
	fsutil.FileUseInodeUnstableAttr `state:"nosave"`
	// contains filtered or unexported fields
}

SocketOperations encapsulates all the state needed to represent a network stack endpoint in the kernel context.

+stateify savable

func (*SocketOperations) Accept

func (s *SocketOperations) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (int32, linux.SockAddr, uint32, *syserr.Error)

Accept implements the linux syscall accept(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Bind

func (s *SocketOperations) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error

Bind implements the linux syscall bind(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Connect

func (s *SocketOperations) Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error

Connect implements the linux syscall connect(2) for sockets backed by tpcip.Endpoint.

func (*SocketOperations) GetPeerName

func (s *SocketOperations) GetPeerName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

GetPeerName implements the linux syscall getpeername(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) GetSockName

func (s *SocketOperations) GetSockName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

GetSockName implements the linux syscall getsockname(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) GetSockOpt

func (s *SocketOperations) GetSockOpt(t *kernel.Task, level, name int, outPtr hostarch.Addr, outLen int) (marshal.Marshallable, *syserr.Error)

GetSockOpt implements the linux syscall getsockopt(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Ioctl

Ioctl implements fs.FileOperations.Ioctl.

func (*SocketOperations) Listen

func (s *SocketOperations) Listen(t *kernel.Task, backlog int) *syserr.Error

Listen implements the linux syscall listen(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Read

func (s *SocketOperations) Read(ctx context.Context, _ *fs.File, dst usermem.IOSequence, _ int64) (int64, error)

Read implements fs.FileOperations.Read.

func (*SocketOperations) ReadFrom

func (s *SocketOperations) ReadFrom(ctx context.Context, _ *fs.File, r io.Reader, count int64) (int64, error)

ReadFrom implements fs.FileOperations.ReadFrom.

func (*SocketOperations) Readiness

func (s *SocketOperations) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness returns a mask of ready events for socket s.

func (*SocketOperations) RecvMsg

func (s *SocketOperations) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlDataLen uint64) (n int, msgFlags int, senderAddr linux.SockAddr, senderAddrLen uint32, controlMessages socket.ControlMessages, err *syserr.Error)

RecvMsg implements the linux syscall recvmsg(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Release

func (s *SocketOperations) Release(ctx context.Context)

Release implements fs.FileOperations.Release.

func (*SocketOperations) SendMsg

func (s *SocketOperations) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, haveDeadline bool, deadline ktime.Time, controlMessages socket.ControlMessages) (int, *syserr.Error)

SendMsg implements the linux syscall sendmsg(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) SetSockOpt

func (s *SocketOperations) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error

SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) Shutdown

func (s *SocketOperations) Shutdown(t *kernel.Task, how int) *syserr.Error

Shutdown implements the linux syscall shutdown(2) for sockets backed by tcpip.Endpoint.

func (*SocketOperations) State

func (s *SocketOperations) State() uint32

State implements socket.Socket.State. State translates the internal state returned by netstack to values defined by Linux.

func (*SocketOperations) StateFields

func (s *SocketOperations) StateFields() []string

func (*SocketOperations) StateLoad

func (s *SocketOperations) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*SocketOperations) StateSave

func (s *SocketOperations) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*SocketOperations) StateTypeName

func (s *SocketOperations) StateTypeName() string

func (*SocketOperations) Type

func (s *SocketOperations) Type() (family int, skType linux.SockType, protocol int)

Type implements socket.Socket.Type.

func (*SocketOperations) Write

func (s *SocketOperations) Write(ctx context.Context, _ *fs.File, src usermem.IOSequence, _ int64) (int64, error)

Write implements fs.FileOperations.Write.

func (*SocketOperations) WriteTo

func (s *SocketOperations) WriteTo(ctx context.Context, _ *fs.File, dst io.Writer, count int64, dup bool) (int64, error)

WriteTo implements fs.FileOperations.WriteTo.

type SocketVFS2

type SocketVFS2 struct {
	vfs.FileDescriptionDefaultImpl
	vfs.DentryMetadataFileDescriptionImpl
	vfs.LockFD
	// contains filtered or unexported fields
}

SocketVFS2 encapsulates all the state needed to represent a network stack endpoint in the kernel context.

+stateify savable

func (*SocketVFS2) Accept

func (s *SocketVFS2) Accept(t *kernel.Task, peerRequested bool, flags int, blocking bool) (int32, linux.SockAddr, uint32, *syserr.Error)

Accept implements the linux syscall accept(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) Bind

func (s *SocketVFS2) Bind(t *kernel.Task, sockaddr []byte) *syserr.Error

Bind implements the linux syscall bind(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) Connect

func (s *SocketVFS2) Connect(t *kernel.Task, sockaddr []byte, blocking bool) *syserr.Error

Connect implements the linux syscall connect(2) for sockets backed by tpcip.Endpoint.

func (*SocketVFS2) EventRegister

func (s *SocketVFS2) EventRegister(e *waiter.Entry, mask waiter.EventMask)

EventRegister implements waiter.Waitable.EventRegister.

func (*SocketVFS2) EventUnregister

func (s *SocketVFS2) EventUnregister(e *waiter.Entry)

EventUnregister implements waiter.Waitable.EventUnregister.

func (*SocketVFS2) GetPeerName

func (s *SocketVFS2) GetPeerName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

GetPeerName implements the linux syscall getpeername(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) GetSockName

func (s *SocketVFS2) GetSockName(t *kernel.Task) (linux.SockAddr, uint32, *syserr.Error)

GetSockName implements the linux syscall getsockname(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) GetSockOpt

func (s *SocketVFS2) GetSockOpt(t *kernel.Task, level, name int, outPtr hostarch.Addr, outLen int) (marshal.Marshallable, *syserr.Error)

GetSockOpt implements the linux syscall getsockopt(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) Ioctl

func (s *SocketVFS2) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArguments) (uintptr, error)

Ioctl implements vfs.FileDescriptionImpl.

func (*SocketVFS2) Listen

func (s *SocketVFS2) Listen(t *kernel.Task, backlog int) *syserr.Error

Listen implements the linux syscall listen(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) Read

func (s *SocketVFS2) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)

Read implements vfs.FileDescriptionImpl.

func (*SocketVFS2) Readiness

func (s *SocketVFS2) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness implements waiter.Waitable.Readiness.

func (*SocketVFS2) RecvMsg

func (s *SocketVFS2) RecvMsg(t *kernel.Task, dst usermem.IOSequence, flags int, haveDeadline bool, deadline ktime.Time, senderRequested bool, controlDataLen uint64) (n int, msgFlags int, senderAddr linux.SockAddr, senderAddrLen uint32, controlMessages socket.ControlMessages, err *syserr.Error)

RecvMsg implements the linux syscall recvmsg(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) Release

func (s *SocketVFS2) Release(ctx context.Context)

Release implements vfs.FileDescriptionImpl.Release.

func (*SocketVFS2) SendMsg

func (s *SocketVFS2) SendMsg(t *kernel.Task, src usermem.IOSequence, to []byte, flags int, haveDeadline bool, deadline ktime.Time, controlMessages socket.ControlMessages) (int, *syserr.Error)

SendMsg implements the linux syscall sendmsg(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) SetSockOpt

func (s *SocketVFS2) SetSockOpt(t *kernel.Task, level int, name int, optVal []byte) *syserr.Error

SetSockOpt implements the linux syscall setsockopt(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) Shutdown

func (s *SocketVFS2) Shutdown(t *kernel.Task, how int) *syserr.Error

Shutdown implements the linux syscall shutdown(2) for sockets backed by tcpip.Endpoint.

func (*SocketVFS2) State

func (s *SocketVFS2) State() uint32

State implements socket.Socket.State. State translates the internal state returned by netstack to values defined by Linux.

func (*SocketVFS2) StateFields

func (s *SocketVFS2) StateFields() []string

func (*SocketVFS2) StateLoad

func (s *SocketVFS2) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*SocketVFS2) StateSave

func (s *SocketVFS2) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*SocketVFS2) StateTypeName

func (s *SocketVFS2) StateTypeName() string

func (*SocketVFS2) Type

func (s *SocketVFS2) Type() (family int, skType linux.SockType, protocol int)

Type implements socket.Socket.Type.

func (*SocketVFS2) Write

func (s *SocketVFS2) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)

Write implements vfs.FileDescriptionImpl.

type Stack

type Stack struct {
	Stack *stack.Stack `state:"manual"`
}

Stack implements inet.Stack for netstack/tcpip/stack.Stack.

+stateify savable

func (*Stack) AddInterfaceAddr

func (s *Stack) AddInterfaceAddr(idx int32, addr inet.InterfaceAddr) error

AddInterfaceAddr implements inet.Stack.AddInterfaceAddr.

func (*Stack) CleanupEndpoints

func (s *Stack) CleanupEndpoints() []stack.TransportEndpoint

CleanupEndpoints implements inet.Stack.CleanupEndpoints.

func (*Stack) Forwarding

func (s *Stack) Forwarding(protocol tcpip.NetworkProtocolNumber) bool

Forwarding implements inet.Stack.Forwarding.

func (*Stack) IPTables

func (s *Stack) IPTables() (*stack.IPTables, error)

IPTables returns the stack's iptables.

func (*Stack) InterfaceAddrs

func (s *Stack) InterfaceAddrs() map[int32][]inet.InterfaceAddr

InterfaceAddrs implements inet.Stack.InterfaceAddrs.

func (*Stack) Interfaces

func (s *Stack) Interfaces() map[int32]inet.Interface

Interfaces implements inet.Stack.Interfaces.

func (*Stack) PortRange

func (s *Stack) PortRange() (uint16, uint16)

PortRange implements inet.Stack.PortRange.

func (*Stack) RegisteredEndpoints

func (s *Stack) RegisteredEndpoints() []stack.TransportEndpoint

RegisteredEndpoints implements inet.Stack.RegisteredEndpoints.

func (*Stack) RemoveInterfaceAddr

func (s *Stack) RemoveInterfaceAddr(idx int32, addr inet.InterfaceAddr) error

RemoveInterfaceAddr implements inet.Stack.RemoveInterfaceAddr.

func (*Stack) RestoreCleanupEndpoints

func (s *Stack) RestoreCleanupEndpoints(es []stack.TransportEndpoint)

RestoreCleanupEndpoints implements inet.Stack.RestoreCleanupEndpoints.

func (*Stack) Resume

func (s *Stack) Resume()

Resume implements inet.Stack.Resume.

func (*Stack) RouteTable

func (s *Stack) RouteTable() []inet.Route

RouteTable implements inet.Stack.RouteTable.

func (*Stack) SetForwarding

func (s *Stack) SetForwarding(protocol tcpip.NetworkProtocolNumber, enable bool) error

SetForwarding implements inet.Stack.SetForwarding.

func (*Stack) SetPortRange

func (s *Stack) SetPortRange(start uint16, end uint16) error

SetPortRange implements inet.Stack.SetPortRange.

func (*Stack) SetTCPReceiveBufferSize

func (s *Stack) SetTCPReceiveBufferSize(size inet.TCPBufferSize) error

SetTCPReceiveBufferSize implements inet.Stack.SetTCPReceiveBufferSize.

func (*Stack) SetTCPRecovery

func (s *Stack) SetTCPRecovery(recovery inet.TCPLossRecovery) error

SetTCPRecovery implements inet.Stack.SetTCPRecovery.

func (*Stack) SetTCPSACKEnabled

func (s *Stack) SetTCPSACKEnabled(enabled bool) error

SetTCPSACKEnabled implements inet.Stack.SetTCPSACKEnabled.

func (*Stack) SetTCPSendBufferSize

func (s *Stack) SetTCPSendBufferSize(size inet.TCPBufferSize) error

SetTCPSendBufferSize implements inet.Stack.SetTCPSendBufferSize.

func (*Stack) StateFields

func (s *Stack) StateFields() []string

func (*Stack) StateLoad

func (s *Stack) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*Stack) StateSave

func (s *Stack) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*Stack) StateTypeName

func (s *Stack) StateTypeName() string

func (*Stack) Statistics

func (s *Stack) Statistics(stat interface{}, arg string) error

Statistics implements inet.Stack.Statistics.

func (*Stack) SupportsIPv6

func (s *Stack) SupportsIPv6() bool

SupportsIPv6 implements Stack.SupportsIPv6.

func (*Stack) TCPReceiveBufferSize

func (s *Stack) TCPReceiveBufferSize() (inet.TCPBufferSize, error)

TCPReceiveBufferSize implements inet.Stack.TCPReceiveBufferSize.

func (*Stack) TCPRecovery

func (s *Stack) TCPRecovery() (inet.TCPLossRecovery, error)

TCPRecovery implements inet.Stack.TCPRecovery.

func (*Stack) TCPSACKEnabled

func (s *Stack) TCPSACKEnabled() (bool, error)

TCPSACKEnabled implements inet.Stack.TCPSACKEnabled.

func (*Stack) TCPSendBufferSize

func (s *Stack) TCPSendBufferSize() (inet.TCPBufferSize, error)

TCPSendBufferSize implements inet.Stack.TCPSendBufferSize.

Jump to

Keyboard shortcuts

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