{"modulePath":"github.com/emnify/vpp-agent","version":"v1.4.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ifplugin\n\n## Functions\n\n```go\nfunc GetLinuxInterfaceIndex(ifName string) int\n```\nGetLinuxInterfaceIndex returns the index of a Linux interface identified by its name. In Linux, interface index is a positive integer that starts at one, zero is never used. Function returns negative number in case of a failure, such as when the interface doesn't exist. TODO: move to the package with network utilities\n\n## Types\n\n```go\ntype LinuxDataPair struct {\n\t// contains filtered or unexported fields\n}\n```\nLinuxDataPair stores linux interface with matching NB configuration\n\n```go\ntype LinuxInterfaceConfig struct {\n\t// contains filtered or unexported fields\n}\n```\nLinuxInterfaceConfig is used to cache the configuration of Linux interfaces.\n\n```go\ntype LinuxInterfaceConfigurator struct {\n\tLog logging.Logger\n\n\t/* logical interface name -\u003e Linux interface index (both managed and unmanaged interfaces) */\n\tIfIndexes ifaceidx.LinuxIfIndexRW\n\tIfIdxSeq  uint32\n\n\t/* VPP interface indices */\n\tVppIfIndices vppIfIdx.SwIfIndex\n\n\tNsHandler *nsplugin.NsHandler\n\n\t/* time measurement */\n\tStopwatch *measure.Stopwatch // timer used to measure and store time\n\t// contains filtered or unexported fields\n}\n```\nLinuxInterfaceConfigurator runs in the background in its own goroutine where it watches for any changes in the configuration of interfaces as modelled by the proto file \"model/interfaces/interfaces.proto\" and stored in ETCD under the key \"/vnf-agent/{vnf-agent}/linux/config/v1/interface\". Updates received from the northbound API are compared with the Linux network configuration and differences are applied through the Netlink API.\n\n```go\nfunc (plugin *LinuxInterfaceConfigurator) Close() error\n```\nClose stops all goroutines started by linuxplugin\n\n```go\nfunc (plugin *LinuxInterfaceConfigurator) ConfigureLinuxInterface(linuxIf *interfaces.LinuxInterfaces_Interface) error\n```\nConfigureLinuxInterface reacts to a new northbound Linux interface config by creating and configuring the interface in the host network stack through Netlink API.\n\n```go\nfunc (plugin *LinuxInterfaceConfigurator) DeleteLinuxInterface(linuxIf *interfaces.LinuxInterfaces_Interface) error\n```\nDeleteLinuxInterface reacts to a removed NB configuration of a Linux interface.\n\n```go\nfunc (plugin *LinuxInterfaceConfigurator) Init(stateChan chan *LinuxInterfaceStateNotification, ifNotif chan *nsplugin.MicroserviceEvent) (err error)\n```\nInit linuxplugin and start go routines.\n\n```go\nfunc (plugin *LinuxInterfaceConfigurator) ModifyLinuxInterface(newLinuxIf, oldLinuxIf *interfaces.LinuxInterfaces_Interface) (err error)\n```\nModifyLinuxInterface applies changes in the NB configuration of a Linux interface into the host network stack through Netlink API.\n\n```go\nfunc (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterfaces_Interface) (errs []error)\n```\nResync writes interfaces to Linux. Interface host name corresponds with Linux host interface name (but name can be different). Resync consists of following steps: 1. Iterate over all NB interfaces. Try to find interface with the same name in required namespace for every NB interface. 2. If interface does not exist, will be created anew 3. If interface exists, it is correlated and modified if needed. Resync configures an initial set of interfaces. Existing Linux interfaces are registered and potentially re-configured.\n\n```go\ntype LinuxInterfaceStateNotification struct {\n\t// contains filtered or unexported fields\n}\n```\nLinuxInterfaceStateNotification aggregates operational status derived from netlink with the details (state) about the interface.\n\n```go\ntype LinuxInterfaceStateUpdater struct {\n\tLog logging.Logger\n\t// contains filtered or unexported fields\n}\n```\nLinuxInterfaceStateUpdater processes all linux interface state data\n\n```go\nfunc (plugin *LinuxInterfaceStateUpdater) Close() error\n```\nClose watcher channel (state chan is closed in LinuxInterfaceConfigurator)\n\n```go\nfunc (plugin *LinuxInterfaceStateUpdater) Init(ctx context.Context, ifIndexes ifaceidx.LinuxIfIndexRW,\n\tstateChan chan *LinuxInterfaceStateNotification, notifChan chan netlink.LinkUpdate, notifDone chan struct{}) error\n```\nInit channels for interface state watcher, start it in separate go routine and subscribe to default namespace\n\n","path":"github.com/emnify/vpp-agent/plugins/linuxplugin/ifplugin","name":"ifplugin","synopsis":"","isRedistributable":true}
