netlink

package
v0.0.0-...-af23f1f Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package netlink provides router implementation that uses netlink.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Retriever

type Retriever struct{}

Retriever is a routes.GatewayRetriever implementation that is using netlink

func (Retriever) Retrieve

func (Retriever) Retrieve(prefix netip.Prefix, ignoreTable uint) (netip.Addr, net.Interface, error)

Retrieve a gateway to a given address while ignoring the given routing table. The mechanism for determining a gateway:

  1. All routes are queried in the system;
  2. Routes are filtered so they contain only those routes which contain the subnet;
  3. Filtered routes are sorted in priority order as it would be on route selection for a packet;
  4. All rules are listed and ordered by priority by default;
  5. Routes are re-ordered by the ip rule that applies to the route. Routes for which same route can be applied, maintain the same order as defined in 3;
  6. First route in the list is chosen as the best match and used to determine a gateway.

type Router

type Router struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Router uses netlink under the hood.

func (*Router) Add

func (r *Router) Add(route routes.Route) error

Add appends route to a routes list via netlink if it does not exist yet.

func (*Router) Flush

func (r *Router) Flush() error

Flush deletes all previously added routes via netlink.

Jump to

Keyboard shortcuts

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