ifmgrd

package module
v0.0.0-...-0d296c2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: BSD-3-Clause, GPL-2.0 Imports: 28 Imported by: 0

README

ifmgrd design

Overview

The ifmgrd service provides a mechanism for applying interface configuration at plug time. It handles interface config events for registered interfaces. For this to work properly configd must be told not to run the commit actions by using the 'configd:defer-child-actions' YANG statement in the desired interface's data-model. These deferred actions will then be run asynchronously by ifmgrd either immediately if the interface exists or at plug time when the interface comes into existance. The ifmgrd service also emulates the configd commit time interface so the environment the deferred action scripts execute in look very similar to the environment configd would run them in.

Each managed interface is controlled by a state-machine that tracks the current state and transitions based on the received events. Events are generated with the ifmgrctl utility.

NOTE: ifmgrd is meant to be a temporary solution providing hotplug configuration services using legacy commit scripts. A more permanent solution would not rely on the commit library to apply the configuration but would have a more direct mechanism, and an intermediate configuration file format. This services state-machine, would however provide an appropriate basis for such a daemon.

interface state-machine transition table

state event action new state
unplugged apply stage new config unplugged
unplugged reset delete staged config unplugged
unplugged plug apply staged config applying
unplugged kill shutdown state-machine shutdown
applying apply stage new config applying
applying reset stage empty config applying
applying unplug remove running config unplugged
applying shutdown shutdown state-machine shutdown
applying done set running = applied config if candidate != running applying else plugged
plugged apply stage new config; apply staged config applying
plugged reset stage empty config; apply staged config applying
plugged unplug remove running config unplugged
plugged kill shutdown state-machine shutdown

ifmgrctl utility

Usage: ifmgrctl <action> <args>
Available actions:
  apply		apply latest config to managed interfaces
  plug		send plug event for device
  register	register a new device to be managed
  unplug	send unplug event for device
  unregister	stop managing a device

Apply downloads the latest configuration from configd and then sends it to ifmgrd.

Plug signals that an interface was added to the system, if the interface is not currently managed by ifmgrd the plug event is ignored. This will apply the cached candidate configuration to the interface.

Unplug signals that an interface was removed, this causes the running configuration to be reset to an empty state. The candidate configuration will remain and be applied on the next plug event.

Register signals to start listening for events on a given interface.

Unregister stops the state-machine for an interface and removes the state from the manager. All previously applied configuration remains active.

Documentation

Overview

Copyright (c) 2019, AT&T Intellectual Property. All rights reserved.

Copyright (c) 2015-2017 by Brocade Communications Systems, Inc. All rights reserved.

SPDX-License-Identifier: GPL-2.0-only

Index

Constants

This section is empty.

Variables

View Source
var SchemaTree *atomicSchemaNode

Functions

func GetFuncName

func GetFuncName() string

GetFuncName() returns the unqualified name of the caller

func IsLoginPidError

func IsLoginPidError(err error) bool

Types

type ArgErr

type ArgErr struct {
	Method string
	Farg   interface{}
	Typ    string
	Etyp   string
}

func (*ArgErr) Error

func (e *ArgErr) Error() string

type ArgNErr

type ArgNErr struct {
	Method string
	Len    int
	Elen   int
}

func (*ArgNErr) Error

func (e *ArgNErr) Error() string

type Client

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

func Dial

func Dial(network, address string) (*Client, error)

func (*Client) Apply

func (c *Client) Apply(config string) error

func (*Client) Plug

func (c *Client) Plug(intfName string) error

func (*Client) Register

func (c *Client) Register(intfName string) error

func (*Client) Running

func (c *Client) Running(intf string) (string, error)

func (*Client) Unplug

func (c *Client) Unplug(intfName string) error

func (*Client) Unregister

func (c *Client) Unregister(intfName string) error

type Committer

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

func NewCommitter

func NewCommitter(
	candidate, running *data.Node,
	schema schema.Node,
	sid string,
) *Committer

func (*Committer) Candidate

func (c *Committer) Candidate() *data.Node

func (*Committer) Debug

func (c *Committer) Debug() bool

func (*Committer) Delete

func (c *Committer) Delete(_ []string) error

func (*Committer) Effective

func (c *Committer) Effective() commit.EffectiveDatabase

func (*Committer) Log

func (c *Committer) Log(msgs ...interface{})

commit.Context

func (*Committer) LogAudit

func (c *Committer) LogAudit(_ string)

func (*Committer) LogCommitMsg

func (c *Committer) LogCommitMsg(string)

func (*Committer) LogCommitTime

func (c *Committer) LogCommitTime(string, time.Time)

func (*Committer) LogError

func (c *Committer) LogError(msgs ...interface{})

func (*Committer) MustDebugThreshold

func (c *Committer) MustDebugThreshold() int

func (*Committer) RunDeferred

func (c *Committer) RunDeferred() bool

func (*Committer) Running

func (c *Committer) Running() *data.Node

func (*Committer) Schema

func (c *Committer) Schema() schema.Node

func (*Committer) Set

func (c *Committer) Set(_ []string) error

commit.EffectiveDatabase

func (*Committer) Sid

func (c *Committer) Sid() string

func (*Committer) Uid

func (c *Committer) Uid() uint32

type Config

type Config struct {
	Yangdir       string
	Socket        string
	Capabilities  string
	ConfigdSocket string
}

type ConfigurationUpdated

type ConfigurationUpdated struct {
	Interface struct {
		Name string `rfc7951:"name"`
	} `rfc7951:"vyatta-ifmgr-v1:interface"`
}

type Disp

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

func (*Disp) Apply

func (d *Disp) Apply(config string) (bool, error)

ifmgrd specific

func (*Disp) AuthAuthorize

func (d *Disp) AuthAuthorize(path string, perm int) (bool, error)

func (*Disp) CallRpc

func (d *Disp) CallRpc(namespace, name, args, encoding string) (string, error)

func (*Disp) CallRpcXml

func (d *Disp) CallRpcXml(namespace, name, args string) (string, error)

func (*Disp) Exists

func (d *Disp) Exists(db rpc.DB, sid string, path string) (bool, error)

func (*Disp) Expand

func (d *Disp) Expand(path string) (string, error)

func (*Disp) Get

func (d *Disp) Get(db rpc.DB, sid string, path string) ([]string, error)

func (*Disp) GetSchemas

func (d *Disp) GetSchemas() (string, error)

func (*Disp) MigrateConfigFile

func (d *Disp) MigrateConfigFile(filename string) (string, error)

func (*Disp) NodeGetStatus

func (d *Disp) NodeGetStatus(
	db rpc.DB,
	sid string,
	path string,
) (rpc.NodeStatus, error)

func (*Disp) NodeGetType

func (d *Disp) NodeGetType(sid string, path string) (rpc.NodeType, error)

Pretend to be configd, proxy safe requests as needed

func (*Disp) NodeIsDefault

func (d *Disp) NodeIsDefault(
	db rpc.DB,
	sid string,
	path string,
) (bool, error)

func (*Disp) Plug

func (d *Disp) Plug(intfName string) (bool, error)

func (*Disp) ReadConfigFile

func (d *Disp) ReadConfigFile(filename string) (string, error)

func (*Disp) Register

func (d *Disp) Register(intfName string) (bool, error)

func (*Disp) Running

func (d *Disp) Running(intf string) (string, error)

Get an interfaces running configuration

func (*Disp) SchemaGet

func (d *Disp) SchemaGet(module string, format string) (string, error)

func (*Disp) SessionExists

func (d *Disp) SessionExists(sid string) (bool, error)

func (*Disp) TmplGet

func (d *Disp) TmplGet(path string) (map[string]string, error)

func (*Disp) TmplGetChildren

func (d *Disp) TmplGetChildren(path string) ([]string, error)

func (*Disp) TmplValidatePath

func (d *Disp) TmplValidatePath(path string) (bool, error)

func (*Disp) TmplValidateValues

func (d *Disp) TmplValidateValues(path string) (bool, error)

func (*Disp) TreeGet

func (d *Disp) TreeGet(
	db rpc.DB,
	sid, path, encoding string,
	flags map[string]interface{},
) (string, error)

func (*Disp) Unplug

func (d *Disp) Unplug(intfName string) (bool, error)

func (*Disp) Unregister

func (d *Disp) Unregister(intfName string) (bool, error)

type InterfaceState

type InterfaceState struct {
	Interface struct {
		Name  string `rfc7951:"name"`
		State string `rfc7951:"state"`
	} `rfc7951:"vyatta-ifmgr-v1:interface"`
}

type IntfMachine

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

func NewIntfMachine

func NewIntfMachine(ifname string) *IntfMachine

func (*IntfMachine) Apply

func (mach *IntfMachine) Apply(cfg *data.Node)

func (*IntfMachine) IsShutdown

func (mach *IntfMachine) IsShutdown() bool

func (*IntfMachine) Kill

func (mach *IntfMachine) Kill()

func (*IntfMachine) Plug

func (mach *IntfMachine) Plug()

func (*IntfMachine) Reset

func (mach *IntfMachine) Reset(cfg *data.Node)

func (*IntfMachine) Unplug

func (mach *IntfMachine) Unplug()

type IntfManager

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

func NewIntfManager

func NewIntfManager() *IntfManager

func (*IntfManager) Apply

func (mgr *IntfManager) Apply(config *data.Node)

func (*IntfManager) Plug

func (mgr *IntfManager) Plug(intfName string)

func (*IntfManager) Register

func (mgr *IntfManager) Register(intfName string)

func (*IntfManager) Unplug

func (mgr *IntfManager) Unplug(intfName string)

func (*IntfManager) Unregister

func (mgr *IntfManager) Unregister(intfName string)

type LoginPidError

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

func (*LoginPidError) Error

func (e *LoginPidError) Error() string

type MethErr

type MethErr struct {
	Name string
}

func (*MethErr) Error

func (e *MethErr) Error() string

type Request

type Request struct {
	//Op is the method that was called via json rpc
	Method string `json:"method"`
	//Args is a list of arguments to that method
	Args []interface{} `json:"params"`
	//Id is the unique request identifier
	Id int `json:"id"`
}

Request represents an RPC request

type Response

type Response struct {
	//Result is any value returned by the handler
	//The client library uses reflection to ensure it received the appropriate type.
	Result interface{} `json:"result"`
	//Error contains a message describing a problem
	Error interface{} `json:"error"`
	//Id is the unique request identifier
	Id int `json:"id"`
}

Response represents an RPC response

type Session

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

type Sessions

type Sessions struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSessionMap

func NewSessionMap() *Sessions

func (*Sessions) Delete

func (s *Sessions) Delete(sid string)

func (*Sessions) Get

func (s *Sessions) Get(sid string) *Session

func (*Sessions) New

func (s *Sessions) New(
	sid string,
	candidate, running *data.Node,
	schema schema.Node,
) (*Session, error)

type Srv

type Srv struct {
	*net.UnixListener

	Config *Config
	// contains filtered or unexported fields
}

func NewSrv

func NewSrv(l *net.UnixListener, config *Config) *Srv

func (*Srv) Log

func (d *Srv) Log(format string, v ...interface{})

Log is a common place to do logging so that the implementation may change in the future.

func (*Srv) LogError

func (d *Srv) LogError(err error)

LogError logs an error if the passed in value is non nil

func (*Srv) LogFatal

func (d *Srv) LogFatal(err error)

func (*Srv) NewConn

func (s *Srv) NewConn(conn *net.UnixConn) *SrvConn

NewConn creates a new SrvConn and returns a reference to it.

func (*Srv) Serve

func (s *Srv) Serve() error

Serve is the server main loop. It accepts connections and spawns a goroutine to handle that connection.

type SrvConn

type SrvConn struct {
	*net.UnixConn
	// contains filtered or unexported fields
}

func (*SrvConn) Call

func (conn *SrvConn) Call(
	disp *Disp,
	method string,
	args []interface{},
) (interface{}, error)

func (*SrvConn) Handle

func (conn *SrvConn) Handle()

Handle is the main loop for a connection. It receives the requests, calls the request method and returns the response to the client.

type State

type State uint32

func (State) String

func (s State) String() string

type TransFn

type TransFn func(*IntfMachine, interface{}) State

Directories

Path Synopsis
cmd
ifmgrd
ifmgrd is a daemon that manages interface configuration.
ifmgrd is a daemon that manages interface configuration.

Jump to

Keyboard shortcuts

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