routing

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteTableSpecific = 100
	RouteTableDefault  = 101
)

Variables

View Source
var (
	ErrTunnelExists  = errors.New("tunnel already exists")
	ErrAddressExists = errors.New("address already exists")
	ErrRuleExists    = errors.New("ip rule already exists")
)
View Source
var (
	DzTableSpecific = 100
	DzTableDefault  = 101
)

Functions

func CreateIPRules

func CreateIPRules(nl Netlinker, rules []*IPRule) error

Types

type EncapType

type EncapType string
const (
	GRE EncapType = "gre"
)

type IPRule

type IPRule struct {
	Priority int
	Table    int
	SrcNet   *net.IPNet
	DstNet   *net.IPNet
}

func NewIPRule

func NewIPRule(priority, table int, srcnet, dstnet string) (*IPRule, error)

NewIPRule creates a new linux IP rule. The priority and table value ranges must be within 100 - 200 for no good reason other than we can't insert rules just anywhere and stomp on other system rules.

func (*IPRule) String

func (r *IPRule) String() string
type Netlink struct{}

func (Netlink) Close

func (n Netlink) Close(t *Tunnel, r []*IPRule, rt []*Route)

func (Netlink) RouteAdd

func (n Netlink) RouteAdd(r *Route) error

RouteAdd adds a route to the kernel routing table via netlink.

func (Netlink) RouteByProtocol

func (n Netlink) RouteByProtocol(protocol int) ([]*Route, error)

func (Netlink) RouteDelete

func (n Netlink) RouteDelete(r *Route) error

RouteDelete deletes a route from the kernel routing table via netlink.

func (Netlink) RouteGet

func (n Netlink) RouteGet(ip net.IP) ([]*Route, error)

RouteGet retrieves a route from the kernel routing table via netlink.

func (Netlink) RuleAdd

func (n Netlink) RuleAdd(r *IPRule) error

func (Netlink) RuleDel

func (n Netlink) RuleDel(r *IPRule) error

func (Netlink) RuleGet

func (n Netlink) RuleGet(r *IPRule) error

func (Netlink) TunnelAdd

func (n Netlink) TunnelAdd(t *Tunnel) error

func (Netlink) TunnelAddrAdd

func (n Netlink) TunnelAddrAdd(t *Tunnel, prefix string) error

func (Netlink) TunnelDelete

func (n Netlink) TunnelDelete(t *Tunnel) error

func (Netlink) TunnelGet

func (n Netlink) TunnelGet(t *Tunnel) error

func (Netlink) TunnelUp

func (n Netlink) TunnelUp(t *Tunnel) error

type Netlinker

type Netlinker interface {
	TunnelAdd(*Tunnel) error
	TunnelDelete(*Tunnel) error
	TunnelAddrAdd(*Tunnel, string) error
	TunnelUp(*Tunnel) error
	RouteAdd(*Route) error
	RouteDelete(*Route) error
	RouteGet(net.IP) ([]*Route, error)
	RuleAdd(*IPRule) error
	RuleDel(*IPRule) error
	RouteByProtocol(int) ([]*Route, error)
}

type Route

type Route struct {
	Dst      *net.IPNet
	Src      net.IP
	Table    int
	NextHop  net.IP
	Protocol int
}

func NewRoute

func NewRoute(table int, dst *net.IPNet, src, nexthop net.IP, protocol int) *Route

func (*Route) String

func (r *Route) String() string

type Tunnel

type Tunnel struct {
	Name string
	EncapType
	LocalUnderlay  net.IP
	RemoteUnderlay net.IP
	LocalOverlay   net.IP
	RemoteOverlay  net.IP
}

func NewTunnel

func NewTunnel(tunnelName string, local, remote net.IP, overlayNet string) (*Tunnel, error)

Jump to

Keyboard shortcuts

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