Documentation
¶
Overview ¶
Package tunnels provides functionality for setting up and managing overlay tunnels in Linux. It includes support for both IPIP and FOU (Foo over Ethernet) encapsulation types.
As much functionality as possible is done via the netlink library, however, FOU tunnels require using the iproute2 user space tooling since they are not currently supported by the netlink library.
Index ¶
Constants ¶
const ( EncapTypeFOU = EncapType("fou") EncapTypeIPIP = EncapType("ipip") // Unix tunnel encap types, unfortunately, these are not understood by the netlink library, so we need to use // our own enums which as far as I can tell come from here: //nolint:lll // URL is long // https://github.com/iproute2/iproute2/blob/e6a170a9d4e75d206631da77e469813279c12134/include/uapi/linux/if_tunnel.h#L84-L89 UnixTunnelEncapTypeNone uint16 = 0 UnixTunnelEncapTypeFOU uint16 = 1 UnixTunnelEncapTypeGUE uint16 = 2 UnixTunnelEncapTypeMPLS uint16 = 3 )
Variables ¶
This section is empty.
Functions ¶
func CleanupTunnel ¶
cleanupTunnel removes any traces of tunnels / routes that were setup by nrc.setupOverlayTunnel() and are no longer needed. All errors are logged only, as we want to attempt to perform all cleanup actions regardless of their success
func GenerateTunnelName ¶
GenerateTunnelName will generate a name for a tunnel interface given a node IP Since linux restricts interface names to 15 characters, we take the sha-256 of the node IP after removing non-entropic characters like '.' and ':', and then use the first 12 bytes of it. This allows us to cater to both long IPv4 addresses and much longer IPv6 addresses.
TODO: In the future, we should consider using the hexadecimal byte representation of IPv4 addresses and using a the SHA256 of the hash. Additionally, we should not remove non-entropic characters as it can cause hash collisions as "21.3.0.4" would has the same as "2.13.0.4" without "."'s.
Types ¶
type EncapType ¶
type EncapType string
EncapType represents the type of encapsulation used for an overlay tunnel in kube-router.
func ParseEncapType ¶
ParseEncapType parses the given string and returns an Encap type if valid. It returns an error if the encapsulation type is invalid.
Parameters:
- s: A string representing the encapsulation type.
Returns:
- Encap: The parsed encapsulation type.
- bool: A boolean indicating whether the encapsulation type is valid.
type OverlayTunnel ¶
type OverlayTunnel struct {
// contains filtered or unexported fields
}
func NewOverlayTunnel ¶
func NewOverlayTunnel(krNode utils.NodeIPAware, encapType EncapType, encapPort EncapPort) *OverlayTunnel
func (*OverlayTunnel) EncapPort ¶
func (o *OverlayTunnel) EncapPort() EncapPort
func (*OverlayTunnel) EncapType ¶
func (o *OverlayTunnel) EncapType() EncapType