routetable

package module
v0.0.0-...-014654c Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

Warning

Though functional, this software is still in an alpha state. Though written with compatibility in mind, this software has not been tested with IPv6.

Description

This repository contains a CNI compatible IPAM plugin for use with container cluster systems. When an address is requested within a given network, the plugin will generate a random address within that network, and then consult the local routing table to determine whether that address already exists. If the host prefix represeting the generated address is not found, the address will be converted to a host prefix and then stored into the routing table using a custom protocol number. A host prefix is a "subnet" where the number of bits in the subnet mask is equal to the number of bits in the address. In other words, a /32 address in IPv4, or a /128 address in IPv6.

The real power of this plugin comes into play when you couple it with a routing protocol. Doing that allows you to get a cluster-wide view of available IP addresses on a given network. Care is taken to avoid race conditions where the same address is selected on multiple nodes simultaneously. There is a configurable amount of time to wait an expected propogation timeout before the routing table is consulted a second time to ensure that the address wasn't first selected somewhere else.

Some initial features include:

  • The ability to request a specific address in the network
  • The ability to exclude some number of addresses from the beginning or from the end of the range

Along with a routing protocol, this plugin is intended to be coupled with a CNI plugin that provides the ability to span layer 2 networks across multiple nodes, such as our vxlan-cni plugin.

The ipam concepts and some of this code were inspired by and are originally from here

Documentation

Index

Constants

View Source
const (
	DefaultRequestedAddressSleepTime = 100
	DefaultPropagationTimeout        = 100
	DefaultRouteProtocol             = 192
)
  • DefaultRequestedAddressSleepTime is the default amount of time (ms) we wait between tries to select a requested address
  • DefaultPropagationTimeout is the amount of time (ms) we wait for the possibility that another host has selected the same address

* DefaultRouteProtocol is the default protocol number for our installed routes

Variables

This section is empty.

Functions

func DelRoute

func DelRoute(linkIndex int, ip *net.IPNet) error

DelRoute deletes the /32 or /128 to the passed address

func GetIPNets

func GetIPNets(address net.IP, subnet *net.IPNet) (*net.IPNet, *net.IPNet)

GetIPNets takes an IP and a subnet and returns the IPNet representing the IP in the subnet, as well as an IPNet representing the "host only" cidr in other words a /32 in IPv4 or a /128 in IPv6

func LinkIndexFromIPNet

func LinkIndexFromIPNet(address *net.IPNet) (int, error)

LinkIndexFromIPNet gets the link index of the first interface which is on the same subnet as the parameter

func NewConfig

func NewConfig(confBytes []byte) (*cni.Config, error)

NewConfig returns a new vxlan config from the byte array

func SelectAddress

func SelectAddress(cidr string, xf, xl int) (*net.IPNet, error)

SelectAddress returns an available IP or the requested IP (if available) or an error on timeout

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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