s6netdev

package module
v0.0.0-...-03b6496 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 8 Imported by: 0

README

s6-netdev

This is a project which can generate s6 service definitions based on a structured definition. It's intended to be used together with nnd but can be adapted to be used with any other distribution based on s6.

Documentation

Index

Constants

View Source
const (
	NETDEV_EXECLINE_HEADER = "#!/bin/execlineb -P"
)

Variables

View Source
var NetdevIfTypes = struct {
	Phys, Loopback, Bridge, Vlan, Wireguard, Bond, Vrf NetdevIfType
}{
	Phys:      NetdevIfType{"", []S6SvcName{"bundle.hw-coldplug"}},
	Loopback:  NetdevIfType{"loopback", []S6SvcName{}},
	Bridge:    NetdevIfType{"bridge", []S6SvcName{"module.bridge"}},
	Vlan:      NetdevIfType{"vlan", []S6SvcName{"module.8021q"}},
	Wireguard: NetdevIfType{"wireguard", []S6SvcName{"module.wireguard"}},
	Bond:      NetdevIfType{"bond", []S6SvcName{"module.bonding"}},
	Vrf:       NetdevIfType{"vrf", []S6SvcName{"module.vrf"}},
}
View Source
var S6SvcTypes = struct {
	Oneshot, Longrun, Bundle string
}{
	Oneshot: "oneshot",
	Longrun: "longrun",
	Bundle:  "bundle",
}

Functions

func ExeclineDefine

func ExeclineDefine(param, value string) string

func ExeclineExport

func ExeclineExport(param, value string) string

func ExeclineImportas

func ExeclineImportas(name string, strict bool, def string) string

func ExeclineXDGConfig

func ExeclineXDGConfig() string

func ExeclineXDGEnvdirConfig

func ExeclineXDGEnvdirConfig(name S6SvcName) string

func NNDLibExec

func NNDLibExec(name string) string

func NetdevIPAddrVer

func NetdevIPAddrVer(IP netip.Addr) int

func NetdevIsDummy

func NetdevIsDummy(s S6SvcName) (r bool)

func NetdevOnlyMAC

func NetdevOnlyMAC(x net.HardwareAddr, _ error) net.HardwareAddr

func S6Pipe

func S6Pipe(src, dst *S6Svc)

Types

type DHCP_IP

type DHCP_IP struct {
	V4, V6 bool // Should we start dhcp on this interface?
}

type IfMap

type IfMap map[string]*Iface

func (IfMap) AddIf

func (im IfMap) AddIf(i *Iface)

type Iface

type Iface struct {
	Name   string        // Interface name
	Type   *NetdevIfType // Type of interface
	Slaves []*Iface      // Slaves for VRFs, Bridges and Bonds etc...

	VlanId VLAN   // VLAN id for VLAN interfaces
	Parent *Iface // Parent interface for VLAN interfaces

	Table RouteTable // Routing table, for VRF

	MACAddr net.HardwareAddr // MAC address of interface (only valid for physical, bridges and VLAN)

	Addresses []netip.Prefix // Addresses to be assigned to interface
	Routes    []Route        // Routes to be assigned to interface

	DHCP DHCP_IP // Should we start dhcp on this interface?

	Properties []Property // List of properties of the interface, valid for many
	Sysctls    Sysctl_IP  // Sysctls associated with this interface
}

func (*Iface) NetdevIfaceAddAddr

func (i *Iface) NetdevIfaceAddAddr(addr string) (err error)

func (*Iface) NetdevIfaceAddRoute

func (i *Iface) NetdevIfaceAddRoute(def bool, route, r_type, via string, vrf *Iface, table *RouteTable, metric Metric) (err error)

func (*Iface) NetdevIfaceEnslave

func (i *Iface) NetdevIfaceEnslave(s ...*Iface)

func (*Iface) NetdevIfaceMAC

func (i *Iface) NetdevIfaceMAC(mac string) (err error)

func (*Iface) NetdevIfaceProperty

func (i *Iface) NetdevIfaceProperty(key, value, def string)

func (*Iface) NetdevIfaceSysctl

func (i *Iface) NetdevIfaceSysctl(ipv int, key, value, def string)

type Metric

type Metric uint32

type NetdevIfType

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

type Property

type Property struct {
	Key, Value, Default string
}

type Route

type Route struct {
	Default bool
	// VRF would be a field but it can be derived from parent
	Type   string // unicast default, can be others
	IPver  int    // if 0, will guess based on Net
	Net    netip.Prefix
	Via    netip.Addr
	Vrf    *Iface
	Table  *RouteTable
	Metric Metric // Should be explicitly initialised to 1024
}

type RouteTable

type RouteTable uint16

type S6Svc

type S6Svc struct {
	Name                     S6SvcName
	Type                     S6SvcType
	Children                 []*S6Svc // Either dependencies or contents depending on type
	ProducerFor, ConsumerFor *S6Svc
	NotifFd                  int
	FlagEssential            bool
	Up, Down, Run            string
	// contains filtered or unexported fields
}

func (*S6Svc) S6AddEnv

func (s *S6Svc) S6AddEnv(key, value string)

func (*S6Svc) S6Children

func (s *S6Svc) S6Children(children ...*S6Svc)

func (*S6Svc) S6DelEnv

func (s *S6Svc) S6DelEnv(key string)

type S6SvcName

type S6SvcName string

func (S6SvcName) Sanitize

func (s S6SvcName) Sanitize() S6SvcName

type S6SvcTree

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

func S6NewTree

func S6NewTree() *S6SvcTree

func (*S6SvcTree) ConfigureServices

func (t *S6SvcTree) ConfigureServices(i Iface) (r []*S6Svc)

func (*S6SvcTree) CreateIfaceService

func (t *S6SvcTree) CreateIfaceService(iface string) *S6Svc

func (*S6SvcTree) LinkIfaceService

func (t *S6SvcTree) LinkIfaceService(iface string) *S6Svc

func (*S6SvcTree) NetdevConfigureIfaceMAC

func (t *S6SvcTree) NetdevConfigureIfaceMAC(iface Iface, addr net.HardwareAddr) *S6Svc

func (*S6SvcTree) NetdevDependBundleStage

func (t *S6SvcTree) NetdevDependBundleStage(iface, stage string, svcs ...*S6Svc) *S6Svc

func (*S6SvcTree) NetdevEnslaveInterface

func (t *S6SvcTree) NetdevEnslaveInterface(iface, master string) *S6Svc

func (*S6SvcTree) NetdevIfaceAddr

func (t *S6SvcTree) NetdevIfaceAddr(iface Iface, addr netip.Prefix) *S6Svc

func (*S6SvcTree) NetdevIfaceCreate

func (t *S6SvcTree) NetdevIfaceCreate(iface Iface, iftype *NetdevIfType) *S6Svc

func (*S6SvcTree) NetdevIfaceDHCP

func (t *S6SvcTree) NetdevIfaceDHCP(iface Iface, ipv int) *S6Svc

func (*S6SvcTree) NetdevIfaceIpSysctl

func (t *S6SvcTree) NetdevIfaceIpSysctl(iface Iface, ipv int, p Property) *S6Svc

func (*S6SvcTree) NetdevIfaceProp

func (t *S6SvcTree) NetdevIfaceProp(iface Iface, p Property) *S6Svc

func (*S6SvcTree) NetdevRoute

func (t *S6SvcTree) NetdevRoute(iface Iface, route Route) *S6Svc

func (*S6SvcTree) NetdevWireguardConfig

func (t *S6SvcTree) NetdevWireguardConfig(iface Iface) *S6Svc

func (*S6SvcTree) ReadyServices

func (t *S6SvcTree) ReadyServices(i Iface) (r []*S6Svc)

func (*S6SvcTree) S6AddSvc

func (t *S6SvcTree) S6AddSvc(s *S6Svc)

func (*S6SvcTree) S6CommitService

func (t *S6SvcTree) S6CommitService(s *S6Svc) (err error)

func (*S6SvcTree) S6GetSvc

func (t *S6SvcTree) S6GetSvc(name S6SvcName) *S6Svc

func (*S6SvcTree) S6New

func (t *S6SvcTree) S6New(name S6SvcName, svc_type S6SvcType) *S6Svc

func (*S6SvcTree) S6Services

func (t *S6SvcTree) S6Services() (r []*S6Svc)

func (*S6SvcTree) Services

func (t *S6SvcTree) Services(i Iface) (r []*S6Svc)

type S6SvcType

type S6SvcType *string

type Sysctl_IP

type Sysctl_IP struct {
	V4, V6 []Property
}

type VLAN

type VLAN uint16

Jump to

Keyboard shortcuts

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