Documentation
¶
Overview ¶
Package rtroute implements interacting with the systems network routing through the Netlink rtnetlink subsystem.
References:
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheInfo ¶
type CacheInfo struct {
Clntref uint32
LastUse uint32
Expires uint32
Error uint32
Used uint32
// only set when peer info is available.
Id uint32
Ts uint32
Tsage uint32
}
CacheInfo contains cache information for a Route.
References:
- linux/include/uapi/linux/rtnetlink.h
- https://www.kernel.org/doc/html/latest/netlink/specs/rt-route.html#rt-route-definition-rta-cacheinfo
func (*CacheInfo) UnmarshalBinary ¶
UnmarshalBinary unmarshals the rta_cacheinfo struct from bytes.
type EncapType ¶
type EncapType uint16
EncapType is the encapsulation type configured for a Route.
References:
- linux/includes/uapi/linux/lw_tunnel.h
Constants for EncapType.
type Family ¶
type Family uint8
Family configures the family of addresses applicable for a Route.
Constants for Family.
type Features ¶
type Features uint32
Features are contained within Metrics.
References:
- linux/include/uapi/linux/rtnetlink.h
type Flags ¶
type Flags uint32
Flags configure the handling of a Route.
References:
- linux/include/uapi/linux/rtnetlink.h
const ( NOTIFY Flags = unix.RTM_F_NOTIFY CLONED Flags = unix.RTM_F_CLONED EQUALIZE Flags = unix.RTM_F_EQUALIZE PREFIX Flags = unix.RTM_F_PREFIX LOOKUP_TABLE Flags = unix.RTM_F_LOOKUP_TABLE FIB_MATCH Flags = unix.RTM_F_FIB_MATCH OFFLOAD Flags = unix.RTM_F_OFFLOAD TRAP Flags = unix.RTM_F_TRAP OFFLOAD_FAILED Flags = unix.RTM_F_OFFLOAD_FAILED )
Constants for Flags.
type Metrics ¶
type Metrics struct {
Lock uint32
MTU uint32
Window uint32
Rtt uint32
Rttvar uint32
Ssthresh uint32
Cwnd uint32
Advmss uint32
Reordering uint32
HopLimit uint32
InitCwnd uint32
Features Features
RtoMin uint32
InitRwnd uint32
QuickAck uint32
CcAlgo string
FastOpenNoCookie uint32
}
Metrics contains statistics for a Route.
References:
func (*Metrics) UnmarshalAttributes ¶
func (m *Metrics) UnmarshalAttributes(attrs *netlink.AttributeDecoder) error
UnmarshalAttributes unmarshals the metrics contained within a Route.
type MfcStats ¶
MfcStats not sure what this is yet.
References:
- linux/include/uapi/linux/rtnetlink.h
func (*MfcStats) UnmarshalBinary ¶
UnmarshalBinary unmarshals the rta_mfc_stats struct from bytes.
type NextHop ¶
NextHop contains parameters for the next multipath hop.
References:
- linux/include/uapi/linux/rtnetlink.h
type Proto ¶
type Proto uint8
Proto is the origin of a Route.
References:
- rtnetlink(7)
const ( REDIRECT Proto = 1 + iota KERNEL BOOT STATIC // these are user defined values for common routing daemons, not // interpreted by the kernel itself. GATED Proto = 8 RA Proto = 9 MRT Proto = 10 ZEBRA Proto = 11 BIRD Proto = 12 DNROUTED Proto = 13 XORP Proto = 14 NTK Proto = 15 DHCP Proto = 16 MROUTED Proto = 17 KEEPALIVED Proto = 18 BABEL Proto = 42 OVN Proto = 84 OPENR Proto = 99 BGP Proto = 186 ISIS Proto = 187 OSPF Proto = 188 RIP Proto = 189 EIGRP Proto = 192 )
Constants for Proto.
type Route ¶
type Route struct {
Family Family
DstLen uint8
SrcLen uint8
Table Table
Proto Proto
Scope Scope
Type Type
Flags Flags
Dst netip.Addr
Src netip.Addr
Iif int
Oif int
Gateway netip.Addr
Priority uint32
PrefSrc netip.Addr
Metrics Metrics
Multipath []*NextHop
Flow uint32
CacheInfo *CacheInfo
Mark uint32
MfcStats *MfcStats
Via *Via
NewDst netip.Addr
Pref uint8
EncapType EncapType
Uid uint32
TtlPropagate uint8
IPProto uint8
Sport uint16
Dport uint16
}
Route contains a network route within one of the systems routing tables.
References:
- rtnetlink(7)
- https://www.kernel.org/doc/html/latest/netlink/specs/rt-route.html#rt-route-attribute-set-route-attrs
func (*Route) UnmarshalAttributes ¶
func (r *Route) UnmarshalAttributes(attrs *netlink.AttributeDecoder) error
UnmarshalAttributes unmarshals a Route attributes from a Netlink message.
It assumes the RtMsg header has already been read and values set on the Route.
func (*Route) UnmarshalNetlink ¶
func (r *Route) UnmarshalNetlink(msg netlink.MessageDecoder) error
UnmarshalNetlink unmarshals a single Route from a Netlink message.
type Routes ¶
type Routes []*Route
Routes contains a list of Route read from a series of Netlink messages.
func (*Routes) UnmarshalNetlink ¶
func (rs *Routes) UnmarshalNetlink(msg netlink.MessageDecoder) error
UnmarshalNetlink unmarshals one-or-more Netlink messages containing a Route and appends it to itself.
type RtMsg ¶
type RtMsg struct {
Family Family
DstLen uint8
SrcLen uint8
TOS uint8
Table uint8
Proto Proto
Scope Scope
Type Type
Flags Flags
}
RtMsg is the fixed-length header before Route messages.
References:
- rtnetlink(7)
func (RtMsg) AppendBinary ¶
AppendBinary appends an RtMsg to bytes using the host byteorder.
func (RtMsg) MarshalBinary ¶
MarshalBinary marshals an RtMsg to bytes using the host byteorder.
type Scope ¶
type Scope uint8
Scope configures the network scope for an [addr.Addr] or Route.
const ( UNIVERSE Scope = unix.RT_SCOPE_UNIVERSE SITE Scope = unix.RT_SCOPE_SITE LINK Scope = unix.RT_SCOPE_LINK HOST Scope = unix.RT_SCOPE_HOST NOWHERE Scope = unix.RT_SCOPE_NOWHERE )
Constants for Scope.
type Table ¶
type Table uint32
Table configures which routing table a Route is part of.
References:
- linux/include/uapi/linux/rtnetlink.h
Constants for Table.
type Type ¶
type Type uint8
Type is the type of Route.
References:
- rtnetlink(7)
- linux/include/uapi/linux/rtnetlink.h
type Via ¶
Via configures a gateway in a different route family.
References:
- rtnetlink(7)
- linux/include/uapi/linux/rtnetlink.h
func (*Via) UnmarshalBinary ¶
UnmarshalBinary unmarshals the rtvia struct from bytes.