l3

package
v0.0.0-...-a9890c3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func L2APIToStack

func L2APIToStack(l2Stack *l2API.Stack) (*l2.Stack, error)

L2APIToStack converts the l2-agent API stack into the more useful stack

func NewID

func NewID() string

NewID generates a unique id which can be assigned to routers

Types

type Router

type Router struct {
	ID    string
	VPCID int32
	NetNS *ns.NetNS
	Veths map[string]netlink.Link
	ExtBr *netlink.Bridge
	// contains filtered or unexported fields
}

Router provides a iso layer 3 router using networknamespaces

func CreateRouter

func CreateRouter(l2 l2api.L2ServiceClient, stack *l2.Stack, id string) (*Router, error)

CreateRouter inits a router given a VPC stack

func (*Router) AddSubnet

func (r *Router) AddSubnet(ip net.IP, cidr *net.IPNet, vlan uint16, dhcp bool) error

AddSubnet attaches a new interface listening to a cidr and optionally enables DHCP

func (*Router) AddSubnetIFace

func (r *Router) AddSubnetIFace(addr net.IP, ipnet *net.IPNet, innerVlan uint16) (*Subnet, error)

AddSubnetIFace creates a new veth pair and adds a specific subnet to it The veth will come up with a specific mac address based on the number of subnets already created - see subnetMacs()

func (*Router) CreateVeth

func (r *Router) CreateVeth(bridge *netlink.Bridge, name string, peerName string, hwaddr string) (netlink.Link, error)

CreateVeth creates a new veth pair attaching one side to a bridge and the other into the network namespace

func (*Router) Delete

func (r *Router) Delete() error

Delete deletes all attached veth pairs and unbinds+deletes the netns

func (*Router) EnableForwarding

func (r *Router) EnableForwarding() error

EnableForwarding turns on ip forwarding via sysctl for packet routing

func (*Router) EnableNATOn

func (r *Router) EnableNATOn(iface string) error

EnableNATOn adds iptable rules to enable natting on a specific interface

func (*Router) Exec

func (r *Router) Exec(fn func() error) error

Exec executes a given func inside the router network namespace

func (*Router) Ifup

func (r *Router) Ifup(iface string) error

Ifup set the link into the 'up' state

func (*Router) SetDefaultFWRules

func (r *Router) SetDefaultFWRules() error

SetDefaultFWRules sets the DROP policy on input and output, allows forwarding

type RouterBGP

type RouterBGP struct {
	// contains filtered or unexported fields
}

RouterBGP contains a small gobgp server to advertise communities and routes between subnets

func NewRouterBGP

func NewRouterBGP(pubIP net.IP, vni uint32, peers []string) (*RouterBGP, error)

NewRouterBGP inits a new BGP server

func (*RouterBGP) ASN

func (rbgp *RouterBGP) ASN() uint32

ASN provides the private ASN of the vpc

func (*RouterBGP) AdvertSubnet

func (rbgp *RouterBGP) AdvertSubnet(subnet *net.IPNet, vlan uint16) error

AdvertSubnet adds a subnet to the bgp server within the vpc community

func (*RouterBGP) Start

func (rbgp *RouterBGP) Start(ns netns.NsHandle) error

Start begins the bgp session and start advertising

type RouterDHCP

type RouterDHCP struct {
	// contains filtered or unexported fields
}

RouterDHCP provides DHCP capabilities to routers

func NewDHCPv4Server

func NewDHCPv4Server(iface string, subnet *net.IPNet, dns []net.IP) (*RouterDHCP, error)

NewDHCPv4Server consturcts a new DHCPv4 server

func (*RouterDHCP) DHCPV4OnSubnet

func (rd *RouterDHCP) DHCPV4OnSubnet() error

DHCPV4OnSubnet starts a DHCPv4 Server on a particular subnet

func (*RouterDHCP) HandleV4

func (rd *RouterDHCP) HandleV4(conn net.PacketConn, peer net.Addr, m *dhcpv4.DHCPv4)

HandleV4 handles DHCP v4

type Subnet

type Subnet struct {
	// contains filtered or unexported fields
}

Subnet contains info on a subnet and related interfaces

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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