diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..0fbea72603 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.git/ +.gitignore +.gtm/ +.idea/ +.travis.yml +*.md +LICENSE +docs/ +examples/ +k8s/ +cmd/agentctl/agentctl +cmd/vpp-agent/vpp-agent +cmd/vpp-agent-ctl/vpp-agent-ctl \ No newline at end of file diff --git a/.gitignore b/.gitignore index f5ead0714f..7230ca6c10 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,33 @@ -glide.lock +*.pyc +*.so +*.test +*.out + .idea/* -cmd/vpp-agent/vpp-agent -cmd/vpp-agent-grpc/vpp-agent-grpc -cmd/vpp-agent-ctl/vpp-agent-ctl -cmd/agentctl/agentctl -examples/govpp_call/govpp_call -examples/idx_bd_cache/idx_bd_cache -examples/idx_iface_cache/idx_iface_cache -examples/idx_mapping_lookup/idx_mapping_lookup -examples/idx_mapping_watcher/idx_mapping_watcher -examples/idx_veth_cache/idx_veth_cache -examples/localclient_linux/veth/veth -examples/localclient_linux/tap/tap -examples/localclient_vpp/plugins/plugins -examples/localclient_vpp/nat/nat -examples/grpc_vpp/remote_client/remote_client -examples/grpc_vpp/notifications/notifications -tests/perf/log -tests/perf/logresult.zip -tests/robot/variables/jozo_local_variables.robot -*.pyc \ No newline at end of file + +# command binaries +/cmd/agentctl/agentctl +/cmd/vpp-agent/vpp-agent +/cmd/vpp-agent-ctl/vpp-agent-ctl + +# example binaries +/examples/govpp_call/govpp_call +/examples/grpc_vpp/notifications/notifications +/examples/grpc_vpp/remote_client/remote_client +/examples/idx_bd_cache/idx_bd_cache +/examples/idx_iface_cache/idx_iface_cache +/examples/idx_mapping_lookup/idx_mapping_lookup +/examples/idx_mapping_watcher/idx_mapping_watcher +/examples/idx_veth_cache/idx_veth_cache +/examples/localclient_linux/tap/tap +/examples/localclient_linux/veth/veth +/examples/localclient_vpp/nat/nat +/examples/localclient_vpp/plugins/plugins + +# test results +/tests/perf/log +/tests/perf/logresult.zip +/tests/robot/variables/jozo_local_variables.robot + +# vpp directory +/vpp/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b33f36c8ec..368502849d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,38 +1,58 @@ dist: trusty sudo: required + language: go +go: + - "1.10.x" + +go_import_path: github.com/ligato/vpp-agent addons: apt: - update: true - -go_import_path: github.com/ligato/vpp-agent + update: + packages: + - npm git: - depth: 1 + depth: 10 submodules: false -go: - - 1.10.x - cache: + apt: true directories: + - $HOME/.cache/go-build - $HOME/build-cache + - $HOME/.npm + - $(npm config get prefix)/lib/node_modules env: - GO_BUILD_TAGS=mockvpp before_install: + - make travis - make get-linkcheck - make get-linters - - make get-covtools - - go get -v github.com/mattn/goveralls + - make get-dep + - go get github.com/mattn/goveralls script: - make check-links || true - make lint + - make dep-check + - make verify-binapi - make - make test-cover after_success: - goveralls -coverprofile=/tmp/coverage.out -service=travis-ci + +notifications: + slack: + rooms: + - ligato:xLH4aTwGx1dexPaloAegQ74O + on_success: always + on_failure: always + template: + - "Build <%{build_url}|#%{build_number}> of *%{repository_slug}* on branch _%{branch}_ in PR: <%{pull_request_url}|#%{pull_request_number}>" + - "> `%{commit_subject}` _by %{author}_ (<%{compare_url}|%{commit}>)" + - "*%{message}* (_%{duration}_)" diff --git a/CHANGELOG.md b/CHANGELOG.md index a88ffee9d1..a870024665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,41 @@ +# Release v1.5 (2018-07-16) + +## Compatibility +- VPP 18.07-rc0~358-ga5ee900 +- cn-infra v1.4 + +## Breaking Changes +- The package `etcdv3` was renamed to `etcd`, along with it's flag and configuration file. + +## New Features +- [LinuxPlugin](plugins/linux) + * Is now optional and can be disabled via configuration file. +- [ifplugin](plugins/vpp/ifplugin) + * Added support for VxLAN multicast + * Rx-placement can be configured on VPP interfaces +- [IPsec](plugins/vpp/ipsecplugin) + * IPsec UDP encapsulation can now be set (NAT traversal) + + +## Bugfix +- Fixed few issues with parsing VPP metrics from CLI for [Telemetry](plugins/telemetry). +- Fixed bug in GoVPP ocurring after some request timed out, causing + the channel to receive replies from previous request and always returning error. +- Fixed issue which prevented setting interface to non-existing VRF. +- Fixed bug where removal of an af-packet interface caused attached Veth to go DOWN. +- Fixed NAT44 address pool resolution which was not correct in some cases. +- Fixed bug with adding SR policies causing incomplete configuration. + +## Docker Images +- Replace `START_AGENT` with `OMIT_AGENT` to match `RETAIN_SUPERVISOR` + and keep both unset by default. +- Refactored and cleaned up execute scripts and remove unused scripts. +- Fixed some issues with `RETAIN_SUPERVISOR` option. +- Location of supervisord pid file is now explicitely set to + `/run/supervisord.pid` in *supervisord.conf* file. +- The vpp-agent is now started with single flag `--config-dir=/opt/vpp-agent/dev`, + and will automatically load all configuration from that directory. + # Release v1.4.1 (2018-06-11) ## Compatibility @@ -26,19 +64,19 @@ A minor release using newer VPP v18.04 version. * New plugin for collecting telemetry data about VPP metrics and serving them via HTTP server for Prometheus. More information in the [readme](plugins/telemetry/README.md). -- [Ipsecplugin](plugins/defaultplugins/ipsecplugin) +- [Ipsecplugin](plugins/vpp/ipsecplugin) * Now supports tunnel interface for encrypting all the data passing through that interface. -- [GRPC](plugins/defaultplugins/rpc) +- [GRPC](plugins/vpp/rpc) * Vpp-agent itself can act as a GRPC server (no need for external executable) * All configuration types are supported (incl. linux interfaces, routes and ARP) * Client can read VPP notifications via vpp-agent. -- [SR plugin](plugins/defaultplugins/srplugin) +- [SR plugin](plugins/vpp/srplugin) * New plugin with support for Segment Routing. - More information in the [readme](plugins/defaultplugins/srplugin/README.md). + More information in the [readme](plugins/vpp/srplugin/README.md). ## Improvements -- [ifplugin](plugins/defaultplugins/ifplugin) +- [ifplugin](plugins/vpp/ifplugin) * Added support for self-twice-NAT - __vpp-agent-grpc__ executable merged with [vpp-agent](cmd/vpp-agent) command. - [govppmux](plugins/govppmux) @@ -60,8 +98,8 @@ A minor release using newer VPP v18.04 version. * Fixed issue with GoVPP channels returning errors after timeout. * Fixed various issues related to caching and resync in L2 cross-connect * Split horizon group is now correctly assigned if interface is created after bridge domain - * Fixed issue where creation of FIB while interface was not a part of the bridge domain returned - error + * Fixed issue where creation of FIB while interface was not a part of + the bridge domain returned error. ## Other * Overall redundancy cleanup and corrected naming for all proto models. @@ -80,28 +118,28 @@ A minor release using newer VPP v18.04 version. The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github.com/vpp-dev/vpp/tree/stable-1801-contiv). ## New Features -- [ipsecplugin](plugins/defaultplugins/ipsecplugin) +- [ipsecplugin](plugins/vpp/ipsecplugin) * New plugin for IPSec added. The IPSec is supported for VPP only with linux set manually for now. IKEv2 is not yet supported. - More information in the [readme](plugins/defaultplugins/ipsecplugin/README.md). -- [nsplugin](plugins/linuxplugin/nsplugin) + More information in the [readme](plugins/vpp/ipsecplugin/README.md). +- [nsplugin](plugins/linux/nsplugin) * New namespace plugin added. The configurator handles common namespace and microservice processing and communication with other Linux plugins. -- [ifplugin](plugins/defaultplugins/ifplugin) +- [ifplugin](plugins/vpp/ifplugin) * Added support for Network address translation. NAT plugin supports configuration of NAT44 interfaces, address pools and DNAT. - More information in the [readme](plugins/defaultplugins/ifplugin/README.md). + More information in the [readme](plugins/vpp/ifplugin/README.md). * DHCP can now be configured for the interface -- [l2plugin](plugins/defaultplugins/l2plugin) +- [l2plugin](plugins/vpp/l2plugin) * Split-horizon group can be configured for bridge domain interface. -- [l3plugin](plugins/defaultplugins/l3plugin) +- [l3plugin](plugins/vpp/l3plugin) * Added support for proxy ARP. For more information and configuration - example, please see [readme](plugins/defaultplugins/l3plugin/README.md). -- [linux ifplugin](plugins/linuxplugin/ifplugin) + example, please see [readme](plugins/vpp/l3plugin/README.md). +- [linux ifplugin](plugins/linux/ifplugin) * Support for automatic interface configuration (currently only TAP). ## Improvements -- [aclplugin](plugins/defaultplugins/aclplugin) +- [aclplugin](plugins/vpp/aclplugin) * Removed configuration order of interfaces. Access list can be now configured even if interfaces do not exist yet, and add them later. - [vpp-agent-ctl](cmd/vpp-agent-ctl) @@ -109,7 +147,7 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github ## Docker Images * VPP can be build and run in release or debug mode. - Read more information in the [readme](https://github.com/ligato/vpp-agent/blob/pantheon-dev/docker/dev_vpp_agent/README.md). + Read more information in the [readme](https://github.com/ligato/vpp-agent/blob/pantheon-dev/docker/dev/README.md). * Production image is now smaller by roughly 40% (229MB). ## Bugfix @@ -131,17 +169,17 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github - cn-infra v1.1 ### Improvements -- [aclplugin](plugins/defaultplugins/aclplugin) +- [aclplugin](plugins/vpp/aclplugin) * Improved resync of ACL entries. Every new ACL entry is correctly configured in the VPP and all obosolete entries are read and removed. -- [ifplugin](plugins/defaultplugins/ifplugin) +- [ifplugin](plugins/vpp/ifplugin) * Improved resync of interfaces, BFD sessions, authentication keys, echo functions and STN. Better resolution of persistence config for interfaces. -- [l2plugin](plugins/defaultplugins/l2plugin) +- [l2plugin](plugins/vpp/l2plugin) * Improved resync of bridge domains, FIB entries and xConnect pairs. Resync now better correlates configuration present on the VPP with the NB setup. -- (Linux) [ifplugin](plugins/linuxplugin/l3plugin) +- (Linux) [ifplugin](plugins/linux/l3plugin) * ARP does not need the interface to be present on the VPP. Configuration is cached and put to the VPP if requirements are fullfiled. ### Fixes - * __vpp-agent-grpc__ now compiles properly + * [vpp-agent-grpc](cmd/vpp-agent) (removed in 1.4 release, since then it is a part of the vpp-agent) now compiles properly together with other commands. ### Dependencies @@ -151,7 +189,7 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github * VPP compilation now skips building of Java/C++ APIs, this saves build time and final image size. * Development image now runs VPP in debug mode with - various debug options added in [VPP config file](docker/dev_vpp_agent/vpp.conf). + various debug options added in [VPP config file](docker/dev/vpp.conf). ## Bugfix - Fixed interface assignment in ACLs @@ -168,27 +206,27 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github - cn-infra v1.0.8 ### New Features -- [ifplugin](plugins/defaultplugins/ifplugin) +- [ifplugin](plugins/vpp/ifplugin) - added support for un-numbered interfaces. Interface can be marked as un-numbered with information about another interface containing required IP address. Un-numbered interface does not need to have IP address set. - added support for virtio-based TAPv2 interfaces. - interface status is no longer stored in the ETCD by default and it can be turned on using appropriate - setting in defaultplugins.conf. See [readme](plugins/defaultplugins/README.md) for more details. -- [l2plugin](plugins/defaultplugins/l2plugin) + setting in vpp-plugin.conf. See [readme](plugins/vpp/README.md) for more details. +- [l2plugin](plugins/vpp/l2plugin) - bridge domain status is no longer stored in the ETCD by default and it can be turned on using appropriate - setting in defaultplugins.conf. See [readme](plugins/defaultplugins/README.md) for more details. + setting in vpp-plugin.conf. See [readme](plugins/vpp/README.md) for more details. ### Improvements -- [ifplugin](plugins/defaultplugins/ifplugin) +- [ifplugin](plugins/vpp/ifplugin) - default MTU value was removed in order to be able to just pass empty MTU field. MTU now can be - set only in interface configuration (preffered) or defined in defaultplugins.conf. If none of them + set only in interface configuration (preffered) or defined in vpp-plugin.conf. If none of them is set, MTU value will be empty. - interface state data are stored in statuscheck readiness probe -- [l3plugin](plugins/defaultplugins/l3plugin) +- [l3plugin](plugins/vpp/l3plugin) - removed strict configuration order for VPP ARP entries and routes. Both ARP entry or route can be configured without interface already present. -- [l4plugin](plugins/defaultplugins/l4plugin) +- [l4plugin](plugins/vpp/l4plugin) - removed strict configuration order for application namespaces. Application namespace can be configured without interface already present. @@ -196,10 +234,10 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github - added API for ARP entries, L4 features, Application namespaces and STN rules. ### Logging -- consolidated and improved logging in defaultplugins and linuxplugins. +- consolidated and improved logging in vpp and linux plugins. ### Bugfix -- fixed skip-resync parameter if defaultplugins.conf is not provided. +- fixed skip-resync parameter if vpp-plugin.conf is not provided. - corrected af_packet type interface behavior if veth interface is created/removed. - several fixes related to the af_packet and veth interface type configuration. - microservice and veth-interface related events are synchronized. @@ -215,31 +253,31 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github - cn-infra v1.0.7 ### New Features -- [ifplugin](plugins/defaultplugins/ifplugin) +- [ifplugin](plugins/vpp/ifplugin) - ability to configure STN rules. See respective - [readme](plugins/defaultplugins/ifplugin/README.md) in interface plugin for more details. + [readme](plugins/vpp/ifplugin/README.md) in interface plugin for more details. - rx-mode settings can be set on interface. Ethernet-type interface can be set to POLLING mode, other types of interfaces supports also INTERRUPT and ADAPTIVE. Fields to set QueueID/QueueIDValid are also available -- [l4plugin](plugins/defaultplugins/l4plugin) +- [l4plugin](plugins/vpp/l4plugin) - added new l4 plugin to the VPP plugins. It can be used to enable/disable L4 features and configure application namespaces. See respective - [readme](plugins/defaultplugins/l4plugin/README.md) in L4 plugin for more details. + [readme](plugins/vpp/l4plugin/README.md) in L4 plugin for more details. - support for VPP plugins/l3plugin ARP configuration. The configurator can perform the basic CRUD operation with ARP config. -### Defaultplugins -- [ifplugin](plugins/defaultplugins/ifplugin) +### VPP plugin +- [ifplugin](plugins/vpp/ifplugin) - added possibility to add interface to any VRF table. -- [resync](plugins/defaultplugins/data_resync.go) +- [resync](plugins/vpp/data_resync.go) - resync error propagation improved. If any resynced configuration fails, rest of the resync completes and will not be interrupted. All errors which appears during resync are logged after. - added defaultpligins API. - API contains new Method `DisableResync(keyPrefix ...string)`. One or more ETCD key prefixes can be used as a parameter to disable resync for that specific key(s). -### Linuxplugin -- [l3plugin](plugins/linuxplugin/l3plugin) +### Linux plugin +- [l3plugin](plugins/linux/l3plugin) - route configuration do not return error if required interface is missing. Instead, the route data are internally stored and configured when the interface appears. @@ -260,16 +298,16 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github ### Major Themes -- [Default VPP plugin](plugins/defaultplugins) - - added resync strategies. Resync of VPP plugins (defaultplugins) can be set using +- [Default VPP plugin](plugins/vpp) + - added resync strategies. Resync of VPP plugins can be set using defaultpluigns config file; Resync can be set to full (always resync everything) or dependent on VPP configuration (if there is none, skip resync). Resync can be also forced to skip using parameter. See appropriate changelog in - [Defaultplugins](plugins/defaultplugins) for details. + [VPP plugins](plugins/vpp) for details. ### New Features -- [Linuxplugins L3Plugin](plugins/linuxplugin/l3plugin) +- [Linuxplugins L3Plugin](plugins/linux/l3plugin) - added support for basic CRUD operations with static Address resolution protocol entries and static Routes. @@ -280,7 +318,7 @@ The vpp-agent is now using custom VPP branch [stable-1801-contiv](https://github ### Major Themes -- [LinuxPlugin](plugins/linuxplugin) +- [LinuxPlugin](plugins/linux) - Configuration of vEth interfaces modified. Veth configuration defines two names: symbolic used internally and the one used in host OS. `HostIfName` field is optional. If it is not defined, the name in the host OS @@ -339,7 +377,7 @@ Preview of new Kafka client API methods that allows to fill also partition and o ### Major Themes Algorithms for applying northbound configuration (stored in ETCD key value data store) -to VPP in the proper order of VPP binary API calls implemented in [Default VPP plugin](plugins/defaultplugins): +to VPP in the proper order of VPP binary API calls implemented in [Default VPP plugin](plugins/vpp): - network interfaces, especially: - MEMIFs (optimized dataplane network interface tailored for a container to container network connectivity) - VETHs (standard Linux Virtual Ethernet network interface) @@ -349,7 +387,7 @@ to VPP in the proper order of VPP binary API calls implemented in [Default VPP p - L3 IP Routes & VRFs - ACL (Access Control List) -Support for Linux VETH northbound configuration implemented in [Linux Plugin](plugins/linuxplugin) +Support for Linux VETH northbound configuration implemented in [Linux Plugin](plugins/linux) applied in proper order with VPP AF_Packet configuration. Data Synchronization during startup for network interfaces & L2 BD @@ -372,8 +410,8 @@ Miscellaneous: ### Extensibility & integration Ability to extend the behavior of the VPP Agent by creating new plugins on top of [VPP Agent flavor](flavors/vpp). New plugins can access API for configured: -[VPP Network interfaces](plugins/defaultplugins/ifplugin/ifaceidx), -[Bridge domains](plugins/defaultplugins/l2plugin/l2idx) and [VETHs](plugins/linuxplugin/ifplugin/ifaceidx) +[VPP Network interfaces](plugins/vpp/ifplugin/ifaceidx), +[Bridge domains](plugins/vpp/l2plugin/l2idx) and [VETHs](plugins/linux/ifplugin/ifaceidx) based on [idxvpp](idxvpp) threadsafe map tailored for VPP data with advanced features (multiple watchers, secondary indexes). diff --git a/Gopkg.lock b/Gopkg.lock index 3d75e57796..e0eb231745 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -10,10 +10,11 @@ "adapter/vppapiclient", "api", "cmd/binapi-generator", + "codec", "core", "core/bin_api/vpe" ] - revision = "3da2b73ec5ce77abf796ebeae6dfc149c8d3c698" + revision = "f1bef4a3c66f4408afdeb64cda62ccd8562d0fc6" [[projects]] branch = "master" @@ -326,7 +327,7 @@ "datasync/syncbase", "db/keyval", "db/keyval/consul", - "db/keyval/etcdv3", + "db/keyval/etcd", "db/keyval/kvproto", "db/keyval/redis", "db/sql", @@ -356,8 +357,8 @@ "utils/safeclose", "utils/structs" ] - revision = "08a0f1c21c3b06b0a797fbbfe58b6acb7595c666" - version = "v1.3.0" + revision = "99b1f3ef1874097c64653096589cd5c166e37d81" + version = "v1.4.0" [[projects]] branch = "master" @@ -655,6 +656,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "b5e9232659e389b3ee3666d5f809d5994b0564d68d44031d6ef3b8eda3c6049d" + inputs-digest = "52dc7c071cf89d7cbda30b6904f92c012092f798f1f6ce60586f65c535da162a" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index f2086c47a6..f07e669969 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -32,11 +32,11 @@ required = [ [[constraint]] name = "git.fd.io/govpp.git" - revision = "3da2b73ec5ce77abf796ebeae6dfc149c8d3c698" + revision = "f1bef4a3c66f4408afdeb64cda62ccd8562d0fc6" [[constraint]] name = "github.com/ligato/cn-infra" - version = "1.3" + version = "1.4" [[constraint]] branch = "master" diff --git a/Makefile b/Makefile index 25e68d0e59..d3d00c6d28 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,21 @@ -VERSION := $(shell git describe --always --tags --dirty) -COMMIT := $(shell git rev-parse HEAD) +include vpp.env + +VERSION ?= $(shell git describe --always --tags --dirty) +COMMIT ?= $(shell git rev-parse HEAD) DATE := $(shell date +'%Y-%m-%dT%H:%M%:z') -CNINFRA_CORE := github.com/ligato/vpp-agent/vendor/github.com/ligato/cn-infra/core -LDFLAGS = -X $(CNINFRA_CORE).BuildVersion=$(VERSION) -X $(CNINFRA_CORE).CommitHash=$(COMMIT) -X $(CNINFRA_CORE).BuildDate=$(DATE) +CNINFRA := github.com/ligato/vpp-agent/vendor/github.com/ligato/cn-infra/core +LDFLAGS = -X $(CNINFRA).BuildVersion=$(VERSION) -X $(CNINFRA).CommitHash=$(COMMIT) -X $(CNINFRA).BuildDate=$(DATE) -ifeq ($(STRIP), y) +ifeq ($(NOSTRIP),) LDFLAGS += -w -s endif -COVER_DIR ?= /tmp/ +ifeq ($(V),1) +GO_BUILD_ARGS += -v +endif + +COVER_DIR ?= /tmp # Build all build: cmd examples @@ -19,17 +25,17 @@ clean: clean-cmd clean-examples # Install commands install: - @echo "=> installing commands" - go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/vpp-agent - go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/vpp-agent-ctl - go install -v -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ./cmd/agentctl + @echo "=> installing commands ${VERSION}" + go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/vpp-agent + go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/vpp-agent-ctl + go install -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} ./cmd/agentctl # Build commands cmd: - @echo "=> building commands" - cd cmd/vpp-agent && go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" - cd cmd/vpp-agent-ctl && go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" - cd cmd/agentctl && go build -v -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" + @echo "=> building commands ${VERSION}" + cd cmd/vpp-agent && go build -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd cmd/vpp-agent-ctl && go build -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd cmd/agentctl && go build -i -ldflags "${LDFLAGS}" -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} # Clean commands clean-cmd: @@ -41,17 +47,18 @@ clean-cmd: # Build examples examples: @echo "=> building examples" - cd examples/govpp_call && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/idx_bd_cache && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/idx_iface_cache && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/idx_mapping_lookup && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/idx_mapping_watcher && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/localclient_linux/veth && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/localclient_linux/tap && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/localclient_vpp/plugins && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/localclient_vpp/nat && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/grpc_vpp/remote_client && go build -v -i -tags="${GO_BUILD_TAGS}" - cd examples/grpc_vpp/notifications && go build -v -i -tags="${GO_BUILD_TAGS}" + cd examples/govpp_call && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/idx_bd_cache && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/idx_iface_cache && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/idx_mapping_lookup && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/idx_mapping_watcher && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/idx_veth_cache && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/localclient_linux/tap && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/localclient_linux/veth && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/localclient_vpp/nat && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/localclient_vpp/plugins && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/grpc_vpp/remote_client && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} + cd examples/grpc_vpp/notifications && go build -i -tags="${GO_BUILD_TAGS}" ${GO_BUILD_ARGS} # Clean examples clean-examples: @@ -61,115 +68,90 @@ clean-examples: rm -f examples/idx_iface_cache/idx_iface_cache rm -f examples/idx_mapping_lookup/idx_mapping_lookup rm -f examples/idx_mapping_watcher/idx_mapping_watcher - rm -f examples/localclient_linux/veth/veth + rm -f examples/idx_veth_cache/idx_veth_cache rm -f examples/localclient_linux/tap/tap - rm -r examples/localclient_vpp/localclient_vpp + rm -f examples/localclient_linux/veth/veth + rm -f examples/localclient_vpp/nat/nat + rm -f examples/localclient_vpp/plugins/plugins + rm -f examples/grpc_vpp/notifications/notifications + rm -f examples/grpc_vpp/remote_client/remote_client # Run tests test: - @echo "=> running scenario tests" - go test -tags="${GO_BUILD_TAGS}" ./tests/go/itest @echo "=> running unit tests" - go test ./cmd/agentctl/utils - go test ./idxvpp/nametoidx - go test ./plugins/defaultplugins/aclplugin/vppdump - go test ./plugins/defaultplugins/ifplugin - go test ./plugins/defaultplugins/ifplugin/vppcalls - go test ./plugins/defaultplugins/ifplugin/vppdump - go test ./plugins/defaultplugins/l2plugin - go test ./plugins/defaultplugins/l2plugin/l2idx - go test ./plugins/defaultplugins/l2plugin/vppcalls - go test ./plugins/defaultplugins/l2plugin/vppdump - go test ./plugins/defaultplugins/rpc - go test ./plugins/defaultplugins/srplugin - go test ./plugins/defaultplugins/srplugin/vppcalls - -# Get coverage report tools -get-covtools: - go get -v github.com/wadey/gocovmerge + go test -tags="${GO_BUILD_TAGS}" ./... # Run coverage report -test-cover: get-covtools - @echo "=> running unit tests with coverage analysis" - go test -covermode=count -coverprofile=${COVER_DIR}coverage_scenario.out -tags="${GO_BUILD_TAGS}" ./tests/go/itest - go test -covermode=count -coverprofile=${COVER_DIR}coverage_unit1.out ./cmd/agentctl/utils - go test -covermode=count -coverprofile=${COVER_DIR}coverage_unit2.out ./idxvpp/nametoidx - go test -covermode=count -coverprofile=${COVER_DIR}coverage_aclplugin_vppdump.out ./plugins/defaultplugins/aclplugin/vppdump - go test -covermode=count -coverprofile=${COVER_DIR}coverage_ifplugin.out -tags=mockvpp ./plugins/defaultplugins/ifplugin - go test -covermode=count -coverprofile=${COVER_DIR}coverage_ifplugin_vppcalls.out ./plugins/defaultplugins/ifplugin/vppcalls - go test -covermode=count -coverprofile=${COVER_DIR}coverage_ifplugin_vppdump.out ./plugins/defaultplugins/ifplugin/vppdump - go test -covermode=count -coverprofile=${COVER_DIR}coverage_l2plugin.out -tags=mockvpp ./plugins/defaultplugins/l2plugin - go test -covermode=count -coverprofile=${COVER_DIR}coverage_l2plugin_l2idx.out ./plugins/defaultplugins/l2plugin/l2idx - go test -covermode=count -coverprofile=${COVER_DIR}coverage_l2plugin_vppcalls.out ./plugins/defaultplugins/l2plugin/vppcalls - go test -covermode=count -coverprofile=${COVER_DIR}coverage_l2plugin_vppdump.out ./plugins/defaultplugins/l2plugin/vppdump - go test -covermode=count -coverprofile=${COVER_DIR}coverage_rpc.out ./plugins/defaultplugins/rpc - go test -covermode=count -coverprofile=${COVER_DIR}coverage_srplugin.out -tags="${GO_BUILD_TAGS}" ./plugins/defaultplugins/srplugin - go test -covermode=count -coverprofile=${COVER_DIR}coverage_srplugin_vppcalls.out -tags="${GO_BUILD_TAGS}" ./plugins/defaultplugins/srplugin/vppcalls - @echo "=> merging coverage results" - gocovmerge \ - ${COVER_DIR}coverage_scenario.out \ - ${COVER_DIR}coverage_unit1.out \ - ${COVER_DIR}coverage_unit2.out \ - ${COVER_DIR}coverage_aclplugin_vppdump.out \ - ${COVER_DIR}coverage_ifplugin.out \ - ${COVER_DIR}coverage_ifplugin_vppcalls.out \ - ${COVER_DIR}coverage_ifplugin_vppdump.out \ - ${COVER_DIR}coverage_l2plugin.out \ - ${COVER_DIR}coverage_l2plugin_l2idx.out \ - ${COVER_DIR}coverage_l2plugin_vppcalls.out \ - ${COVER_DIR}coverage_l2plugin_vppdump.out \ - ${COVER_DIR}coverage_rpc.out \ - ${COVER_DIR}coverage_srplugin.out \ - ${COVER_DIR}coverage_srplugin_vppcalls.out \ - > ${COVER_DIR}coverage.out - @echo "=> coverage data generated into ${COVER_DIR}coverage.out" +test-cover: + @echo "=> running unit tests with coverage" + go test -tags="${GO_BUILD_TAGS}" -covermode=count -coverprofile=${COVER_DIR}/coverage.out ./... + @echo "=> coverage data generated into ${COVER_DIR}/coverage.out" test-cover-html: test-cover - go tool cover -html=${COVER_DIR}coverage.out -o ${COVER_DIR}coverage.html - @echo "=> coverage report generated into ${COVER_DIR}coverage.html" + go tool cover -html=${COVER_DIR}/coverage.out -o ${COVER_DIR}/coverage.html + @echo "=> coverage report generated into ${COVER_DIR}/coverage.html" test-cover-xml: test-cover - gocov convert ${COVER_DIR}coverage.out | gocov-xml > ${COVER_DIR}coverage.xml - @echo "=> coverage report generated into ${COVER_DIR}coverage.xml" + gocov convert ${COVER_DIR}/coverage.out | gocov-xml > ${COVER_DIR}/coverage.xml + @echo "=> coverage report generated into ${COVER_DIR}/coverage.xml" + +# Code generation +generate: generate-proto generate-binapi # Get generator tools -get-generators: - go install -v ./vendor/github.com/gogo/protobuf/protoc-gen-gogo - go install -v ./vendor/git.fd.io/govpp.git/cmd/binapi-generator - go install -v ./vendor/github.com/ungerik/pkgreflect - -# Generate sources -generate: get-generators - @echo "=> generating sources" - cd plugins/linuxplugin && go generate - cd plugins/defaultplugins/aclplugin && go generate - cd plugins/defaultplugins/ifplugin && go generate - cd plugins/defaultplugins/ipsecplugin && go generate - cd plugins/defaultplugins/l2plugin && go generate - cd plugins/defaultplugins/l3plugin && go generate - cd plugins/defaultplugins/l4plugin && go generate - cd plugins/defaultplugins/srplugin && go generate - cd plugins/defaultplugins/rpc && go generate - cd plugins/linuxplugin/ifplugin && go generate - cd plugins/linuxplugin/l3plugin && go generate - cd plugins/defaultplugins/common/bin_api/acl && pkgreflect - cd plugins/defaultplugins/common/bin_api/af_packet && pkgreflect - cd plugins/defaultplugins/common/bin_api/bfd && pkgreflect - cd plugins/defaultplugins/common/bin_api/dhcp && pkgreflect - cd plugins/defaultplugins/common/bin_api/interfaces && pkgreflect - cd plugins/defaultplugins/common/bin_api/ip && pkgreflect - cd plugins/defaultplugins/common/bin_api/ipsec && pkgreflect - cd plugins/defaultplugins/common/bin_api/l2 && pkgreflect - cd plugins/defaultplugins/common/bin_api/memif && pkgreflect - cd plugins/defaultplugins/common/bin_api/nat && pkgreflect - cd plugins/defaultplugins/common/bin_api/session && pkgreflect - cd plugins/defaultplugins/common/bin_api/stats && pkgreflect - cd plugins/defaultplugins/common/bin_api/stn && pkgreflect - cd plugins/defaultplugins/common/bin_api/tap && pkgreflect - cd plugins/defaultplugins/common/bin_api/tapv2 && pkgreflect - cd plugins/defaultplugins/common/bin_api/vpe && pkgreflect - cd plugins/defaultplugins/common/bin_api/vxlan && pkgreflect - cd plugins/defaultplugins/common/bin_api/sr && pkgreflect +get-proto-generators: + go install ./vendor/github.com/gogo/protobuf/protoc-gen-gogo + +# Generate proto models +generate-proto: get-proto-generators + @echo "=> generating proto" + cd plugins/linux/ifplugin && go generate + cd plugins/linux/l3plugin && go generate + cd plugins/vpp/aclplugin && go generate + cd plugins/vpp/ifplugin && go generate + cd plugins/vpp/ipsecplugin && go generate + cd plugins/vpp/l2plugin && go generate + cd plugins/vpp/l3plugin && go generate + cd plugins/vpp/l4plugin && go generate + cd plugins/vpp/rpc && go generate + cd plugins/vpp/srplugin && go generate + +# Get generator tools +get-binapi-generators: + go install ./vendor/git.fd.io/govpp.git/cmd/binapi-generator + go install ./vendor/github.com/ungerik/pkgreflect + +# Generate binary api +generate-binapi: get-binapi-generators + @echo "=> generating binapi" + cd plugins/vpp/binapi && go generate + cd plugins/vpp/binapi/acl && pkgreflect + cd plugins/vpp/binapi/af_packet && pkgreflect + cd plugins/vpp/binapi/bfd && pkgreflect + cd plugins/vpp/binapi/dhcp && pkgreflect + cd plugins/vpp/binapi/interfaces && pkgreflect + cd plugins/vpp/binapi/ip && pkgreflect + cd plugins/vpp/binapi/ipsec && pkgreflect + cd plugins/vpp/binapi/l2 && pkgreflect + cd plugins/vpp/binapi/memif && pkgreflect + cd plugins/vpp/binapi/nat && pkgreflect + cd plugins/vpp/binapi/session && pkgreflect + cd plugins/vpp/binapi/sr && pkgreflect + cd plugins/vpp/binapi/stats && pkgreflect + cd plugins/vpp/binapi/stn && pkgreflect + cd plugins/vpp/binapi/tap && pkgreflect + cd plugins/vpp/binapi/tapv2 && pkgreflect + cd plugins/vpp/binapi/vpe && pkgreflect + cd plugins/vpp/binapi/vxlan && pkgreflect + @echo "=> applying patches" + patch -p1 -i plugins/vpp/binapi/*.patch + +verify-binapi: + @echo "=> verifying binary api" + docker build -f docker/dev/Dockerfile \ + --build-arg VPP_REPO_URL=${VPP_REPO_URL} \ + --build-arg VPP_COMMIT=${VPP_COMMIT} \ + --target verify-stage . get-bindata: go get -v github.com/jteeuwen/go-bindata/... @@ -181,17 +163,22 @@ bindata: get-bindata # Get dependency manager tool get-dep: go get -v github.com/golang/dep/cmd/dep + dep version # Install the project's dependencies dep-install: get-dep @echo "=> installing project's dependencies" - dep ensure + dep ensure -v # Update the locked versions of all dependencies dep-update: get-dep @echo "=> updating all dependencies" dep ensure -update +# Check state of dependencies +dep-check: get-dep + dep ensure -dry-run -no-vendor + # Get linter tools get-linters: @echo "=> installing linters" @@ -217,10 +204,26 @@ get-linkcheck: check-links: get-linkcheck ./scripts/check_links.sh +# Travis +travis: + @echo "=> TRAVIS: $$TRAVIS_BUILD_STAGE_NAME" + @echo "Build: #$$TRAVIS_BUILD_NUMBER ($$TRAVIS_BUILD_ID)" + @echo "Job: #$$TRAVIS_JOB_NUMBER ($$TRAVIS_JOB_ID)" + @echo "AllowFailure: $$TRAVIS_ALLOW_FAILURE TestResult: $$TRAVIS_TEST_RESULT" + @echo "Type: $$TRAVIS_EVENT_TYPE PullRequest: $$TRAVIS_PULL_REQUEST" + @echo "Repo: $$TRAVIS_REPO_SLUG Branch: $$TRAVIS_BRANCH" + @echo "Commit: $$TRAVIS_COMMIT" + @echo "$$TRAVIS_COMMIT_MESSAGE" + @echo "Range: $$TRAVIS_COMMIT_RANGE" + @echo "Files:" + @echo "$$(git diff --name-only $$TRAVIS_COMMIT_RANGE)" + + .PHONY: build clean \ install cmd examples clean-examples test \ - get-covtools test-cover test-cover-html test-cover-xml \ - get-generators generate \ - get-dep dep-install dep-update \ + test-cover test-cover-html test-cover-xml \ + generate genereate-binapi generate-proto get-binapi-generators get-proto-generators \ + get-dep dep-install dep-update dep-check \ get-linters lint format \ - get-linkcheck check-links + get-linkcheck check-links \ + travis diff --git a/README.md b/README.md index 052245fbd7..92342c3718 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ The set of plugins in the VPP Agent is as follows: * [CN-Infra datasync][12] - data synchronization after HA events * [CN-Infra core][13] - lifecycle management of plugins (loading, initialization, unloading) -* [RESTAPI](plugins/restplugin) - allows to run VPP CLI commands and also provides API to expose existing Northbound objects +* [RESTAPI](plugins/rest) - allows to run VPP CLI commands and also provides API to expose existing Northbound objects ## Tools @@ -107,7 +107,7 @@ docker exec -it vpp vppctl -s localhost:5002 GoDoc can be browsed [online](https://godoc.org/github.com/ligato/vpp-agent). ## Next Steps -Read the README for the [Development Docker Image](docker/dev_vpp_agent/README.md) for more details. +Read the README for the [Development Docker Image](docker/dev/README.md) for more details. #### Deployment: [![K8s integration](docs/imgs/k8s_deployment_thumb.png "VPP Agent - K8s integration")](docs/Deployment.md) @@ -122,15 +122,15 @@ If you are interested in contributing, please see the [contribution guidelines]( [2]: https://github.com/ligato/cn-infra/blob/master/docs/readmes/cn_virtual_function.md [3]: https://developers.google.com/protocol-buffers/ [4]: https://wiki.fd.io/view/GoVPP -[5]: plugins/defaultplugins -[6]: plugins/defaultplugins/ifplugin -[7]: plugins/defaultplugins/l2plugin -[8]: plugins/defaultplugins/l3plugin -[9]: plugins/defaultplugins/aclplugin +[5]: plugins/vpp +[6]: plugins/vpp/ifplugin +[7]: plugins/vpp/l2plugin +[8]: plugins/vpp/l3plugin +[9]: plugins/vpp/aclplugin [10]: plugins/govppmux -[11]: plugins/linuxplugin +[11]: plugins/linux [12]: https://github.com/ligato/cn-infra/tree/master/datasync [13]: https://github.com/ligato/cn-infra/tree/master/core [14]: https://hub.docker.com/r/ligato/vpp-agent/ -[15]: docker/dev_vpp_agent/README.md#running-etcd-server-on-local-host +[15]: docker/dev/README.md#running-etcd-server-on-local-host [16]: https://github.com/ligato/cn-infra \ No newline at end of file diff --git a/clientv1/defaultplugins/doc.go b/clientv1/defaultplugins/doc.go deleted file mode 100644 index 7c7c665955..0000000000 --- a/clientv1/defaultplugins/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package defaultplugins contains clients for local and remote management -// of VPP configuration via default plugins. -package defaultplugins diff --git a/clientv1/linux/data_change_api.go b/clientv1/linux/data_change_api.go index d230aba3ed..450be6f55a 100644 --- a/clientv1/linux/data_change_api.go +++ b/clientv1/linux/data_change_api.go @@ -12,20 +12,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -package linux +package linuxclient import ( - vpp_clientv1 "github.com/ligato/vpp-agent/clientv1/defaultplugins" - vpp_acl "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - vpp_bfd "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - vpp_intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - vpp_l2 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - vpp_l3 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - vpp_l4 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - vpp_stn "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + vpp_clientv1 "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + "github.com/ligato/vpp-agent/plugins/linux/model/l3" + vpp_acl "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + vpp_bfd "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + vpp_intf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + vpp_l2 "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + vpp_l3 "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + vpp_l4 "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + vpp_stn "github.com/ligato/vpp-agent/plugins/vpp/model/stn" ) // DataChangeDSL defines the Domain Specific Language (DSL) for data change diff --git a/clientv1/linux/data_resync_api.go b/clientv1/linux/data_resync_api.go index 67c4b84b8e..ed59579020 100644 --- a/clientv1/linux/data_resync_api.go +++ b/clientv1/linux/data_resync_api.go @@ -12,21 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -package linux +package linuxclient import ( - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" - vpp_clientv1 "github.com/ligato/vpp-agent/clientv1/defaultplugins" - vpp_acl "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - vpp_bfd "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - vpp_intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - vpp_l2 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - vpp_l3 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - vpp_l4 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - vpp_stn "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + vpp_clientv1 "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/plugins/linux/model/l3" + vpp_acl "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + vpp_bfd "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + vpp_intf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + vpp_l2 "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + vpp_l3 "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + vpp_l4 "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + vpp_stn "github.com/ligato/vpp-agent/plugins/vpp/model/stn" ) // DataResyncDSL defines the Domain Specific Language (DSL) for data RESYNC diff --git a/clientv1/linux/dbadapter/data_change_db.go b/clientv1/linux/dbadapter/data_change_db.go index 6ce165f911..ae2f38371c 100644 --- a/clientv1/linux/dbadapter/data_change_db.go +++ b/clientv1/linux/dbadapter/data_change_db.go @@ -17,28 +17,28 @@ package dbadapter import ( "github.com/ligato/cn-infra/db/keyval" "github.com/ligato/vpp-agent/clientv1/linux" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - - vpp_clientv1 "github.com/ligato/vpp-agent/clientv1/defaultplugins" - vpp_dbadapter "github.com/ligato/vpp-agent/clientv1/defaultplugins/dbadapter" - vpp_acl "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - vpp_bfd "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - vpp_intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - vpp_l2 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - vpp_l3 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - vpp_l4 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - vpp_stn "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" - - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + + "github.com/ligato/vpp-agent/clientv1/vpp/dbadapter" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" + + "github.com/ligato/vpp-agent/clientv1/vpp" + linuxIf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + linuxL3 "github.com/ligato/vpp-agent/plugins/linux/model/l3" ) // NewDataChangeDSL returns a new instance of DataChangeDSL which implements // the data change DSL for both Linux and VPP config (inherits dbadapter -// from defaultplugins). +// from vppplugin). // Transaction is used to propagate changes to plugins. func NewDataChangeDSL(txn keyval.ProtoTxn) *DataChangeDSL { - vppDbAdapter := vpp_dbadapter.NewDataChangeDSL(txn) + vppDbAdapter := dbadapter.NewDataChangeDSL(txn) return &DataChangeDSL{txn: txn, vppDataChange: vppDbAdapter} } @@ -46,302 +46,302 @@ func NewDataChangeDSL(txn keyval.ProtoTxn) *DataChangeDSL { // for changes of both Linux and VPP configuration. type DataChangeDSL struct { txn keyval.ProtoTxn - vppDataChange vpp_clientv1.DataChangeDSL + vppDataChange vppclient.DataChangeDSL } // PutDSL implements put operations of data change DSL. type PutDSL struct { parent *DataChangeDSL - vppPut vpp_clientv1.PutDSL + vppPut vppclient.PutDSL } // DeleteDSL implements delete operations of data change DSL. type DeleteDSL struct { parent *DataChangeDSL - vppDelete vpp_clientv1.DeleteDSL + vppDelete vppclient.DeleteDSL } // Put initiates a chained sequence of data change DSL statements and declares // new configurable objects or changes existing ones. -func (dsl *DataChangeDSL) Put() linux.PutDSL { +func (dsl *DataChangeDSL) Put() linuxclient.PutDSL { return &PutDSL{dsl, dsl.vppDataChange.Put()} } // Delete initiates a chained sequence of data change DSL statements // removing existing configurable objects. -func (dsl *DataChangeDSL) Delete() linux.DeleteDSL { +func (dsl *DataChangeDSL) Delete() linuxclient.DeleteDSL { return &DeleteDSL{dsl, dsl.vppDataChange.Delete()} } // Send propagates requested changes to the plugins. -func (dsl *DataChangeDSL) Send() vpp_clientv1.Reply { +func (dsl *DataChangeDSL) Send() vppclient.Reply { return dsl.vppDataChange.Send() } // LinuxInterface adds a request to create or update Linux network interface. -func (dsl *PutDSL) LinuxInterface(val *interfaces.LinuxInterfaces_Interface) linux.PutDSL { - dsl.parent.txn.Put(interfaces.InterfaceKey(val.Name), val) +func (dsl *PutDSL) LinuxInterface(val *linuxIf.LinuxInterfaces_Interface) linuxclient.PutDSL { + dsl.parent.txn.Put(linuxIf.InterfaceKey(val.Name), val) return dsl } // LinuxArpEntry adds a request to create or update Linux ARP entry. -func (dsl *PutDSL) LinuxArpEntry(val *l3.LinuxStaticArpEntries_ArpEntry) linux.PutDSL { - dsl.parent.txn.Put(l3.StaticArpKey(val.Name), val) +func (dsl *PutDSL) LinuxArpEntry(val *linuxL3.LinuxStaticArpEntries_ArpEntry) linuxclient.PutDSL { + dsl.parent.txn.Put(linuxL3.StaticArpKey(val.Name), val) return dsl } // LinuxRoute adds a request to create or update Linux route. -func (dsl *PutDSL) LinuxRoute(val *l3.LinuxStaticRoutes_Route) linux.PutDSL { - dsl.parent.txn.Put(l3.StaticRouteKey(val.Name), val) +func (dsl *PutDSL) LinuxRoute(val *linuxL3.LinuxStaticRoutes_Route) linuxclient.PutDSL { + dsl.parent.txn.Put(linuxL3.StaticRouteKey(val.Name), val) return dsl } // VppInterface adds a request to create or update VPP network interface. -func (dsl *PutDSL) VppInterface(val *vpp_intf.Interfaces_Interface) linux.PutDSL { +func (dsl *PutDSL) VppInterface(val *interfaces.Interfaces_Interface) linuxclient.PutDSL { dsl.vppPut.Interface(val) return dsl } // BfdSession adds a request to create or update VPP bidirectional forwarding // detection session. -func (dsl *PutDSL) BfdSession(val *vpp_bfd.SingleHopBFD_Session) linux.PutDSL { +func (dsl *PutDSL) BfdSession(val *bfd.SingleHopBFD_Session) linuxclient.PutDSL { dsl.vppPut.BfdSession(val) return dsl } // BfdAuthKeys adds a request to create or update VPP bidirectional forwarding // detection key. -func (dsl *PutDSL) BfdAuthKeys(val *vpp_bfd.SingleHopBFD_Key) linux.PutDSL { +func (dsl *PutDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) linuxclient.PutDSL { dsl.vppPut.BfdAuthKeys(val) return dsl } // BfdEchoFunction adds a request to create or update VPP bidirectional forwarding // detection echo function. -func (dsl *PutDSL) BfdEchoFunction(val *vpp_bfd.SingleHopBFD_EchoFunction) linux.PutDSL { +func (dsl *PutDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) linuxclient.PutDSL { dsl.vppPut.BfdEchoFunction(val) return dsl } // BD adds a request to create or update VPP Bridge Domain. -func (dsl *PutDSL) BD(val *vpp_l2.BridgeDomains_BridgeDomain) linux.PutDSL { +func (dsl *PutDSL) BD(val *l2.BridgeDomains_BridgeDomain) linuxclient.PutDSL { dsl.vppPut.BD(val) return dsl } // BDFIB adds a request to create or update VPP L2 Forwarding Information Base. -func (dsl *PutDSL) BDFIB(fib *vpp_l2.FibTable_FibEntry) linux.PutDSL { +func (dsl *PutDSL) BDFIB(fib *l2.FibTable_FibEntry) linuxclient.PutDSL { dsl.vppPut.BDFIB(fib) return dsl } // XConnect adds a request to create or update VPP Cross Connect. -func (dsl *PutDSL) XConnect(val *vpp_l2.XConnectPairs_XConnectPair) linux.PutDSL { +func (dsl *PutDSL) XConnect(val *l2.XConnectPairs_XConnectPair) linuxclient.PutDSL { dsl.vppPut.XConnect(val) return dsl } // StaticRoute adds a request to create or update VPP L3 Static Route. -func (dsl *PutDSL) StaticRoute(val *vpp_l3.StaticRoutes_Route) linux.PutDSL { +func (dsl *PutDSL) StaticRoute(val *l3.StaticRoutes_Route) linuxclient.PutDSL { dsl.vppPut.StaticRoute(val) return dsl } // ACL adds a request to create or update VPP Access Control List. -func (dsl *PutDSL) ACL(acl *vpp_acl.AccessLists_Acl) linux.PutDSL { +func (dsl *PutDSL) ACL(acl *acl.AccessLists_Acl) linuxclient.PutDSL { dsl.vppPut.ACL(acl) return dsl } // Arp adds a request to create or update VPP L3 ARP. -func (dsl *PutDSL) Arp(arp *vpp_l3.ArpTable_ArpEntry) linux.PutDSL { +func (dsl *PutDSL) Arp(arp *l3.ArpTable_ArpEntry) linuxclient.PutDSL { dsl.vppPut.Arp(arp) return dsl } // ProxyArpInterfaces adds a request to create or update VPP L3 proxy ARP interfaces. -func (dsl *PutDSL) ProxyArpInterfaces(arp *vpp_l3.ProxyArpInterfaces_InterfaceList) linux.PutDSL { +func (dsl *PutDSL) ProxyArpInterfaces(arp *l3.ProxyArpInterfaces_InterfaceList) linuxclient.PutDSL { dsl.vppPut.ProxyArpInterfaces(arp) return dsl } // ProxyArpRanges adds a request to create or update VPP L3 proxy ARP ranges -func (dsl *PutDSL) ProxyArpRanges(arp *vpp_l3.ProxyArpRanges_RangeList) linux.PutDSL { +func (dsl *PutDSL) ProxyArpRanges(arp *l3.ProxyArpRanges_RangeList) linuxclient.PutDSL { dsl.vppPut.ProxyArpRanges(arp) return dsl } // L4Features adds a request to enable or disable L4 features -func (dsl *PutDSL) L4Features(val *vpp_l4.L4Features) linux.PutDSL { +func (dsl *PutDSL) L4Features(val *l4.L4Features) linuxclient.PutDSL { dsl.vppPut.L4Features(val) return dsl } // AppNamespace adds a request to create or update VPP Application namespace -func (dsl *PutDSL) AppNamespace(appNs *vpp_l4.AppNamespaces_AppNamespace) linux.PutDSL { +func (dsl *PutDSL) AppNamespace(appNs *l4.AppNamespaces_AppNamespace) linuxclient.PutDSL { dsl.vppPut.AppNamespace(appNs) return dsl } // StnRule adds a request to create or update VPP Stn rule. -func (dsl *PutDSL) StnRule(stn *vpp_stn.STN_Rule) linux.PutDSL { +func (dsl *PutDSL) StnRule(stn *stn.STN_Rule) linuxclient.PutDSL { dsl.vppPut.StnRule(stn) return dsl } // NAT44Global adds a request to set global configuration for NAT44 -func (dsl *PutDSL) NAT44Global(nat44 *nat.Nat44Global) linux.PutDSL { +func (dsl *PutDSL) NAT44Global(nat44 *nat.Nat44Global) linuxclient.PutDSL { dsl.vppPut.NAT44Global(nat44) return dsl } // NAT44DNat adds a request to create a new DNAT configuration -func (dsl *PutDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) linux.PutDSL { +func (dsl *PutDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) linuxclient.PutDSL { dsl.vppPut.NAT44DNat(nat44) return dsl } // Delete changes the DSL mode to allow removal of an existing configuration. -func (dsl *PutDSL) Delete() linux.DeleteDSL { +func (dsl *PutDSL) Delete() linuxclient.DeleteDSL { return &DeleteDSL{dsl.parent, dsl.vppPut.Delete()} } // Send propagates requested changes to the plugins. -func (dsl *PutDSL) Send() vpp_clientv1.Reply { +func (dsl *PutDSL) Send() vppclient.Reply { return dsl.parent.Send() } // LinuxInterface adds a request to delete an existing Linux network // interface. -func (dsl *DeleteDSL) LinuxInterface(interfaceName string) linux.DeleteDSL { +func (dsl *DeleteDSL) LinuxInterface(interfaceName string) linuxclient.DeleteDSL { dsl.parent.txn.Delete(interfaces.InterfaceKey(interfaceName)) return dsl } // LinuxArpEntry adds a request to delete Linux ARP entry. -func (dsl *DeleteDSL) LinuxArpEntry(entryName string) linux.DeleteDSL { - dsl.parent.txn.Delete(l3.StaticArpKey(entryName)) +func (dsl *DeleteDSL) LinuxArpEntry(entryName string) linuxclient.DeleteDSL { + dsl.parent.txn.Delete(linuxL3.StaticArpKey(entryName)) return dsl } // LinuxRoute adds a request to delete Linux route. -func (dsl *DeleteDSL) LinuxRoute(routeName string) linux.DeleteDSL { - dsl.parent.txn.Delete(l3.StaticRouteKey(routeName)) +func (dsl *DeleteDSL) LinuxRoute(routeName string) linuxclient.DeleteDSL { + dsl.parent.txn.Delete(linuxL3.StaticRouteKey(routeName)) return dsl } // VppInterface adds a request to delete an existing VPP network interface. -func (dsl *DeleteDSL) VppInterface(ifaceName string) linux.DeleteDSL { +func (dsl *DeleteDSL) VppInterface(ifaceName string) linuxclient.DeleteDSL { dsl.vppDelete.Interface(ifaceName) return dsl } // BfdSession adds a request to delete an existing VPP bidirectional forwarding // detection session. -func (dsl *DeleteDSL) BfdSession(bfdSessionIfaceName string) linux.DeleteDSL { +func (dsl *DeleteDSL) BfdSession(bfdSessionIfaceName string) linuxclient.DeleteDSL { dsl.vppDelete.BfdSession(bfdSessionIfaceName) return dsl } // BfdAuthKeys adds a request to delete an existing VPP bidirectional forwarding // detection key. -func (dsl *DeleteDSL) BfdAuthKeys(bfdKey string) linux.DeleteDSL { +func (dsl *DeleteDSL) BfdAuthKeys(bfdKey string) linuxclient.DeleteDSL { dsl.vppDelete.BfdAuthKeys(bfdKey) return dsl } // BfdEchoFunction adds a request to delete an existing VPP bidirectional // forwarding detection echo function. -func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) linux.DeleteDSL { +func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) linuxclient.DeleteDSL { dsl.vppDelete.BfdEchoFunction(bfdEchoName) return dsl } // BD adds a request to delete an existing VPP Bridge Domain. -func (dsl *DeleteDSL) BD(bdName string) linux.DeleteDSL { +func (dsl *DeleteDSL) BD(bdName string) linuxclient.DeleteDSL { dsl.vppDelete.BD(bdName) return dsl } // BDFIB adds a request to delete an existing VPP L2 Forwarding Information Base. -func (dsl *DeleteDSL) BDFIB(bdName string, mac string) linux.DeleteDSL { +func (dsl *DeleteDSL) BDFIB(bdName string, mac string) linuxclient.DeleteDSL { dsl.vppDelete.BDFIB(bdName, mac) return dsl } // XConnect adds a request to delete an existing VPP Cross Connect. -func (dsl *DeleteDSL) XConnect(rxIfaceName string) linux.DeleteDSL { +func (dsl *DeleteDSL) XConnect(rxIfaceName string) linuxclient.DeleteDSL { dsl.vppDelete.XConnect(rxIfaceName) return dsl } // StaticRoute adds a request to delete an existing VPP L3 Static Route. -func (dsl *DeleteDSL) StaticRoute(vrf uint32, dstAddr string, nextHopAddr string) linux.DeleteDSL { +func (dsl *DeleteDSL) StaticRoute(vrf uint32, dstAddr string, nextHopAddr string) linuxclient.DeleteDSL { dsl.vppDelete.StaticRoute(vrf, dstAddr, nextHopAddr) return dsl } // ACL adds a request to delete an existing VPP Access Control List. -func (dsl *DeleteDSL) ACL(aclName string) linux.DeleteDSL { +func (dsl *DeleteDSL) ACL(aclName string) linuxclient.DeleteDSL { dsl.vppDelete.ACL(aclName) return dsl } // L4Features adds a request to enable or disable L4 features -func (dsl *DeleteDSL) L4Features() linux.DeleteDSL { +func (dsl *DeleteDSL) L4Features() linuxclient.DeleteDSL { dsl.vppDelete.L4Features() return dsl } // AppNamespace adds a request to delete VPP Application namespace // Note: current version does not support application namespace deletion -func (dsl *DeleteDSL) AppNamespace(id string) linux.DeleteDSL { +func (dsl *DeleteDSL) AppNamespace(id string) linuxclient.DeleteDSL { dsl.vppDelete.AppNamespace(id) return dsl } // Arp adds a request to delete an existing VPP L3 ARP. -func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) linux.DeleteDSL { +func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) linuxclient.DeleteDSL { dsl.vppDelete.Arp(ifaceName, ipAddr) return dsl } // ProxyArpInterfaces adds a request to delete an existing VPP L3 proxy ARP interfaces -func (dsl *DeleteDSL) ProxyArpInterfaces(label string) linux.DeleteDSL { +func (dsl *DeleteDSL) ProxyArpInterfaces(label string) linuxclient.DeleteDSL { dsl.vppDelete.ProxyArpInterfaces(label) return dsl } // ProxyArpRanges adds a request to delete an existing VPP L3 proxy ARP ranges -func (dsl *DeleteDSL) ProxyArpRanges(label string) linux.DeleteDSL { +func (dsl *DeleteDSL) ProxyArpRanges(label string) linuxclient.DeleteDSL { dsl.vppDelete.ProxyArpRanges(label) return dsl } // StnRule adds a request to delete an existing VPP Stn rule. -func (dsl *DeleteDSL) StnRule(ruleName string) linux.DeleteDSL { +func (dsl *DeleteDSL) StnRule(ruleName string) linuxclient.DeleteDSL { dsl.vppDelete.StnRule(ruleName) return dsl } // NAT44Global adds a request to remove global configuration for NAT44 -func (dsl *DeleteDSL) NAT44Global() linux.DeleteDSL { +func (dsl *DeleteDSL) NAT44Global() linuxclient.DeleteDSL { dsl.vppDelete.NAT44Global() return dsl } // NAT44DNat adds a request to delete a new DNAT configuration -func (dsl *DeleteDSL) NAT44DNat(label string) linux.DeleteDSL { +func (dsl *DeleteDSL) NAT44DNat(label string) linuxclient.DeleteDSL { dsl.vppDelete.NAT44DNat(label) return dsl } // Put changes the DSL mode to allow configuration editing. -func (dsl *DeleteDSL) Put() linux.PutDSL { +func (dsl *DeleteDSL) Put() linuxclient.PutDSL { return &PutDSL{dsl.parent, dsl.vppDelete.Put()} } // Send propagates requested changes to the plugins. -func (dsl *DeleteDSL) Send() vpp_clientv1.Reply { +func (dsl *DeleteDSL) Send() vppclient.Reply { return dsl.parent.Send() } diff --git a/clientv1/linux/dbadapter/data_resync_db.go b/clientv1/linux/dbadapter/data_resync_db.go index 0fdbf1ac7f..877253f6fe 100644 --- a/clientv1/linux/dbadapter/data_resync_db.go +++ b/clientv1/linux/dbadapter/data_resync_db.go @@ -16,30 +16,31 @@ package dbadapter import ( "github.com/ligato/vpp-agent/clientv1/linux" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - - vpp_clientv1 "github.com/ligato/vpp-agent/clientv1/defaultplugins" - vpp_dbadapter "github.com/ligato/vpp-agent/clientv1/defaultplugins/dbadapter" - vpp_acl "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - vpp_bfd "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - vpp_intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - vpp_l2 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - vpp_l3 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - vpp_l4 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - vpp_stn "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" + + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + + "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + "github.com/ligato/vpp-agent/clientv1/vpp/dbadapter" + linuxIf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + linuxL3 "github.com/ligato/vpp-agent/plugins/linux/model/l3" ) // NewDataResyncDSL returns a new instance of DataResyncDSL which implements // the data RESYNC DSL for both Linux and VPP config (inherits dbadapter -// from defaultplugins). +// from vppplugin). // Transaction is used to propagate changes to plugins. // Function is used to list keys with already existing configuration. func NewDataResyncDSL(txn keyval.ProtoTxn, listKeys func(prefix string) (keyval.ProtoKeyIterator, error)) *DataResyncDSL { - vppDataResync := vpp_dbadapter.NewDataResyncDSL(txn, listKeys) + vppDataResync := dbadapter.NewDataResyncDSL(txn, listKeys) return &DataResyncDSL{txn, []string{}, listKeys, vppDataResync} } @@ -50,12 +51,12 @@ type DataResyncDSL struct { txnKeys []string listKeys func(prefix string) (keyval.ProtoKeyIterator, error) - vppDataResync vpp_clientv1.DataResyncDSL + vppDataResync vppclient.DataResyncDSL } // LinuxInterface adds Linux interface to the RESYNC request. -func (dsl *DataResyncDSL) LinuxInterface(val *interfaces.LinuxInterfaces_Interface) linux.DataResyncDSL { - key := interfaces.InterfaceKey(val.Name) +func (dsl *DataResyncDSL) LinuxInterface(val *linuxIf.LinuxInterfaces_Interface) linuxclient.DataResyncDSL { + key := linuxIf.InterfaceKey(val.Name) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -63,8 +64,8 @@ func (dsl *DataResyncDSL) LinuxInterface(val *interfaces.LinuxInterfaces_Interfa } // LinuxArpEntry adds Linux ARP entry to the RESYNC request. -func (dsl *DataResyncDSL) LinuxArpEntry(val *l3.LinuxStaticArpEntries_ArpEntry) linux.DataResyncDSL { - key := l3.StaticArpKey(val.Name) +func (dsl *DataResyncDSL) LinuxArpEntry(val *linuxL3.LinuxStaticArpEntries_ArpEntry) linuxclient.DataResyncDSL { + key := linuxL3.StaticArpKey(val.Name) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -72,8 +73,8 @@ func (dsl *DataResyncDSL) LinuxArpEntry(val *l3.LinuxStaticArpEntries_ArpEntry) } // LinuxRoute adds Linux route to the RESYNC request. -func (dsl *DataResyncDSL) LinuxRoute(val *l3.LinuxStaticRoutes_Route) linux.DataResyncDSL { - key := l3.StaticRouteKey(val.Name) +func (dsl *DataResyncDSL) LinuxRoute(val *linuxL3.LinuxStaticRoutes_Route) linuxclient.DataResyncDSL { + key := linuxL3.StaticRouteKey(val.Name) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -81,107 +82,107 @@ func (dsl *DataResyncDSL) LinuxRoute(val *l3.LinuxStaticRoutes_Route) linux.Data } // VppInterface adds VPP interface to the RESYNC request. -func (dsl *DataResyncDSL) VppInterface(intf *vpp_intf.Interfaces_Interface) linux.DataResyncDSL { +func (dsl *DataResyncDSL) VppInterface(intf *interfaces.Interfaces_Interface) linuxclient.DataResyncDSL { dsl.vppDataResync.Interface(intf) return dsl } // BfdSession adds VPP bidirectional forwarding detection session // to the RESYNC request. -func (dsl *DataResyncDSL) BfdSession(val *vpp_bfd.SingleHopBFD_Session) linux.DataResyncDSL { +func (dsl *DataResyncDSL) BfdSession(val *bfd.SingleHopBFD_Session) linuxclient.DataResyncDSL { dsl.vppDataResync.BfdSession(val) return dsl } // BfdAuthKeys adds VPP bidirectional forwarding detection key to the RESYNC // request. -func (dsl *DataResyncDSL) BfdAuthKeys(val *vpp_bfd.SingleHopBFD_Key) linux.DataResyncDSL { +func (dsl *DataResyncDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) linuxclient.DataResyncDSL { dsl.vppDataResync.BfdAuthKeys(val) return dsl } // BfdEchoFunction adds VPP bidirectional forwarding detection echo function // to the RESYNC request. -func (dsl *DataResyncDSL) BfdEchoFunction(val *vpp_bfd.SingleHopBFD_EchoFunction) linux.DataResyncDSL { +func (dsl *DataResyncDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) linuxclient.DataResyncDSL { dsl.vppDataResync.BfdEchoFunction(val) return dsl } // BD adds VPP Bridge Domain to the RESYNC request. -func (dsl *DataResyncDSL) BD(bd *vpp_l2.BridgeDomains_BridgeDomain) linux.DataResyncDSL { +func (dsl *DataResyncDSL) BD(bd *l2.BridgeDomains_BridgeDomain) linuxclient.DataResyncDSL { dsl.vppDataResync.BD(bd) return dsl } // BDFIB adds VPP L2 FIB to the RESYNC request. -func (dsl *DataResyncDSL) BDFIB(fib *vpp_l2.FibTable_FibEntry) linux.DataResyncDSL { +func (dsl *DataResyncDSL) BDFIB(fib *l2.FibTable_FibEntry) linuxclient.DataResyncDSL { dsl.vppDataResync.BDFIB(fib) return dsl } // XConnect adds VPP Cross Connect to the RESYNC request. -func (dsl *DataResyncDSL) XConnect(xcon *vpp_l2.XConnectPairs_XConnectPair) linux.DataResyncDSL { +func (dsl *DataResyncDSL) XConnect(xcon *l2.XConnectPairs_XConnectPair) linuxclient.DataResyncDSL { dsl.vppDataResync.XConnect(xcon) return dsl } // StaticRoute adds VPP L3 Static Route to the RESYNC request. -func (dsl *DataResyncDSL) StaticRoute(staticRoute *vpp_l3.StaticRoutes_Route) linux.DataResyncDSL { +func (dsl *DataResyncDSL) StaticRoute(staticRoute *l3.StaticRoutes_Route) linuxclient.DataResyncDSL { dsl.vppDataResync.StaticRoute(staticRoute) return dsl } // ACL adds VPP Access Control List to the RESYNC request. -func (dsl *DataResyncDSL) ACL(acl *vpp_acl.AccessLists_Acl) linux.DataResyncDSL { +func (dsl *DataResyncDSL) ACL(acl *acl.AccessLists_Acl) linuxclient.DataResyncDSL { dsl.vppDataResync.ACL(acl) return dsl } // Arp adds VPP L3 ARP to the RESYNC request. -func (dsl *DataResyncDSL) Arp(arp *vpp_l3.ArpTable_ArpEntry) linux.DataResyncDSL { +func (dsl *DataResyncDSL) Arp(arp *l3.ArpTable_ArpEntry) linuxclient.DataResyncDSL { dsl.vppDataResync.Arp(arp) return dsl } // ProxyArpInterfaces adds L3 proxy ARP interfaces to the RESYNC request. -func (dsl *DataResyncDSL) ProxyArpInterfaces(val *vpp_l3.ProxyArpInterfaces_InterfaceList) linux.DataResyncDSL { +func (dsl *DataResyncDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_InterfaceList) linuxclient.DataResyncDSL { dsl.vppDataResync.ProxyArpInterfaces(val) return dsl } // ProxyArpRanges adds L3 proxy ARP ranges to the RESYNC request. -func (dsl *DataResyncDSL) ProxyArpRanges(val *vpp_l3.ProxyArpRanges_RangeList) linux.DataResyncDSL { +func (dsl *DataResyncDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) linuxclient.DataResyncDSL { dsl.vppDataResync.ProxyArpRanges(val) return dsl } // L4Features adds L4 features to the RESYNC request -func (dsl *DataResyncDSL) L4Features(val *vpp_l4.L4Features) linux.DataResyncDSL { +func (dsl *DataResyncDSL) L4Features(val *l4.L4Features) linuxclient.DataResyncDSL { dsl.vppDataResync.L4Features(val) return dsl } // AppNamespace adds VPP Application namespaces to the RESYNC request -func (dsl *DataResyncDSL) AppNamespace(appNs *vpp_l4.AppNamespaces_AppNamespace) linux.DataResyncDSL { +func (dsl *DataResyncDSL) AppNamespace(appNs *l4.AppNamespaces_AppNamespace) linuxclient.DataResyncDSL { dsl.vppDataResync.AppNamespace(appNs) return dsl } // StnRule adds Stn rule to the RESYNC request. -func (dsl *DataResyncDSL) StnRule(stn *vpp_stn.STN_Rule) linux.DataResyncDSL { +func (dsl *DataResyncDSL) StnRule(stn *stn.STN_Rule) linuxclient.DataResyncDSL { dsl.vppDataResync.StnRule(stn) return dsl } // NAT44Global adds a request to RESYNC global configuration for NAT44 -func (dsl *DataResyncDSL) NAT44Global(nat44 *nat.Nat44Global) linux.DataResyncDSL { +func (dsl *DataResyncDSL) NAT44Global(nat44 *nat.Nat44Global) linuxclient.DataResyncDSL { dsl.vppDataResync.NAT44Global(nat44) return dsl } // NAT44DNat adds a request to RESYNC a new DNAT configuration -func (dsl *DataResyncDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) linux.DataResyncDSL { +func (dsl *DataResyncDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) linuxclient.DataResyncDSL { dsl.vppDataResync.NAT44DNat(nat44) return dsl @@ -206,7 +207,7 @@ type keySet map[string] /*key*/ interface{} /*nil*/ // Send propagates the request to the plugins. // It deletes obsolete keys if listKeys() (from constructor) function is not nil. -func (dsl *DataResyncDSL) Send() vpp_clientv1.Reply { +func (dsl *DataResyncDSL) Send() vppclient.Reply { for dsl.listKeys != nil { toBeDeleted := keySet{} diff --git a/clientv1/linux/doc.go b/clientv1/linux/doc.go index f661f90df7..1cbcb0f927 100644 --- a/clientv1/linux/doc.go +++ b/clientv1/linux/doc.go @@ -1,3 +1,3 @@ -// Package linux contains clients for local and remote management of both +// Package linuxclient contains clients for local and remote management of both // VPP and Linux configuration via Linux and default plugins. -package linux +package linuxclient diff --git a/clientv1/linux/localclient/localclient_api.go b/clientv1/linux/localclient/localclient_api.go index 9f091ae57a..9f585d101a 100644 --- a/clientv1/linux/localclient/localclient_api.go +++ b/clientv1/linux/localclient/localclient_api.go @@ -26,7 +26,7 @@ const PluginID core.PluginName = "LinuxPlugin_LOCAL_CLIENT" // DataResyncRequest allows creating a RESYNC request using convenient RESYNC // DSL and sending it locally through go channels (i.e. without using Data Store). -func DataResyncRequest(caller core.PluginName) linux.DataResyncDSL { +func DataResyncRequest(caller core.PluginName) linuxclient.DataResyncDSL { return dbadapter.NewDataResyncDSL(local.NewProtoTxn(local.Get().PropagateResync), nil /*no need to list anything*/) } @@ -34,6 +34,6 @@ func DataResyncRequest(caller core.PluginName) linux.DataResyncDSL { // DataChangeRequest allows creating Data Change request(s) using convenient // Data Change DSL and sending it locally through go channels (i.e. without using // Data Store). -func DataChangeRequest(caller core.PluginName) linux.DataChangeDSL { +func DataChangeRequest(caller core.PluginName) linuxclient.DataChangeDSL { return dbadapter.NewDataChangeDSL(local.NewProtoTxn(local.Get().PropagateChanges)) } diff --git a/clientv1/linux/remoteclient/remoteclient_api.go b/clientv1/linux/remoteclient/remoteclient_api.go index cf9b0a1211..16c683c8af 100644 --- a/clientv1/linux/remoteclient/remoteclient_api.go +++ b/clientv1/linux/remoteclient/remoteclient_api.go @@ -25,13 +25,13 @@ import ( // User of the API does not need to be aware of keys. // User of the API does not need to delete the obsolete objects/keys // prior to RESYNC - it is handled by DataResyncDSL. -func DataResyncRequestDB(broker keyval.ProtoBroker) linux.DataResyncDSL { +func DataResyncRequestDB(broker keyval.ProtoBroker) linuxclient.DataResyncDSL { return dbadapter.NewDataResyncDSL(broker.NewTxn(), broker.ListKeys) } // DataChangeRequestDB allows creating Data Change requests, using convenient // Data Change DSL and sending it through the provided . // User of the API does not need to be aware of keys. -func DataChangeRequestDB(broker keyval.ProtoBroker) linux.DataChangeDSL { +func DataChangeRequestDB(broker keyval.ProtoBroker) linuxclient.DataChangeDSL { return dbadapter.NewDataChangeDSL(broker.NewTxn()) } diff --git a/clientv1/defaultplugins/data_change_api.go b/clientv1/vpp/data_change_api.go similarity index 91% rename from clientv1/defaultplugins/data_change_api.go rename to clientv1/vpp/data_change_api.go index a937b55baa..1b57fc82b3 100644 --- a/clientv1/defaultplugins/data_change_api.go +++ b/clientv1/vpp/data_change_api.go @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -package defaultplugins +package vppclient import ( - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/ipsec" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" ) // DataChangeDSL defines Domain Specific Language (DSL) for data change. diff --git a/clientv1/defaultplugins/data_resync_api.go b/clientv1/vpp/data_resync_api.go similarity index 83% rename from clientv1/defaultplugins/data_resync_api.go rename to clientv1/vpp/data_resync_api.go index 433256c058..2cb3f46279 100644 --- a/clientv1/defaultplugins/data_resync_api.go +++ b/clientv1/vpp/data_resync_api.go @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -package defaultplugins +package vppclient import ( - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/ipsec" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" ) // DataResyncDSL defines the Domain Specific Language (DSL) for data RESYNC diff --git a/clientv1/defaultplugins/dbadapter/data_change_db.go b/clientv1/vpp/dbadapter/data_change_db.go similarity index 69% rename from clientv1/defaultplugins/dbadapter/data_change_db.go rename to clientv1/vpp/dbadapter/data_change_db.go index 6c70df5763..f6a556ad97 100644 --- a/clientv1/defaultplugins/dbadapter/data_change_db.go +++ b/clientv1/vpp/dbadapter/data_change_db.go @@ -16,17 +16,17 @@ package dbadapter import ( "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/vpp-agent/clientv1/defaultplugins" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" + "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + intf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/ipsec" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" ) // NewDataChangeDSL returns a new instance of DataChangeDSL which implements @@ -54,276 +54,276 @@ type DeleteDSL struct { // Put initiates a chained sequence of data change DSL statements declaring // new configurable objects or changing existing ones. -func (dsl *DataChangeDSL) Put() defaultplugins.PutDSL { +func (dsl *DataChangeDSL) Put() vppclient.PutDSL { return &PutDSL{dsl} } // Delete initiates a chained sequence of data change DSL statements // removing existing configurable objects. -func (dsl *DataChangeDSL) Delete() defaultplugins.DeleteDSL { +func (dsl *DataChangeDSL) Delete() vppclient.DeleteDSL { return &DeleteDSL{dsl} } // Send propagates requested changes to the plugins. -func (dsl *DataChangeDSL) Send() defaultplugins.Reply { +func (dsl *DataChangeDSL) Send() vppclient.Reply { err := dsl.txn.Commit() return &Reply{err} } // Interface adds a request to create or update VPP network interface. -func (dsl *PutDSL) Interface(val *interfaces.Interfaces_Interface) defaultplugins.PutDSL { +func (dsl *PutDSL) Interface(val *interfaces.Interfaces_Interface) vppclient.PutDSL { dsl.parent.txn.Put(intf.InterfaceKey(val.Name), val) return dsl } // BfdSession adds a request to create or update bidirectional forwarding // detection session. -func (dsl *PutDSL) BfdSession(val *bfd.SingleHopBFD_Session) defaultplugins.PutDSL { +func (dsl *PutDSL) BfdSession(val *bfd.SingleHopBFD_Session) vppclient.PutDSL { dsl.parent.txn.Put(bfd.SessionKey(val.Interface), val) return dsl } // BfdAuthKeys adds a request to create or update bidirectional forwarding // detection key. -func (dsl *PutDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) defaultplugins.PutDSL { +func (dsl *PutDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) vppclient.PutDSL { dsl.parent.txn.Put(bfd.AuthKeysKey(string(val.Id)), val) return dsl } // BfdEchoFunction adds a request to create or update bidirectional forwarding // detection echo function. -func (dsl *PutDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) defaultplugins.PutDSL { +func (dsl *PutDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) vppclient.PutDSL { dsl.parent.txn.Put(bfd.EchoFunctionKey(val.EchoSourceInterface), val) return dsl } // BD adds a request to create or update VPP Bridge Domain. -func (dsl *PutDSL) BD(val *l2.BridgeDomains_BridgeDomain) defaultplugins.PutDSL { +func (dsl *PutDSL) BD(val *l2.BridgeDomains_BridgeDomain) vppclient.PutDSL { dsl.parent.txn.Put(l2.BridgeDomainKey(val.Name), val) return dsl } // BDFIB adds a request to create or update VPP L2 Forwarding Information Base. -func (dsl *PutDSL) BDFIB(val *l2.FibTable_FibEntry) defaultplugins.PutDSL { +func (dsl *PutDSL) BDFIB(val *l2.FibTable_FibEntry) vppclient.PutDSL { dsl.parent.txn.Put(l2.FibKey(val.BridgeDomain, val.PhysAddress), val) return dsl } // XConnect adds a request to create or update VPP Cross Connect. -func (dsl *PutDSL) XConnect(val *l2.XConnectPairs_XConnectPair) defaultplugins.PutDSL { +func (dsl *PutDSL) XConnect(val *l2.XConnectPairs_XConnectPair) vppclient.PutDSL { dsl.parent.txn.Put(l2.XConnectKey(val.ReceiveInterface), val) return dsl } // StaticRoute adds a request to create or update VPP L3 Static Route. -func (dsl *PutDSL) StaticRoute(val *l3.StaticRoutes_Route) defaultplugins.PutDSL { +func (dsl *PutDSL) StaticRoute(val *l3.StaticRoutes_Route) vppclient.PutDSL { dsl.parent.txn.Put(l3.RouteKey(val.VrfId, val.DstIpAddr, val.NextHopAddr), val) return dsl } // ACL adds a request to create or update VPP Access Control List. -func (dsl *PutDSL) ACL(val *acl.AccessLists_Acl) defaultplugins.PutDSL { +func (dsl *PutDSL) ACL(val *acl.AccessLists_Acl) vppclient.PutDSL { dsl.parent.txn.Put(acl.Key(val.AclName), val) return dsl } // L4Features create or update request for the L4Features -func (dsl *PutDSL) L4Features(val *l4.L4Features) defaultplugins.PutDSL { +func (dsl *PutDSL) L4Features(val *l4.L4Features) vppclient.PutDSL { dsl.parent.txn.Put(l4.FeatureKey(), val) return dsl } // AppNamespace create or update request for the Application Namespaces List -func (dsl *PutDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) defaultplugins.PutDSL { +func (dsl *PutDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) vppclient.PutDSL { dsl.parent.txn.Put(l4.AppNamespacesKey(val.NamespaceId), val) return dsl } // Arp adds a request to create or update VPP L3 ARP entry. -func (dsl *PutDSL) Arp(arp *l3.ArpTable_ArpEntry) defaultplugins.PutDSL { +func (dsl *PutDSL) Arp(arp *l3.ArpTable_ArpEntry) vppclient.PutDSL { dsl.parent.txn.Put(l3.ArpEntryKey(arp.Interface, arp.IpAddress), arp) return dsl } // ProxyArpInterfaces adds a request to create or update VPP L3 proxy ARP interfaces. -func (dsl *PutDSL) ProxyArpInterfaces(arp *l3.ProxyArpInterfaces_InterfaceList) defaultplugins.PutDSL { +func (dsl *PutDSL) ProxyArpInterfaces(arp *l3.ProxyArpInterfaces_InterfaceList) vppclient.PutDSL { dsl.parent.txn.Put(l3.ProxyArpInterfaceKey(arp.Label), arp) return dsl } // ProxyArpRanges adds a request to create or update VPP L3 proxy ARP ranges -func (dsl *PutDSL) ProxyArpRanges(arp *l3.ProxyArpRanges_RangeList) defaultplugins.PutDSL { +func (dsl *PutDSL) ProxyArpRanges(arp *l3.ProxyArpRanges_RangeList) vppclient.PutDSL { dsl.parent.txn.Put(l3.ProxyArpRangeKey(arp.Label), arp) return dsl } // StnRule adds a request to create or update STN rule. -func (dsl *PutDSL) StnRule(val *stn.STN_Rule) defaultplugins.PutDSL { +func (dsl *PutDSL) StnRule(val *stn.STN_Rule) vppclient.PutDSL { dsl.parent.txn.Put(stn.Key(val.RuleName), val) return dsl } // NAT44Global adds a request to set global configuration for NAT44 -func (dsl *PutDSL) NAT44Global(nat44 *nat.Nat44Global) defaultplugins.PutDSL { +func (dsl *PutDSL) NAT44Global(nat44 *nat.Nat44Global) vppclient.PutDSL { dsl.parent.txn.Put(nat.GlobalConfigKey(), nat44) return dsl } // NAT44DNat adds a request to create a new DNAT configuration -func (dsl *PutDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) defaultplugins.PutDSL { +func (dsl *PutDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) vppclient.PutDSL { dsl.parent.txn.Put(nat.DNatKey(nat44.Label), nat44) return dsl } // IPSecSA adds request to create a new Security Association -func (dsl *PutDSL) IPSecSA(sa *ipsec.SecurityAssociations_SA) defaultplugins.PutDSL { +func (dsl *PutDSL) IPSecSA(sa *ipsec.SecurityAssociations_SA) vppclient.PutDSL { dsl.parent.txn.Put(ipsec.SAKey(sa.Name), sa) return dsl } // IPSecSPD adds request to create a new Security Policy Database -func (dsl *PutDSL) IPSecSPD(spd *ipsec.SecurityPolicyDatabases_SPD) defaultplugins.PutDSL { +func (dsl *PutDSL) IPSecSPD(spd *ipsec.SecurityPolicyDatabases_SPD) vppclient.PutDSL { dsl.parent.txn.Put(ipsec.SPDKey(spd.Name), spd) return dsl } // Delete changes the DSL mode to allow removal of an existing configuration. -func (dsl *PutDSL) Delete() defaultplugins.DeleteDSL { +func (dsl *PutDSL) Delete() vppclient.DeleteDSL { return &DeleteDSL{dsl.parent} } // Send propagates requested changes to the plugins. -func (dsl *PutDSL) Send() defaultplugins.Reply { +func (dsl *PutDSL) Send() vppclient.Reply { return dsl.parent.Send() } // Interface adds a request to delete an existing VPP network interface. -func (dsl *DeleteDSL) Interface(interfaceName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) Interface(interfaceName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(intf.InterfaceKey(interfaceName)) return dsl } // BfdSession adds a request to delete an existing bidirectional forwarding // detection session. -func (dsl *DeleteDSL) BfdSession(bfdSessionIfaceName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BfdSession(bfdSessionIfaceName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(bfd.SessionKey(bfdSessionIfaceName)) return dsl } // BfdAuthKeys adds a request to delete an existing bidirectional forwarding // detection key. -func (dsl *DeleteDSL) BfdAuthKeys(bfdKey string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BfdAuthKeys(bfdKey string) vppclient.DeleteDSL { dsl.parent.txn.Delete(bfd.AuthKeysKey(bfdKey)) return dsl } // BfdEchoFunction adds a request to delete an existing bidirectional forwarding // detection echo function. -func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(bfd.EchoFunctionKey(bfdEchoName)) return dsl } // BD adds a request to delete an existing VPP Bridge Domain. -func (dsl *DeleteDSL) BD(bdName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BD(bdName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l2.BridgeDomainKey(bdName)) return dsl } // BDFIB adds a request to delete an existing VPP L2 Forwarding Information // Base. -func (dsl *DeleteDSL) BDFIB(bdName string, mac string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BDFIB(bdName string, mac string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l2.FibKey(bdName, mac)) return dsl } // XConnect adds a request to delete an existing VPP Cross Connect. -func (dsl *DeleteDSL) XConnect(rxIfName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) XConnect(rxIfName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l2.XConnectKey(rxIfName)) return dsl } // StaticRoute adds a request to delete an existing VPP L3 Static Route. -func (dsl *DeleteDSL) StaticRoute(vrf uint32, dstAddr string, nextHopAddr string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) StaticRoute(vrf uint32, dstAddr string, nextHopAddr string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l3.RouteKey(vrf, dstAddr, nextHopAddr)) return dsl } // ACL adds a request to delete an existing VPP Access Control List. -func (dsl *DeleteDSL) ACL(aclName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) ACL(aclName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(acl.Key(aclName)) return dsl } // L4Features delete request for the L4Features -func (dsl *DeleteDSL) L4Features() defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) L4Features() vppclient.DeleteDSL { dsl.parent.txn.Delete(l4.FeatureKey()) return dsl } // Arp adds a request to delete an existing VPP L3 ARP entry. -func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l3.ArpEntryKey(ifaceName, ipAddr)) return dsl } // ProxyArpInterfaces adds a request to delete an existing VPP L3 proxy ARP interfaces -func (dsl *DeleteDSL) ProxyArpInterfaces(label string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) ProxyArpInterfaces(label string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l3.ProxyArpInterfaceKey(label)) return dsl } // ProxyArpRanges adds a request to delete an existing VPP L3 proxy ARP ranges -func (dsl *DeleteDSL) ProxyArpRanges(label string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) ProxyArpRanges(label string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l3.ProxyArpRangeKey(label)) return dsl } // AppNamespace adds a request to delete an existing VPP Application Namespace. -func (dsl *DeleteDSL) AppNamespace(id string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) AppNamespace(id string) vppclient.DeleteDSL { dsl.parent.txn.Delete(l4.AppNamespacesKey(id)) return dsl } // StnRule adds request to delete Stn rule. -func (dsl *DeleteDSL) StnRule(ruleName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) StnRule(ruleName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(stn.Key(ruleName)) return dsl } // NAT44Global adds a request to remove global configuration for NAT44 -func (dsl *DeleteDSL) NAT44Global() defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) NAT44Global() vppclient.DeleteDSL { dsl.parent.txn.Delete(nat.GlobalConfigKey()) return dsl } // NAT44DNat adds a request to delete a new DNAT configuration -func (dsl *DeleteDSL) NAT44DNat(label string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) NAT44DNat(label string) vppclient.DeleteDSL { dsl.parent.txn.Delete(nat.DNatKey(label)) return dsl } // IPSecSA adds request to create a new Security Association -func (dsl *DeleteDSL) IPSecSA(saName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) IPSecSA(saName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(ipsec.SAKey(saName)) return dsl } // IPSecSPD adds request to create a new Security Policy Database -func (dsl *DeleteDSL) IPSecSPD(spdName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) IPSecSPD(spdName string) vppclient.DeleteDSL { dsl.parent.txn.Delete(ipsec.SPDKey(spdName)) return dsl } // Put changes the DSL mode to allow configuration editing. -func (dsl *DeleteDSL) Put() defaultplugins.PutDSL { +func (dsl *DeleteDSL) Put() vppclient.PutDSL { return &PutDSL{dsl.parent} } // Send propagates requested changes to the plugins. -func (dsl *DeleteDSL) Send() defaultplugins.Reply { +func (dsl *DeleteDSL) Send() vppclient.Reply { return dsl.parent.Send() } diff --git a/clientv1/defaultplugins/dbadapter/data_resync_db.go b/clientv1/vpp/dbadapter/data_resync_db.go similarity index 79% rename from clientv1/defaultplugins/dbadapter/data_resync_db.go rename to clientv1/vpp/dbadapter/data_resync_db.go index da070265aa..306a8dac46 100644 --- a/clientv1/defaultplugins/dbadapter/data_resync_db.go +++ b/clientv1/vpp/dbadapter/data_resync_db.go @@ -16,17 +16,17 @@ package dbadapter import ( "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/vpp-agent/clientv1/defaultplugins" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" + "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + intf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/ipsec" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" ) // NewDataResyncDSL returns a new instance of DataResyncDSL which implements @@ -46,7 +46,7 @@ type DataResyncDSL struct { } // Interface adds VPP interface to the RESYNC request. -func (dsl *DataResyncDSL) Interface(val *interfaces.Interfaces_Interface) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) Interface(val *interfaces.Interfaces_Interface) vppclient.DataResyncDSL { key := intf.InterfaceKey(val.Name) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -56,7 +56,7 @@ func (dsl *DataResyncDSL) Interface(val *interfaces.Interfaces_Interface) defaul // BfdSession adds bidirectional forwarding detection session to the RESYNC // request. -func (dsl *DataResyncDSL) BfdSession(val *bfd.SingleHopBFD_Session) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BfdSession(val *bfd.SingleHopBFD_Session) vppclient.DataResyncDSL { key := bfd.SessionKey(val.Interface) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -66,7 +66,7 @@ func (dsl *DataResyncDSL) BfdSession(val *bfd.SingleHopBFD_Session) defaultplugi // BfdAuthKeys adds bidirectional forwarding detection key to the RESYNC // request. -func (dsl *DataResyncDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) vppclient.DataResyncDSL { key := bfd.AuthKeysKey(string(val.Id)) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -76,7 +76,7 @@ func (dsl *DataResyncDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) defaultplugins. // BfdEchoFunction adds bidirectional forwarding detection echo function // to the RESYNC request. -func (dsl *DataResyncDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) vppclient.DataResyncDSL { key := bfd.EchoFunctionKey(val.EchoSourceInterface) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -85,7 +85,7 @@ func (dsl *DataResyncDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) de } // BD adds Bridge Domain to the RESYNC request. -func (dsl *DataResyncDSL) BD(val *l2.BridgeDomains_BridgeDomain) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BD(val *l2.BridgeDomains_BridgeDomain) vppclient.DataResyncDSL { key := l2.BridgeDomainKey(val.Name) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -94,7 +94,7 @@ func (dsl *DataResyncDSL) BD(val *l2.BridgeDomains_BridgeDomain) defaultplugins. } // BDFIB adds Bridge Domain to the RESYNC request. -func (dsl *DataResyncDSL) BDFIB(val *l2.FibTable_FibEntry) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BDFIB(val *l2.FibTable_FibEntry) vppclient.DataResyncDSL { key := l2.FibKey(val.BridgeDomain, val.PhysAddress) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -103,7 +103,7 @@ func (dsl *DataResyncDSL) BDFIB(val *l2.FibTable_FibEntry) defaultplugins.DataRe } // XConnect adds Cross Connect to the RESYNC request. -func (dsl *DataResyncDSL) XConnect(val *l2.XConnectPairs_XConnectPair) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) XConnect(val *l2.XConnectPairs_XConnectPair) vppclient.DataResyncDSL { key := l2.XConnectKey(val.ReceiveInterface) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -112,7 +112,7 @@ func (dsl *DataResyncDSL) XConnect(val *l2.XConnectPairs_XConnectPair) defaultpl } // StaticRoute adds L3 Static Route to the RESYNC request. -func (dsl *DataResyncDSL) StaticRoute(val *l3.StaticRoutes_Route) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) StaticRoute(val *l3.StaticRoutes_Route) vppclient.DataResyncDSL { key := l3.RouteKey(val.VrfId, val.DstIpAddr, val.NextHopAddr) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -121,7 +121,7 @@ func (dsl *DataResyncDSL) StaticRoute(val *l3.StaticRoutes_Route) defaultplugins } // ACL adds Access Control List to the RESYNC request. -func (dsl *DataResyncDSL) ACL(val *acl.AccessLists_Acl) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) ACL(val *acl.AccessLists_Acl) vppclient.DataResyncDSL { key := acl.Key(val.AclName) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -130,7 +130,7 @@ func (dsl *DataResyncDSL) ACL(val *acl.AccessLists_Acl) defaultplugins.DataResyn } // L4Features adds L4Features to the RESYNC request -func (dsl *DataResyncDSL) L4Features(val *l4.L4Features) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) L4Features(val *l4.L4Features) vppclient.DataResyncDSL { key := l4.FeatureKey() dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -139,7 +139,7 @@ func (dsl *DataResyncDSL) L4Features(val *l4.L4Features) defaultplugins.DataResy } // AppNamespace adds Application Namespace to the RESYNC request -func (dsl *DataResyncDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) vppclient.DataResyncDSL { key := l4.AppNamespacesKey(val.NamespaceId) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -148,7 +148,7 @@ func (dsl *DataResyncDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) defau } // ProxyArpInterfaces adds L3 proxy ARP interfaces to the RESYNC request. -func (dsl *DataResyncDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_InterfaceList) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_InterfaceList) vppclient.DataResyncDSL { key := l3.ProxyArpInterfaceKey(val.Label) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -157,7 +157,7 @@ func (dsl *DataResyncDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_Interfac } // ProxyArpRanges adds L3 proxy ARP ranges to the RESYNC request. -func (dsl *DataResyncDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) vppclient.DataResyncDSL { key := l3.ProxyArpRangeKey(val.Label) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -166,7 +166,7 @@ func (dsl *DataResyncDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) defau } // Arp adds L3 ARP entry to the RESYNC request. -func (dsl *DataResyncDSL) Arp(val *l3.ArpTable_ArpEntry) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) Arp(val *l3.ArpTable_ArpEntry) vppclient.DataResyncDSL { key := l3.ArpEntryKey(val.Interface, val.IpAddress) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -175,7 +175,7 @@ func (dsl *DataResyncDSL) Arp(val *l3.ArpTable_ArpEntry) defaultplugins.DataResy } // StnRule adds Stn rule to the RESYNC request. -func (dsl *DataResyncDSL) StnRule(val *stn.STN_Rule) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) StnRule(val *stn.STN_Rule) vppclient.DataResyncDSL { key := stn.Key(val.RuleName) dsl.txn.Put(key, val) dsl.txnKeys = append(dsl.txnKeys, key) @@ -184,7 +184,7 @@ func (dsl *DataResyncDSL) StnRule(val *stn.STN_Rule) defaultplugins.DataResyncDS } // NAT44Global adds a request to RESYNC global configuration for NAT44 -func (dsl *DataResyncDSL) NAT44Global(nat44 *nat.Nat44Global) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) NAT44Global(nat44 *nat.Nat44Global) vppclient.DataResyncDSL { key := nat.GlobalConfigKey() dsl.txn.Put(key, nat44) dsl.txnKeys = append(dsl.txnKeys, key) @@ -193,7 +193,7 @@ func (dsl *DataResyncDSL) NAT44Global(nat44 *nat.Nat44Global) defaultplugins.Dat } // NAT44DNat adds a request to RESYNC a new DNAT configuration -func (dsl *DataResyncDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) vppclient.DataResyncDSL { key := nat.DNatKey(nat44.Label) dsl.txn.Put(key, nat44) dsl.txnKeys = append(dsl.txnKeys, key) @@ -202,7 +202,7 @@ func (dsl *DataResyncDSL) NAT44DNat(nat44 *nat.Nat44DNat_DNatConfig) defaultplug } // IPSecSA adds request to create a new Security Association -func (dsl *DataResyncDSL) IPSecSA(sa *ipsec.SecurityAssociations_SA) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) IPSecSA(sa *ipsec.SecurityAssociations_SA) vppclient.DataResyncDSL { key := ipsec.SAKey(sa.Name) dsl.txn.Put(key, sa) dsl.txnKeys = append(dsl.txnKeys, key) @@ -211,7 +211,7 @@ func (dsl *DataResyncDSL) IPSecSA(sa *ipsec.SecurityAssociations_SA) defaultplug } // IPSecSPD adds request to create a new Security Policy Database -func (dsl *DataResyncDSL) IPSecSPD(spd *ipsec.SecurityPolicyDatabases_SPD) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) IPSecSPD(spd *ipsec.SecurityPolicyDatabases_SPD) vppclient.DataResyncDSL { key := ipsec.SPDKey(spd.Name) dsl.txn.Put(key, spd) dsl.txnKeys = append(dsl.txnKeys, key) @@ -238,7 +238,7 @@ type keySet map[string] /*key*/ interface{} /*nil*/ // Send propagates the request to the plugins. // It deletes obsolete keys if listKeys() (from constructor) function is not nil. -func (dsl *DataResyncDSL) Send() defaultplugins.Reply { +func (dsl *DataResyncDSL) Send() vppclient.Reply { for dsl.listKeys != nil { toBeDeleted := keySet{} diff --git a/clientv1/defaultplugins/dbadapter/doc.go b/clientv1/vpp/dbadapter/doc.go similarity index 100% rename from clientv1/defaultplugins/dbadapter/doc.go rename to clientv1/vpp/dbadapter/doc.go diff --git a/clientv1/vpp/doc.go b/clientv1/vpp/doc.go new file mode 100644 index 0000000000..0f4907c458 --- /dev/null +++ b/clientv1/vpp/doc.go @@ -0,0 +1,3 @@ +// Package vppclient contains clients for local and remote management +// of VPP configuration via default plugins. +package vppclient diff --git a/clientv1/defaultplugins/grpcadapter/data_change_grpc.go b/clientv1/vpp/grpcadapter/data_change_grpc.go similarity index 74% rename from clientv1/defaultplugins/grpcadapter/data_change_grpc.go rename to clientv1/vpp/grpcadapter/data_change_grpc.go index b932995e0e..0de0491a80 100644 --- a/clientv1/defaultplugins/grpcadapter/data_change_grpc.go +++ b/clientv1/vpp/grpcadapter/data_change_grpc.go @@ -17,19 +17,19 @@ package grpcadapter import ( "github.com/gogo/protobuf/proto" "github.com/ligato/cn-infra/logging/logrus" - "github.com/ligato/vpp-agent/clientv1/defaultplugins" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/rpc" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" - linuxIf "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - linuxL3 "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + "github.com/ligato/vpp-agent/clientv1/vpp" + linuxIf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + linuxL3 "github.com/ligato/vpp-agent/plugins/linux/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/ipsec" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + "github.com/ligato/vpp-agent/plugins/vpp/model/rpc" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" "golang.org/x/net/context" ) @@ -57,141 +57,141 @@ type DeleteDSL struct { } // Interface creates or updates the network interface. -func (dsl *PutDSL) Interface(val *interfaces.Interfaces_Interface) defaultplugins.PutDSL { +func (dsl *PutDSL) Interface(val *interfaces.Interfaces_Interface) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // BfdSession creates or updates the bidirectional forwarding detection session. -func (dsl *PutDSL) BfdSession(val *bfd.SingleHopBFD_Session) defaultplugins.PutDSL { +func (dsl *PutDSL) BfdSession(val *bfd.SingleHopBFD_Session) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // BfdAuthKeys creates or updates the bidirectional forwarding detection key. -func (dsl *PutDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) defaultplugins.PutDSL { +func (dsl *PutDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // BfdEchoFunction creates or updates the bidirectional forwarding detection echo function. -func (dsl *PutDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) defaultplugins.PutDSL { +func (dsl *PutDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // BD creates or updates the Bridge Domain. -func (dsl *PutDSL) BD(val *l2.BridgeDomains_BridgeDomain) defaultplugins.PutDSL { +func (dsl *PutDSL) BD(val *l2.BridgeDomains_BridgeDomain) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // BDFIB deletes request for the L2 Forwarding Information Base. -func (dsl *PutDSL) BDFIB(val *l2.FibTable_FibEntry) defaultplugins.PutDSL { +func (dsl *PutDSL) BDFIB(val *l2.FibTable_FibEntry) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // XConnect creates or updates the Cross Connect. -func (dsl *PutDSL) XConnect(val *l2.XConnectPairs_XConnectPair) defaultplugins.PutDSL { +func (dsl *PutDSL) XConnect(val *l2.XConnectPairs_XConnectPair) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // StaticRoute creates or updates the L3 Static Route. -func (dsl *PutDSL) StaticRoute(val *l3.StaticRoutes_Route) defaultplugins.PutDSL { +func (dsl *PutDSL) StaticRoute(val *l3.StaticRoutes_Route) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // ACL creates or updates request for the Access Control List. -func (dsl *PutDSL) ACL(val *acl.AccessLists_Acl) defaultplugins.PutDSL { +func (dsl *PutDSL) ACL(val *acl.AccessLists_Acl) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // L4Features creates or updates the request for the L4Features. -func (dsl *PutDSL) L4Features(val *l4.L4Features) defaultplugins.PutDSL { +func (dsl *PutDSL) L4Features(val *l4.L4Features) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // AppNamespace creates or updates the request for the Application Namespaces List. -func (dsl *PutDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) defaultplugins.PutDSL { +func (dsl *PutDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // Arp adds a request to create or update VPP L3 ARP entry. -func (dsl *PutDSL) Arp(val *l3.ArpTable_ArpEntry) defaultplugins.PutDSL { +func (dsl *PutDSL) Arp(val *l3.ArpTable_ArpEntry) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // ProxyArpInterfaces adds a request to create or update VPP L3 proxy ARP interfaces. -func (dsl *PutDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_InterfaceList) defaultplugins.PutDSL { +func (dsl *PutDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_InterfaceList) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // ProxyArpRanges adds a request to create or update VPP L3 proxy ARP ranges -func (dsl *PutDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) defaultplugins.PutDSL { +func (dsl *PutDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // StnRule adds a request to create or update STN rule. -func (dsl *PutDSL) StnRule(val *stn.STN_Rule) defaultplugins.PutDSL { +func (dsl *PutDSL) StnRule(val *stn.STN_Rule) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // NAT44Global adds a request to set global configuration for NAT44 -func (dsl *PutDSL) NAT44Global(val *nat.Nat44Global) defaultplugins.PutDSL { +func (dsl *PutDSL) NAT44Global(val *nat.Nat44Global) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // NAT44DNat adds a request to create a new DNAT configuration -func (dsl *PutDSL) NAT44DNat(val *nat.Nat44DNat_DNatConfig) defaultplugins.PutDSL { +func (dsl *PutDSL) NAT44DNat(val *nat.Nat44DNat_DNatConfig) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // IPSecSA adds request to create a new Security Association -func (dsl *PutDSL) IPSecSA(val *ipsec.SecurityAssociations_SA) defaultplugins.PutDSL { +func (dsl *PutDSL) IPSecSA(val *ipsec.SecurityAssociations_SA) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // IPSecSPD adds request to create a new Security Policy Database -func (dsl *PutDSL) IPSecSPD(val *ipsec.SecurityPolicyDatabases_SPD) defaultplugins.PutDSL { +func (dsl *PutDSL) IPSecSPD(val *ipsec.SecurityPolicyDatabases_SPD) vppclient.PutDSL { dsl.parent.put = append(dsl.parent.put, val) return dsl } // Put enables creating Interface/BD... -func (dsl *DataChangeDSL) Put() defaultplugins.PutDSL { +func (dsl *DataChangeDSL) Put() vppclient.PutDSL { return &PutDSL{dsl} } // Delete enables deleting Interface/BD... -func (dsl *DataChangeDSL) Delete() defaultplugins.DeleteDSL { +func (dsl *DataChangeDSL) Delete() vppclient.DeleteDSL { return &DeleteDSL{dsl} } // Delete enables deleting Interface/BD... -func (dsl *PutDSL) Delete() defaultplugins.DeleteDSL { +func (dsl *PutDSL) Delete() vppclient.DeleteDSL { return &DeleteDSL{dsl.parent} } // Send propagates changes to the channels. -func (dsl *PutDSL) Send() defaultplugins.Reply { +func (dsl *PutDSL) Send() vppclient.Reply { return dsl.parent.Send() } // Interface deletes request for the network interface. -func (dsl *DeleteDSL) Interface(interfaceName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) Interface(interfaceName string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &interfaces.Interfaces_Interface{ Name: interfaceName, }) @@ -200,7 +200,7 @@ func (dsl *DeleteDSL) Interface(interfaceName string) defaultplugins.DeleteDSL { // BfdSession adds a request to delete an existing bidirectional forwarding // detection session. -func (dsl *DeleteDSL) BfdSession(ifName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BfdSession(ifName string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &bfd.SingleHopBFD_Session{ Interface: ifName, }) @@ -209,7 +209,7 @@ func (dsl *DeleteDSL) BfdSession(ifName string) defaultplugins.DeleteDSL { // BfdAuthKeys adds a request to delete an existing bidirectional forwarding // detection key. -func (dsl *DeleteDSL) BfdAuthKeys(bfdKeyID string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BfdAuthKeys(bfdKeyID string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &bfd.SingleHopBFD_Key{ Name: bfdKeyID, }) @@ -218,7 +218,7 @@ func (dsl *DeleteDSL) BfdAuthKeys(bfdKeyID string) defaultplugins.DeleteDSL { // BfdEchoFunction adds a request to delete an existing bidirectional forwarding // detection echo function. -func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &bfd.SingleHopBFD_EchoFunction{ Name: bfdEchoName, }) @@ -226,7 +226,7 @@ func (dsl *DeleteDSL) BfdEchoFunction(bfdEchoName string) defaultplugins.DeleteD } // BD deletes request for the Bridge Domain. -func (dsl *DeleteDSL) BD(bdName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BD(bdName string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l2.BridgeDomains_BridgeDomain{ Name: bdName, }) @@ -234,7 +234,7 @@ func (dsl *DeleteDSL) BD(bdName string) defaultplugins.DeleteDSL { } // BDFIB deletes request for the L2 Forwarding Information Base. -func (dsl *DeleteDSL) BDFIB(bdName string, mac string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) BDFIB(bdName string, mac string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l2.FibTable_FibEntry{ PhysAddress: mac, BridgeDomain: bdName, @@ -243,7 +243,7 @@ func (dsl *DeleteDSL) BDFIB(bdName string, mac string) defaultplugins.DeleteDSL } // XConnect deletes the Cross Connect. -func (dsl *DeleteDSL) XConnect(rxIfName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) XConnect(rxIfName string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l2.XConnectPairs_XConnectPair{ ReceiveInterface: rxIfName, }) @@ -251,7 +251,7 @@ func (dsl *DeleteDSL) XConnect(rxIfName string) defaultplugins.DeleteDSL { } // StaticRoute deletes the L3 Static Route. -func (dsl *DeleteDSL) StaticRoute(vrf uint32, dstAddr string, nextHopAddr string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) StaticRoute(vrf uint32, dstAddr string, nextHopAddr string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l3.StaticRoutes_Route{ VrfId: vrf, DstIpAddr: dstAddr, @@ -261,7 +261,7 @@ func (dsl *DeleteDSL) StaticRoute(vrf uint32, dstAddr string, nextHopAddr string } // ACL deletes request for Access Control List. -func (dsl *DeleteDSL) ACL(aclName string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) ACL(aclName string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &acl.AccessLists_Acl{ AclName: aclName, }) @@ -269,13 +269,13 @@ func (dsl *DeleteDSL) ACL(aclName string) defaultplugins.DeleteDSL { } // L4Features deletes request for the L4Features. -func (dsl *DeleteDSL) L4Features() defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) L4Features() vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l4.L4Features{}) return dsl } // AppNamespace delets request for the Application Namespaces List. -func (dsl *DeleteDSL) AppNamespace(id string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) AppNamespace(id string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l4.AppNamespaces_AppNamespace{ NamespaceId: id, }) @@ -283,7 +283,7 @@ func (dsl *DeleteDSL) AppNamespace(id string) defaultplugins.DeleteDSL { } // Arp adds a request to delete an existing VPP L3 ARP entry. -func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l3.ArpTable_ArpEntry{ Interface: ifaceName, IpAddress: ipAddr, @@ -292,7 +292,7 @@ func (dsl *DeleteDSL) Arp(ifaceName string, ipAddr string) defaultplugins.Delete } // ProxyArpInterfaces adds a request to delete an existing VPP L3 proxy ARP interfaces -func (dsl *DeleteDSL) ProxyArpInterfaces(label string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) ProxyArpInterfaces(label string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l3.ProxyArpInterfaces_InterfaceList{ Label: label, }) @@ -300,7 +300,7 @@ func (dsl *DeleteDSL) ProxyArpInterfaces(label string) defaultplugins.DeleteDSL } // ProxyArpRanges adds a request to delete an existing VPP L3 proxy ARP ranges -func (dsl *DeleteDSL) ProxyArpRanges(label string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) ProxyArpRanges(label string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &l3.ProxyArpRanges_RangeList{ Label: label, }) @@ -308,7 +308,7 @@ func (dsl *DeleteDSL) ProxyArpRanges(label string) defaultplugins.DeleteDSL { } // StnRule adds request to delete Stn rule. -func (dsl *DeleteDSL) StnRule(name string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) StnRule(name string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &stn.STN_Rule{ RuleName: name, }) @@ -316,13 +316,13 @@ func (dsl *DeleteDSL) StnRule(name string) defaultplugins.DeleteDSL { } // NAT44Global adds a request to remove global configuration for NAT44 -func (dsl *DeleteDSL) NAT44Global() defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) NAT44Global() vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &nat.Nat44Global{}) return dsl } // NAT44DNat adds a request to delete a DNAT configuration -func (dsl *DeleteDSL) NAT44DNat(label string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) NAT44DNat(label string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &nat.Nat44DNat_DNatConfig{ Label: label, }) @@ -330,7 +330,7 @@ func (dsl *DeleteDSL) NAT44DNat(label string) defaultplugins.DeleteDSL { } // IPSecSA adds request to delete a Security Association -func (dsl *DeleteDSL) IPSecSA(name string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) IPSecSA(name string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &ipsec.SecurityAssociations_SA{ Name: name, }) @@ -338,7 +338,7 @@ func (dsl *DeleteDSL) IPSecSA(name string) defaultplugins.DeleteDSL { } // IPSecSPD adds request to delete a Security Policy Database -func (dsl *DeleteDSL) IPSecSPD(name string) defaultplugins.DeleteDSL { +func (dsl *DeleteDSL) IPSecSPD(name string) vppclient.DeleteDSL { dsl.parent.del = append(dsl.parent.del, &ipsec.SecurityPolicyDatabases_SPD{ Name: name, }) @@ -346,17 +346,17 @@ func (dsl *DeleteDSL) IPSecSPD(name string) defaultplugins.DeleteDSL { } // Put enables creating Interface/BD... -func (dsl *DeleteDSL) Put() defaultplugins.PutDSL { +func (dsl *DeleteDSL) Put() vppclient.PutDSL { return &PutDSL{dsl.parent} } // Send propagates changes to the channels. -func (dsl *DeleteDSL) Send() defaultplugins.Reply { +func (dsl *DeleteDSL) Send() vppclient.Reply { return dsl.parent.Send() } // Send propagates changes to the channels. -func (dsl *DataChangeDSL) Send() defaultplugins.Reply { +func (dsl *DataChangeDSL) Send() vppclient.Reply { var wasErr error // Prepare requests with data todo can be scalable diff --git a/clientv1/defaultplugins/grpcadapter/data_resync_grpc.go b/clientv1/vpp/grpcadapter/data_resync_grpc.go similarity index 70% rename from clientv1/defaultplugins/grpcadapter/data_resync_grpc.go rename to clientv1/vpp/grpcadapter/data_resync_grpc.go index 0d0fc174b1..4f61a5687b 100644 --- a/clientv1/defaultplugins/grpcadapter/data_resync_grpc.go +++ b/clientv1/vpp/grpcadapter/data_resync_grpc.go @@ -16,17 +16,17 @@ package grpcadapter import ( "github.com/gogo/protobuf/proto" - "github.com/ligato/vpp-agent/clientv1/defaultplugins" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/rpc" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" + "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/ipsec" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + "github.com/ligato/vpp-agent/plugins/vpp/model/rpc" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" "golang.org/x/net/context" ) @@ -43,122 +43,122 @@ type DataResyncDSL struct { } // Interface adds Bridge Domain to the RESYNC request. -func (dsl *DataResyncDSL) Interface(val *interfaces.Interfaces_Interface) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) Interface(val *interfaces.Interfaces_Interface) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // BfdSession adds BFD session to the RESYNC request. -func (dsl *DataResyncDSL) BfdSession(val *bfd.SingleHopBFD_Session) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BfdSession(val *bfd.SingleHopBFD_Session) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // BfdAuthKeys adds BFD key to the RESYNC request. -func (dsl *DataResyncDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BfdAuthKeys(val *bfd.SingleHopBFD_Key) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // BfdEchoFunction adds BFD echo function to the RESYNC request. -func (dsl *DataResyncDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BfdEchoFunction(val *bfd.SingleHopBFD_EchoFunction) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // BD adds Bridge Domain to the RESYNC request. -func (dsl *DataResyncDSL) BD(val *l2.BridgeDomains_BridgeDomain) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BD(val *l2.BridgeDomains_BridgeDomain) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // BDFIB adds Bridge Domain to the RESYNC request. -func (dsl *DataResyncDSL) BDFIB(val *l2.FibTable_FibEntry) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) BDFIB(val *l2.FibTable_FibEntry) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // XConnect adds Cross Connect to the RESYNC request. -func (dsl *DataResyncDSL) XConnect(val *l2.XConnectPairs_XConnectPair) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) XConnect(val *l2.XConnectPairs_XConnectPair) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // StaticRoute adds L3 Static Route to the RESYNC request. -func (dsl *DataResyncDSL) StaticRoute(val *l3.StaticRoutes_Route) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) StaticRoute(val *l3.StaticRoutes_Route) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // ACL adds Access Control List to the RESYNC request. -func (dsl *DataResyncDSL) ACL(val *acl.AccessLists_Acl) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) ACL(val *acl.AccessLists_Acl) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // L4Features adds L4Features to the RESYNC request. -func (dsl *DataResyncDSL) L4Features(val *l4.L4Features) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) L4Features(val *l4.L4Features) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // AppNamespace adds Application Namespace to the RESYNC request. -func (dsl *DataResyncDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) AppNamespace(val *l4.AppNamespaces_AppNamespace) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // Arp adds VPP L3 ARP to the RESYNC request. -func (dsl *DataResyncDSL) Arp(val *l3.ArpTable_ArpEntry) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) Arp(val *l3.ArpTable_ArpEntry) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // ProxyArpInterfaces adds L3 proxy ARP interfaces to the RESYNC request. -func (dsl *DataResyncDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_InterfaceList) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) ProxyArpInterfaces(val *l3.ProxyArpInterfaces_InterfaceList) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // ProxyArpRanges adds L3 proxy ARP ranges to the RESYNC request. -func (dsl *DataResyncDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) ProxyArpRanges(val *l3.ProxyArpRanges_RangeList) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // StnRule adds Stn rule to the RESYNC request. -func (dsl *DataResyncDSL) StnRule(val *stn.STN_Rule) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) StnRule(val *stn.STN_Rule) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // NAT44Global adds a request to RESYNC global configuration for NAT44 -func (dsl *DataResyncDSL) NAT44Global(val *nat.Nat44Global) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) NAT44Global(val *nat.Nat44Global) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // NAT44DNat adds a request to RESYNC a new DNAT configuration -func (dsl *DataResyncDSL) NAT44DNat(val *nat.Nat44DNat_DNatConfig) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) NAT44DNat(val *nat.Nat44DNat_DNatConfig) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // IPSecSA adds request to create a new Security Association -func (dsl *DataResyncDSL) IPSecSA(val *ipsec.SecurityAssociations_SA) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) IPSecSA(val *ipsec.SecurityAssociations_SA) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // IPSecSPD adds request to create a new Security Policy Database -func (dsl *DataResyncDSL) IPSecSPD(val *ipsec.SecurityPolicyDatabases_SPD) defaultplugins.DataResyncDSL { +func (dsl *DataResyncDSL) IPSecSPD(val *ipsec.SecurityPolicyDatabases_SPD) vppclient.DataResyncDSL { dsl.put = append(dsl.put, val) return dsl } // Send propagates the request to the plugins. It deletes obsolete keys if listKeys() function is not null. // The listkeys() function is used to list all current keys. -func (dsl *DataResyncDSL) Send() defaultplugins.Reply { +func (dsl *DataResyncDSL) Send() vppclient.Reply { var wasErr error // Prepare requests with data todo can be scalable diff --git a/clientv1/defaultplugins/grpcadapter/doc.go b/clientv1/vpp/grpcadapter/doc.go similarity index 100% rename from clientv1/defaultplugins/grpcadapter/doc.go rename to clientv1/vpp/grpcadapter/doc.go diff --git a/clientv1/defaultplugins/localclient/doc.go b/clientv1/vpp/localclient/doc.go similarity index 100% rename from clientv1/defaultplugins/localclient/doc.go rename to clientv1/vpp/localclient/doc.go diff --git a/clientv1/defaultplugins/localclient/localclient_api.go b/clientv1/vpp/localclient/localclient_api.go similarity index 79% rename from clientv1/defaultplugins/localclient/localclient_api.go rename to clientv1/vpp/localclient/localclient_api.go index 498afb4a4e..ed7ab820fd 100644 --- a/clientv1/defaultplugins/localclient/localclient_api.go +++ b/clientv1/vpp/localclient/localclient_api.go @@ -17,16 +17,16 @@ package localclient import ( "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/datasync/kvdbsync/local" - "github.com/ligato/vpp-agent/clientv1/defaultplugins" - "github.com/ligato/vpp-agent/clientv1/defaultplugins/dbadapter" + "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/clientv1/vpp/dbadapter" ) -// PluginID defines the name of VPP (defaultplugins) localclient plugin. +// PluginID defines the name of VPP (vppplugin) localclient plugin. const PluginID core.PluginName = "DefaultVppPlugins_LOCAL_CLIENT" // DataResyncRequest allows creating a RESYNC request using convenient RESYNC // DSL and sending it locally through go channels (i.e. without using Data Store). -func DataResyncRequest(caller core.PluginName) defaultplugins.DataResyncDSL { +func DataResyncRequest(caller core.PluginName) vppclient.DataResyncDSL { return dbadapter.NewDataResyncDSL(local.NewProtoTxn(local.Get().PropagateResync), nil /*no need to list anything*/) } @@ -34,6 +34,6 @@ func DataResyncRequest(caller core.PluginName) defaultplugins.DataResyncDSL { // DataChangeRequest allows creating Data Change request(s) using convenient // Data Change DSL and sending it locally through go channels (i.e. without using // Data Store). -func DataChangeRequest(caller core.PluginName) defaultplugins.DataChangeDSL { +func DataChangeRequest(caller core.PluginName) vppclient.DataChangeDSL { return dbadapter.NewDataChangeDSL(local.NewProtoTxn(local.Get().PropagateChanges)) } diff --git a/clientv1/defaultplugins/localclient/localclient_init.go b/clientv1/vpp/localclient/localclient_init.go similarity index 100% rename from clientv1/defaultplugins/localclient/localclient_init.go rename to clientv1/vpp/localclient/localclient_init.go diff --git a/clientv1/defaultplugins/remoteclient/doc.go b/clientv1/vpp/remoteclient/doc.go similarity index 100% rename from clientv1/defaultplugins/remoteclient/doc.go rename to clientv1/vpp/remoteclient/doc.go diff --git a/clientv1/defaultplugins/remoteclient/remoteclient_api.go b/clientv1/vpp/remoteclient/remoteclient_api.go similarity index 74% rename from clientv1/defaultplugins/remoteclient/remoteclient_api.go rename to clientv1/vpp/remoteclient/remoteclient_api.go index e6de27d7c4..650c3272f1 100644 --- a/clientv1/defaultplugins/remoteclient/remoteclient_api.go +++ b/clientv1/vpp/remoteclient/remoteclient_api.go @@ -16,10 +16,10 @@ package remoteclient import ( "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/vpp-agent/clientv1/defaultplugins" - "github.com/ligato/vpp-agent/clientv1/defaultplugins/dbadapter" - "github.com/ligato/vpp-agent/clientv1/defaultplugins/grpcadapter" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/rpc" + "github.com/ligato/vpp-agent/clientv1/vpp" + "github.com/ligato/vpp-agent/clientv1/vpp/dbadapter" + "github.com/ligato/vpp-agent/clientv1/vpp/grpcadapter" + "github.com/ligato/vpp-agent/plugins/vpp/model/rpc" ) // DataResyncRequestDB allows creating a RESYNC request using convenient RESYNC @@ -27,26 +27,26 @@ import ( // User of the API does not need to be aware of keys. // User of the API does not need to delete the obsolete objects/keys // prior to RESYNC - it is handled by DataResyncDSL. -func DataResyncRequestDB(broker keyval.ProtoBroker) defaultplugins.DataResyncDSL { +func DataResyncRequestDB(broker keyval.ProtoBroker) vppclient.DataResyncDSL { return dbadapter.NewDataResyncDSL(broker.NewTxn(), broker.ListKeys) } // DataChangeRequestDB allows createing Data Change requests using convenient // Data Change DSL and sending it through the provided . // User of the API does not need to be aware of keys. -func DataChangeRequestDB(broker keyval.ProtoBroker) defaultplugins.DataChangeDSL { +func DataChangeRequestDB(broker keyval.ProtoBroker) vppclient.DataChangeDSL { return dbadapter.NewDataChangeDSL(broker.NewTxn()) } // DataResyncRequestGRPC allows sending RESYNC requests conveniently. // User of the API does not need to be aware of keys. // User of the API does not need to delete the obsolete objects/keys during RESYNC. -func DataResyncRequestGRPC(client rpc.DataResyncServiceClient) defaultplugins.DataResyncDSL { +func DataResyncRequestGRPC(client rpc.DataResyncServiceClient) vppclient.DataResyncDSL { return grpcadapter.NewDataResyncDSL(client) } // DataChangeRequestGRPC allows sending Data Change requests conveniently (even without directly using Broker). // User of the API does not need to be aware of keys. -func DataChangeRequestGRPC(client rpc.DataChangeServiceClient) defaultplugins.DataChangeDSL { +func DataChangeRequestGRPC(client rpc.DataChangeServiceClient) vppclient.DataChangeDSL { return grpcadapter.NewDataChangeDSL(client) } diff --git a/cmd/agentctl/cmd/clean_cmd.go b/cmd/agentctl/cmd/clean_cmd.go index c24717fda5..1064b891f1 100644 --- a/cmd/agentctl/cmd/clean_cmd.go +++ b/cmd/agentctl/cmd/clean_cmd.go @@ -27,9 +27,9 @@ import ( "github.com/ligato/cn-infra/health/statuscheck/model/status" "github.com/ligato/cn-infra/servicelabel" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" ) const dataTypeFlagName = "dataType" diff --git a/cmd/agentctl/cmd/interface_cmd.go b/cmd/agentctl/cmd/interface_cmd.go index b48b0dc956..2c87421c19 100644 --- a/cmd/agentctl/cmd/interface_cmd.go +++ b/cmd/agentctl/cmd/interface_cmd.go @@ -17,7 +17,7 @@ package cmd import ( "github.com/ligato/vpp-agent/cmd/agentctl/impl" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" "github.com/spf13/cobra" ) diff --git a/cmd/agentctl/cmd/root_cmd.go b/cmd/agentctl/cmd/root_cmd.go index 08b8d4701b..756ec4396a 100644 --- a/cmd/agentctl/cmd/root_cmd.go +++ b/cmd/agentctl/cmd/root_cmd.go @@ -32,11 +32,11 @@ var RootCmd = &cobra.Command{ Short: "A CLI tool for the vnf-agent", Long: ` A CLI tool to show the state of and to configure agents connected to -Etcd. Use the 'ETCDV3_ENDPOINTS'' environment variable or the 'endpoints' +Etcd. Use the 'ETCD_ENDPOINTS'' environment variable or the 'endpoints' flag in the command line to specify one or more Etcd instances to connect to.`, Example: `Specify the etcd to connect to and list all agents that it knows about: - $ export ETCDV3_ENDPOINTS=172.17.0.1:2379 + $ export ETCD_ENDPOINTS=172.17.0.1:2379 $ ./agentctl list Do as above, but with a command line flag: diff --git a/cmd/agentctl/impl/bridge_domains.go b/cmd/agentctl/impl/bridge_domains.go index 5992073304..fd6bc7c501 100644 --- a/cmd/agentctl/impl/bridge_domains.go +++ b/cmd/agentctl/impl/bridge_domains.go @@ -18,7 +18,7 @@ import ( "errors" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" "github.com/spf13/cobra" ) diff --git a/cmd/agentctl/impl/interfaces.go b/cmd/agentctl/impl/interfaces.go index a1e25c4571..f940a8986d 100644 --- a/cmd/agentctl/impl/interfaces.go +++ b/cmd/agentctl/impl/interfaces.go @@ -22,7 +22,7 @@ import ( "os" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" "github.com/spf13/cobra" ) diff --git a/cmd/agentctl/testing/data.go b/cmd/agentctl/testing/data.go index 57fd29cf13..0f16bd17c6 100644 --- a/cmd/agentctl/testing/data.go +++ b/cmd/agentctl/testing/data.go @@ -18,9 +18,9 @@ import ( "strconv" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" ) // TableData with 3x VPP, each with 3 interfaces. With such a data, all filtering options can be tested. diff --git a/cmd/agentctl/utils/common_utils.go b/cmd/agentctl/utils/common_utils.go index 30b3ab4b06..adf0ade3d0 100644 --- a/cmd/agentctl/utils/common_utils.go +++ b/cmd/agentctl/utils/common_utils.go @@ -21,12 +21,12 @@ import ( "fmt" "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/cn-infra/db/keyval/etcdv3" + "github.com/ligato/cn-infra/db/keyval/etcd" "github.com/ligato/cn-infra/db/keyval/kvproto" "github.com/ligato/cn-infra/logging" "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/cn-infra/servicelabel" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" ) // Common exit flags @@ -163,48 +163,48 @@ func rebuildName(params []string) string { } // GetDbForAllAgents opens a connection to etcd, specified in the command line -// or the "ETCDV3_ENDPOINTS" environment variable. +// or the "ETCD_ENDPOINTS" environment variable. func GetDbForAllAgents(endpoints []string) (keyval.ProtoBroker, error) { if len(endpoints) > 0 { ep := strings.Join(endpoints, ",") - os.Setenv("ETCDV3_ENDPOINTS", ep) + os.Setenv("ETCD_ENDPOINTS", ep) } - cfg := &etcdv3.Config{} - etcdConfig, err := etcdv3.ConfigToClient(cfg) + cfg := &etcd.Config{} + etcdConfig, err := etcd.ConfigToClient(cfg) // Log warnings and errors only. log := logrus.DefaultLogger() log.SetLevel(logging.WarnLevel) - etcdv3Broker, err := etcdv3.NewEtcdConnectionWithBytes(*etcdConfig, log) + etcdBroker, err := etcd.NewEtcdConnectionWithBytes(*etcdConfig, log) if err != nil { return nil, err } - return kvproto.NewProtoWrapperWithSerializer(etcdv3Broker, &keyval.SerializerJSON{}), nil + return kvproto.NewProtoWrapperWithSerializer(etcdBroker, &keyval.SerializerJSON{}), nil } // GetDbForOneAgent opens a connection to etcd, specified in the command line -// or the "ETCDV3_ENDPOINTS" environment variable. +// or the "ETCD_ENDPOINTS" environment variable. func GetDbForOneAgent(endpoints []string, agentLabel string) (keyval.ProtoBroker, error) { if len(endpoints) > 0 { ep := strings.Join(endpoints, ",") - os.Setenv("ETCDV3_ENDPOINTS", ep) + os.Setenv("ETCD_ENDPOINTS", ep) } - cfg := &etcdv3.Config{} - etcdConfig, err := etcdv3.ConfigToClient(cfg) + cfg := &etcd.Config{} + etcdConfig, err := etcd.ConfigToClient(cfg) // Log warnings and errors only. log := logrus.DefaultLogger() log.SetLevel(logging.WarnLevel) - etcdv3Broker, err := etcdv3.NewEtcdConnectionWithBytes(*etcdConfig, log) + etcdBroker, err := etcd.NewEtcdConnectionWithBytes(*etcdConfig, log) if err != nil { return nil, err } - return kvproto.NewProtoWrapperWithSerializer(etcdv3Broker, &keyval.SerializerJSON{}). + return kvproto.NewProtoWrapperWithSerializer(etcdBroker, &keyval.SerializerJSON{}). NewBroker(servicelabel.GetAllAgentsPrefix() + agentLabel + "/"), nil } diff --git a/cmd/agentctl/utils/common_utils_test.go b/cmd/agentctl/utils/common_utils_test.go index 72698a1930..2a5e51d56d 100644 --- a/cmd/agentctl/utils/common_utils_test.go +++ b/cmd/agentctl/utils/common_utils_test.go @@ -19,9 +19,9 @@ import ( "github.com/ligato/cn-infra/health/statuscheck/model/status" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" "github.com/onsi/gomega" ) diff --git a/cmd/agentctl/utils/db_utils.go b/cmd/agentctl/utils/db_utils.go index 9bb2c25e9f..d7c910b2f8 100644 --- a/cmd/agentctl/utils/db_utils.go +++ b/cmd/agentctl/utils/db_utils.go @@ -24,9 +24,9 @@ import ( "github.com/ligato/cn-infra/db/keyval" "github.com/ligato/cn-infra/health/statuscheck/model/status" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" ) // VppMetaData defines the etcd metadata. diff --git a/cmd/agentctl/utils/db_utils_test.go b/cmd/agentctl/utils/db_utils_test.go index 313bbc09c5..69cf673dfa 100644 --- a/cmd/agentctl/utils/db_utils_test.go +++ b/cmd/agentctl/utils/db_utils_test.go @@ -18,7 +18,7 @@ import ( "testing" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" "github.com/onsi/gomega" ) diff --git a/cmd/agentctl/utils/interface_utils.go b/cmd/agentctl/utils/interface_utils.go index b58c091aa0..99f14c9fc7 100644 --- a/cmd/agentctl/utils/interface_utils.go +++ b/cmd/agentctl/utils/interface_utils.go @@ -22,7 +22,7 @@ import ( "strings" "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" ) // Interface flag names diff --git a/cmd/agentctl/utils/l2_utils.go b/cmd/agentctl/utils/l2_utils.go index 23413c0013..0f2441ca8c 100644 --- a/cmd/agentctl/utils/l2_utils.go +++ b/cmd/agentctl/utils/l2_utils.go @@ -19,7 +19,7 @@ import ( "fmt" "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" ) // Bridge domain flag names diff --git a/cmd/agentctl/utils/print_json.go b/cmd/agentctl/utils/print_json.go index d024f7990e..84bc8cd6a3 100644 --- a/cmd/agentctl/utils/print_json.go +++ b/cmd/agentctl/utils/print_json.go @@ -21,9 +21,9 @@ import ( "sort" "strings" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" "github.com/logrusorgru/aurora.git" ) diff --git a/cmd/agentctl/utils/print_text.go b/cmd/agentctl/utils/print_text.go index 4385b9c281..6319e6b74b 100644 --- a/cmd/agentctl/utils/print_text.go +++ b/cmd/agentctl/utils/print_text.go @@ -24,7 +24,7 @@ import ( "bytes" "github.com/ligato/cn-infra/health/statuscheck/model/status" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" "github.com/logrusorgru/aurora.git" ) diff --git a/cmd/agentctl/utils/tree_writer_test.go b/cmd/agentctl/utils/tree_writer_test.go index 4b484d370c..a5f6226b35 100644 --- a/cmd/agentctl/utils/tree_writer_test.go +++ b/cmd/agentctl/utils/tree_writer_test.go @@ -20,7 +20,7 @@ import ( "text/template" "github.com/ligato/vpp-agent/cmd/agentctl/utils" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" "github.com/onsi/gomega" ) diff --git a/cmd/vpp-agent-ctl/data_cmd.go b/cmd/vpp-agent-ctl/data_cmd.go index b1a8495875..ac4d7316f1 100644 --- a/cmd/vpp-agent-ctl/data_cmd.go +++ b/cmd/vpp-agent-ctl/data_cmd.go @@ -23,20 +23,21 @@ import ( "os" "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/cn-infra/db/keyval/etcdv3" + "github.com/ligato/cn-infra/db/keyval/etcd" "github.com/ligato/cn-infra/logging" "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/cn-infra/servicelabel" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/bfd" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l4" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/stn" - linuxIf "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - linuxL3 "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + linuxIf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + linuxL3 "github.com/ligato/vpp-agent/plugins/linux/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/bfd" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/ipsec" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/l4" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" + "github.com/ligato/vpp-agent/plugins/vpp/model/stn" "github.com/namsral/flag" ) @@ -45,7 +46,7 @@ type VppAgentCtl struct { Log logging.Logger Commands []string serviceLabel servicelabel.Plugin - bytesConnection *etcdv3.BytesConnectionEtcd + bytesConnection *etcd.BytesConnectionEtcd broker keyval.ProtoBroker } @@ -272,6 +273,10 @@ func (ctl *VppAgentCtl) createEthernet() { "192.168.1.1", "2001:db8:0:0:0:ff00:5168:2bc8/48", }, + //RxPlacementSettings: &interfaces.Interfaces_Interface_RxPlacementSettings{ + // Queue: 0, + // Worker: 1, + //}, //Unnumbered: &interfaces.Interfaces_Interface_Unnumbered{ // IsUnnumbered: true, // InterfaceWithIP: "memif1", @@ -309,7 +314,7 @@ func (ctl *VppAgentCtl) createTap() { // InterfaceWithIP: "memif1", //}, Tap: &interfaces.Interfaces_Interface_Tap{ - HostIfName: "tap1", + HostIfName: "tap-host", }, }, }, @@ -417,6 +422,7 @@ func (ctl *VppAgentCtl) createVxlan() { // InterfaceWithIP: "memif1", //}, Vxlan: &interfaces.Interfaces_Interface_Vxlan{ + //Multicast: "if1", SrcAddress: "192.168.42.1", DstAddress: "192.168.42.2", Vni: 13, @@ -568,6 +574,108 @@ func (ctl *VppAgentCtl) deleteLinuxTap() { ctl.broker.Delete(linuxTapKey) } +// IPsec + +// createIPsecSPD puts STD configuration to the ETCD +func (ctl *VppAgentCtl) createIPsecSPD() { + spd := ipsec.SecurityPolicyDatabases_SPD{ + Name: "spd1", + Interfaces: []*ipsec.SecurityPolicyDatabases_SPD_Interface{ + { + Name: "tap1", + }, + { + Name: "loop1", + }, + }, + PolicyEntries: []*ipsec.SecurityPolicyDatabases_SPD_PolicyEntry{ + { + Priority: 100, + IsOutbound: false, + Action: 0, + Protocol: 50, + }, + { + Priority: 100, + IsOutbound: true, + Action: 0, + Protocol: 50, + }, + { + Priority: 10, + IsOutbound: false, + RemoteAddrStart: "10.0.0.1", + RemoteAddrStop: "10.0.0.1", + LocalAddrStart: "10.0.0.2", + LocalAddrStop: "10.0.0.2", + Action: 3, + Sa: "sa1", + }, + { + Priority: 10, + IsOutbound: true, + RemoteAddrStart: "10.0.0.1", + RemoteAddrStop: "10.0.0.1", + LocalAddrStart: "10.0.0.2", + LocalAddrStop: "10.0.0.2", + Action: 3, + Sa: "sa2", + }, + }, + } + + ctl.Log.Println(spd) + ctl.broker.Put(ipsec.SPDKey(spd.Name), &spd) +} + +// deleteIPsecSPD removes STD configuration from the ETCD +func (ctl *VppAgentCtl) deleteIPsecSPD() { + stdKey := ipsec.SPDKey("spd1") + + ctl.Log.Println("Deleting", stdKey) + ctl.broker.Delete(stdKey) +} + +// creteIPsecSA puts two security association configurations to the ETCD +func (ctl *VppAgentCtl) createIPsecSA() { + sa1 := ipsec.SecurityAssociations_SA{ + Name: "sa1", + Spi: 1001, + Protocol: 1, + CryptoAlg: 1, + CryptoKey: "4a506a794f574265564551694d653768", + IntegAlg: 2, + IntegKey: "4339314b55523947594d6d3547666b45764e6a58", + EnableUdpEncap: true, + } + sa2 := ipsec.SecurityAssociations_SA{ + Name: "sa2", + Spi: 1000, + Protocol: 1, + CryptoAlg: 1, + CryptoKey: "4a506a794f574265564551694d653768", + IntegAlg: 2, + IntegKey: "4339314b55523947594d6d3547666b45764e6a58", + EnableUdpEncap: false, + } + + ctl.Log.Println(sa1) + ctl.broker.Put(ipsec.SAKey(sa1.Name), &sa1) + ctl.Log.Println(sa2) + ctl.broker.Put(ipsec.SAKey(sa2.Name), &sa2) +} + +// deleteIPsecSA removes SA configuration from the ETCD +func (ctl *VppAgentCtl) deleteIPsecSA() { + saKey1 := ipsec.SPDKey("sa1") + saKey2 := ipsec.SPDKey("sa2") + + ctl.Log.Println("Deleting", saKey1) + ctl.broker.Delete(saKey1) + ctl.Log.Println("Deleting", saKey2) + ctl.broker.Delete(saKey2) +} + // STN // CreateStn puts STN configuration to the ETCD diff --git a/cmd/vpp-agent-ctl/etcd.go b/cmd/vpp-agent-ctl/etcd.go index 00c0f71240..6339c1dbec 100644 --- a/cmd/vpp-agent-ctl/etcd.go +++ b/cmd/vpp-agent-ctl/etcd.go @@ -29,31 +29,31 @@ import ( "github.com/ligato/cn-infra/config" "github.com/ligato/cn-infra/datasync" "github.com/ligato/cn-infra/db/keyval" - "github.com/ligato/cn-infra/db/keyval/etcdv3" + "github.com/ligato/cn-infra/db/keyval/etcd" "github.com/ligato/cn-infra/db/keyval/kvproto" ) // CreateEtcdClient uses environment variable or ETCD config file to establish connection -func (ctl *VppAgentCtl) createEtcdClient(configFile string) (*etcdv3.BytesConnectionEtcd, keyval.ProtoBroker, error) { +func (ctl *VppAgentCtl) createEtcdClient(configFile string) (*etcd.BytesConnectionEtcd, keyval.ProtoBroker, error) { var err error if configFile == "" { - configFile = os.Getenv("ETCDV3_CONFIG") + configFile = os.Getenv("ETCD_CONFIG") } - cfg := &etcdv3.Config{} + cfg := &etcd.Config{} if configFile != "" { err := config.ParseConfigFromYamlFile(configFile, cfg) if err != nil { return nil, nil, err } } - etcdConfig, err := etcdv3.ConfigToClient(cfg) + etcdConfig, err := etcd.ConfigToClient(cfg) if err != nil { ctl.Log.Fatal(err) } - bDB, err := etcdv3.NewEtcdConnectionWithBytes(*etcdConfig, ctl.Log) + bDB, err := etcd.NewEtcdConnectionWithBytes(*etcdConfig, ctl.Log) if err != nil { return nil, nil, err } diff --git a/cmd/vpp-agent-ctl/json/routes-linux-default.json b/cmd/vpp-agent-ctl/json/routes-linux-default.json new file mode 100644 index 0000000000..6fb34e1575 --- /dev/null +++ b/cmd/vpp-agent-ctl/json/routes-linux-default.json @@ -0,0 +1,11 @@ +{ + "name": "defRoute", + "default": true, + "gw-addr": "10.0.2.0/24", + "interface": "veth1", + "metric": 100, + "namespace": { + "name": "ns1", + "type": 2 + } +} \ No newline at end of file diff --git a/cmd/vpp-agent-ctl/json/routes-linux-static.json b/cmd/vpp-agent-ctl/json/routes-linux-static.json new file mode 100644 index 0000000000..4208794761 --- /dev/null +++ b/cmd/vpp-agent-ctl/json/routes-linux-static.json @@ -0,0 +1,11 @@ +{ + "name": "route1", + "dst-ip-addr": "10.0.2.0/24", + "interface": "veth1", + "metric": 100, + "namespace": { + "name": "ns1", + "type": 2 + } +} + diff --git a/cmd/vpp-agent-ctl/vpp-agent-ctl.go b/cmd/vpp-agent-ctl/vpp-agent-ctl.go index b5412783dc..b613b1d464 100644 --- a/cmd/vpp-agent-ctl/vpp-agent-ctl.go +++ b/cmd/vpp-agent-ctl/vpp-agent-ctl.go @@ -137,6 +137,15 @@ func do(ctl *VppAgentCtl) { ctl.createLinuxTap() case "-ltapd": ctl.deleteLinuxTap() + // IPsec + case "-spd": + ctl.createIPsecSPD() + case "-spdd": + ctl.deleteIPsecSPD() + case "-sa": + ctl.createIPsecSA() + case "-sad": + ctl.deleteIPsecSA() // STN case "-stn": ctl.createStn() @@ -249,6 +258,8 @@ func usage() { -afpkt, -afpktd - af_packet type interface -veth, -vethd - Linux VETH interface pair -ltap, -ltapd - Linux TAP interface + -spd, -spdd - IPsec security policy database + -sa, -sad - IPsec security associations -stn, -stnd - STN rule -gnat, -gnatd - Global NAT configuration -snat, -snatd - SNAT configuration diff --git a/cmd/vpp-agent/main.go b/cmd/vpp-agent/main.go index a0586c003b..aa28305b0a 100644 --- a/cmd/vpp-agent/main.go +++ b/cmd/vpp-agent/main.go @@ -22,7 +22,7 @@ import ( "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/logging" log "github.com/ligato/cn-infra/logging/logrus" - vpp_flavor "github.com/ligato/vpp-agent/flavors/vpp" + flavor "github.com/ligato/vpp-agent/flavors/vpp" ) // main is the main entry point into the VPP Agent. Firstly, a new CN-Infra @@ -32,9 +32,7 @@ import ( // to terminate the VPP Agent process with SIGINT. All VPP Agent's work between // the initialization and termination is performed by the plugins. func main() { - - f := vpp_flavor.Flavor{} - agent := core.NewAgent(&f) + agent := flavor.NewAgent() err := core.EventLoopWithInterrupt(agent, nil) if err != nil { diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile new file mode 100644 index 0000000000..89645c0b3e --- /dev/null +++ b/docker/dev/Dockerfile @@ -0,0 +1,124 @@ +ARG BASE_IMG=ubuntu:16.04 + +FROM golang as verify-stage + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + patch python-pip \ + && rm -rf /var/lib/apt/lists/* \ + && pip install ply + +ARG VPP_REPO_URL +ARG VPP_COMMIT + +RUN git clone ${VPP_REPO_URL} /opt/vpp \ + && cd /opt/vpp \ + && git checkout ${VPP_COMMIT} + +COPY scripts/genjsonapi.sh /opt/genjsonapi.sh +RUN /opt/genjsonapi.sh + +WORKDIR /go/src/github.com/ligato/vpp-agent + +COPY plugins/vpp/binapi plugins/vpp/binapi +COPY vendor vendor +COPY Makefile vpp.env ./ + +RUN cp -r plugins/vpp/binapi /tmp/orig_binapi \ + && make generate-binapi \ + && diff -r plugins/vpp/binapi /tmp/orig_binapi + +FROM ${BASE_IMG} as dev-stage + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf automake build-essential ca-certificates curl gdb git \ + inetutils-traceroute iproute2 ipsec-tools iputils-ping \ + libapr1 libmbedcrypto0 libmbedtls10 libmbedx509-0 libtool \ + make netcat python software-properties-common sudo supervisor \ + telnet unzip wget \ + && rm -rf /var/lib/apt/lists/* + +# build & install Protobuf +RUN git clone --depth=1 https://github.com/google/protobuf.git \ + && cd protobuf \ + && ./autogen.sh \ + && ./configure \ + && make -j4 \ + && make install \ + && ldconfig \ + && cd .. \ + && rm -rf protobuf + +RUN mkdir -p /opt/vpp-agent/dev /opt/vpp-agent/plugin + +WORKDIR /opt/vpp-agent/dev + +ARG VPP_REPO_URL=https://gerrit.fd.io/r/vpp.git +ARG VPP_COMMIT + +ARG VPP_DEBUG_DEB + +RUN set -eux; \ + git clone "${VPP_REPO_URL}" vpp; \ + cd vpp; \ + git checkout "${VPP_COMMIT}"; \ + export UNATTENDED=y; \ + make install-dep dpdk-install-dev; \ + if [ -n "${VPP_DEBUG_DEB}" ]; then \ + make vpp_configure_args_vpp='--disable-japi' build; \ + make -C build-root PLATFORM=vpp TAG=vpp_debug install-deb; \ + else \ + make vpp_configure_args_vpp='--disable-japi' build-release pkg-deb; \ + fi; \ + cd build-root; \ + dpkg -i vpp_*.deb vpp-dev_*.deb vpp-lib_*.deb vpp-plugins_*.deb vpp-dbg_*.deb; \ + rm -rf .ccache /var/lib/apt/lists/*; \ + find . -type f -name '*.o' -exec rm -rf '{}' \; + +# install Go +ENV GOLANG_VERSION 1.10.3 +ARG GOLANG_OS_ARCH=linux-amd64 +RUN wget -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.${GOLANG_OS_ARCH}.tar.gz" \ + && tar -C /usr/local -xzf go.tgz \ + && rm go.tgz + +ENV GOPATH /go +ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH +RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" \ + && chmod -R 777 "$GOPATH" + +# copy configs +COPY \ + docker/dev/etcd.conf \ + docker/dev/kafka.conf \ + docker/dev/govpp.conf \ + docker/dev/vpp-plugin.conf \ + docker/dev/linux-plugin.conf \ + docker/dev/logs.conf \ + ./ + +COPY docker/dev/vpp.conf /etc/vpp/vpp.conf +COPY docker/dev/supervisord.conf /etc/supervisord/supervisord.conf + +# copy scripts +COPY \ + docker/dev/exec_vpp.sh \ + docker/dev/exec_agent.sh \ + docker/dev/supervisord_kill.py \ + /usr/bin/ + +ARG VERSION +ARG COMMIT + +# copy & build agent +COPY . $GOPATH/src/github.com/ligato/vpp-agent + +RUN cd $GOPATH/src/github.com/ligato/vpp-agent \ + && VERSION=$VERSION COMMIT=$COMMIT make install + +WORKDIR / + +# run supervisor as the default executable +CMD rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api && \ + /usr/bin/supervisord -c /etc/supervisord/supervisord.conf diff --git a/docker/dev_vpp_agent/README.md b/docker/dev/README.md similarity index 69% rename from docker/dev_vpp_agent/README.md rename to docker/dev/README.md index 65c3107724..8c0aab5424 100644 --- a/docker/dev_vpp_agent/README.md +++ b/docker/dev/README.md @@ -1,68 +1,61 @@ -## Development Docker Image +# Dev Docker Image -This image can be used to get started with the vpp-agent Go code. It -contains: +This image is used for development and debugging. -- The development environment with all libs & dependencies required - to build both the VPP itself and the VPP Agent -- A pre-built vpp ready to be used -- A pre-built VPP Agent +### What is included: +- **VPP-Agent** with default config files and ready to use +- **VPP** (compatible with VPP-Agent) including source code and build artifacts +- development environment with all requirements needed + to build both the **VPP** and **VPP-Agent** itself +- code generation tools for **proto models** (gogoprotobuf) + and also **VPP binary API** using GoVPP generator) +- several other development utilities (agentctl, vpp-agent-ctl) -### Getting an Image from Dockerhub -For a quick start with the Development image, you can use pre-built -Development docker images that contain pre-built VPP Agent, VPP, and -tools, the Ligato and VPP source code, Git, and build tools for both -the VPP Agent and VPP. The pre-built Development docker images are -available from [Dockerhub](https://hub.docker.com/r/ligato/dev-vpp-agent/), -or you can just type: -``` -docker pull ligato/dev-vpp-agent -``` -Then you can start the downloaded Development image as described [here][1]. +## Get the official image -### Building Locally -To build the docker image on your local machine, type: -``` -./build.sh -``` -This will build dev_vpp_agent image with default parameters: -- vpp-agent - latest commit number from the cloned repo, -- vpp - commit number specified in vpp submodule. - -To build specific commits (one or both), use `build.sh` with parameters: -- `-a` or `--agent` to specify vpp-agent commit number, -- `-v` or `--vpp` to specify vpp commit number. +For a quick start with the development image, you can download +the [official image](https://hub.docker.com/r/ligato/dev-vpp-agent/) from **DockerHub**. -Example: -``` -./build.sh --agent 9c35e43e9bfad377f3c2186f30d9853e3f3db3ad --vpp f3bcdbf071c98ed676591bd22c3d3f8601009fa8 +```sh +$ docker pull docker.io/ligato/dev-vpp-agent # latest release (stable) +$ docker pull docker.io/ligato/dev-vpp-agent:pantheon-dev # bleeding edge (unstable) ``` -You can still build image using docker build command, but you must -explicitly specify the agent and vpp commit numbers: +List of all available docker image tags for development image can +be found [here](https://hub.docker.com/r/ligato/dev-vpp-agent/tags/). + +## Building the image locally + +To build the docker image on your local machine run: + ``` -sudo docker build -t dev_vpp_agent --build-arg AGENT_COMMIT=2c2b0df32201c9bc814a167e0318329c78165b5c --build-arg VPP_COMMIT=f3bcdbf071c98ed676591bd22c3d3f8601009fa8 --no-cache . +$ ./build.sh ``` -In addition, these environment variables can be set in Dockerfile: -- `START_AGENT` - whether the vpp-agent should be started after start of the container (default is true, agent will be started) -- `RETAIN_SUPERVISOR` - whether the supervisor should be killed (default is false, supervisor will be stopped) -Their values can be also changed before image start with `docker -e` to have desired behavior +This will by default build image with name `dev_vpp_agent` +and use following sources: +- **VPP-Agent** version from local repository +- **VPP** from repository and commit specified in `vpp.env` file + +### Build VPP in _debug_ mode -### Building VPP .deb Packages in Debug or Release Mode -You can build VPP .deb packages with debug or release mode. By default the image is built for release mode. -The environmental variable `VPP_DEBUG_DEB=y` can be used to build VPP .deb packages with debug mode. +By default the image builds **VPP** _.deb_ packages in **release** mode. +You can change mode to **debug** by setting the environmental variable: -To build the image with VPP .deb packages with debug mode: ``` -VPP_DEBUG_DEB=y ./build.sh +$ VPP_DEBUG_DEB=y ./build.sh ``` -#### Verifying a Created or Downloaded Image -You can verify the newly built or downloaded image as follows: +*Note:* This will only build the _.deb_ packages in **debug** mode. +The running mode of the **VPP** can be changed to **debug** by +setting `RUN_VPP_DEBUG=y` environmental variable for the container. + +### Verifying the built image + +You can verify the newly built image using: ``` -docker images +$ docker images ``` You should see something like this: @@ -72,36 +65,18 @@ REPOSITORY TAG IMAGE ID CREATED dev_vpp_agent latest 0692f574f21a 11 minutes ago 3.58 GB ... ``` -Get the details of the newly built or downloaded image: - -``` -docker image inspect dev_vpp_agent -docker image history dev_vpp_agent -``` -### Shrinking the Image -Dev_vpp_agent image can be shrunk by typing the command: +To inspect the details or see the history of the image use: ``` -./shrink.sh +$ docker image inspect dev_vpp_agent +$ docker image history dev_vpp_agent ``` -This will build a new image with the name `dev_vpp_agent_shrink`, where -vpp sources and build related files have been removed (in total about 2GB). - -The `shrink.sh` script is using docker export and import command, but due -[Docker issue](https://github.com/moby/moby/issues/26173) it will fail on -docker older than 1.13. - -``` -$ docker images -REPOSITORY TAG IMAGE ID CREATED SIZE -dev_vpp_agent latest 442771972e4a 8 hours ago 3.57 GB -dev_vpp_agent_shrink latest bd2e76980236 8 hours ago 1.68 GB -``` --- ## Starting the Image + By default, the VPP & the Agent processes will be started automatically in the container. This is useful e.g. for deployments with Kubernetes, as described in [this README](../../k8s/dev-setup/README.md). However, this option is @@ -117,7 +92,12 @@ To open another terminal into the image: sudo docker exec -it vpp_agent bash ``` -### Running VPP in Debug or Release Mode +These environment variables can be set: +- `OMIT_AGENT` - whether the start of vpp-agent should be omitted (default is unset, agent will be started normally) +- `RETAIN_SUPERVISOR` - whether the supervisord should quit on unexpected exit of vpp or vpp-agent (default is unset, supervisord will quit) + +## Running VPP in Debug or Release Mode + You can run VPP in debug or release mode. By default the image runs in release mode. The environmental variable `RUN_VPP_DEBUG=y` can be used to run VPP in debug mode. @@ -126,7 +106,8 @@ To start the image with VPP in debug mode: sudo docker run -it --env RUN_VPP_DEBUG=y --rm --privileged dev_vpp_agent bash ``` -### Mounting VPP Build Using Volume +## Mounting VPP Build Using Volume + You can run custom build of VPP by using volume mount. The VPP build in the image is located at `/opt/vpp-agent/dev/vpp`. To start the image with custom VPP build mounted from host: @@ -134,7 +115,7 @@ To start the image with custom VPP build mounted from host: sudo docker run -it --volume $HOME/myvpp:/opt/vpp-agent/dev/vpp --rm --privileged dev_vpp_agent bash ``` -### Running VPP and the Agent +## Running VPP and the Agent **NOTE: The Agent will terminate if it cannot connect to VPP and to a Etcd server. If Kafka config is specified, a successful connection to Kafka is @@ -194,10 +175,11 @@ networking settings.* - Start the Agent: ``` -vpp-agent --etcdv3-config=/opt/vpp-agent/dev/etcd.conf --kafka-config=/opt/vpp-agent/dev/kafka.conf +vpp-agent --etcd-config=/opt/vpp-agent/dev/etcd.conf --kafka-config=/opt/vpp-agent/dev/kafka.conf ``` -### Running Etcd Server on Local Host +## Running Etcd Server on Local Host + You can run an ETCD server in a separate container on your local host as follows: ``` @@ -215,14 +197,15 @@ vpp-agent-ctl /opt/vpp-agent/dev/etcd.conf -tap vpp-agent-ctl /opt/vpp-agent/dev/etcd.conf -tapd ``` -### Running Kafka on Local Host +## Running Kafka on Local Host + You can start Kafka in a separate container: ``` sudo docker run -p 2181:2181 -p 9092:9092 --name kafka --rm \ --env ADVERTISED_HOST=172.17.0.1 --env ADVERTISED_PORT=9092 spotify/kafka ``` -### Rebuilding the Agent +## Rebuilding the Agent ``` cd $GOPATH/src/github.com/ligato/vpp-agent/ git pull # if needed @@ -233,13 +216,15 @@ make install This should update the `agent` binary in yor `$GOPATH/bin` directory. -### Rebuilding of the container image: +## Rebuilding of the container image: + Use the `--no-cache` flag for `docker build`: ``` sudo docker build --no-cache -t dev_vpp_agent . ``` -### Mounting of a host directory into the Docker container: +## Mounting of a host directory into the Docker container: + Use `-v` option of the docker command: ``` sudo docker run -v /host/folder:/container/folder -it --name vpp_agent --privileged --rm dev_vpp_agent bash @@ -257,6 +242,7 @@ building and testing it. --- ## Example: Using the Development Environment on a MacBook with Gogland + This section describes the setup of a lightweight, portable development environment on your local notebook (MacBook or MacBook Pro in this example). The MacBook will be the host for the Development Environment container @@ -264,7 +250,7 @@ and the folder containing the agent sources will be shared between the host and the container. Then, you can run the IDE, git, and other tools on the host and the compilations/testing in the container. -#### Prerequisites +### Prerequisites 1. Get [Docker for Mac](https://docs.docker.com/docker-for-mac/). If you don't have it already installed, follow these @@ -279,7 +265,8 @@ on the host and the compilations/testing in the container. 2. Once you have Docker up & running on your Mac, build and verify the Development Environment container [as described above](#getting-the-image). -#### Building and Running the Agent +### Building and Running the Agent + For the mixed host-container environment, the folder holding the Agent source code must be setup properly on both the host and in the container. You must also set GOPATH and GOROOT appropriately @@ -344,5 +331,3 @@ console. - Use the newly built agent as described in Section '[Running VPP and the Agent](#running-vpp-and-the-agent)'. - -[1]: #starting-the-image diff --git a/docker/dev/build.sh b/docker/dev/build.sh new file mode 100755 index 0000000000..34dd489883 --- /dev/null +++ b/docker/dev/build.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +cd "$(dirname "$0")" + +set -e + +IMAGE_TAG=${IMAGE_TAG:-'dev_vpp_agent'} +DOCKERFILE=${DOCKERFILE:-'Dockerfile'} + +BASE_IMG=${BASE_IMG:-'ubuntu:16.04'} +GOLANG_OS_ARCH=${GOLANG_OS_ARCH:-'linux-amd64'} + +source ../../vpp.env +VPP_DEBUG_DEB=${VPP_DEBUG_DEB:-} + +VERSION=$(git describe --always --tags --dirty) +COMMIT=$(git rev-parse HEAD) + +echo "==============================" +echo "VPP repo URL: ${VPP_REPO_URL}" +echo "VPP commit: ${VPP_COMMIT}" +echo +echo "Agent version: ${VERSION}" +echo "Agent commit: ${COMMIT}" +echo +echo "base image: ${BASE_IMG}" +echo "image tag: ${IMAGE_TAG}" +echo "==============================" + +docker build -f ${DOCKERFILE} \ + --tag ${IMAGE_TAG} \ + --build-arg BASE_IMG=${BASE_IMG} \ + --build-arg VPP_COMMIT=${VPP_COMMIT} \ + --build-arg VPP_REPO_URL=${VPP_REPO_URL} \ + --build-arg VPP_DEBUG_DEB=${VPP_DEBUG_DEB} \ + --build-arg GOLANG_OS_ARCH=${GOLANG_OS_ARCH} \ + --build-arg VERSION=${VERSION} \ + --build-arg COMMIT=${COMMIT} \ + ${DOCKER_BUILD_ARGS} ../.. diff --git a/docker/dev_vpp_agent/etcd.conf b/docker/dev/etcd.conf similarity index 100% rename from docker/dev_vpp_agent/etcd.conf rename to docker/dev/etcd.conf diff --git a/docker/dev/exec_agent.sh b/docker/dev/exec_agent.sh new file mode 120000 index 0000000000..b2f3c76bc9 --- /dev/null +++ b/docker/dev/exec_agent.sh @@ -0,0 +1 @@ +../prod/exec_agent.sh \ No newline at end of file diff --git a/docker/dev_vpp_agent/runvpp.sh b/docker/dev/exec_vpp.sh similarity index 100% rename from docker/dev_vpp_agent/runvpp.sh rename to docker/dev/exec_vpp.sh diff --git a/docker/dev_vpp_agent/govpp.conf b/docker/dev/govpp.conf similarity index 100% rename from docker/dev_vpp_agent/govpp.conf rename to docker/dev/govpp.conf diff --git a/docker/dev_vpp_agent/kafka.conf b/docker/dev/kafka.conf similarity index 100% rename from docker/dev_vpp_agent/kafka.conf rename to docker/dev/kafka.conf diff --git a/docker/dev_vpp_agent/linuxplugin.conf b/docker/dev/linux-plugin.conf similarity index 100% rename from docker/dev_vpp_agent/linuxplugin.conf rename to docker/dev/linux-plugin.conf diff --git a/docker/dev_vpp_agent/logs.conf b/docker/dev/logs.conf similarity index 100% rename from docker/dev_vpp_agent/logs.conf rename to docker/dev/logs.conf diff --git a/docker/dev_vpp_agent/redis.conf b/docker/dev/redis.conf similarity index 100% rename from docker/dev_vpp_agent/redis.conf rename to docker/dev/redis.conf diff --git a/docker/dev_vpp_agent/supervisord.conf b/docker/dev/supervisord.conf similarity index 59% rename from docker/dev_vpp_agent/supervisord.conf rename to docker/dev/supervisord.conf index df5eded9dc..a8880f034b 100644 --- a/docker/dev_vpp_agent/supervisord.conf +++ b/docker/dev/supervisord.conf @@ -2,21 +2,25 @@ logfile=/var/log/supervisord.log loglevel=debug nodaemon=true +pidfile=/run/supervisord.pid [program:vpp] -command=/usr/bin/runvpp +command=/usr/bin/exec_vpp.sh autorestart=false redirect_stderr=true priority=1 [program:agent] -command=/usr/bin/agent_start.py +command=/usr/bin/exec_agent.sh +startsecs=0 autorestart=false redirect_stderr=true priority=2 -; This event listener waits for event of vpp or agent exitting. Once received, it kills supervisord process and this makes -; subsequently the exit of docker container. You should also set agent's autorestart=false. +; This event listener waits for event of vpp or agent exitting. +; Once received, it kills supervisord process and this makes +; subsequently the exit of docker container. +; You should also set agent's autorestart=false. [eventlistener:vpp_or_agent_not_running] command=/usr/bin/supervisord_kill.py events=PROCESS_STATE_EXITED diff --git a/docker/dev/supervisord_kill.py b/docker/dev/supervisord_kill.py new file mode 120000 index 0000000000..4b3a7743b5 --- /dev/null +++ b/docker/dev/supervisord_kill.py @@ -0,0 +1 @@ +../prod/supervisord_kill.py \ No newline at end of file diff --git a/docker/dev_vpp_agent/defaultplugins.conf b/docker/dev/vpp-plugin.conf similarity index 100% rename from docker/dev_vpp_agent/defaultplugins.conf rename to docker/dev/vpp-plugin.conf diff --git a/docker/dev_vpp_agent/vpp.conf b/docker/dev/vpp.conf similarity index 100% rename from docker/dev_vpp_agent/vpp.conf rename to docker/dev/vpp.conf diff --git a/docker/dev_vpp_agent/Dockerfile b/docker/dev_vpp_agent/Dockerfile deleted file mode 100644 index 65374f5e9d..0000000000 --- a/docker/dev_vpp_agent/Dockerfile +++ /dev/null @@ -1,92 +0,0 @@ -FROM ubuntu:16.04 - -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - sudo wget git build-essential gdb vim nano python \ - iproute2 iputils-ping inetutils-traceroute libapr1 supervisor \ - default-jre default-jdk telnet netcat software-properties-common \ - libmbedcrypto0 libmbedtls10 libmbedx509-0 ca-certificates \ - make autoconf automake libtool curl unzip ipsec-tools \ - && apt-get remove -y --purge gcc \ - && rm -rf /var/lib/apt/lists/* - - -RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test \ - && apt-get update \ - && apt-get install -y gcc-7 g++-7 \ - && cd /usr/bin/ \ - && ln -s gcc-7 gcc \ - && ln -s g++-7 g++ \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /opt/vpp-agent/dev /opt/vpp-agent/plugin - -WORKDIR /opt/vpp-agent/dev - -ARG VPP_COMMIT -ARG VPP_REPO_URL - -RUN /bin/bash -c "\ - git clone ${VPP_REPO_URL} \ - && cd vpp \ - && git checkout ${VPP_COMMIT} \ - && UNATTENDED=y make vpp_configure_args_vpp='--disable-japi --disable-vom' install-dep bootstrap dpdk-install-dev build build-release;" - -ARG VPP_DEBUG_DEB - -RUN /bin/bash -c "\ - cd vpp; \ - if [ -n '${VPP_DEBUG_DEB}' ]; then \ - cd build-root \ - && make PLATFORM=vpp TAG=vpp_debug install-deb; \ - else \ - make pkg-deb && \ - cd build-root; \ - fi; \ - dpkg -i vpp_*.deb vpp-dev_*.deb vpp-lib_*.deb vpp-plugins_*.deb vpp-dbg_*.deb;" - -# install Go -ENV GOLANG_VERSION 1.10 -RUN wget -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz" \ - && tar -C /usr/local -xzf go.tgz \ - && rm go.tgz - -ENV PATH /usr/local/go/bin:$PATH - -# build & install Protobuf & gogo protobuf compiler -RUN git clone https://github.com/google/protobuf.git \ - && cd protobuf \ - && ./autogen.sh \ - && ./configure \ - && make -j4 \ - && make install \ - && ldconfig \ - && cd .. \ - && rm -rf protobuf - -ARG AGENT_COMMIT - -# copy and execute agent build script -COPY build-agent.sh . -RUN ./build-agent.sh ${AGENT_COMMIT} - -# copy configs -COPY etcd.conf kafka.conf govpp.conf defaultplugins.conf linuxplugin.conf logs.conf ./ -COPY vpp.conf /etc/vpp/vpp.conf -COPY supervisord.conf /etc/supervisord/supervisord.conf - -# copy scripts -COPY runvpp.sh /usr/bin/runvpp -COPY agent_start.py /usr/bin/agent_start.py -COPY supervisord_kill.py /usr/bin/supervisord_kill.py - -WORKDIR /root/ - -# start agent -ENV START_AGENT "True" -# kill supervisor if vpp or agent is closed -ENV RETAIN_SUPERVISOR "False" - -# run supervisor as the default executable -CMD rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api && \ - /usr/bin/supervisord -c /etc/supervisord/supervisord.conf diff --git a/docker/dev_vpp_agent/agent_start.py b/docker/dev_vpp_agent/agent_start.py deleted file mode 100755 index b7a14daaa8..0000000000 --- a/docker/dev_vpp_agent/agent_start.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -import sys -import os - -def write_stdout(msg): - sys.stdout.write(msg) - sys.stdout.flush() - -def main(): - # start agent if set - if 'START_AGENT' in os.environ: - agent_start = os.environ['START_AGENT'] - if agent_start=='true' or agent_start == 'True': - write_stdout('\nStarting vpp-agent...\n') - os.system("/root/go/bin/vpp-agent --etcdv3-config=/opt/vpp-agent/dev/etcd.conf --kafka-config=/opt/vpp-agent/dev/kafka.conf --default-plugins-config=/opt/vpp-agent/dev/defaultplugins.conf --linuxplugin-config=/opt/vpp-agent/dev/linuxplugin.conf --logs-config=/opt/vpp-agent/dev/logs.conf") - return - write_stdout('\nVpp-agent omitted\n') - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/docker/dev_vpp_agent/build-agent.sh b/docker/dev_vpp_agent/build-agent.sh deleted file mode 100755 index 0a4688b5f7..0000000000 --- a/docker/dev_vpp_agent/build-agent.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -e - -# setup Go paths -export GOROOT=/usr/local/go -export GOPATH=$HOME/go -export PATH=$PATH:${GOROOT}/bin:${GOPATH}/bin -echo "export GOROOT=$GOROOT" >> ~/.bashrc -echo "export GOPATH=$GOPATH" >> ~/.bashrc -echo "export PATH=$PATH" >> ~/.bashrc - -# checkout agent code -mkdir -p ${GOPATH}/src/github.com/ligato -cd ${GOPATH}/src/github.com/ligato -git clone https://github.com/ligato/vpp-agent - -# build the agent -cd ${GOPATH}/src/github.com/ligato/vpp-agent -git checkout $1 -make install diff --git a/docker/dev_vpp_agent/build.sh b/docker/dev_vpp_agent/build.sh deleted file mode 100755 index 764d081931..0000000000 --- a/docker/dev_vpp_agent/build.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -e - -VPP_DEBUG_DEB=${VPP_DEBUG_DEB:-} -IMAGE_TAG=${IMAGE_TAG:-dev_vpp_agent} - -AGENT_COMMIT=`git rev-parse HEAD` - -source ../../vpp.env - -echo "repo agent commit: ${AGENT_COMMIT}" -echo "repo vpp commit: ${VPP_COMMIT}" -echo "repo vpp repo url: ${VPP_REPO_URL}" - -while [ "$1" != "" ]; do - case $1 in - -a | --agent ) shift - AGENT_COMMIT=$1 - echo "using agent commit: ${AGENT_COMMIT}" - ;; - -v | --vpp ) shift - VPP_COMMIT=$1 - echo "using vpp commit: ${VPP_COMMIT}" - ;; - * ) echo "invalid parameter $1" - exit 1 - esac - shift -done - -echo -echo "building docker image: ${IMAGE_TAG}" - -sudo docker build --tag ${IMAGE_TAG} \ - --build-arg VPP_DEBUG_DEB=${VPP_DEBUG_DEB} \ - --build-arg AGENT_COMMIT=${AGENT_COMMIT} \ - --build-arg VPP_COMMIT=${VPP_COMMIT} \ - --build-arg VPP_REPO_URL=${VPP_REPO_URL} \ - . diff --git a/docker/dev_vpp_agent/shrink.sh b/docker/dev_vpp_agent/shrink.sh deleted file mode 100755 index 2b21227a50..0000000000 --- a/docker/dev_vpp_agent/shrink.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set +e -sudo docker rmi -f dev_vpp_agent_shrink 2>/dev/null -sudo docker rm -f shrink 2>/dev/null -set -e - -sudo docker run -itd --name shrink dev_vpp_agent bash -sudo docker exec shrink /bin/bash -c 'mkdir -p /root/vpp/build-root && cp /opt/vpp-agent/dev/vpp/build-root/*.deb /root/vpp/build-root && rm -rf /opt/vpp-agent/dev/vpp && \ - mv /root/vpp /opt/vpp-agent/dev' -sudo docker export shrink >shrink.tar -sudo docker rm -f shrink -sudo docker import -c "WORKDIR /root/" -c 'CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]' shrink.tar dev_vpp_agent_shrink -rm shrink.tar diff --git a/docker/dev_vpp_agent/supervisord_kill.py b/docker/dev_vpp_agent/supervisord_kill.py deleted file mode 100755 index 773a74ecd1..0000000000 --- a/docker/dev_vpp_agent/supervisord_kill.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -import sys -import os -import signal - - -def write_stdout(msg): - # only eventlistener protocol messages may be sent to stdout - sys.stdout.write(msg) - sys.stdout.flush() - - -def write_stderr(msg): - sys.stderr.write("EVENT LISTENER: " + msg) - sys.stderr.flush() - - -def main(): - while 1: - # do not kill supervisor if retained - retain = os.environ['RETAIN_SUPERVISOR'] - if retain=='true' or retain=='True': - write_stdout('\nSupervisor will be preserved\n') - continue - # transition from ACKNOWLEDGED to READY - write_stdout('READY\n') - - # read header line and print it to stderr - line = sys.stdin.readline() - write_stderr(line) - - # read event payload and print it to stderr - headers = dict([x.split(':') for x in line.split()]) - data = sys.stdin.read(int(headers['len'])) - write_stderr(data) - try: - parsed_data = dict([x.split(':') for x in data.split()]) - # ignore non vpp events, skipping - if parsed_data["processname"] not in ["vpp", "agent"]: - msg = 'Ignoring event from ' + parsed_data["processname"] - write_stderr(msg) - write_stdout('RESULT 2\nOK') - continue - with open('/root/supervisord.pid', 'r') as pidfile: - pid = int(pidfile.readline()) - write_stderr('Killing supervisors with pid: ' + str(pid)) - os.kill(pid, signal.SIGQUIT) - except Exception as e: - write_stderr('Could not kill supervisor: ' + str(e) + '\n') - - # transition from READY to ACKNOWLEDGED - write_stdout('RESULT 2\nOK') - - -if __name__ == '__main__': - main() diff --git a/docker/prod_vpp_agent/Dockerfile b/docker/prod/Dockerfile similarity index 67% rename from docker/prod_vpp_agent/Dockerfile rename to docker/prod/Dockerfile index 47bcecc589..c137ba4f30 100644 --- a/docker/prod_vpp_agent/Dockerfile +++ b/docker/prod/Dockerfile @@ -1,9 +1,5 @@ FROM dev_vpp_agent as devimg -RUN /bin/bash -c "\ - cd /root/go/src/github.com/ligato/vpp-agent \ - && make STRIP=y install" - FROM ubuntu:16.04 RUN apt-get update \ @@ -28,27 +24,31 @@ RUN cd /opt/vpp/ && dpkg -i vpp_*.deb vpp-lib_*.deb vpp-plugins_*.deb # install agent COPY --from=devimg \ - /root/go/bin/vpp-agent \ - /root/go/bin/vpp-agent-ctl \ - /root/go/bin/agentctl \ + /go/bin/vpp-agent \ + /go/bin/vpp-agent-ctl \ + /go/bin/agentctl \ /bin/ # copy configs -COPY etcd.conf kafka.conf govpp.conf defaultplugins.conf linuxplugin.conf /opt/vpp-agent/dev/ +COPY \ + etcd.conf \ + kafka.conf \ + govpp.conf \ + vpp-plugin.conf \ + linux-plugin.conf \ + /opt/vpp-agent/dev/ + COPY vpp.conf /etc/vpp/vpp.conf COPY supervisord.conf /etc/supervisord/supervisord.conf # copy scripts -COPY supervisord_kill.py /usr/bin/supervisord_kill.py -COPY agent_start.py /usr/bin/agent_start.py +COPY \ + exec_agent.sh \ + supervisord_kill.py \ + /usr/bin/ WORKDIR /root/ -# start agent -ENV START_AGENT "True" -# kill supervisor if vpp or agent is closed -ENV RETAIN_SUPERVISOR "False" - # run supervisor as the default executable CMD rm -f /dev/shm/db /dev/shm/global_vm /dev/shm/vpe-api && \ /usr/bin/supervisord -c /etc/supervisord/supervisord.conf diff --git a/docker/prod_vpp_agent/README.md b/docker/prod/README.md similarity index 91% rename from docker/prod_vpp_agent/README.md rename to docker/prod/README.md index 9fd77227c7..1d1e3a7874 100644 --- a/docker/prod_vpp_agent/README.md +++ b/docker/prod/README.md @@ -21,8 +21,8 @@ To build the production image on your local machine, type: This will build `prod_vpp_agent` image with agent and vpp files taken from dev image. In addition, these environment variables can be set in Dockerfile: -- `START_AGENT` - whether the vpp-agent should be started after start of the container (default is true, agent will be started) -- `RETAIN_SUPERVISOR` - whether the supervisor should be killed (default is false, supervisor will be stopped) +- `OMIT_AGENT` - whether the start of vpp-agent should be omitted (default is unset, agent will be started normally) +- `RETAIN_SUPERVISOR` - whether the supervisord should quit on unexpected exit of vpp or vpp-agent (default is unset, supervisord will quit) Their values can be also changed before image start with `docker -e` to have desired behavior @@ -92,6 +92,6 @@ sudo docker exec -it vpp_agent bash ### Running VPP and the Agent You can use the image the same way as the development image, see this -[README](../dev_vpp_agent/README.md). +[README](../dev/README.md). [1]: https://github.com/moby/moby/issues/26173 \ No newline at end of file diff --git a/docker/prod/build.sh b/docker/prod/build.sh new file mode 100755 index 0000000000..c74fb9223b --- /dev/null +++ b/docker/prod/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +cd "$(dirname "$0")" + +set -e + +IMAGE_TAG=${IMAGE_TAG:-'prod_vpp_agent'} + +sudo docker build ${DOCKER_BUILD_ARGS} --tag ${IMAGE_TAG} . diff --git a/docker/prod_vpp_agent/etcd.conf b/docker/prod/etcd.conf similarity index 100% rename from docker/prod_vpp_agent/etcd.conf rename to docker/prod/etcd.conf diff --git a/docker/prod/exec_agent.sh b/docker/prod/exec_agent.sh new file mode 100755 index 0000000000..f6a74b028c --- /dev/null +++ b/docker/prod/exec_agent.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e + +if [ -n "$OMIT_AGENT" ]; then + echo "Start of vpp-agent disabled (unset OMIT_AGENT to enable it)" +else + echo "Starting vpp-agent.." + exec vpp-agent --config-dir=/opt/vpp-agent/dev +fi diff --git a/docker/prod_vpp_agent/govpp.conf b/docker/prod/govpp.conf similarity index 100% rename from docker/prod_vpp_agent/govpp.conf rename to docker/prod/govpp.conf diff --git a/docker/prod_vpp_agent/kafka.conf b/docker/prod/kafka.conf similarity index 100% rename from docker/prod_vpp_agent/kafka.conf rename to docker/prod/kafka.conf diff --git a/docker/prod_vpp_agent/defaultplugins.conf b/docker/prod/linux-plugin.conf similarity index 100% rename from docker/prod_vpp_agent/defaultplugins.conf rename to docker/prod/linux-plugin.conf diff --git a/docker/prod_vpp_agent/supervisord.conf b/docker/prod/supervisord.conf similarity index 52% rename from docker/prod_vpp_agent/supervisord.conf rename to docker/prod/supervisord.conf index d789aa30e3..0be10c28b7 100644 --- a/docker/prod_vpp_agent/supervisord.conf +++ b/docker/prod/supervisord.conf @@ -2,6 +2,7 @@ logfile=/var/log/supervisord.log loglevel=debug nodaemon=true +pidfile=/run/supervisord.pid [program:vpp] command=/usr/bin/vpp -c /etc/vpp/vpp.conf @@ -10,13 +11,16 @@ redirect_stderr=true priority=1 [program:agent] -command=/bin/vpp-agent --etcdv3-config=/opt/vpp-agent/dev/etcd.conf --kafka-config=/opt/vpp-agent/dev/kafka.conf --default-plugins-config=/opt/vpp-agent/dev/defaultplugins.conf --linuxplugin-config=/opt/vpp-agent/dev/linuxplugin.conf +command=/usr/bin/exec_agent.sh +startsecs=0 autorestart=false redirect_stderr=true priority=2 -; This event listener waits for event of vpp or agent exitting. Once received, it kills supervisord process and this makes -; subsequently the exit of docker container. You should also set agent's autorestart=false. +; This event listener waits for event of vpp or agent exitting. +; Once received, it kills supervisord process and this makes +; subsequently the exit of docker container. +; You should also set agent's autorestart=false. [eventlistener:vpp_or_agent_not_running] command=/usr/bin/supervisord_kill.py events=PROCESS_STATE_EXITED diff --git a/docker/prod/supervisord_kill.py b/docker/prod/supervisord_kill.py new file mode 100755 index 0000000000..debf647cb0 --- /dev/null +++ b/docker/prod/supervisord_kill.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +import sys +import os +import signal + + +def write_stdout(msg): + # only eventlistener protocol messages may be sent to stdout + sys.stdout.write(msg) + sys.stdout.flush() + + +def write_stderr(msg): + sys.stderr.write(msg) + sys.stderr.flush() + + +def main(): + while 1: + # transition from ACKNOWLEDGED to READY + write_stdout('READY\n') + + # read header line and print it to stderr + line = sys.stdin.readline() + write_stderr('EVENT: ' + line) + + # read event payload and print it to stderr + headers = dict([x.split(':') for x in line.split()]) + data = sys.stdin.read(int(headers['len'])) + write_stderr('DATA: ' + data + '\n') + + # ignore non vpp events, skipping + parsed_data = dict([x.split(':') for x in data.split()]) + if parsed_data["processname"] not in ["vpp", "agent"]: + write_stderr('Ignoring event from ' + parsed_data["processname"] + '\n') + write_stdout('RESULT 2\nOK') + continue + + # ignore exits with expected exit codes + if parsed_data["expected"] == "1": + write_stderr('Exit state from ' + parsed_data["processname"] + ' was expected\n') + write_stdout('RESULT 2\nOK') + continue + + # do not kill supervisor if retained and exit + if 'RETAIN_SUPERVISOR' in os.environ and os.environ['RETAIN_SUPERVISOR'] != '': + write_stderr('Supervisord is configured to retain after unexpected exits (unset RETAIN_SUPERVISOR to disable it)\n') + write_stdout('RESULT 2\nOK') + continue + + try: + with open('/run/supervisord.pid', 'r') as pidfile: + pid = int(pidfile.readline()) + write_stderr('Killing supervisord with pid: ' + str(pid) + '\n') + os.kill(pid, signal.SIGQUIT) + except Exception as e: + write_stderr('Could not kill supervisor: ' + str(e) + '\n') + + # transition from READY to ACKNOWLEDGED + write_stdout('RESULT 2\nOK') + return + + +if __name__ == '__main__': + main() diff --git a/docker/prod_vpp_agent/linuxplugin.conf b/docker/prod/vpp-plugin.conf similarity index 100% rename from docker/prod_vpp_agent/linuxplugin.conf rename to docker/prod/vpp-plugin.conf diff --git a/docker/prod_vpp_agent/vpp.conf b/docker/prod/vpp.conf similarity index 100% rename from docker/prod_vpp_agent/vpp.conf rename to docker/prod/vpp.conf diff --git a/docker/prod_vpp_agent/agent_start.py b/docker/prod_vpp_agent/agent_start.py deleted file mode 100755 index 890e716682..0000000000 --- a/docker/prod_vpp_agent/agent_start.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python - -import sys -import os - -def write_stdout(msg): - sys.stdout.write(msg) - sys.stdout.flush() - -def main(): - # start agent if set - if 'START_AGENT' in os.environ: - agent_start = os.environ['START_AGENT'] - if agent_start=='true' or agent_start == 'True': - write_stdout('\nStarting vpp-agent...\n') - os.system("/bin/vpp-agent --etcdv3-config=/opt/vpp-agent/dev/etcd.conf --kafka-config=/opt/vpp-agent/dev/kafka.conf --default-plugins-config=/opt/vpp-agent/dev/defaultplugins.conf --linuxplugin-config=/opt/vpp-agent/dev/linuxplugin.conf") - return - write_stdout('\nVpp-agent omitted\n') - -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/docker/prod_vpp_agent/build.sh b/docker/prod_vpp_agent/build.sh deleted file mode 100755 index f4f788b4cf..0000000000 --- a/docker/prod_vpp_agent/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -IMAGE_TAG=${IMAGE_TAG:-prod_vpp_agent} - -sudo docker build --tag ${IMAGE_TAG} . diff --git a/docker/prod_vpp_agent/shrink.sh b/docker/prod_vpp_agent/shrink.sh deleted file mode 100755 index bfcc887d9e..0000000000 --- a/docker/prod_vpp_agent/shrink.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -set +e -sudo docker rmi -f prod_vpp_agent_shrink 2>/dev/null -sudo docker rm -f shrink 2>/dev/null -set -e - -sudo docker run -itd --name shrink prod_vpp_agent bash -sudo docker export shrink >shrink.tar -sudo docker rm -f shrink -sudo docker import -c "WORKDIR /root/" -c 'CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"]' shrink.tar prod_vpp_agent_shrink -rm shrink.tar - diff --git a/docker/prod_vpp_agent/supervisord_kill.py b/docker/prod_vpp_agent/supervisord_kill.py deleted file mode 100755 index b55752712f..0000000000 --- a/docker/prod_vpp_agent/supervisord_kill.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env python - -import sys -import os -import signal - - -def write_stdout(msg): - # only eventlistener protocol messages may be sent to stdout - sys.stdout.write(msg) - sys.stdout.flush() - - -def write_stderr(msg): - sys.stderr.write("EVENT LISTENER: " + msg) - sys.stderr.flush() - - -def main(): - while 1: - # do not kill supervisor if retained - retain = os.environ['RETAIN_SUPERVISOR'] - if retain=='true' or retain == 'True': - write_stdout('\nSupervisor will be preserved\n') - continue - # transition from ACKNOWLEDGED to READY - write_stdout('READY\n') - - # read header line and print it to stderr - line = sys.stdin.readline() - write_stderr(line) - - # read event payload and print it to stderr - headers = dict([x.split(':') for x in line.split()]) - data = sys.stdin.read(int(headers['len'])) - write_stderr(data) - try: - parsed_data = dict([x.split(':') for x in data.split()]) - # ignore non vpp events, skipping - if parsed_data["processname"] not in ["vpp", "agent"]: - msg = 'Ignoring event from ' + parsed_data["processname"] - write_stderr(msg) - write_stdout('RESULT 2\nOK') - continue - with open('/root/supervisord.pid', 'r') as pidfile: - pid = int(pidfile.readline()) - write_stderr('Killing supervisors with pid: ' + str(pid)) - os.kill(pid, signal.SIGQUIT) - except Exception as e: - write_stderr('Could not kill supervisor: ' + str(e) + '\n') - - # transition from READY to ACKNOWLEDGED - write_stdout('RESULT 2\nOK') - - -if __name__ == '__main__': - main() diff --git a/examples/README.md b/examples/README.md index eec7fb1119..95efa9180c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -72,7 +72,7 @@ Current examples: Example can be started now from particular directory. ``` go run main.go \ - --etcdv3-config=/opt/vpp-agent/dev/etcd.conf \ + --etcd-config=/opt/vpp-agent/dev/etcd.conf \ --kafka-config=/opt/vpp-agent/dev/kafka.conf ``` [1]: https://github.com/ligato/cn-infra/tree/master/examples \ No newline at end of file diff --git a/examples/govpp_call/main.go b/examples/govpp_call/main.go index 6dd81f68f1..7fae0be00e 100644 --- a/examples/govpp_call/main.go +++ b/examples/govpp_call/main.go @@ -17,13 +17,13 @@ package main import ( "time" - "git.fd.io/govpp.git/api" + govppapi "git.fd.io/govpp.git/api" "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/utils/safeclose" - "github.com/ligato/vpp-agent/flavors/vpp" - "github.com/ligato/vpp-agent/plugins/defaultplugins" - bin_api "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" + vppFlavor "github.com/ligato/vpp-agent/flavors/vpp" + "github.com/ligato/vpp-agent/plugins/vpp" + l2Api "github.com/ligato/vpp-agent/plugins/vpp/binapi/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" ) // ************************************************************************* @@ -46,12 +46,12 @@ func main() { exampleFinished := make(chan struct{}, 1) // Start Agent with ExampleFlavor - vppFlavor := vpp.Flavor{} + flavor := vppFlavor.Flavor{} exampleFlavor := ExampleFlavor{ GovppExample: ExamplePlugin{closeChannel: &exampleFinished}, - Flavor: &vppFlavor, // inject VPP flavor + Flavor: &flavor, // inject VPP flavor } - agent := core.NewAgent(core.Inject(&vppFlavor, &exampleFlavor)) + agent := core.NewAgent(core.Inject(&flavor, &exampleFlavor)) core.EventLoopWithInterrupt(agent, exampleFinished) } @@ -60,10 +60,10 @@ func main() { type ExamplePlugin struct { Deps - VPP defaultplugins.API + VPP vpp.API - exampleIDSeq uint32 // Plugin-specific ID initialization - vppChannel *api.Channel // Vpp channel to communicate with VPP + exampleIDSeq uint32 // Plugin-specific ID initialization + vppChannel govppapi.Channel // Vpp channel to communicate with VPP // Fields below are used to properly finish the example. closeChannel *chan struct{} } @@ -87,8 +87,7 @@ func (plugin *ExamplePlugin) Init() (err error) { // Close is called by Agent Core when the Agent is shutting down. It is supposed // to clean up resources that were allocated by the plugin during its lifetime. func (plugin *ExamplePlugin) Close() error { - safeclose.CloseAll(plugin.GoVppmux, plugin.vppChannel) - return nil + return safeclose.Close(plugin.GoVppmux, plugin.vppChannel) } /*********** @@ -116,7 +115,7 @@ func (plugin *ExamplePlugin) VppCall() { plugin.exampleIDSeq++ // Generic bin api reply (request: BridgeDomainAddDel) - reply := &bin_api.BridgeDomainAddDelReply{} + reply := &l2Api.BridgeDomainAddDelReply{} plugin.Log.Info("Sending data to VPP ...") @@ -159,8 +158,8 @@ func buildData(name string) *l2.BridgeDomains { } // Auxiliary method to transform agent model data to binary api format -func buildBinapiMessage(data *l2.BridgeDomains, id uint32) *bin_api.BridgeDomainAddDel { - req := &bin_api.BridgeDomainAddDel{} +func buildBinapiMessage(data *l2.BridgeDomains, id uint32) *l2Api.BridgeDomainAddDel { + req := &l2Api.BridgeDomainAddDel{} req.IsAdd = 1 req.BdID = id req.Flood = boolToInt(data.BridgeDomains[0].Flood) diff --git a/examples/grpc_vpp/notifications/README.md b/examples/grpc_vpp/notifications/README.md index 70494f68df..3025badb78 100644 --- a/examples/grpc_vpp/notifications/README.md +++ b/examples/grpc_vpp/notifications/README.md @@ -15,8 +15,9 @@ vpp-agent --grpc-config=/opt/vpp-agent/dev/grpc.conf go run main.go ``` -Two flags can be set: -* `-address=
` - for grpc server address (otherwise localhost will be used) +Several flags can be set: +* `-address=
` - for grpc server address/socket-file (otherwise localhost will be used) +* `-socket-type=` - options are tcp, tcp4, tcp6, unix or unixpacket. Defaults to tcp if not set * `request-period=` - time between grpc requests The example prints all received VPP notifications. \ No newline at end of file diff --git a/examples/grpc_vpp/notifications/main.go b/examples/grpc_vpp/notifications/main.go index a305796b14..0a8194a393 100644 --- a/examples/grpc_vpp/notifications/main.go +++ b/examples/grpc_vpp/notifications/main.go @@ -19,11 +19,14 @@ import ( "os" "time" + "fmt" + "net" + "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/flavors/local" "github.com/ligato/cn-infra/logging" log "github.com/ligato/cn-infra/logging/logrus" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/rpc" + "github.com/ligato/vpp-agent/plugins/vpp/model/rpc" "github.com/namsral/flag" "golang.org/x/net/context" "google.golang.org/grpc" @@ -31,12 +34,14 @@ import ( const ( defaultAddress = "localhost:9111" + defaultSocket = "tcp" requestPeriod = 3 ) var ( - address = defaultAddress - reqPer = requestPeriod + address = defaultAddress + socketType string + reqPer = requestPeriod ) // init sets the default logging level @@ -51,6 +56,7 @@ func main() { closeChannel := make(chan struct{}, 1) flag.StringVar(&address, "address", defaultAddress, "address of GRPC server") + flag.StringVar(&socketType, "socket-type", defaultSocket, "[tcp, tcp4, tcp6, unix, unixpacket]") flag.IntVar(&reqPer, "request-period", requestPeriod, "notification request period in seconds") // Example plugin @@ -71,7 +77,14 @@ type ExamplePlugin struct { // Init initializes example plugin. func (plugin *ExamplePlugin) Init() (err error) { // Set up connection to the server. - plugin.conn, err = grpc.Dial(address, grpc.WithInsecure()) + switch socketType { + case "tcp", "tcp4", "tcp6", "unix", "unixpacket": + plugin.conn, err = grpc.Dial("unix", grpc.WithInsecure(), + grpc.WithDialer(dialer(socketType, address, 2*time.Second))) + default: + return fmt.Errorf("unknown gRPC socket type: %s", socketType) + } + if err != nil { return err } @@ -133,3 +146,13 @@ func (plugin *ExamplePlugin) watchNotifications() { time.Sleep(time.Duration(reqPer) * time.Second) } } + +// Dialer for unix domain socket +func dialer(socket, address string, timeoutVal time.Duration) func(string, time.Duration) (net.Conn, error) { + return func(addr string, timeout time.Duration) (net.Conn, error) { + // Pass values + addr, timeout = address, timeoutVal + // Dial with timeout + return net.DialTimeout(socket, addr, timeoutVal) + } +} diff --git a/examples/grpc_vpp/remote_client/README.md b/examples/grpc_vpp/remote_client/README.md index 0caa191cf9..caa17922f7 100644 --- a/examples/grpc_vpp/remote_client/README.md +++ b/examples/grpc_vpp/remote_client/README.md @@ -17,4 +17,8 @@ vpp-agent --grpc-config=/opt/vpp-agent/dev/grpc.conf go run main.go ``` +Two flags can be set: +* `-address=
` - for grpc server address/socket-file (otherwise localhost will be used) +* `-socket-type=` - options are tcp, tcp4, tcp6, unix or unixpacket. Defaults to tcp if not set + The example creates resync request with configuration which is then updated with data change request. diff --git a/examples/grpc_vpp/remote_client/main.go b/examples/grpc_vpp/remote_client/main.go index 167765facf..e63b64cb83 100644 --- a/examples/grpc_vpp/remote_client/main.go +++ b/examples/grpc_vpp/remote_client/main.go @@ -26,20 +26,26 @@ import ( "github.com/ligato/cn-infra/logging" log "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/cn-infra/utils/safeclose" - "github.com/ligato/vpp-agent/clientv1/defaultplugins/remoteclient" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/rpc" + "github.com/ligato/vpp-agent/clientv1/vpp/remoteclient" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/rpc" + + "fmt" "github.com/namsral/flag" "google.golang.org/grpc" ) -const defaultAddress = "localhost:9111" +const ( + defaultAddress = "localhost:9111" + defaultSocket = "tcp" +) var address = defaultAddress +var socketType string // init sets the default logging level func init() { @@ -57,6 +63,7 @@ func main() { closeChannel := make(chan struct{}, 1) flag.StringVar(&address, "address", defaultAddress, "address of GRPC server") + flag.StringVar(&socketType, "socket-type", defaultSocket, "socket type [tcp, tcp4, tcp6, unix, unixpacket]") // Example plugin agent := local.NewAgent(local.WithPlugins(func(flavor *local.FlavorLocal) []*core.NamedPlugin { @@ -95,9 +102,12 @@ type ExamplePlugin struct { // Init initializes example plugin. func (plugin *ExamplePlugin) Init() (err error) { // Set up connection to the server. - plugin.conn, err = grpc.Dial(address, grpc.WithInsecure()) - if err != nil { - return err + switch socketType { + case "tcp", "tcp4", "tcp6", "unix", "unixpacket": + plugin.conn, err = grpc.Dial("unix", grpc.WithInsecure(), + grpc.WithDialer(dialer(socketType, address, 2*time.Second))) + default: + return fmt.Errorf("unknown gRPC socket type: %s", socketType) } // Apply initial VPP configuration. @@ -127,6 +137,16 @@ func (plugin *ExamplePlugin) Close() error { return nil } +// Dialer for unix domain socket +func dialer(socket, address string, timeoutVal time.Duration) func(string, time.Duration) (net.Conn, error) { + return func(addr string, timeout time.Duration) (net.Conn, error) { + // Pass values + addr, timeout = address, timeoutVal + // Dial with timeout + return net.DialTimeout(socket, addr, timeoutVal) + } +} + // resyncVPP propagates snapshot of the whole initial configuration to VPP plugins. func (plugin *ExamplePlugin) resyncVPP() { err := remoteclient.DataResyncRequestGRPC(rpc.NewDataResyncServiceClient(plugin.conn)). diff --git a/examples/idx_bd_cache/main.go b/examples/idx_bd_cache/main.go index c68d69a0f3..2d453a67a6 100644 --- a/examples/idx_bd_cache/main.go +++ b/examples/idx_bd_cache/main.go @@ -17,10 +17,10 @@ package main import ( "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/utils/safeclose" - "github.com/ligato/vpp-agent/flavors/vpp" - "github.com/ligato/vpp-agent/plugins/defaultplugins" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/l2plugin/l2idx" + vppFlavor "github.com/ligato/vpp-agent/flavors/vpp" + "github.com/ligato/vpp-agent/plugins/vpp" + "github.com/ligato/vpp-agent/plugins/vpp/l2plugin/l2idx" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" "github.com/ligato/vpp-agent/tests/go/itest/l2tst" ) @@ -30,12 +30,12 @@ func main() { exampleFinished := make(chan struct{}, 1) // Start Agent with VPP Flavor and ExampleFlavor. - vppFlavor := vpp.Flavor{} + flavor := vppFlavor.Flavor{} exampleFlavor := ExampleFlavor{ IdxBdCacheExample: ExamplePlugin{closeChannel: &exampleFinished}, - Flavor: &vppFlavor, // inject VPP flavor + Flavor: &flavor, // inject VPP flavor } - agent := core.NewAgent(core.Inject(&vppFlavor, &exampleFlavor)) + agent := core.NewAgent(core.Inject(&flavor, &exampleFlavor)) core.EventLoopWithInterrupt(agent, exampleFinished) } @@ -45,7 +45,7 @@ type ExamplePlugin struct { Deps // Linux plugin dependency - VPP defaultplugins.API + VPP vpp.API bdIdxLocal l2idx.BDIndex bdIdxAgent1 l2idx.BDIndex @@ -103,10 +103,8 @@ func (plugin *ExamplePlugin) AfterInit() error { // Close is called by Agent Core when the Agent is shutting down. It is supposed // to clean up resources that were allocated by the plugin during its lifetime. func (plugin *ExamplePlugin) Close() error { - var wasErr error - _, wasErr = safeclose.CloseAll(plugin.Agent1, plugin.Agent2, plugin.Publisher, plugin.Agent1, plugin.Agent2, + return safeclose.Close(plugin.Agent1, plugin.Agent2, plugin.Publisher, plugin.Agent1, plugin.Agent2, plugin.bdIdxLocal, plugin.bdIdxAgent1, plugin.bdIdxAgent2, plugin.closeChannel) - return wasErr } // Test data are published to different agents (including local). diff --git a/examples/idx_iface_cache/main.go b/examples/idx_iface_cache/main.go index 099c56ab10..faf709a7cc 100644 --- a/examples/idx_iface_cache/main.go +++ b/examples/idx_iface_cache/main.go @@ -17,10 +17,10 @@ package main import ( "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/utils/safeclose" - "github.com/ligato/vpp-agent/flavors/vpp" - "github.com/ligato/vpp-agent/plugins/defaultplugins" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/ifaceidx" + vppFlavor "github.com/ligato/vpp-agent/flavors/vpp" + "github.com/ligato/vpp-agent/plugins/vpp" + "github.com/ligato/vpp-agent/plugins/vpp/ifplugin/ifaceidx" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" "github.com/ligato/vpp-agent/tests/go/itest/iftst" ) @@ -30,12 +30,12 @@ func main() { exampleFinished := make(chan struct{}, 1) // Start Agent with ExampleFlavor. - vppFlavor := vpp.Flavor{} + flavor := vppFlavor.Flavor{} exampleFlavor := ExampleFlavor{ IdxIfaceCacheExample: ExamplePlugin{closeChannel: &exampleFinished}, - Flavor: &vppFlavor, // inject VPP flavor + Flavor: &flavor, // inject VPP flavor } - agent := core.NewAgent(core.Inject(&vppFlavor, &exampleFlavor)) + agent := core.NewAgent(core.Inject(&flavor, &exampleFlavor)) core.EventLoopWithInterrupt(agent, exampleFinished) } @@ -45,7 +45,7 @@ type ExamplePlugin struct { Deps // Linux plugin dependency - VPP defaultplugins.API + VPP vpp.API swIfIdxLocal ifaceidx.SwIfIndex swIfIdxAgent1 ifaceidx.SwIfIndex @@ -103,10 +103,8 @@ func (plugin *ExamplePlugin) AfterInit() error { // Close is called by Agent Core when the Agent is shutting down. It is supposed // to clean up resources that were allocated by the plugin during its lifetime. func (plugin *ExamplePlugin) Close() error { - var wasErr error - _, wasErr = safeclose.CloseAll(plugin.Agent1, plugin.Agent2, plugin.Publisher, plugin.Agent1, plugin.Agent2, + return safeclose.Close(plugin.Agent1, plugin.Agent2, plugin.Publisher, plugin.Agent1, plugin.Agent2, plugin.swIfIdxLocal, plugin.swIfIdxAgent1, plugin.swIfIdxAgent2, plugin.closeChannel) - return wasErr } // Test data are published to different agents (including local). diff --git a/examples/idx_veth_cache/deps.go b/examples/idx_veth_cache/deps.go index 0818cd9aec..16bdded7e6 100644 --- a/examples/idx_veth_cache/deps.go +++ b/examples/idx_veth_cache/deps.go @@ -1,3 +1,17 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package main import ( diff --git a/examples/idx_veth_cache/main.go b/examples/idx_veth_cache/main.go index ad7b1e818a..2b540f22f0 100644 --- a/examples/idx_veth_cache/main.go +++ b/examples/idx_veth_cache/main.go @@ -25,9 +25,9 @@ import ( log "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/cn-infra/utils/safeclose" "github.com/ligato/vpp-agent/flavors/vpp" - "github.com/ligato/vpp-agent/plugins/linuxplugin" - linux_intf "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - linux_if "github.com/ligato/vpp-agent/plugins/linuxplugin/ifplugin/ifaceidx" + "github.com/ligato/vpp-agent/plugins/linux" + linux_if "github.com/ligato/vpp-agent/plugins/linux/ifplugin/ifaceidx" + linux_intf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" ) // ************************************************************************* @@ -70,7 +70,7 @@ type ExamplePlugin struct { Deps // Linux plugin dependency - Linux linuxplugin.API + Linux linux.API linuxIfIdxLocal linux_if.LinuxIfIndex linuxIfIdxAgent1 linux_if.LinuxIfIndex @@ -105,8 +105,8 @@ func (plugin *ExamplePlugin) Init() error { go plugin.consume() // Cache the agent1/agent2 name-to-idx mapping to separate mapping within plugin example. - plugin.linuxIfIdxAgent1 = linux_if.Cache(plugin.Agent1, plugin.PluginName) - plugin.linuxIfIdxAgent2 = linux_if.Cache(plugin.Agent2, plugin.PluginName) + plugin.linuxIfIdxAgent1 = linux_if.Cache(plugin.Agent1) + plugin.linuxIfIdxAgent2 = linux_if.Cache(plugin.Agent2) log.DefaultLogger().Info("Initialization of the example plugin has completed") @@ -135,10 +135,8 @@ func (plugin *ExamplePlugin) AfterInit() error { func (plugin *ExamplePlugin) Close() error { plugin.wg.Wait() - var wasErr error - _, wasErr = safeclose.CloseAll(plugin.Agent1, plugin.Agent2, plugin.Publisher, plugin.Agent1, plugin.Agent2, + return safeclose.Close(plugin.Agent1, plugin.Agent2, plugin.Publisher, plugin.Agent1, plugin.Agent2, plugin.linuxIfIdxLocal, plugin.linuxIfIdxAgent1, plugin.linuxIfIdxAgent2, plugin.closeChannel) - return wasErr } // publish propagates example configuration to etcd. diff --git a/examples/localclient_linux/tap/main.go b/examples/localclient_linux/tap/main.go index 1a5463866d..a47686b945 100644 --- a/examples/localclient_linux/tap/main.go +++ b/examples/localclient_linux/tap/main.go @@ -24,9 +24,9 @@ import ( log "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/vpp-agent/clientv1/linux/localclient" "github.com/ligato/vpp-agent/flavors/local" - vpp_intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - vpp_l2 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - linux_intf "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" + linux_intf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + vpp_intf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + vpp_l2 "github.com/ligato/vpp-agent/plugins/vpp/model/l2" "github.com/namsral/flag" ) diff --git a/examples/localclient_linux/veth/main.go b/examples/localclient_linux/veth/main.go index 5f550e8502..23f7111bcb 100644 --- a/examples/localclient_linux/veth/main.go +++ b/examples/localclient_linux/veth/main.go @@ -24,9 +24,9 @@ import ( log "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/vpp-agent/clientv1/linux/localclient" "github.com/ligato/vpp-agent/flavors/local" - vpp_intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - vpp_l2 "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - linux_intf "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" + linux_intf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + vpp_intf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + vpp_l2 "github.com/ligato/vpp-agent/plugins/vpp/model/l2" "github.com/namsral/flag" ) diff --git a/examples/localclient_vpp/nat/main.go b/examples/localclient_vpp/nat/main.go index a963154177..8a5bdf7a54 100644 --- a/examples/localclient_vpp/nat/main.go +++ b/examples/localclient_vpp/nat/main.go @@ -22,10 +22,10 @@ import ( "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/logging" log "github.com/ligato/cn-infra/logging/logrus" - "github.com/ligato/vpp-agent/clientv1/defaultplugins/localclient" + "github.com/ligato/vpp-agent/clientv1/vpp/localclient" "github.com/ligato/vpp-agent/flavors/local" - vpp_intf "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/nat" + vpp_intf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/nat" "github.com/namsral/flag" ) diff --git a/examples/localclient_vpp/plugins/main.go b/examples/localclient_vpp/plugins/main.go index 9a9965d2fb..3862b35543 100644 --- a/examples/localclient_vpp/plugins/main.go +++ b/examples/localclient_vpp/plugins/main.go @@ -23,12 +23,12 @@ import ( "github.com/ligato/cn-infra/core" "github.com/ligato/cn-infra/logging" log "github.com/ligato/cn-infra/logging/logrus" - "github.com/ligato/vpp-agent/clientv1/defaultplugins/localclient" + "github.com/ligato/vpp-agent/clientv1/vpp/localclient" "github.com/ligato/vpp-agent/flavors/local" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l2" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/l3" + "github.com/ligato/vpp-agent/plugins/vpp/model/acl" + "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" + "github.com/ligato/vpp-agent/plugins/vpp/model/l2" + "github.com/ligato/vpp-agent/plugins/vpp/model/l3" ) // init sets the default logging level. diff --git a/flavors/local/local_flavor.go b/flavors/local/local_flavor.go index 86be8d580e..18ee3971ff 100644 --- a/flavors/local/local_flavor.go +++ b/flavors/local/local_flavor.go @@ -22,9 +22,9 @@ import ( "github.com/ligato/cn-infra/datasync" local_sync "github.com/ligato/cn-infra/datasync/kvdbsync/local" "github.com/ligato/vpp-agent/clientv1/linux/localclient" - "github.com/ligato/vpp-agent/plugins/defaultplugins" "github.com/ligato/vpp-agent/plugins/govppmux" - "github.com/ligato/vpp-agent/plugins/linuxplugin" + "github.com/ligato/vpp-agent/plugins/linux" + "github.com/ligato/vpp-agent/plugins/vpp" ) // NewAgent returns a new instance of the Agent with plugins. @@ -52,8 +52,8 @@ type FlavorVppLocal struct { *local.FlavorLocal LinuxLocalClient localclient.Plugin GoVPP govppmux.GOVPPPlugin - Linux linuxplugin.Plugin - VPP defaultplugins.Plugin + Linux linux.Plugin + VPP vpp.Plugin injected bool } @@ -71,10 +71,10 @@ func (f *FlavorVppLocal) Inject() bool { f.FlavorLocal.Inject() f.GoVPP.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("govpp") - f.Linux.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("linuxplugin", local.WithConf()) + f.Linux.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("linux-plugin", local.WithConf()) f.Linux.Watcher = &datasync.CompositeKVProtoWatcher{Adapters: []datasync.KeyValProtoWatcher{local_sync.Get()}} f.VPP.Watch = &datasync.CompositeKVProtoWatcher{Adapters: []datasync.KeyValProtoWatcher{local_sync.Get()}} - f.VPP.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("default-plugins", local.WithConf()) + f.VPP.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("vpp-plugin", local.WithConf()) f.VPP.Deps.Linux = &f.Linux f.VPP.Deps.GoVppmux = &f.GoVPP diff --git a/flavors/vpp/vpp_flavor.go b/flavors/vpp/vpp_flavor.go index e863b94f35..b43404ed2c 100644 --- a/flavors/vpp/vpp_flavor.go +++ b/flavors/vpp/vpp_flavor.go @@ -1,3 +1,17 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Package vpp defines the standard flavor used for full-featured VPP agents. package vpp @@ -11,12 +25,12 @@ import ( "github.com/ligato/cn-infra/flavors/connectors" "github.com/ligato/cn-infra/flavors/local" "github.com/ligato/cn-infra/flavors/rpc" - "github.com/ligato/vpp-agent/plugins/defaultplugins" - rpcsvc "github.com/ligato/vpp-agent/plugins/defaultplugins/rpc" "github.com/ligato/vpp-agent/plugins/govppmux" - "github.com/ligato/vpp-agent/plugins/linuxplugin" - "github.com/ligato/vpp-agent/plugins/restplugin" + "github.com/ligato/vpp-agent/plugins/linux" + "github.com/ligato/vpp-agent/plugins/rest" "github.com/ligato/vpp-agent/plugins/telemetry" + "github.com/ligato/vpp-agent/plugins/vpp" + rpcsvc "github.com/ligato/vpp-agent/plugins/vpp/rpc" ) // kafkaIfStateTopic is the topic where interface state changes are published. @@ -52,11 +66,11 @@ type Flavor struct { IfStatePub msgsync.PubPlugin GoVPP govppmux.GOVPPPlugin - Linux linuxplugin.Plugin - VPP defaultplugins.Plugin + Linux linux.Plugin + VPP vpp.Plugin GRPCSvcPlugin rpcsvc.GRPCSvcPlugin - RESTAPIPlugin restplugin.Plugin + RESTAPIPlugin rest.Plugin TelemetryPlugin telemetry.Plugin injected bool @@ -72,7 +86,8 @@ func (f *Flavor) Inject() bool { f.injectEmbedded() f.GoVPP.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("govpp", local.WithConf()) - f.VPP.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("default-plugins", local.WithConf()) + f.GoVPP.Deps.Resync = &f.ResyncOrch + f.VPP.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("vpp-plugin", local.WithConf()) f.VPP.Deps.Linux = &f.Linux f.VPP.Deps.GoVppmux = &f.GoVPP @@ -81,7 +96,7 @@ func (f *Flavor) Inject() bool { &f.AllConnectorsFlavor.ConsulDataSync, }} - /* note: now configurable with `status-publishers` in defaultplugins + /* note: now configurable with `status-publishers` in vppplugin f.VPP.Deps.PublishStatistics = &datasync.CompositeKVProtoWriter{Adapters: []datasync.KeyProtoValWriter{ &f.AllConnectorsFlavor.ETCDDataSync, &f.AllConnectorsFlavor.RedisDataSync}, }*/ @@ -106,7 +121,8 @@ func (f *Flavor) Inject() bool { }} f.VPP.Deps.GRPCSvc = &f.GRPCSvcPlugin - f.Linux.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("linuxplugin", local.WithConf()) + f.Linux.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("linux-plugin", local.WithConf()) + f.Linux.Deps.VPP = &f.VPP f.Linux.Deps.Watcher = &datasync.CompositeKVProtoWatcher{Adapters: []datasync.KeyValProtoWatcher{ local_sync.Get(), &f.AllConnectorsFlavor.ETCDDataSync, @@ -122,11 +138,11 @@ func (f *Flavor) Inject() bool { f.GRPCSvcPlugin.Deps.PluginLogDeps = *f.LogDeps("vpp-grpc-svc") f.GRPCSvcPlugin.Deps.GRPCServer = &f.FlavorRPC.GRPC - f.RESTAPIPlugin.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("restapi-plugin") + f.RESTAPIPlugin.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("rest") f.RESTAPIPlugin.Deps.HTTPHandlers = &f.FlavorRPC.HTTP f.RESTAPIPlugin.Deps.GoVppmux = &f.GoVPP - f.TelemetryPlugin.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("telemetry-plugin") + f.TelemetryPlugin.Deps.PluginInfraDeps = *f.FlavorLocal.InfraDeps("telemetry") f.TelemetryPlugin.Deps.Prometheus = &f.FlavorRPC.Prometheus f.TelemetryPlugin.Deps.GoVppmux = &f.GoVPP diff --git a/idxvpp/api.go b/idxvpp/api.go index 3492a50721..23bed6baef 100644 --- a/idxvpp/api.go +++ b/idxvpp/api.go @@ -77,10 +77,13 @@ type NameToIdxRW interface { UnregisterName(name string) (idx uint32, metadata interface{}, exists bool) // UpdateMetadata replaces metadata value in existing name-to-index - // mapping entry. Unlike registration, this function does not create - // any notification. If mapping associated with the name does not + // mapping entry. If mapping associated with the name does not // exist, it is not created. UpdateMetadata(name string, metadata interface{}) (success bool) + + // Clear removes all entries present in the name-to-index mapping. + // This action does not trigger any notification. + Clear() } // NameToIdx is the "user API" to the NameToIdx registry. It provides diff --git a/idxvpp/nametoidx/inmemory_name_to_idx_mapping.go b/idxvpp/nametoidx/inmemory_name_to_idx_mapping.go index ce6ad63370..32769bb973 100644 --- a/idxvpp/nametoidx/inmemory_name_to_idx_mapping.go +++ b/idxvpp/nametoidx/inmemory_name_to_idx_mapping.go @@ -95,6 +95,11 @@ func (mem *nameToIdxMem) UpdateMetadata(name string, metadata interface{}) (succ return false } +// Clear removes all entries from the mapping +func (mem *nameToIdxMem) Clear() { + mem.internal.Clear() +} + // GetRegistryTitle returns a name assigned to mapping. func (mem *nameToIdxMem) GetRegistryTitle() string { return mem.internal.GetRegistryTitle() diff --git a/idxvpp/nametoidx/inmemory_scenario_test.go b/idxvpp/nametoidx/inmemory_scenario_test.go index 7c8008342c..5ae8c6d61d 100644 --- a/idxvpp/nametoidx/inmemory_scenario_test.go +++ b/idxvpp/nametoidx/inmemory_scenario_test.go @@ -179,3 +179,55 @@ func TestOldIndexRemove(t *testing.T) { gomega.Expect(found).To(gomega.BeFalse()) gomega.Expect(name).To(gomega.BeEquivalentTo("")) } + +func TestUpdateMetadata(t *testing.T) { + gomega.RegisterTestingT(t) + idxm := NewNameToIdx(logrus.DefaultLogger(), "title", nil) + + idxm.RegisterName(string(eth0), idx1, nil) + + idx, meta, found := idxm.LookupIdx(string(eth0)) + gomega.Expect(found).To(gomega.BeTrue()) + gomega.Expect(idx).To(gomega.BeEquivalentTo(idx1)) + gomega.Expect(meta).To(gomega.BeNil()) + + success := idxm.UpdateMetadata(string(eth0), "dummy-meta") + gomega.Expect(success).To(gomega.BeTrue()) + + idx, meta, found = idxm.LookupIdx(string(eth0)) + gomega.Expect(found).To(gomega.BeTrue()) + gomega.Expect(idx).To(gomega.BeEquivalentTo(idx1)) + gomega.Expect(meta).ToNot(gomega.BeNil()) +} + +func TestClearMapping(t *testing.T) { + gomega.RegisterTestingT(t) + idxm := NewNameToIdx(logrus.DefaultLogger(), "title", nil) + + idxm.RegisterName(string(eth0), idx1, nil) + idxm.RegisterName(string(eth1), idx2, nil) + idxm.RegisterName(string(eth2), idx3, nil) + + idx, _, found := idxm.LookupIdx(string(eth0)) + gomega.Expect(found).To(gomega.BeTrue()) + gomega.Expect(idx).To(gomega.BeEquivalentTo(idx1)) + + idx, _, found = idxm.LookupIdx(string(eth1)) + gomega.Expect(found).To(gomega.BeTrue()) + gomega.Expect(idx).To(gomega.BeEquivalentTo(idx2)) + + idx, _, found = idxm.LookupIdx(string(eth2)) + gomega.Expect(found).To(gomega.BeTrue()) + gomega.Expect(idx).To(gomega.BeEquivalentTo(idx3)) + + idxm.Clear() + + _, _, found = idxm.LookupIdx(string(eth0)) + gomega.Expect(found).To(gomega.BeFalse()) + + _, _, found = idxm.LookupIdx(string(eth1)) + gomega.Expect(found).To(gomega.BeFalse()) + + _, _, found = idxm.LookupIdx(string(eth2)) + gomega.Expect(found).To(gomega.BeFalse()) +} diff --git a/k8s/dev-setup/README.md b/k8s/dev-setup/README.md index 86abf608d7..03400bf2c6 100644 --- a/k8s/dev-setup/README.md +++ b/k8s/dev-setup/README.md @@ -52,7 +52,7 @@ kubectl describe pods Write some config into ETCD (using etcd.conf that refers to the port 22379): ``` -export ETCDV3_CONFIG=./etcd.conf +export ETCD_CONFIG=./etcd.conf ../../cmd/vpp-agent-ctl/topology.sh ``` diff --git a/k8s/perf-demo/README.md b/k8s/perf-demo/README.md index 9433672f35..3f31c62b5d 100644 --- a/k8s/perf-demo/README.md +++ b/k8s/perf-demo/README.md @@ -23,7 +23,7 @@ Verify the ETCD and Kafka PODs are ready: ``` $ kubectl get pods NAME READY STATUS RESTARTS AGE -etcdv3-server 1/1 Running 0 12s +etcd-server 1/1 Running 0 12s kafka-server 1/1 Running 0 5s ``` @@ -59,7 +59,7 @@ Verify the PODs are ready: ``` $ kubectl get pods NAME READY STATUS RESTARTS AGE -etcdv3-server 1/1 Running 0 33m +etcd-server 1/1 Running 0 33m kafka-server 1/1 Running 0 6h vnf-vpp 1/1 Running 0 26s vswitch-vpp 1/1 Running 0 26s diff --git a/k8s/perf-demo/etcd.yaml b/k8s/perf-demo/etcd.yaml index 2210de65b5..e8969307bd 100644 --- a/k8s/perf-demo/etcd.yaml +++ b/k8s/perf-demo/etcd.yaml @@ -1,12 +1,12 @@ apiVersion: v1 kind: Pod metadata: - name: etcdv3-server + name: etcd-server spec: hostNetwork: true containers: - image: quay.io/coreos/etcd:v3.0.16 - name: etcdv3 + name: etcd command: - /usr/local/bin/etcd - --advertise-client-urls diff --git a/k8s/perf-demo/etcdimport.sh b/k8s/perf-demo/etcdimport.sh index 11c9b1dfde..b734916393 100755 --- a/k8s/perf-demo/etcdimport.sh +++ b/k8s/perf-demo/etcdimport.sh @@ -4,7 +4,7 @@ etcdKey="" while read line || [[ -n "$line" ]]; do if [ "${line:0:1}" != "/" ] ; then value="$(echo "$line"|tr -d '\r\n')" - kubectl exec etcdv3-server etcdctl -- put --endpoints=[127.0.0.1:22379] $etcdKey "$value" + kubectl exec etcd-server etcdctl -- put --endpoints=[127.0.0.1:22379] $etcdKey "$value" else etcdKey="$(echo "$line"|tr -d '\r\n')" fi diff --git a/k8s/perf-demo/with-controller/scenario1/sfc/sfc.yaml b/k8s/perf-demo/with-controller/scenario1/sfc/sfc.yaml index 03ad8d497f..e2a03a1902 100644 --- a/k8s/perf-demo/with-controller/scenario1/sfc/sfc.yaml +++ b/k8s/perf-demo/with-controller/scenario1/sfc/sfc.yaml @@ -10,7 +10,7 @@ spec: imagePullPolicy: IfNotPresent command: - /root/go/bin/sfc-controller - - -etcdv3-config=/opt/sfc-controller/dev/etcd.conf + - -etcd-config=/opt/sfc-controller/dev/etcd.conf - -sfc-config=/opt/sfc-controller/dev/sfc.conf - -vnf-config=/opt/sfc-controller/dev/vnf.conf volumeMounts: diff --git a/k8s/perf-demo/with-controller/scenario2/sfc/sfc.yaml b/k8s/perf-demo/with-controller/scenario2/sfc/sfc.yaml index 03ad8d497f..e2a03a1902 100644 --- a/k8s/perf-demo/with-controller/scenario2/sfc/sfc.yaml +++ b/k8s/perf-demo/with-controller/scenario2/sfc/sfc.yaml @@ -10,7 +10,7 @@ spec: imagePullPolicy: IfNotPresent command: - /root/go/bin/sfc-controller - - -etcdv3-config=/opt/sfc-controller/dev/etcd.conf + - -etcd-config=/opt/sfc-controller/dev/etcd.conf - -sfc-config=/opt/sfc-controller/dev/sfc.conf - -vnf-config=/opt/sfc-controller/dev/vnf.conf volumeMounts: diff --git a/k8s/perf-demo/with-controller/scenario23/sfc/sfc.yaml b/k8s/perf-demo/with-controller/scenario23/sfc/sfc.yaml index 03ad8d497f..e2a03a1902 100644 --- a/k8s/perf-demo/with-controller/scenario23/sfc/sfc.yaml +++ b/k8s/perf-demo/with-controller/scenario23/sfc/sfc.yaml @@ -10,7 +10,7 @@ spec: imagePullPolicy: IfNotPresent command: - /root/go/bin/sfc-controller - - -etcdv3-config=/opt/sfc-controller/dev/etcd.conf + - -etcd-config=/opt/sfc-controller/dev/etcd.conf - -sfc-config=/opt/sfc-controller/dev/sfc.conf - -vnf-config=/opt/sfc-controller/dev/vnf.conf volumeMounts: diff --git a/k8s/perf-demo/with-controller/scenario4/sfc/sfc.yaml b/k8s/perf-demo/with-controller/scenario4/sfc/sfc.yaml index 03ad8d497f..e2a03a1902 100644 --- a/k8s/perf-demo/with-controller/scenario4/sfc/sfc.yaml +++ b/k8s/perf-demo/with-controller/scenario4/sfc/sfc.yaml @@ -10,7 +10,7 @@ spec: imagePullPolicy: IfNotPresent command: - /root/go/bin/sfc-controller - - -etcdv3-config=/opt/sfc-controller/dev/etcd.conf + - -etcd-config=/opt/sfc-controller/dev/etcd.conf - -sfc-config=/opt/sfc-controller/dev/sfc.conf - -vnf-config=/opt/sfc-controller/dev/vnf.conf volumeMounts: diff --git a/plugins/defaultplugins/aclplugin/acl_config_test.go b/plugins/defaultplugins/aclplugin/acl_config_test.go deleted file mode 100644 index d38b6f4a5d..0000000000 --- a/plugins/defaultplugins/aclplugin/acl_config_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package aclplugin - -import ( - "testing" - - . "github.com/onsi/gomega" -) - -func TestDiffInterfaces(t *testing.T) { - RegisterTestingT(t) - - for _, test := range []struct { - oldIfaces, newIfaces []uint32 - expectAdded, expectRemoved []uint32 - }{ - { - oldIfaces: []uint32{}, - newIfaces: []uint32{}, - expectAdded: nil, - expectRemoved: nil, - }, - { - oldIfaces: []uint32{1}, - newIfaces: []uint32{1}, - expectAdded: nil, - expectRemoved: nil, - }, - { - oldIfaces: []uint32{1}, - newIfaces: []uint32{2}, - expectAdded: []uint32{2}, - expectRemoved: []uint32{1}, - }, - { - oldIfaces: []uint32{1}, - newIfaces: []uint32{}, - expectAdded: nil, - expectRemoved: []uint32{1}, - }, - { - oldIfaces: []uint32{}, - newIfaces: []uint32{2}, - expectAdded: []uint32{2}, - expectRemoved: nil, - }, - { - oldIfaces: []uint32{1, 2, 3}, - newIfaces: []uint32{2, 4}, - expectAdded: []uint32{4}, - expectRemoved: []uint32{1, 3}, - }, - } { - added, removed := diffInterfaces(test.oldIfaces, test.newIfaces) - - Expect(added).To(Equal(test.expectAdded)) - Expect(removed).To(Equal(test.expectRemoved)) - } -} diff --git a/plugins/defaultplugins/aclplugin/data_resync.go b/plugins/defaultplugins/aclplugin/data_resync.go deleted file mode 100644 index 3362e98f3c..0000000000 --- a/plugins/defaultplugins/aclplugin/data_resync.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2017 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package aclplugin - -import ( - "github.com/ligato/cn-infra/logging" - "github.com/ligato/vpp-agent/plugins/defaultplugins/aclplugin/vppcalls" - "github.com/ligato/vpp-agent/plugins/defaultplugins/aclplugin/vppdump" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/acl" -) - -// Resync writes ACLs to the empty VPP. -func (plugin *ACLConfigurator) Resync(nbACLs []*acl.AccessLists_Acl, log logging.Logger) error { - log.Debug("Resync ACLs started") - // Calculate and log acl resync. - defer func() { - if plugin.Stopwatch != nil { - plugin.Stopwatch.PrintLog() - } - }() - - // Retrieve existing ACL config - vppACLs, err := vppdump.DumpACLs(plugin.Log, plugin.SwIfIndexes, plugin.vppChannel, plugin.Stopwatch) - if err != nil { - return err - } - - // Remove all configured VPP ACLs - // Note: due to unablity to dump ACL interfaces, it is not currently possible to correctly - // calculate difference between configs - var wasErr error - for _, vppACL := range vppACLs { - - // ACL with IP-type rules uses different binary call to create/remove than MACIP-type. - // Check what type of rules is in the ACL - ipRulesExist := len(vppACL.ACLDetails.Rules) > 0 && vppACL.ACLDetails.Rules[0].GetMatch().GetIpRule() != nil - - if ipRulesExist { - if err := vppcalls.DeleteIPAcl(vppACL.Identifier.ACLIndex, plugin.Log, plugin.vppChannel, plugin.Stopwatch); err != nil { - log.Error(err) - wasErr = err - } - continue - } else { - if err := vppcalls.DeleteMacIPAcl(vppACL.Identifier.ACLIndex, plugin.Log, plugin.vppChannel, plugin.Stopwatch); err != nil { - log.Error(err) - wasErr = err - } - } - } - - // Configure new ACLs - for _, nbACL := range nbACLs { - if err := plugin.ConfigureACL(nbACL); err != nil { - plugin.Log.Error(err) - wasErr = err - } - } - - return wasErr -} diff --git a/plugins/defaultplugins/aclplugin/vppcalls/compatibility_check_vppcalls.go b/plugins/defaultplugins/aclplugin/vppcalls/compatibility_check_vppcalls.go deleted file mode 100644 index 7bee212bf0..0000000000 --- a/plugins/defaultplugins/aclplugin/vppcalls/compatibility_check_vppcalls.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2017 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vppcalls - -import ( - govppapi "git.fd.io/govpp.git/api" - "github.com/ligato/cn-infra/logging" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/acl" -) - -// CheckMsgCompatibilityForACL checks if CRSs are compatible with VPP in runtime. -func CheckMsgCompatibilityForACL(log logging.Logger, vppChannel *govppapi.Channel) error { - msgs := []govppapi.Message{ - &acl.ACLAddReplace{}, - &acl.ACLAddReplaceReply{}, - &acl.ACLDel{}, - &acl.ACLDelReply{}, - &acl.MacipACLAdd{}, - &acl.MacipACLAddReply{}, - &acl.MacipACLDel{}, - &acl.MacipACLDelReply{}, - &acl.ACLDump{}, - &acl.ACLDetails{}, - &acl.MacipACLDump{}, - &acl.MacipACLDetails{}, - &acl.ACLInterfaceListDump{}, - &acl.ACLInterfaceListDetails{}, - &acl.ACLInterfaceSetACLList{}, - &acl.ACLInterfaceSetACLListReply{}, - &acl.MacipACLInterfaceAddDel{}, - &acl.MacipACLInterfaceAddDelReply{}, - } - err := vppChannel.CheckMessageCompatibility(msgs...) - if err != nil { - log.Error(err) - return err - } - return nil -} diff --git a/plugins/defaultplugins/aclplugin/vppcalls/vpp_channel.go b/plugins/defaultplugins/aclplugin/vppcalls/vpp_channel.go deleted file mode 100644 index dbd9b9ead1..0000000000 --- a/plugins/defaultplugins/aclplugin/vppcalls/vpp_channel.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2018 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vppcalls - -import ( - govppapi "git.fd.io/govpp.git/api" -) - -// VPPChannel is interface for send request to VPP channel -type VPPChannel interface { - SendRequest(msg govppapi.Message) *govppapi.RequestCtx - - SendMultiRequest(msg govppapi.Message) *govppapi.MultiRequestCtx -} diff --git a/plugins/defaultplugins/aclplugin/vppdump/dump_vppcalls_test.go b/plugins/defaultplugins/aclplugin/vppdump/dump_vppcalls_test.go deleted file mode 100644 index c1a2a98507..0000000000 --- a/plugins/defaultplugins/aclplugin/vppdump/dump_vppcalls_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package vppdump - -import ( - "testing" - - "github.com/ligato/cn-infra/logging/logrus" - "github.com/ligato/vpp-agent/idxvpp/nametoidx" - "github.com/ligato/vpp-agent/plugins/defaultplugins/aclplugin/vppcalls" - acl_api "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/acl" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/vpe" - "github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/ifaceidx" - "github.com/ligato/vpp-agent/tests/vppcallmock" - - . "github.com/onsi/gomega" -) - -func TestGetIPRuleMatch(t *testing.T) { - ipRule := getIPRuleMatches(acl_api.ACLRule{ - SrcIPAddr: []byte{10, 0, 0, 1}, - SrcIPPrefixLen: 24, - DstIPAddr: []byte{20, 0, 0, 1}, - DstIPPrefixLen: 24, - Proto: vppcalls.ICMPv4Proto, - }) - t.Logf("ip rule: %+v", ipRule) - - if ipRule.GetIcmp() == nil { - t.Fatal("should have icmp match") - } -} - -func TestDumpACLInterfaces(t *testing.T) { - ctx := vppcallmock.SetupTestCtx(t) - defer ctx.TeardownTestCtx() - - ctx.MockVpp.MockReply(&acl_api.ACLInterfaceListDetails{ - SwIfIndex: 1, - Count: 2, - NInput: 1, - Acls: []uint32{11, 22}, - }) - ctx.MockVpp.MockReply(&vpe.ControlPingReply{}) - - swIfIndexes := ifaceidx.NewSwIfIndex(nametoidx.NewNameToIdx(logrus.DefaultLogger(), "test-sw_if_indexes", ifaceidx.IndexMetadata)) - swIfIndexes.RegisterName("if0", 1, nil) - - indexes := []uint32{11, 22} - ifaces, err := DumpACLInterfaces(indexes, swIfIndexes, logrus.DefaultLogger(), ctx.MockChannel, nil) - Expect(err).To(Succeed()) - Expect(ifaces).To(HaveLen(2)) - Expect(ifaces[11].Ingress).To(Equal([]string{"if0"})) - Expect(ifaces[22].Egress).To(Equal([]string{"if0"})) -} diff --git a/plugins/defaultplugins/common/bin_api/acl/pkgreflect.go b/plugins/defaultplugins/common/bin_api/acl/pkgreflect.go deleted file mode 100644 index ca1119365f..0000000000 --- a/plugins/defaultplugins/common/bin_api/acl/pkgreflect.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package acl - -import "reflect" - -var Types = map[string]reflect.Type{ - "ACLAddReplace": reflect.TypeOf((*ACLAddReplace)(nil)).Elem(), - "ACLAddReplaceReply": reflect.TypeOf((*ACLAddReplaceReply)(nil)).Elem(), - "ACLDel": reflect.TypeOf((*ACLDel)(nil)).Elem(), - "ACLDelReply": reflect.TypeOf((*ACLDelReply)(nil)).Elem(), - "ACLDetails": reflect.TypeOf((*ACLDetails)(nil)).Elem(), - "ACLDump": reflect.TypeOf((*ACLDump)(nil)).Elem(), - "ACLInterfaceAddDel": reflect.TypeOf((*ACLInterfaceAddDel)(nil)).Elem(), - "ACLInterfaceAddDelReply": reflect.TypeOf((*ACLInterfaceAddDelReply)(nil)).Elem(), - "ACLInterfaceEtypeWhitelistDetails": reflect.TypeOf((*ACLInterfaceEtypeWhitelistDetails)(nil)).Elem(), - "ACLInterfaceEtypeWhitelistDump": reflect.TypeOf((*ACLInterfaceEtypeWhitelistDump)(nil)).Elem(), - "ACLInterfaceListDetails": reflect.TypeOf((*ACLInterfaceListDetails)(nil)).Elem(), - "ACLInterfaceListDump": reflect.TypeOf((*ACLInterfaceListDump)(nil)).Elem(), - "ACLInterfaceSetACLList": reflect.TypeOf((*ACLInterfaceSetACLList)(nil)).Elem(), - "ACLInterfaceSetACLListReply": reflect.TypeOf((*ACLInterfaceSetACLListReply)(nil)).Elem(), - "ACLInterfaceSetEtypeWhitelist": reflect.TypeOf((*ACLInterfaceSetEtypeWhitelist)(nil)).Elem(), - "ACLInterfaceSetEtypeWhitelistReply": reflect.TypeOf((*ACLInterfaceSetEtypeWhitelistReply)(nil)).Elem(), - "ACLPluginControlPing": reflect.TypeOf((*ACLPluginControlPing)(nil)).Elem(), - "ACLPluginControlPingReply": reflect.TypeOf((*ACLPluginControlPingReply)(nil)).Elem(), - "ACLPluginGetVersion": reflect.TypeOf((*ACLPluginGetVersion)(nil)).Elem(), - "ACLPluginGetVersionReply": reflect.TypeOf((*ACLPluginGetVersionReply)(nil)).Elem(), - "ACLRule": reflect.TypeOf((*ACLRule)(nil)).Elem(), - "MacipACLAdd": reflect.TypeOf((*MacipACLAdd)(nil)).Elem(), - "MacipACLAddReplace": reflect.TypeOf((*MacipACLAddReplace)(nil)).Elem(), - "MacipACLAddReplaceReply": reflect.TypeOf((*MacipACLAddReplaceReply)(nil)).Elem(), - "MacipACLAddReply": reflect.TypeOf((*MacipACLAddReply)(nil)).Elem(), - "MacipACLDel": reflect.TypeOf((*MacipACLDel)(nil)).Elem(), - "MacipACLDelReply": reflect.TypeOf((*MacipACLDelReply)(nil)).Elem(), - "MacipACLDetails": reflect.TypeOf((*MacipACLDetails)(nil)).Elem(), - "MacipACLDump": reflect.TypeOf((*MacipACLDump)(nil)).Elem(), - "MacipACLInterfaceAddDel": reflect.TypeOf((*MacipACLInterfaceAddDel)(nil)).Elem(), - "MacipACLInterfaceAddDelReply": reflect.TypeOf((*MacipACLInterfaceAddDelReply)(nil)).Elem(), - "MacipACLInterfaceGet": reflect.TypeOf((*MacipACLInterfaceGet)(nil)).Elem(), - "MacipACLInterfaceGetReply": reflect.TypeOf((*MacipACLInterfaceGetReply)(nil)).Elem(), - "MacipACLInterfaceListDetails": reflect.TypeOf((*MacipACLInterfaceListDetails)(nil)).Elem(), - "MacipACLInterfaceListDump": reflect.TypeOf((*MacipACLInterfaceListDump)(nil)).Elem(), - "MacipACLRule": reflect.TypeOf((*MacipACLRule)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewACLAddReplace": reflect.ValueOf(NewACLAddReplace), - "NewACLAddReplaceReply": reflect.ValueOf(NewACLAddReplaceReply), - "NewACLDel": reflect.ValueOf(NewACLDel), - "NewACLDelReply": reflect.ValueOf(NewACLDelReply), - "NewACLDetails": reflect.ValueOf(NewACLDetails), - "NewACLDump": reflect.ValueOf(NewACLDump), - "NewACLInterfaceAddDel": reflect.ValueOf(NewACLInterfaceAddDel), - "NewACLInterfaceAddDelReply": reflect.ValueOf(NewACLInterfaceAddDelReply), - "NewACLInterfaceEtypeWhitelistDetails": reflect.ValueOf(NewACLInterfaceEtypeWhitelistDetails), - "NewACLInterfaceEtypeWhitelistDump": reflect.ValueOf(NewACLInterfaceEtypeWhitelistDump), - "NewACLInterfaceListDetails": reflect.ValueOf(NewACLInterfaceListDetails), - "NewACLInterfaceListDump": reflect.ValueOf(NewACLInterfaceListDump), - "NewACLInterfaceSetACLList": reflect.ValueOf(NewACLInterfaceSetACLList), - "NewACLInterfaceSetACLListReply": reflect.ValueOf(NewACLInterfaceSetACLListReply), - "NewACLInterfaceSetEtypeWhitelist": reflect.ValueOf(NewACLInterfaceSetEtypeWhitelist), - "NewACLInterfaceSetEtypeWhitelistReply": reflect.ValueOf(NewACLInterfaceSetEtypeWhitelistReply), - "NewACLPluginControlPing": reflect.ValueOf(NewACLPluginControlPing), - "NewACLPluginControlPingReply": reflect.ValueOf(NewACLPluginControlPingReply), - "NewACLPluginGetVersion": reflect.ValueOf(NewACLPluginGetVersion), - "NewACLPluginGetVersionReply": reflect.ValueOf(NewACLPluginGetVersionReply), - "NewMacipACLAdd": reflect.ValueOf(NewMacipACLAdd), - "NewMacipACLAddReplace": reflect.ValueOf(NewMacipACLAddReplace), - "NewMacipACLAddReplaceReply": reflect.ValueOf(NewMacipACLAddReplaceReply), - "NewMacipACLAddReply": reflect.ValueOf(NewMacipACLAddReply), - "NewMacipACLDel": reflect.ValueOf(NewMacipACLDel), - "NewMacipACLDelReply": reflect.ValueOf(NewMacipACLDelReply), - "NewMacipACLDetails": reflect.ValueOf(NewMacipACLDetails), - "NewMacipACLDump": reflect.ValueOf(NewMacipACLDump), - "NewMacipACLInterfaceAddDel": reflect.ValueOf(NewMacipACLInterfaceAddDel), - "NewMacipACLInterfaceAddDelReply": reflect.ValueOf(NewMacipACLInterfaceAddDelReply), - "NewMacipACLInterfaceGet": reflect.ValueOf(NewMacipACLInterfaceGet), - "NewMacipACLInterfaceGetReply": reflect.ValueOf(NewMacipACLInterfaceGetReply), - "NewMacipACLInterfaceListDetails": reflect.ValueOf(NewMacipACLInterfaceListDetails), - "NewMacipACLInterfaceListDump": reflect.ValueOf(NewMacipACLInterfaceListDump), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/af_packet/pkgreflect.go b/plugins/defaultplugins/common/bin_api/af_packet/pkgreflect.go deleted file mode 100644 index 4c87bfca10..0000000000 --- a/plugins/defaultplugins/common/bin_api/af_packet/pkgreflect.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package af_packet - -import "reflect" - -var Types = map[string]reflect.Type{ - "AfPacketCreate": reflect.TypeOf((*AfPacketCreate)(nil)).Elem(), - "AfPacketCreateReply": reflect.TypeOf((*AfPacketCreateReply)(nil)).Elem(), - "AfPacketDelete": reflect.TypeOf((*AfPacketDelete)(nil)).Elem(), - "AfPacketDeleteReply": reflect.TypeOf((*AfPacketDeleteReply)(nil)).Elem(), - "AfPacketSetL4CksumOffload": reflect.TypeOf((*AfPacketSetL4CksumOffload)(nil)).Elem(), - "AfPacketSetL4CksumOffloadReply": reflect.TypeOf((*AfPacketSetL4CksumOffloadReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewAfPacketCreate": reflect.ValueOf(NewAfPacketCreate), - "NewAfPacketCreateReply": reflect.ValueOf(NewAfPacketCreateReply), - "NewAfPacketDelete": reflect.ValueOf(NewAfPacketDelete), - "NewAfPacketDeleteReply": reflect.ValueOf(NewAfPacketDeleteReply), - "NewAfPacketSetL4CksumOffload": reflect.ValueOf(NewAfPacketSetL4CksumOffload), - "NewAfPacketSetL4CksumOffloadReply": reflect.ValueOf(NewAfPacketSetL4CksumOffloadReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/bfd/pkgreflect.go b/plugins/defaultplugins/common/bin_api/bfd/pkgreflect.go deleted file mode 100644 index 7adfaaa0fc..0000000000 --- a/plugins/defaultplugins/common/bin_api/bfd/pkgreflect.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package bfd - -import "reflect" - -var Types = map[string]reflect.Type{ - "BfdAuthDelKey": reflect.TypeOf((*BfdAuthDelKey)(nil)).Elem(), - "BfdAuthDelKeyReply": reflect.TypeOf((*BfdAuthDelKeyReply)(nil)).Elem(), - "BfdAuthKeysDetails": reflect.TypeOf((*BfdAuthKeysDetails)(nil)).Elem(), - "BfdAuthKeysDump": reflect.TypeOf((*BfdAuthKeysDump)(nil)).Elem(), - "BfdAuthSetKey": reflect.TypeOf((*BfdAuthSetKey)(nil)).Elem(), - "BfdAuthSetKeyReply": reflect.TypeOf((*BfdAuthSetKeyReply)(nil)).Elem(), - "BfdUDPAdd": reflect.TypeOf((*BfdUDPAdd)(nil)).Elem(), - "BfdUDPAddReply": reflect.TypeOf((*BfdUDPAddReply)(nil)).Elem(), - "BfdUDPAuthActivate": reflect.TypeOf((*BfdUDPAuthActivate)(nil)).Elem(), - "BfdUDPAuthActivateReply": reflect.TypeOf((*BfdUDPAuthActivateReply)(nil)).Elem(), - "BfdUDPAuthDeactivate": reflect.TypeOf((*BfdUDPAuthDeactivate)(nil)).Elem(), - "BfdUDPAuthDeactivateReply": reflect.TypeOf((*BfdUDPAuthDeactivateReply)(nil)).Elem(), - "BfdUDPDel": reflect.TypeOf((*BfdUDPDel)(nil)).Elem(), - "BfdUDPDelEchoSource": reflect.TypeOf((*BfdUDPDelEchoSource)(nil)).Elem(), - "BfdUDPDelEchoSourceReply": reflect.TypeOf((*BfdUDPDelEchoSourceReply)(nil)).Elem(), - "BfdUDPDelReply": reflect.TypeOf((*BfdUDPDelReply)(nil)).Elem(), - "BfdUDPMod": reflect.TypeOf((*BfdUDPMod)(nil)).Elem(), - "BfdUDPModReply": reflect.TypeOf((*BfdUDPModReply)(nil)).Elem(), - "BfdUDPSessionDetails": reflect.TypeOf((*BfdUDPSessionDetails)(nil)).Elem(), - "BfdUDPSessionDump": reflect.TypeOf((*BfdUDPSessionDump)(nil)).Elem(), - "BfdUDPSessionSetFlags": reflect.TypeOf((*BfdUDPSessionSetFlags)(nil)).Elem(), - "BfdUDPSessionSetFlagsReply": reflect.TypeOf((*BfdUDPSessionSetFlagsReply)(nil)).Elem(), - "BfdUDPSetEchoSource": reflect.TypeOf((*BfdUDPSetEchoSource)(nil)).Elem(), - "BfdUDPSetEchoSourceReply": reflect.TypeOf((*BfdUDPSetEchoSourceReply)(nil)).Elem(), - "WantBfdEvents": reflect.TypeOf((*WantBfdEvents)(nil)).Elem(), - "WantBfdEventsReply": reflect.TypeOf((*WantBfdEventsReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewBfdAuthDelKey": reflect.ValueOf(NewBfdAuthDelKey), - "NewBfdAuthDelKeyReply": reflect.ValueOf(NewBfdAuthDelKeyReply), - "NewBfdAuthKeysDetails": reflect.ValueOf(NewBfdAuthKeysDetails), - "NewBfdAuthKeysDump": reflect.ValueOf(NewBfdAuthKeysDump), - "NewBfdAuthSetKey": reflect.ValueOf(NewBfdAuthSetKey), - "NewBfdAuthSetKeyReply": reflect.ValueOf(NewBfdAuthSetKeyReply), - "NewBfdUDPAdd": reflect.ValueOf(NewBfdUDPAdd), - "NewBfdUDPAddReply": reflect.ValueOf(NewBfdUDPAddReply), - "NewBfdUDPAuthActivate": reflect.ValueOf(NewBfdUDPAuthActivate), - "NewBfdUDPAuthActivateReply": reflect.ValueOf(NewBfdUDPAuthActivateReply), - "NewBfdUDPAuthDeactivate": reflect.ValueOf(NewBfdUDPAuthDeactivate), - "NewBfdUDPAuthDeactivateReply": reflect.ValueOf(NewBfdUDPAuthDeactivateReply), - "NewBfdUDPDel": reflect.ValueOf(NewBfdUDPDel), - "NewBfdUDPDelEchoSource": reflect.ValueOf(NewBfdUDPDelEchoSource), - "NewBfdUDPDelEchoSourceReply": reflect.ValueOf(NewBfdUDPDelEchoSourceReply), - "NewBfdUDPDelReply": reflect.ValueOf(NewBfdUDPDelReply), - "NewBfdUDPMod": reflect.ValueOf(NewBfdUDPMod), - "NewBfdUDPModReply": reflect.ValueOf(NewBfdUDPModReply), - "NewBfdUDPSessionDetails": reflect.ValueOf(NewBfdUDPSessionDetails), - "NewBfdUDPSessionDump": reflect.ValueOf(NewBfdUDPSessionDump), - "NewBfdUDPSessionSetFlags": reflect.ValueOf(NewBfdUDPSessionSetFlags), - "NewBfdUDPSessionSetFlagsReply": reflect.ValueOf(NewBfdUDPSessionSetFlagsReply), - "NewBfdUDPSetEchoSource": reflect.ValueOf(NewBfdUDPSetEchoSource), - "NewBfdUDPSetEchoSourceReply": reflect.ValueOf(NewBfdUDPSetEchoSourceReply), - "NewWantBfdEvents": reflect.ValueOf(NewWantBfdEvents), - "NewWantBfdEventsReply": reflect.ValueOf(NewWantBfdEventsReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/dhcp/dhcp.go b/plugins/defaultplugins/common/bin_api/dhcp/dhcp.go deleted file mode 100644 index 94f959d7df..0000000000 --- a/plugins/defaultplugins/common/bin_api/dhcp/dhcp.go +++ /dev/null @@ -1,541 +0,0 @@ -// Code generated by govpp binapi-generator DO NOT EDIT. -// Package dhcp represents the VPP binary API of the 'dhcp' VPP module. -// Generated from '/usr/share/vpp/api/dhcp.api.json' -package dhcp - -import "git.fd.io/govpp.git/api" - -// DhcpServer represents the VPP binary API data type 'dhcp_server'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 55: -// -// "dhcp_server", -// 16 -// -type DhcpServer struct { - ServerVrfID uint32 - DhcpServer []byte `struc:"[16]byte"` -} - -func (*DhcpServer) GetTypeName() string { - return "dhcp_server" -} -func (*DhcpServer) GetCrcString() string { - return "f16506c4" -} - -// DhcpProxyConfig represents the VPP binary API message 'dhcp_proxy_config'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 24: -// -// "dhcp_proxy_config", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "client_index" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "u32", -// "rx_vrf_id" -// ], -// [ -// "u32", -// "server_vrf_id" -// ], -// [ -// "u8", -// "is_ipv6" -// ], -// [ -// "u8", -// "is_add" -// ], -// [ -// "u8", -// "dhcp_server", -// 16 -// ], -// [ -// "u8", -// "dhcp_src_address", -// 16 -// ], -// { -// "crc": "0x6af4b645" -// } -// -type DhcpProxyConfig struct { - RxVrfID uint32 - ServerVrfID uint32 - IsIpv6 uint8 - IsAdd uint8 - DhcpServer []byte `struc:"[16]byte"` - DhcpSrcAddress []byte `struc:"[16]byte"` -} - -func (*DhcpProxyConfig) GetMessageName() string { - return "dhcp_proxy_config" -} -func (*DhcpProxyConfig) GetMessageType() api.MessageType { - return api.RequestMessage -} -func (*DhcpProxyConfig) GetCrcString() string { - return "6af4b645" -} -func NewDhcpProxyConfig() api.Message { - return &DhcpProxyConfig{} -} - -// DhcpProxyConfigReply represents the VPP binary API message 'dhcp_proxy_config_reply'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 68: -// -// "dhcp_proxy_config_reply", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "i32", -// "retval" -// ], -// { -// "crc": "0xe8d4e804" -// } -// -type DhcpProxyConfigReply struct { - Retval int32 -} - -func (*DhcpProxyConfigReply) GetMessageName() string { - return "dhcp_proxy_config_reply" -} -func (*DhcpProxyConfigReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} -func (*DhcpProxyConfigReply) GetCrcString() string { - return "e8d4e804" -} -func NewDhcpProxyConfigReply() api.Message { - return &DhcpProxyConfigReply{} -} - -// DhcpProxySetVss represents the VPP binary API message 'dhcp_proxy_set_vss'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 86: -// -// "dhcp_proxy_set_vss", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "client_index" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "u32", -// "tbl_id" -// ], -// [ -// "u8", -// "vss_type" -// ], -// [ -// "u8", -// "vpn_ascii_id", -// 129 -// ], -// [ -// "u32", -// "oui" -// ], -// [ -// "u32", -// "vpn_index" -// ], -// [ -// "u8", -// "is_ipv6" -// ], -// [ -// "u8", -// "is_add" -// ], -// { -// "crc": "0x606535aa" -// } -// -type DhcpProxySetVss struct { - TblID uint32 - VssType uint8 - VpnASCIIID []byte `struc:"[129]byte"` - Oui uint32 - VpnIndex uint32 - IsIpv6 uint8 - IsAdd uint8 -} - -func (*DhcpProxySetVss) GetMessageName() string { - return "dhcp_proxy_set_vss" -} -func (*DhcpProxySetVss) GetMessageType() api.MessageType { - return api.RequestMessage -} -func (*DhcpProxySetVss) GetCrcString() string { - return "606535aa" -} -func NewDhcpProxySetVss() api.Message { - return &DhcpProxySetVss{} -} - -// DhcpProxySetVssReply represents the VPP binary API message 'dhcp_proxy_set_vss_reply'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 133: -// -// "dhcp_proxy_set_vss_reply", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "i32", -// "retval" -// ], -// { -// "crc": "0xe8d4e804" -// } -// -type DhcpProxySetVssReply struct { - Retval int32 -} - -func (*DhcpProxySetVssReply) GetMessageName() string { - return "dhcp_proxy_set_vss_reply" -} -func (*DhcpProxySetVssReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} -func (*DhcpProxySetVssReply) GetCrcString() string { - return "e8d4e804" -} -func NewDhcpProxySetVssReply() api.Message { - return &DhcpProxySetVssReply{} -} - -// DhcpClientConfig represents the VPP binary API message 'dhcp_client_config'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 151: -// -// "dhcp_client_config", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "client_index" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "u32", -// "sw_if_index" -// ], -// [ -// "u8", -// "hostname", -// 64 -// ], -// [ -// "u8", -// "client_id", -// 64 -// ], -// [ -// "u8", -// "is_add" -// ], -// [ -// "u8", -// "want_dhcp_event" -// ], -// [ -// "u8", -// "set_broadcast_flag" -// ], -// [ -// "u32", -// "pid" -// ], -// { -// "crc": "0x652052aa" -// } -// -type DhcpClientConfig struct { - SwIfIndex uint32 - Hostname []byte `struc:"[64]byte"` - ClientID []byte `struc:"[64]byte"` - IsAdd uint8 - WantDhcpEvent uint8 - SetBroadcastFlag uint8 - Pid uint32 -} - -func (*DhcpClientConfig) GetMessageName() string { - return "dhcp_client_config" -} -func (*DhcpClientConfig) GetMessageType() api.MessageType { - return api.RequestMessage -} -func (*DhcpClientConfig) GetCrcString() string { - return "652052aa" -} -func NewDhcpClientConfig() api.Message { - return &DhcpClientConfig{} -} - -// DhcpClientConfigReply represents the VPP binary API message 'dhcp_client_config_reply'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 199: -// -// "dhcp_client_config_reply", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "i32", -// "retval" -// ], -// { -// "crc": "0xe8d4e804" -// } -// -type DhcpClientConfigReply struct { - Retval int32 -} - -func (*DhcpClientConfigReply) GetMessageName() string { - return "dhcp_client_config_reply" -} -func (*DhcpClientConfigReply) GetMessageType() api.MessageType { - return api.ReplyMessage -} -func (*DhcpClientConfigReply) GetCrcString() string { - return "e8d4e804" -} -func NewDhcpClientConfigReply() api.Message { - return &DhcpClientConfigReply{} -} - -// DhcpComplEvent represents the VPP binary API message 'dhcp_compl_event'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 217: -// -// "dhcp_compl_event", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "client_index" -// ], -// [ -// "u32", -// "pid" -// ], -// [ -// "u8", -// "hostname", -// 64 -// ], -// [ -// "u8", -// "is_ipv6" -// ], -// [ -// "u8", -// "mask_width" -// ], -// [ -// "u8", -// "host_address", -// 16 -// ], -// [ -// "u8", -// "router_address", -// 16 -// ], -// [ -// "u8", -// "host_mac", -// 6 -// ], -// { -// "crc": "0x28c60f01" -// } -// -type DhcpComplEvent struct { - Pid uint32 - Hostname []byte `struc:"[64]byte"` - IsIpv6 uint8 - MaskWidth uint8 - HostAddress []byte `struc:"[16]byte"` - RouterAddress []byte `struc:"[16]byte"` - HostMac []byte `struc:"[6]byte"` -} - -func (*DhcpComplEvent) GetMessageName() string { - return "dhcp_compl_event" -} -func (*DhcpComplEvent) GetMessageType() api.MessageType { - return api.EventMessage -} -func (*DhcpComplEvent) GetCrcString() string { - return "28c60f01" -} -func NewDhcpComplEvent() api.Message { - return &DhcpComplEvent{} -} - -// DhcpProxyDump represents the VPP binary API message 'dhcp_proxy_dump'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 263: -// -// "dhcp_proxy_dump", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "client_index" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "u8", -// "is_ip6" -// ], -// { -// "crc": "0x6fe91190" -// } -// -type DhcpProxyDump struct { - IsIP6 uint8 -} - -func (*DhcpProxyDump) GetMessageName() string { - return "dhcp_proxy_dump" -} -func (*DhcpProxyDump) GetMessageType() api.MessageType { - return api.RequestMessage -} -func (*DhcpProxyDump) GetCrcString() string { - return "6fe91190" -} -func NewDhcpProxyDump() api.Message { - return &DhcpProxyDump{} -} - -// DhcpProxyDetails represents the VPP binary API message 'dhcp_proxy_details'. -// Generated from '/usr/share/vpp/api/dhcp.api.json', line 285: -// -// "dhcp_proxy_details", -// [ -// "u16", -// "_vl_msg_id" -// ], -// [ -// "u32", -// "context" -// ], -// [ -// "u32", -// "rx_vrf_id" -// ], -// [ -// "u32", -// "vss_oui" -// ], -// [ -// "u32", -// "vss_fib_id" -// ], -// [ -// "u8", -// "vss_type" -// ], -// [ -// "u8", -// "vss_vpn_ascii_id", -// 129 -// ], -// [ -// "u8", -// "is_ipv6" -// ], -// [ -// "u8", -// "dhcp_src_address", -// 16 -// ], -// [ -// "u8", -// "count" -// ], -// [ -// "vl_api_dhcp_server_t", -// "servers", -// 0, -// "count" -// ], -// { -// "crc": "0xa5f2ad84" -// } -// -type DhcpProxyDetails struct { - RxVrfID uint32 - VssOui uint32 - VssFibID uint32 - VssType uint8 - VssVpnASCIIID []byte `struc:"[129]byte"` - IsIpv6 uint8 - DhcpSrcAddress []byte `struc:"[16]byte"` - Count uint8 `struc:"sizeof=Servers"` - Servers []DhcpServer -} - -func (*DhcpProxyDetails) GetMessageName() string { - return "dhcp_proxy_details" -} -func (*DhcpProxyDetails) GetMessageType() api.MessageType { - return api.ReplyMessage -} -func (*DhcpProxyDetails) GetCrcString() string { - return "a5f2ad84" -} -func NewDhcpProxyDetails() api.Message { - return &DhcpProxyDetails{} -} diff --git a/plugins/defaultplugins/common/bin_api/dhcp/pkgreflect.go b/plugins/defaultplugins/common/bin_api/dhcp/pkgreflect.go deleted file mode 100644 index 06c7cc6ffb..0000000000 --- a/plugins/defaultplugins/common/bin_api/dhcp/pkgreflect.go +++ /dev/null @@ -1,34 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package dhcp - -import "reflect" - -var Types = map[string]reflect.Type{ - "DhcpClientConfig": reflect.TypeOf((*DhcpClientConfig)(nil)).Elem(), - "DhcpClientConfigReply": reflect.TypeOf((*DhcpClientConfigReply)(nil)).Elem(), - "DhcpComplEvent": reflect.TypeOf((*DhcpComplEvent)(nil)).Elem(), - "DhcpProxyConfig": reflect.TypeOf((*DhcpProxyConfig)(nil)).Elem(), - "DhcpProxyConfigReply": reflect.TypeOf((*DhcpProxyConfigReply)(nil)).Elem(), - "DhcpProxyDetails": reflect.TypeOf((*DhcpProxyDetails)(nil)).Elem(), - "DhcpProxyDump": reflect.TypeOf((*DhcpProxyDump)(nil)).Elem(), - "DhcpProxySetVss": reflect.TypeOf((*DhcpProxySetVss)(nil)).Elem(), - "DhcpProxySetVssReply": reflect.TypeOf((*DhcpProxySetVssReply)(nil)).Elem(), - "DhcpServer": reflect.TypeOf((*DhcpServer)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewDhcpClientConfig": reflect.ValueOf(NewDhcpClientConfig), - "NewDhcpClientConfigReply": reflect.ValueOf(NewDhcpClientConfigReply), - "NewDhcpComplEvent": reflect.ValueOf(NewDhcpComplEvent), - "NewDhcpProxyConfig": reflect.ValueOf(NewDhcpProxyConfig), - "NewDhcpProxyConfigReply": reflect.ValueOf(NewDhcpProxyConfigReply), - "NewDhcpProxyDetails": reflect.ValueOf(NewDhcpProxyDetails), - "NewDhcpProxyDump": reflect.ValueOf(NewDhcpProxyDump), - "NewDhcpProxySetVss": reflect.ValueOf(NewDhcpProxySetVss), - "NewDhcpProxySetVssReply": reflect.ValueOf(NewDhcpProxySetVssReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/interfaces/pkgreflect.go b/plugins/defaultplugins/common/bin_api/interfaces/pkgreflect.go deleted file mode 100644 index ce944db3be..0000000000 --- a/plugins/defaultplugins/common/bin_api/interfaces/pkgreflect.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package interfaces - -import "reflect" - -var Types = map[string]reflect.Type{ - "CollectDetailedInterfaceStats": reflect.TypeOf((*CollectDetailedInterfaceStats)(nil)).Elem(), - "CollectDetailedInterfaceStatsReply": reflect.TypeOf((*CollectDetailedInterfaceStatsReply)(nil)).Elem(), - "CreateLoopback": reflect.TypeOf((*CreateLoopback)(nil)).Elem(), - "CreateLoopbackInstance": reflect.TypeOf((*CreateLoopbackInstance)(nil)).Elem(), - "CreateLoopbackInstanceReply": reflect.TypeOf((*CreateLoopbackInstanceReply)(nil)).Elem(), - "CreateLoopbackReply": reflect.TypeOf((*CreateLoopbackReply)(nil)).Elem(), - "CreateSubif": reflect.TypeOf((*CreateSubif)(nil)).Elem(), - "CreateSubifReply": reflect.TypeOf((*CreateSubifReply)(nil)).Elem(), - "CreateVlanSubif": reflect.TypeOf((*CreateVlanSubif)(nil)).Elem(), - "CreateVlanSubifReply": reflect.TypeOf((*CreateVlanSubifReply)(nil)).Elem(), - "DeleteLoopback": reflect.TypeOf((*DeleteLoopback)(nil)).Elem(), - "DeleteLoopbackReply": reflect.TypeOf((*DeleteLoopbackReply)(nil)).Elem(), - "DeleteSubif": reflect.TypeOf((*DeleteSubif)(nil)).Elem(), - "DeleteSubifReply": reflect.TypeOf((*DeleteSubifReply)(nil)).Elem(), - "InterfaceNameRenumber": reflect.TypeOf((*InterfaceNameRenumber)(nil)).Elem(), - "InterfaceNameRenumberReply": reflect.TypeOf((*InterfaceNameRenumberReply)(nil)).Elem(), - "SwInterfaceAddDelAddress": reflect.TypeOf((*SwInterfaceAddDelAddress)(nil)).Elem(), - "SwInterfaceAddDelAddressReply": reflect.TypeOf((*SwInterfaceAddDelAddressReply)(nil)).Elem(), - "SwInterfaceClearStats": reflect.TypeOf((*SwInterfaceClearStats)(nil)).Elem(), - "SwInterfaceClearStatsReply": reflect.TypeOf((*SwInterfaceClearStatsReply)(nil)).Elem(), - "SwInterfaceDetails": reflect.TypeOf((*SwInterfaceDetails)(nil)).Elem(), - "SwInterfaceDump": reflect.TypeOf((*SwInterfaceDump)(nil)).Elem(), - "SwInterfaceEvent": reflect.TypeOf((*SwInterfaceEvent)(nil)).Elem(), - "SwInterfaceGetMacAddress": reflect.TypeOf((*SwInterfaceGetMacAddress)(nil)).Elem(), - "SwInterfaceGetMacAddressReply": reflect.TypeOf((*SwInterfaceGetMacAddressReply)(nil)).Elem(), - "SwInterfaceGetTable": reflect.TypeOf((*SwInterfaceGetTable)(nil)).Elem(), - "SwInterfaceGetTableReply": reflect.TypeOf((*SwInterfaceGetTableReply)(nil)).Elem(), - "SwInterfaceSetFlags": reflect.TypeOf((*SwInterfaceSetFlags)(nil)).Elem(), - "SwInterfaceSetFlagsReply": reflect.TypeOf((*SwInterfaceSetFlagsReply)(nil)).Elem(), - "SwInterfaceSetMacAddress": reflect.TypeOf((*SwInterfaceSetMacAddress)(nil)).Elem(), - "SwInterfaceSetMacAddressReply": reflect.TypeOf((*SwInterfaceSetMacAddressReply)(nil)).Elem(), - "SwInterfaceSetMtu": reflect.TypeOf((*SwInterfaceSetMtu)(nil)).Elem(), - "SwInterfaceSetMtuReply": reflect.TypeOf((*SwInterfaceSetMtuReply)(nil)).Elem(), - "SwInterfaceSetRxMode": reflect.TypeOf((*SwInterfaceSetRxMode)(nil)).Elem(), - "SwInterfaceSetRxModeReply": reflect.TypeOf((*SwInterfaceSetRxModeReply)(nil)).Elem(), - "SwInterfaceSetTable": reflect.TypeOf((*SwInterfaceSetTable)(nil)).Elem(), - "SwInterfaceSetTableReply": reflect.TypeOf((*SwInterfaceSetTableReply)(nil)).Elem(), - "SwInterfaceSetUnnumbered": reflect.TypeOf((*SwInterfaceSetUnnumbered)(nil)).Elem(), - "SwInterfaceSetUnnumberedReply": reflect.TypeOf((*SwInterfaceSetUnnumberedReply)(nil)).Elem(), - "SwInterfaceTagAddDel": reflect.TypeOf((*SwInterfaceTagAddDel)(nil)).Elem(), - "SwInterfaceTagAddDelReply": reflect.TypeOf((*SwInterfaceTagAddDelReply)(nil)).Elem(), - "VlibCounter": reflect.TypeOf((*VlibCounter)(nil)).Elem(), - "VnetCombinedCounter": reflect.TypeOf((*VnetCombinedCounter)(nil)).Elem(), - "VnetSimpleCounter": reflect.TypeOf((*VnetSimpleCounter)(nil)).Elem(), - "WantInterfaceEvents": reflect.TypeOf((*WantInterfaceEvents)(nil)).Elem(), - "WantInterfaceEventsReply": reflect.TypeOf((*WantInterfaceEventsReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewCollectDetailedInterfaceStats": reflect.ValueOf(NewCollectDetailedInterfaceStats), - "NewCollectDetailedInterfaceStatsReply": reflect.ValueOf(NewCollectDetailedInterfaceStatsReply), - "NewCreateLoopback": reflect.ValueOf(NewCreateLoopback), - "NewCreateLoopbackInstance": reflect.ValueOf(NewCreateLoopbackInstance), - "NewCreateLoopbackInstanceReply": reflect.ValueOf(NewCreateLoopbackInstanceReply), - "NewCreateLoopbackReply": reflect.ValueOf(NewCreateLoopbackReply), - "NewCreateSubif": reflect.ValueOf(NewCreateSubif), - "NewCreateSubifReply": reflect.ValueOf(NewCreateSubifReply), - "NewCreateVlanSubif": reflect.ValueOf(NewCreateVlanSubif), - "NewCreateVlanSubifReply": reflect.ValueOf(NewCreateVlanSubifReply), - "NewDeleteLoopback": reflect.ValueOf(NewDeleteLoopback), - "NewDeleteLoopbackReply": reflect.ValueOf(NewDeleteLoopbackReply), - "NewDeleteSubif": reflect.ValueOf(NewDeleteSubif), - "NewDeleteSubifReply": reflect.ValueOf(NewDeleteSubifReply), - "NewInterfaceNameRenumber": reflect.ValueOf(NewInterfaceNameRenumber), - "NewInterfaceNameRenumberReply": reflect.ValueOf(NewInterfaceNameRenumberReply), - "NewSwInterfaceAddDelAddress": reflect.ValueOf(NewSwInterfaceAddDelAddress), - "NewSwInterfaceAddDelAddressReply": reflect.ValueOf(NewSwInterfaceAddDelAddressReply), - "NewSwInterfaceClearStats": reflect.ValueOf(NewSwInterfaceClearStats), - "NewSwInterfaceClearStatsReply": reflect.ValueOf(NewSwInterfaceClearStatsReply), - "NewSwInterfaceDetails": reflect.ValueOf(NewSwInterfaceDetails), - "NewSwInterfaceDump": reflect.ValueOf(NewSwInterfaceDump), - "NewSwInterfaceEvent": reflect.ValueOf(NewSwInterfaceEvent), - "NewSwInterfaceGetMacAddress": reflect.ValueOf(NewSwInterfaceGetMacAddress), - "NewSwInterfaceGetMacAddressReply": reflect.ValueOf(NewSwInterfaceGetMacAddressReply), - "NewSwInterfaceGetTable": reflect.ValueOf(NewSwInterfaceGetTable), - "NewSwInterfaceGetTableReply": reflect.ValueOf(NewSwInterfaceGetTableReply), - "NewSwInterfaceSetFlags": reflect.ValueOf(NewSwInterfaceSetFlags), - "NewSwInterfaceSetFlagsReply": reflect.ValueOf(NewSwInterfaceSetFlagsReply), - "NewSwInterfaceSetMacAddress": reflect.ValueOf(NewSwInterfaceSetMacAddress), - "NewSwInterfaceSetMacAddressReply": reflect.ValueOf(NewSwInterfaceSetMacAddressReply), - "NewSwInterfaceSetMtu": reflect.ValueOf(NewSwInterfaceSetMtu), - "NewSwInterfaceSetMtuReply": reflect.ValueOf(NewSwInterfaceSetMtuReply), - "NewSwInterfaceSetRxMode": reflect.ValueOf(NewSwInterfaceSetRxMode), - "NewSwInterfaceSetRxModeReply": reflect.ValueOf(NewSwInterfaceSetRxModeReply), - "NewSwInterfaceSetTable": reflect.ValueOf(NewSwInterfaceSetTable), - "NewSwInterfaceSetTableReply": reflect.ValueOf(NewSwInterfaceSetTableReply), - "NewSwInterfaceSetUnnumbered": reflect.ValueOf(NewSwInterfaceSetUnnumbered), - "NewSwInterfaceSetUnnumberedReply": reflect.ValueOf(NewSwInterfaceSetUnnumberedReply), - "NewSwInterfaceTagAddDel": reflect.ValueOf(NewSwInterfaceTagAddDel), - "NewSwInterfaceTagAddDelReply": reflect.ValueOf(NewSwInterfaceTagAddDelReply), - "NewWantInterfaceEvents": reflect.ValueOf(NewWantInterfaceEvents), - "NewWantInterfaceEventsReply": reflect.ValueOf(NewWantInterfaceEventsReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/ip/pkgreflect.go b/plugins/defaultplugins/common/bin_api/ip/pkgreflect.go deleted file mode 100644 index a840ebf5a5..0000000000 --- a/plugins/defaultplugins/common/bin_api/ip/pkgreflect.go +++ /dev/null @@ -1,172 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package ip - -import "reflect" - -var Types = map[string]reflect.Type{ - "FibMplsLabel": reflect.TypeOf((*FibMplsLabel)(nil)).Elem(), - "FibPath": reflect.TypeOf((*FibPath)(nil)).Elem(), - "IP4ArpEvent": reflect.TypeOf((*IP4ArpEvent)(nil)).Elem(), - "IP6FibDetails": reflect.TypeOf((*IP6FibDetails)(nil)).Elem(), - "IP6FibDump": reflect.TypeOf((*IP6FibDump)(nil)).Elem(), - "IP6MfibDetails": reflect.TypeOf((*IP6MfibDetails)(nil)).Elem(), - "IP6MfibDump": reflect.TypeOf((*IP6MfibDump)(nil)).Elem(), - "IP6NdEvent": reflect.TypeOf((*IP6NdEvent)(nil)).Elem(), - "IP6RaEvent": reflect.TypeOf((*IP6RaEvent)(nil)).Elem(), - "IP6RaPrefixInfo": reflect.TypeOf((*IP6RaPrefixInfo)(nil)).Elem(), - "IP6ndProxyAddDel": reflect.TypeOf((*IP6ndProxyAddDel)(nil)).Elem(), - "IP6ndProxyAddDelReply": reflect.TypeOf((*IP6ndProxyAddDelReply)(nil)).Elem(), - "IP6ndProxyDetails": reflect.TypeOf((*IP6ndProxyDetails)(nil)).Elem(), - "IP6ndProxyDump": reflect.TypeOf((*IP6ndProxyDump)(nil)).Elem(), - "IP6ndSendRouterSolicitation": reflect.TypeOf((*IP6ndSendRouterSolicitation)(nil)).Elem(), - "IP6ndSendRouterSolicitationReply": reflect.TypeOf((*IP6ndSendRouterSolicitationReply)(nil)).Elem(), - "IPAddDelRoute": reflect.TypeOf((*IPAddDelRoute)(nil)).Elem(), - "IPAddDelRouteReply": reflect.TypeOf((*IPAddDelRouteReply)(nil)).Elem(), - "IPAddressDetails": reflect.TypeOf((*IPAddressDetails)(nil)).Elem(), - "IPAddressDump": reflect.TypeOf((*IPAddressDump)(nil)).Elem(), - "IPContainerProxyAddDel": reflect.TypeOf((*IPContainerProxyAddDel)(nil)).Elem(), - "IPContainerProxyAddDelReply": reflect.TypeOf((*IPContainerProxyAddDelReply)(nil)).Elem(), - "IPDetails": reflect.TypeOf((*IPDetails)(nil)).Elem(), - "IPDump": reflect.TypeOf((*IPDump)(nil)).Elem(), - "IPFibDetails": reflect.TypeOf((*IPFibDetails)(nil)).Elem(), - "IPFibDump": reflect.TypeOf((*IPFibDump)(nil)).Elem(), - "IPMfibDetails": reflect.TypeOf((*IPMfibDetails)(nil)).Elem(), - "IPMfibDump": reflect.TypeOf((*IPMfibDump)(nil)).Elem(), - "IPMrouteAddDel": reflect.TypeOf((*IPMrouteAddDel)(nil)).Elem(), - "IPMrouteAddDelReply": reflect.TypeOf((*IPMrouteAddDelReply)(nil)).Elem(), - "IPNeighborAddDel": reflect.TypeOf((*IPNeighborAddDel)(nil)).Elem(), - "IPNeighborAddDelReply": reflect.TypeOf((*IPNeighborAddDelReply)(nil)).Elem(), - "IPNeighborDetails": reflect.TypeOf((*IPNeighborDetails)(nil)).Elem(), - "IPNeighborDump": reflect.TypeOf((*IPNeighborDump)(nil)).Elem(), - "IPPuntPolice": reflect.TypeOf((*IPPuntPolice)(nil)).Elem(), - "IPPuntPoliceReply": reflect.TypeOf((*IPPuntPoliceReply)(nil)).Elem(), - "IPPuntRedirect": reflect.TypeOf((*IPPuntRedirect)(nil)).Elem(), - "IPPuntRedirectReply": reflect.TypeOf((*IPPuntRedirectReply)(nil)).Elem(), - "IPReassemblyEnableDisable": reflect.TypeOf((*IPReassemblyEnableDisable)(nil)).Elem(), - "IPReassemblyEnableDisableReply": reflect.TypeOf((*IPReassemblyEnableDisableReply)(nil)).Elem(), - "IPReassemblyGet": reflect.TypeOf((*IPReassemblyGet)(nil)).Elem(), - "IPReassemblyGetReply": reflect.TypeOf((*IPReassemblyGetReply)(nil)).Elem(), - "IPReassemblySet": reflect.TypeOf((*IPReassemblySet)(nil)).Elem(), - "IPReassemblySetReply": reflect.TypeOf((*IPReassemblySetReply)(nil)).Elem(), - "IPSourceAndPortRangeCheckAddDel": reflect.TypeOf((*IPSourceAndPortRangeCheckAddDel)(nil)).Elem(), - "IPSourceAndPortRangeCheckAddDelReply": reflect.TypeOf((*IPSourceAndPortRangeCheckAddDelReply)(nil)).Elem(), - "IPSourceAndPortRangeCheckInterfaceAddDel": reflect.TypeOf((*IPSourceAndPortRangeCheckInterfaceAddDel)(nil)).Elem(), - "IPSourceAndPortRangeCheckInterfaceAddDelReply": reflect.TypeOf((*IPSourceAndPortRangeCheckInterfaceAddDelReply)(nil)).Elem(), - "IPTableAddDel": reflect.TypeOf((*IPTableAddDel)(nil)).Elem(), - "IPTableAddDelReply": reflect.TypeOf((*IPTableAddDelReply)(nil)).Elem(), - "IoamDisable": reflect.TypeOf((*IoamDisable)(nil)).Elem(), - "IoamDisableReply": reflect.TypeOf((*IoamDisableReply)(nil)).Elem(), - "IoamEnable": reflect.TypeOf((*IoamEnable)(nil)).Elem(), - "IoamEnableReply": reflect.TypeOf((*IoamEnableReply)(nil)).Elem(), - "MfibSignalDetails": reflect.TypeOf((*MfibSignalDetails)(nil)).Elem(), - "MfibSignalDump": reflect.TypeOf((*MfibSignalDump)(nil)).Elem(), - "ProxyArpAddDel": reflect.TypeOf((*ProxyArpAddDel)(nil)).Elem(), - "ProxyArpAddDelReply": reflect.TypeOf((*ProxyArpAddDelReply)(nil)).Elem(), - "ProxyArpIntfcEnableDisable": reflect.TypeOf((*ProxyArpIntfcEnableDisable)(nil)).Elem(), - "ProxyArpIntfcEnableDisableReply": reflect.TypeOf((*ProxyArpIntfcEnableDisableReply)(nil)).Elem(), - "ResetFib": reflect.TypeOf((*ResetFib)(nil)).Elem(), - "ResetFibReply": reflect.TypeOf((*ResetFibReply)(nil)).Elem(), - "SetArpNeighborLimit": reflect.TypeOf((*SetArpNeighborLimit)(nil)).Elem(), - "SetArpNeighborLimitReply": reflect.TypeOf((*SetArpNeighborLimitReply)(nil)).Elem(), - "SetIPFlowHash": reflect.TypeOf((*SetIPFlowHash)(nil)).Elem(), - "SetIPFlowHashReply": reflect.TypeOf((*SetIPFlowHashReply)(nil)).Elem(), - "SwInterfaceIP6EnableDisable": reflect.TypeOf((*SwInterfaceIP6EnableDisable)(nil)).Elem(), - "SwInterfaceIP6EnableDisableReply": reflect.TypeOf((*SwInterfaceIP6EnableDisableReply)(nil)).Elem(), - "SwInterfaceIP6SetLinkLocalAddress": reflect.TypeOf((*SwInterfaceIP6SetLinkLocalAddress)(nil)).Elem(), - "SwInterfaceIP6SetLinkLocalAddressReply": reflect.TypeOf((*SwInterfaceIP6SetLinkLocalAddressReply)(nil)).Elem(), - "SwInterfaceIP6ndRaConfig": reflect.TypeOf((*SwInterfaceIP6ndRaConfig)(nil)).Elem(), - "SwInterfaceIP6ndRaConfigReply": reflect.TypeOf((*SwInterfaceIP6ndRaConfigReply)(nil)).Elem(), - "SwInterfaceIP6ndRaPrefix": reflect.TypeOf((*SwInterfaceIP6ndRaPrefix)(nil)).Elem(), - "SwInterfaceIP6ndRaPrefixReply": reflect.TypeOf((*SwInterfaceIP6ndRaPrefixReply)(nil)).Elem(), - "WantIP4ArpEvents": reflect.TypeOf((*WantIP4ArpEvents)(nil)).Elem(), - "WantIP4ArpEventsReply": reflect.TypeOf((*WantIP4ArpEventsReply)(nil)).Elem(), - "WantIP6NdEvents": reflect.TypeOf((*WantIP6NdEvents)(nil)).Elem(), - "WantIP6NdEventsReply": reflect.TypeOf((*WantIP6NdEventsReply)(nil)).Elem(), - "WantIP6RaEvents": reflect.TypeOf((*WantIP6RaEvents)(nil)).Elem(), - "WantIP6RaEventsReply": reflect.TypeOf((*WantIP6RaEventsReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewIP4ArpEvent": reflect.ValueOf(NewIP4ArpEvent), - "NewIP6FibDetails": reflect.ValueOf(NewIP6FibDetails), - "NewIP6FibDump": reflect.ValueOf(NewIP6FibDump), - "NewIP6MfibDetails": reflect.ValueOf(NewIP6MfibDetails), - "NewIP6MfibDump": reflect.ValueOf(NewIP6MfibDump), - "NewIP6NdEvent": reflect.ValueOf(NewIP6NdEvent), - "NewIP6RaEvent": reflect.ValueOf(NewIP6RaEvent), - "NewIP6ndProxyAddDel": reflect.ValueOf(NewIP6ndProxyAddDel), - "NewIP6ndProxyAddDelReply": reflect.ValueOf(NewIP6ndProxyAddDelReply), - "NewIP6ndProxyDetails": reflect.ValueOf(NewIP6ndProxyDetails), - "NewIP6ndProxyDump": reflect.ValueOf(NewIP6ndProxyDump), - "NewIP6ndSendRouterSolicitation": reflect.ValueOf(NewIP6ndSendRouterSolicitation), - "NewIP6ndSendRouterSolicitationReply": reflect.ValueOf(NewIP6ndSendRouterSolicitationReply), - "NewIPAddDelRoute": reflect.ValueOf(NewIPAddDelRoute), - "NewIPAddDelRouteReply": reflect.ValueOf(NewIPAddDelRouteReply), - "NewIPAddressDetails": reflect.ValueOf(NewIPAddressDetails), - "NewIPAddressDump": reflect.ValueOf(NewIPAddressDump), - "NewIPContainerProxyAddDel": reflect.ValueOf(NewIPContainerProxyAddDel), - "NewIPContainerProxyAddDelReply": reflect.ValueOf(NewIPContainerProxyAddDelReply), - "NewIPDetails": reflect.ValueOf(NewIPDetails), - "NewIPDump": reflect.ValueOf(NewIPDump), - "NewIPFibDetails": reflect.ValueOf(NewIPFibDetails), - "NewIPFibDump": reflect.ValueOf(NewIPFibDump), - "NewIPMfibDetails": reflect.ValueOf(NewIPMfibDetails), - "NewIPMfibDump": reflect.ValueOf(NewIPMfibDump), - "NewIPMrouteAddDel": reflect.ValueOf(NewIPMrouteAddDel), - "NewIPMrouteAddDelReply": reflect.ValueOf(NewIPMrouteAddDelReply), - "NewIPNeighborAddDel": reflect.ValueOf(NewIPNeighborAddDel), - "NewIPNeighborAddDelReply": reflect.ValueOf(NewIPNeighborAddDelReply), - "NewIPNeighborDetails": reflect.ValueOf(NewIPNeighborDetails), - "NewIPNeighborDump": reflect.ValueOf(NewIPNeighborDump), - "NewIPPuntPolice": reflect.ValueOf(NewIPPuntPolice), - "NewIPPuntPoliceReply": reflect.ValueOf(NewIPPuntPoliceReply), - "NewIPPuntRedirect": reflect.ValueOf(NewIPPuntRedirect), - "NewIPPuntRedirectReply": reflect.ValueOf(NewIPPuntRedirectReply), - "NewIPReassemblyEnableDisable": reflect.ValueOf(NewIPReassemblyEnableDisable), - "NewIPReassemblyEnableDisableReply": reflect.ValueOf(NewIPReassemblyEnableDisableReply), - "NewIPReassemblyGet": reflect.ValueOf(NewIPReassemblyGet), - "NewIPReassemblyGetReply": reflect.ValueOf(NewIPReassemblyGetReply), - "NewIPReassemblySet": reflect.ValueOf(NewIPReassemblySet), - "NewIPReassemblySetReply": reflect.ValueOf(NewIPReassemblySetReply), - "NewIPSourceAndPortRangeCheckAddDel": reflect.ValueOf(NewIPSourceAndPortRangeCheckAddDel), - "NewIPSourceAndPortRangeCheckAddDelReply": reflect.ValueOf(NewIPSourceAndPortRangeCheckAddDelReply), - "NewIPSourceAndPortRangeCheckInterfaceAddDel": reflect.ValueOf(NewIPSourceAndPortRangeCheckInterfaceAddDel), - "NewIPSourceAndPortRangeCheckInterfaceAddDelReply": reflect.ValueOf(NewIPSourceAndPortRangeCheckInterfaceAddDelReply), - "NewIPTableAddDel": reflect.ValueOf(NewIPTableAddDel), - "NewIPTableAddDelReply": reflect.ValueOf(NewIPTableAddDelReply), - "NewIoamDisable": reflect.ValueOf(NewIoamDisable), - "NewIoamDisableReply": reflect.ValueOf(NewIoamDisableReply), - "NewIoamEnable": reflect.ValueOf(NewIoamEnable), - "NewIoamEnableReply": reflect.ValueOf(NewIoamEnableReply), - "NewMfibSignalDetails": reflect.ValueOf(NewMfibSignalDetails), - "NewMfibSignalDump": reflect.ValueOf(NewMfibSignalDump), - "NewProxyArpAddDel": reflect.ValueOf(NewProxyArpAddDel), - "NewProxyArpAddDelReply": reflect.ValueOf(NewProxyArpAddDelReply), - "NewProxyArpIntfcEnableDisable": reflect.ValueOf(NewProxyArpIntfcEnableDisable), - "NewProxyArpIntfcEnableDisableReply": reflect.ValueOf(NewProxyArpIntfcEnableDisableReply), - "NewResetFib": reflect.ValueOf(NewResetFib), - "NewResetFibReply": reflect.ValueOf(NewResetFibReply), - "NewSetArpNeighborLimit": reflect.ValueOf(NewSetArpNeighborLimit), - "NewSetArpNeighborLimitReply": reflect.ValueOf(NewSetArpNeighborLimitReply), - "NewSetIPFlowHash": reflect.ValueOf(NewSetIPFlowHash), - "NewSetIPFlowHashReply": reflect.ValueOf(NewSetIPFlowHashReply), - "NewSwInterfaceIP6EnableDisable": reflect.ValueOf(NewSwInterfaceIP6EnableDisable), - "NewSwInterfaceIP6EnableDisableReply": reflect.ValueOf(NewSwInterfaceIP6EnableDisableReply), - "NewSwInterfaceIP6SetLinkLocalAddress": reflect.ValueOf(NewSwInterfaceIP6SetLinkLocalAddress), - "NewSwInterfaceIP6SetLinkLocalAddressReply": reflect.ValueOf(NewSwInterfaceIP6SetLinkLocalAddressReply), - "NewSwInterfaceIP6ndRaConfig": reflect.ValueOf(NewSwInterfaceIP6ndRaConfig), - "NewSwInterfaceIP6ndRaConfigReply": reflect.ValueOf(NewSwInterfaceIP6ndRaConfigReply), - "NewSwInterfaceIP6ndRaPrefix": reflect.ValueOf(NewSwInterfaceIP6ndRaPrefix), - "NewSwInterfaceIP6ndRaPrefixReply": reflect.ValueOf(NewSwInterfaceIP6ndRaPrefixReply), - "NewWantIP4ArpEvents": reflect.ValueOf(NewWantIP4ArpEvents), - "NewWantIP4ArpEventsReply": reflect.ValueOf(NewWantIP4ArpEventsReply), - "NewWantIP6NdEvents": reflect.ValueOf(NewWantIP6NdEvents), - "NewWantIP6NdEventsReply": reflect.ValueOf(NewWantIP6NdEventsReply), - "NewWantIP6RaEvents": reflect.ValueOf(NewWantIP6RaEvents), - "NewWantIP6RaEventsReply": reflect.ValueOf(NewWantIP6RaEventsReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/ipsec/pkgreflect.go b/plugins/defaultplugins/common/bin_api/ipsec/pkgreflect.go deleted file mode 100644 index 630efdd998..0000000000 --- a/plugins/defaultplugins/common/bin_api/ipsec/pkgreflect.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package ipsec - -import "reflect" - -var Types = map[string]reflect.Type{ - "Ikev2InitiateDelChildSa": reflect.TypeOf((*Ikev2InitiateDelChildSa)(nil)).Elem(), - "Ikev2InitiateDelChildSaReply": reflect.TypeOf((*Ikev2InitiateDelChildSaReply)(nil)).Elem(), - "Ikev2InitiateDelIkeSa": reflect.TypeOf((*Ikev2InitiateDelIkeSa)(nil)).Elem(), - "Ikev2InitiateDelIkeSaReply": reflect.TypeOf((*Ikev2InitiateDelIkeSaReply)(nil)).Elem(), - "Ikev2InitiateRekeyChildSa": reflect.TypeOf((*Ikev2InitiateRekeyChildSa)(nil)).Elem(), - "Ikev2InitiateRekeyChildSaReply": reflect.TypeOf((*Ikev2InitiateRekeyChildSaReply)(nil)).Elem(), - "Ikev2InitiateSaInit": reflect.TypeOf((*Ikev2InitiateSaInit)(nil)).Elem(), - "Ikev2InitiateSaInitReply": reflect.TypeOf((*Ikev2InitiateSaInitReply)(nil)).Elem(), - "Ikev2ProfileAddDel": reflect.TypeOf((*Ikev2ProfileAddDel)(nil)).Elem(), - "Ikev2ProfileAddDelReply": reflect.TypeOf((*Ikev2ProfileAddDelReply)(nil)).Elem(), - "Ikev2ProfileSetAuth": reflect.TypeOf((*Ikev2ProfileSetAuth)(nil)).Elem(), - "Ikev2ProfileSetAuthReply": reflect.TypeOf((*Ikev2ProfileSetAuthReply)(nil)).Elem(), - "Ikev2ProfileSetID": reflect.TypeOf((*Ikev2ProfileSetID)(nil)).Elem(), - "Ikev2ProfileSetIDReply": reflect.TypeOf((*Ikev2ProfileSetIDReply)(nil)).Elem(), - "Ikev2ProfileSetTs": reflect.TypeOf((*Ikev2ProfileSetTs)(nil)).Elem(), - "Ikev2ProfileSetTsReply": reflect.TypeOf((*Ikev2ProfileSetTsReply)(nil)).Elem(), - "Ikev2SetEspTransforms": reflect.TypeOf((*Ikev2SetEspTransforms)(nil)).Elem(), - "Ikev2SetEspTransformsReply": reflect.TypeOf((*Ikev2SetEspTransformsReply)(nil)).Elem(), - "Ikev2SetIkeTransforms": reflect.TypeOf((*Ikev2SetIkeTransforms)(nil)).Elem(), - "Ikev2SetIkeTransformsReply": reflect.TypeOf((*Ikev2SetIkeTransformsReply)(nil)).Elem(), - "Ikev2SetLocalKey": reflect.TypeOf((*Ikev2SetLocalKey)(nil)).Elem(), - "Ikev2SetLocalKeyReply": reflect.TypeOf((*Ikev2SetLocalKeyReply)(nil)).Elem(), - "Ikev2SetResponder": reflect.TypeOf((*Ikev2SetResponder)(nil)).Elem(), - "Ikev2SetResponderReply": reflect.TypeOf((*Ikev2SetResponderReply)(nil)).Elem(), - "Ikev2SetSaLifetime": reflect.TypeOf((*Ikev2SetSaLifetime)(nil)).Elem(), - "Ikev2SetSaLifetimeReply": reflect.TypeOf((*Ikev2SetSaLifetimeReply)(nil)).Elem(), - "IpsecInterfaceAddDelSpd": reflect.TypeOf((*IpsecInterfaceAddDelSpd)(nil)).Elem(), - "IpsecInterfaceAddDelSpdReply": reflect.TypeOf((*IpsecInterfaceAddDelSpdReply)(nil)).Elem(), - "IpsecSaDetails": reflect.TypeOf((*IpsecSaDetails)(nil)).Elem(), - "IpsecSaDump": reflect.TypeOf((*IpsecSaDump)(nil)).Elem(), - "IpsecSaSetKey": reflect.TypeOf((*IpsecSaSetKey)(nil)).Elem(), - "IpsecSaSetKeyReply": reflect.TypeOf((*IpsecSaSetKeyReply)(nil)).Elem(), - "IpsecSadAddDelEntry": reflect.TypeOf((*IpsecSadAddDelEntry)(nil)).Elem(), - "IpsecSadAddDelEntryReply": reflect.TypeOf((*IpsecSadAddDelEntryReply)(nil)).Elem(), - "IpsecSpdAddDel": reflect.TypeOf((*IpsecSpdAddDel)(nil)).Elem(), - "IpsecSpdAddDelEntry": reflect.TypeOf((*IpsecSpdAddDelEntry)(nil)).Elem(), - "IpsecSpdAddDelEntryReply": reflect.TypeOf((*IpsecSpdAddDelEntryReply)(nil)).Elem(), - "IpsecSpdAddDelReply": reflect.TypeOf((*IpsecSpdAddDelReply)(nil)).Elem(), - "IpsecSpdDetails": reflect.TypeOf((*IpsecSpdDetails)(nil)).Elem(), - "IpsecSpdDump": reflect.TypeOf((*IpsecSpdDump)(nil)).Elem(), - "IpsecTunnelIfAddDel": reflect.TypeOf((*IpsecTunnelIfAddDel)(nil)).Elem(), - "IpsecTunnelIfAddDelReply": reflect.TypeOf((*IpsecTunnelIfAddDelReply)(nil)).Elem(), - "IpsecTunnelIfSetKey": reflect.TypeOf((*IpsecTunnelIfSetKey)(nil)).Elem(), - "IpsecTunnelIfSetKeyReply": reflect.TypeOf((*IpsecTunnelIfSetKeyReply)(nil)).Elem(), - "IpsecTunnelIfSetSa": reflect.TypeOf((*IpsecTunnelIfSetSa)(nil)).Elem(), - "IpsecTunnelIfSetSaReply": reflect.TypeOf((*IpsecTunnelIfSetSaReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewIkev2InitiateDelChildSa": reflect.ValueOf(NewIkev2InitiateDelChildSa), - "NewIkev2InitiateDelChildSaReply": reflect.ValueOf(NewIkev2InitiateDelChildSaReply), - "NewIkev2InitiateDelIkeSa": reflect.ValueOf(NewIkev2InitiateDelIkeSa), - "NewIkev2InitiateDelIkeSaReply": reflect.ValueOf(NewIkev2InitiateDelIkeSaReply), - "NewIkev2InitiateRekeyChildSa": reflect.ValueOf(NewIkev2InitiateRekeyChildSa), - "NewIkev2InitiateRekeyChildSaReply": reflect.ValueOf(NewIkev2InitiateRekeyChildSaReply), - "NewIkev2InitiateSaInit": reflect.ValueOf(NewIkev2InitiateSaInit), - "NewIkev2InitiateSaInitReply": reflect.ValueOf(NewIkev2InitiateSaInitReply), - "NewIkev2ProfileAddDel": reflect.ValueOf(NewIkev2ProfileAddDel), - "NewIkev2ProfileAddDelReply": reflect.ValueOf(NewIkev2ProfileAddDelReply), - "NewIkev2ProfileSetAuth": reflect.ValueOf(NewIkev2ProfileSetAuth), - "NewIkev2ProfileSetAuthReply": reflect.ValueOf(NewIkev2ProfileSetAuthReply), - "NewIkev2ProfileSetID": reflect.ValueOf(NewIkev2ProfileSetID), - "NewIkev2ProfileSetIDReply": reflect.ValueOf(NewIkev2ProfileSetIDReply), - "NewIkev2ProfileSetTs": reflect.ValueOf(NewIkev2ProfileSetTs), - "NewIkev2ProfileSetTsReply": reflect.ValueOf(NewIkev2ProfileSetTsReply), - "NewIkev2SetEspTransforms": reflect.ValueOf(NewIkev2SetEspTransforms), - "NewIkev2SetEspTransformsReply": reflect.ValueOf(NewIkev2SetEspTransformsReply), - "NewIkev2SetIkeTransforms": reflect.ValueOf(NewIkev2SetIkeTransforms), - "NewIkev2SetIkeTransformsReply": reflect.ValueOf(NewIkev2SetIkeTransformsReply), - "NewIkev2SetLocalKey": reflect.ValueOf(NewIkev2SetLocalKey), - "NewIkev2SetLocalKeyReply": reflect.ValueOf(NewIkev2SetLocalKeyReply), - "NewIkev2SetResponder": reflect.ValueOf(NewIkev2SetResponder), - "NewIkev2SetResponderReply": reflect.ValueOf(NewIkev2SetResponderReply), - "NewIkev2SetSaLifetime": reflect.ValueOf(NewIkev2SetSaLifetime), - "NewIkev2SetSaLifetimeReply": reflect.ValueOf(NewIkev2SetSaLifetimeReply), - "NewIpsecInterfaceAddDelSpd": reflect.ValueOf(NewIpsecInterfaceAddDelSpd), - "NewIpsecInterfaceAddDelSpdReply": reflect.ValueOf(NewIpsecInterfaceAddDelSpdReply), - "NewIpsecSaDetails": reflect.ValueOf(NewIpsecSaDetails), - "NewIpsecSaDump": reflect.ValueOf(NewIpsecSaDump), - "NewIpsecSaSetKey": reflect.ValueOf(NewIpsecSaSetKey), - "NewIpsecSaSetKeyReply": reflect.ValueOf(NewIpsecSaSetKeyReply), - "NewIpsecSadAddDelEntry": reflect.ValueOf(NewIpsecSadAddDelEntry), - "NewIpsecSadAddDelEntryReply": reflect.ValueOf(NewIpsecSadAddDelEntryReply), - "NewIpsecSpdAddDel": reflect.ValueOf(NewIpsecSpdAddDel), - "NewIpsecSpdAddDelEntry": reflect.ValueOf(NewIpsecSpdAddDelEntry), - "NewIpsecSpdAddDelEntryReply": reflect.ValueOf(NewIpsecSpdAddDelEntryReply), - "NewIpsecSpdAddDelReply": reflect.ValueOf(NewIpsecSpdAddDelReply), - "NewIpsecSpdDetails": reflect.ValueOf(NewIpsecSpdDetails), - "NewIpsecSpdDump": reflect.ValueOf(NewIpsecSpdDump), - "NewIpsecTunnelIfAddDel": reflect.ValueOf(NewIpsecTunnelIfAddDel), - "NewIpsecTunnelIfAddDelReply": reflect.ValueOf(NewIpsecTunnelIfAddDelReply), - "NewIpsecTunnelIfSetKey": reflect.ValueOf(NewIpsecTunnelIfSetKey), - "NewIpsecTunnelIfSetKeyReply": reflect.ValueOf(NewIpsecTunnelIfSetKeyReply), - "NewIpsecTunnelIfSetSa": reflect.ValueOf(NewIpsecTunnelIfSetSa), - "NewIpsecTunnelIfSetSaReply": reflect.ValueOf(NewIpsecTunnelIfSetSaReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/l2/pkgreflect.go b/plugins/defaultplugins/common/bin_api/l2/pkgreflect.go deleted file mode 100644 index 7508a58f5d..0000000000 --- a/plugins/defaultplugins/common/bin_api/l2/pkgreflect.go +++ /dev/null @@ -1,103 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package l2 - -import "reflect" - -var Types = map[string]reflect.Type{ - "BdIPMacAddDel": reflect.TypeOf((*BdIPMacAddDel)(nil)).Elem(), - "BdIPMacAddDelReply": reflect.TypeOf((*BdIPMacAddDelReply)(nil)).Elem(), - "BridgeDomainAddDel": reflect.TypeOf((*BridgeDomainAddDel)(nil)).Elem(), - "BridgeDomainAddDelReply": reflect.TypeOf((*BridgeDomainAddDelReply)(nil)).Elem(), - "BridgeDomainDetails": reflect.TypeOf((*BridgeDomainDetails)(nil)).Elem(), - "BridgeDomainDump": reflect.TypeOf((*BridgeDomainDump)(nil)).Elem(), - "BridgeDomainSetMacAge": reflect.TypeOf((*BridgeDomainSetMacAge)(nil)).Elem(), - "BridgeDomainSetMacAgeReply": reflect.TypeOf((*BridgeDomainSetMacAgeReply)(nil)).Elem(), - "BridgeDomainSwIf": reflect.TypeOf((*BridgeDomainSwIf)(nil)).Elem(), - "BridgeFlags": reflect.TypeOf((*BridgeFlags)(nil)).Elem(), - "BridgeFlagsReply": reflect.TypeOf((*BridgeFlagsReply)(nil)).Elem(), - "L2FibClearTable": reflect.TypeOf((*L2FibClearTable)(nil)).Elem(), - "L2FibClearTableReply": reflect.TypeOf((*L2FibClearTableReply)(nil)).Elem(), - "L2FibTableDetails": reflect.TypeOf((*L2FibTableDetails)(nil)).Elem(), - "L2FibTableDump": reflect.TypeOf((*L2FibTableDump)(nil)).Elem(), - "L2Flags": reflect.TypeOf((*L2Flags)(nil)).Elem(), - "L2FlagsReply": reflect.TypeOf((*L2FlagsReply)(nil)).Elem(), - "L2InterfaceEfpFilter": reflect.TypeOf((*L2InterfaceEfpFilter)(nil)).Elem(), - "L2InterfaceEfpFilterReply": reflect.TypeOf((*L2InterfaceEfpFilterReply)(nil)).Elem(), - "L2InterfacePbbTagRewrite": reflect.TypeOf((*L2InterfacePbbTagRewrite)(nil)).Elem(), - "L2InterfacePbbTagRewriteReply": reflect.TypeOf((*L2InterfacePbbTagRewriteReply)(nil)).Elem(), - "L2InterfaceVlanTagRewrite": reflect.TypeOf((*L2InterfaceVlanTagRewrite)(nil)).Elem(), - "L2InterfaceVlanTagRewriteReply": reflect.TypeOf((*L2InterfaceVlanTagRewriteReply)(nil)).Elem(), - "L2MacsEvent": reflect.TypeOf((*L2MacsEvent)(nil)).Elem(), - "L2PatchAddDel": reflect.TypeOf((*L2PatchAddDel)(nil)).Elem(), - "L2PatchAddDelReply": reflect.TypeOf((*L2PatchAddDelReply)(nil)).Elem(), - "L2XconnectDetails": reflect.TypeOf((*L2XconnectDetails)(nil)).Elem(), - "L2XconnectDump": reflect.TypeOf((*L2XconnectDump)(nil)).Elem(), - "L2fibAddDel": reflect.TypeOf((*L2fibAddDel)(nil)).Elem(), - "L2fibAddDelReply": reflect.TypeOf((*L2fibAddDelReply)(nil)).Elem(), - "L2fibFlushAll": reflect.TypeOf((*L2fibFlushAll)(nil)).Elem(), - "L2fibFlushAllReply": reflect.TypeOf((*L2fibFlushAllReply)(nil)).Elem(), - "L2fibFlushBd": reflect.TypeOf((*L2fibFlushBd)(nil)).Elem(), - "L2fibFlushBdReply": reflect.TypeOf((*L2fibFlushBdReply)(nil)).Elem(), - "L2fibFlushInt": reflect.TypeOf((*L2fibFlushInt)(nil)).Elem(), - "L2fibFlushIntReply": reflect.TypeOf((*L2fibFlushIntReply)(nil)).Elem(), - "MacEntry": reflect.TypeOf((*MacEntry)(nil)).Elem(), - "SwInterfaceSetL2Bridge": reflect.TypeOf((*SwInterfaceSetL2Bridge)(nil)).Elem(), - "SwInterfaceSetL2BridgeReply": reflect.TypeOf((*SwInterfaceSetL2BridgeReply)(nil)).Elem(), - "SwInterfaceSetL2Xconnect": reflect.TypeOf((*SwInterfaceSetL2Xconnect)(nil)).Elem(), - "SwInterfaceSetL2XconnectReply": reflect.TypeOf((*SwInterfaceSetL2XconnectReply)(nil)).Elem(), - "SwInterfaceSetVpath": reflect.TypeOf((*SwInterfaceSetVpath)(nil)).Elem(), - "SwInterfaceSetVpathReply": reflect.TypeOf((*SwInterfaceSetVpathReply)(nil)).Elem(), - "WantL2MacsEvents": reflect.TypeOf((*WantL2MacsEvents)(nil)).Elem(), - "WantL2MacsEventsReply": reflect.TypeOf((*WantL2MacsEventsReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewBdIPMacAddDel": reflect.ValueOf(NewBdIPMacAddDel), - "NewBdIPMacAddDelReply": reflect.ValueOf(NewBdIPMacAddDelReply), - "NewBridgeDomainAddDel": reflect.ValueOf(NewBridgeDomainAddDel), - "NewBridgeDomainAddDelReply": reflect.ValueOf(NewBridgeDomainAddDelReply), - "NewBridgeDomainDetails": reflect.ValueOf(NewBridgeDomainDetails), - "NewBridgeDomainDump": reflect.ValueOf(NewBridgeDomainDump), - "NewBridgeDomainSetMacAge": reflect.ValueOf(NewBridgeDomainSetMacAge), - "NewBridgeDomainSetMacAgeReply": reflect.ValueOf(NewBridgeDomainSetMacAgeReply), - "NewBridgeFlags": reflect.ValueOf(NewBridgeFlags), - "NewBridgeFlagsReply": reflect.ValueOf(NewBridgeFlagsReply), - "NewL2FibClearTable": reflect.ValueOf(NewL2FibClearTable), - "NewL2FibClearTableReply": reflect.ValueOf(NewL2FibClearTableReply), - "NewL2FibTableDetails": reflect.ValueOf(NewL2FibTableDetails), - "NewL2FibTableDump": reflect.ValueOf(NewL2FibTableDump), - "NewL2Flags": reflect.ValueOf(NewL2Flags), - "NewL2FlagsReply": reflect.ValueOf(NewL2FlagsReply), - "NewL2InterfaceEfpFilter": reflect.ValueOf(NewL2InterfaceEfpFilter), - "NewL2InterfaceEfpFilterReply": reflect.ValueOf(NewL2InterfaceEfpFilterReply), - "NewL2InterfacePbbTagRewrite": reflect.ValueOf(NewL2InterfacePbbTagRewrite), - "NewL2InterfacePbbTagRewriteReply": reflect.ValueOf(NewL2InterfacePbbTagRewriteReply), - "NewL2InterfaceVlanTagRewrite": reflect.ValueOf(NewL2InterfaceVlanTagRewrite), - "NewL2InterfaceVlanTagRewriteReply": reflect.ValueOf(NewL2InterfaceVlanTagRewriteReply), - "NewL2MacsEvent": reflect.ValueOf(NewL2MacsEvent), - "NewL2PatchAddDel": reflect.ValueOf(NewL2PatchAddDel), - "NewL2PatchAddDelReply": reflect.ValueOf(NewL2PatchAddDelReply), - "NewL2XconnectDetails": reflect.ValueOf(NewL2XconnectDetails), - "NewL2XconnectDump": reflect.ValueOf(NewL2XconnectDump), - "NewL2fibAddDel": reflect.ValueOf(NewL2fibAddDel), - "NewL2fibAddDelReply": reflect.ValueOf(NewL2fibAddDelReply), - "NewL2fibFlushAll": reflect.ValueOf(NewL2fibFlushAll), - "NewL2fibFlushAllReply": reflect.ValueOf(NewL2fibFlushAllReply), - "NewL2fibFlushBd": reflect.ValueOf(NewL2fibFlushBd), - "NewL2fibFlushBdReply": reflect.ValueOf(NewL2fibFlushBdReply), - "NewL2fibFlushInt": reflect.ValueOf(NewL2fibFlushInt), - "NewL2fibFlushIntReply": reflect.ValueOf(NewL2fibFlushIntReply), - "NewSwInterfaceSetL2Bridge": reflect.ValueOf(NewSwInterfaceSetL2Bridge), - "NewSwInterfaceSetL2BridgeReply": reflect.ValueOf(NewSwInterfaceSetL2BridgeReply), - "NewSwInterfaceSetL2Xconnect": reflect.ValueOf(NewSwInterfaceSetL2Xconnect), - "NewSwInterfaceSetL2XconnectReply": reflect.ValueOf(NewSwInterfaceSetL2XconnectReply), - "NewSwInterfaceSetVpath": reflect.ValueOf(NewSwInterfaceSetVpath), - "NewSwInterfaceSetVpathReply": reflect.ValueOf(NewSwInterfaceSetVpathReply), - "NewWantL2MacsEvents": reflect.ValueOf(NewWantL2MacsEvents), - "NewWantL2MacsEventsReply": reflect.ValueOf(NewWantL2MacsEventsReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/memif/pkgreflect.go b/plugins/defaultplugins/common/bin_api/memif/pkgreflect.go deleted file mode 100644 index 8e1268145c..0000000000 --- a/plugins/defaultplugins/common/bin_api/memif/pkgreflect.go +++ /dev/null @@ -1,35 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package memif - -import "reflect" - -var Types = map[string]reflect.Type{ - "MemifCreate": reflect.TypeOf((*MemifCreate)(nil)).Elem(), - "MemifCreateReply": reflect.TypeOf((*MemifCreateReply)(nil)).Elem(), - "MemifDelete": reflect.TypeOf((*MemifDelete)(nil)).Elem(), - "MemifDeleteReply": reflect.TypeOf((*MemifDeleteReply)(nil)).Elem(), - "MemifDetails": reflect.TypeOf((*MemifDetails)(nil)).Elem(), - "MemifDump": reflect.TypeOf((*MemifDump)(nil)).Elem(), - "MemifSocketFilenameAddDel": reflect.TypeOf((*MemifSocketFilenameAddDel)(nil)).Elem(), - "MemifSocketFilenameAddDelReply": reflect.TypeOf((*MemifSocketFilenameAddDelReply)(nil)).Elem(), - "MemifSocketFilenameDetails": reflect.TypeOf((*MemifSocketFilenameDetails)(nil)).Elem(), - "MemifSocketFilenameDump": reflect.TypeOf((*MemifSocketFilenameDump)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewMemifCreate": reflect.ValueOf(NewMemifCreate), - "NewMemifCreateReply": reflect.ValueOf(NewMemifCreateReply), - "NewMemifDelete": reflect.ValueOf(NewMemifDelete), - "NewMemifDeleteReply": reflect.ValueOf(NewMemifDeleteReply), - "NewMemifDetails": reflect.ValueOf(NewMemifDetails), - "NewMemifDump": reflect.ValueOf(NewMemifDump), - "NewMemifSocketFilenameAddDel": reflect.ValueOf(NewMemifSocketFilenameAddDel), - "NewMemifSocketFilenameAddDelReply": reflect.ValueOf(NewMemifSocketFilenameAddDelReply), - "NewMemifSocketFilenameDetails": reflect.ValueOf(NewMemifSocketFilenameDetails), - "NewMemifSocketFilenameDump": reflect.ValueOf(NewMemifSocketFilenameDump), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/nat/pkgreflect.go b/plugins/defaultplugins/common/bin_api/nat/pkgreflect.go deleted file mode 100644 index 6f93b148e2..0000000000 --- a/plugins/defaultplugins/common/bin_api/nat/pkgreflect.go +++ /dev/null @@ -1,244 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package nat - -import "reflect" - -var Types = map[string]reflect.Type{ - "DsliteAddDelPoolAddrRange": reflect.TypeOf((*DsliteAddDelPoolAddrRange)(nil)).Elem(), - "DsliteAddDelPoolAddrRangeReply": reflect.TypeOf((*DsliteAddDelPoolAddrRangeReply)(nil)).Elem(), - "DsliteGetAftrAddr": reflect.TypeOf((*DsliteGetAftrAddr)(nil)).Elem(), - "DsliteGetAftrAddrReply": reflect.TypeOf((*DsliteGetAftrAddrReply)(nil)).Elem(), - "DsliteGetB4Addr": reflect.TypeOf((*DsliteGetB4Addr)(nil)).Elem(), - "DsliteGetB4AddrReply": reflect.TypeOf((*DsliteGetB4AddrReply)(nil)).Elem(), - "DsliteSetAftrAddr": reflect.TypeOf((*DsliteSetAftrAddr)(nil)).Elem(), - "DsliteSetAftrAddrReply": reflect.TypeOf((*DsliteSetAftrAddrReply)(nil)).Elem(), - "DsliteSetB4Addr": reflect.TypeOf((*DsliteSetB4Addr)(nil)).Elem(), - "DsliteSetB4AddrReply": reflect.TypeOf((*DsliteSetB4AddrReply)(nil)).Elem(), - "Nat44AddDelAddressRange": reflect.TypeOf((*Nat44AddDelAddressRange)(nil)).Elem(), - "Nat44AddDelAddressRangeReply": reflect.TypeOf((*Nat44AddDelAddressRangeReply)(nil)).Elem(), - "Nat44AddDelIdentityMapping": reflect.TypeOf((*Nat44AddDelIdentityMapping)(nil)).Elem(), - "Nat44AddDelIdentityMappingReply": reflect.TypeOf((*Nat44AddDelIdentityMappingReply)(nil)).Elem(), - "Nat44AddDelInterfaceAddr": reflect.TypeOf((*Nat44AddDelInterfaceAddr)(nil)).Elem(), - "Nat44AddDelInterfaceAddrReply": reflect.TypeOf((*Nat44AddDelInterfaceAddrReply)(nil)).Elem(), - "Nat44AddDelLbStaticMapping": reflect.TypeOf((*Nat44AddDelLbStaticMapping)(nil)).Elem(), - "Nat44AddDelLbStaticMappingReply": reflect.TypeOf((*Nat44AddDelLbStaticMappingReply)(nil)).Elem(), - "Nat44AddDelStaticMapping": reflect.TypeOf((*Nat44AddDelStaticMapping)(nil)).Elem(), - "Nat44AddDelStaticMappingReply": reflect.TypeOf((*Nat44AddDelStaticMappingReply)(nil)).Elem(), - "Nat44AddressDetails": reflect.TypeOf((*Nat44AddressDetails)(nil)).Elem(), - "Nat44AddressDump": reflect.TypeOf((*Nat44AddressDump)(nil)).Elem(), - "Nat44DelSession": reflect.TypeOf((*Nat44DelSession)(nil)).Elem(), - "Nat44DelSessionReply": reflect.TypeOf((*Nat44DelSessionReply)(nil)).Elem(), - "Nat44ForwardingEnableDisable": reflect.TypeOf((*Nat44ForwardingEnableDisable)(nil)).Elem(), - "Nat44ForwardingEnableDisableReply": reflect.TypeOf((*Nat44ForwardingEnableDisableReply)(nil)).Elem(), - "Nat44ForwardingIsEnabled": reflect.TypeOf((*Nat44ForwardingIsEnabled)(nil)).Elem(), - "Nat44ForwardingIsEnabledReply": reflect.TypeOf((*Nat44ForwardingIsEnabledReply)(nil)).Elem(), - "Nat44IdentityMappingDetails": reflect.TypeOf((*Nat44IdentityMappingDetails)(nil)).Elem(), - "Nat44IdentityMappingDump": reflect.TypeOf((*Nat44IdentityMappingDump)(nil)).Elem(), - "Nat44InterfaceAddDelFeature": reflect.TypeOf((*Nat44InterfaceAddDelFeature)(nil)).Elem(), - "Nat44InterfaceAddDelFeatureReply": reflect.TypeOf((*Nat44InterfaceAddDelFeatureReply)(nil)).Elem(), - "Nat44InterfaceAddDelOutputFeature": reflect.TypeOf((*Nat44InterfaceAddDelOutputFeature)(nil)).Elem(), - "Nat44InterfaceAddDelOutputFeatureReply": reflect.TypeOf((*Nat44InterfaceAddDelOutputFeatureReply)(nil)).Elem(), - "Nat44InterfaceAddrDetails": reflect.TypeOf((*Nat44InterfaceAddrDetails)(nil)).Elem(), - "Nat44InterfaceAddrDump": reflect.TypeOf((*Nat44InterfaceAddrDump)(nil)).Elem(), - "Nat44InterfaceDetails": reflect.TypeOf((*Nat44InterfaceDetails)(nil)).Elem(), - "Nat44InterfaceDump": reflect.TypeOf((*Nat44InterfaceDump)(nil)).Elem(), - "Nat44InterfaceOutputFeatureDetails": reflect.TypeOf((*Nat44InterfaceOutputFeatureDetails)(nil)).Elem(), - "Nat44InterfaceOutputFeatureDump": reflect.TypeOf((*Nat44InterfaceOutputFeatureDump)(nil)).Elem(), - "Nat44LbAddrPort": reflect.TypeOf((*Nat44LbAddrPort)(nil)).Elem(), - "Nat44LbStaticMappingDetails": reflect.TypeOf((*Nat44LbStaticMappingDetails)(nil)).Elem(), - "Nat44LbStaticMappingDump": reflect.TypeOf((*Nat44LbStaticMappingDump)(nil)).Elem(), - "Nat44StaticMappingDetails": reflect.TypeOf((*Nat44StaticMappingDetails)(nil)).Elem(), - "Nat44StaticMappingDump": reflect.TypeOf((*Nat44StaticMappingDump)(nil)).Elem(), - "Nat44UserDetails": reflect.TypeOf((*Nat44UserDetails)(nil)).Elem(), - "Nat44UserDump": reflect.TypeOf((*Nat44UserDump)(nil)).Elem(), - "Nat44UserSessionDetails": reflect.TypeOf((*Nat44UserSessionDetails)(nil)).Elem(), - "Nat44UserSessionDump": reflect.TypeOf((*Nat44UserSessionDump)(nil)).Elem(), - "Nat64AddDelInterface": reflect.TypeOf((*Nat64AddDelInterface)(nil)).Elem(), - "Nat64AddDelInterfaceAddr": reflect.TypeOf((*Nat64AddDelInterfaceAddr)(nil)).Elem(), - "Nat64AddDelInterfaceAddrReply": reflect.TypeOf((*Nat64AddDelInterfaceAddrReply)(nil)).Elem(), - "Nat64AddDelInterfaceReply": reflect.TypeOf((*Nat64AddDelInterfaceReply)(nil)).Elem(), - "Nat64AddDelPoolAddrRange": reflect.TypeOf((*Nat64AddDelPoolAddrRange)(nil)).Elem(), - "Nat64AddDelPoolAddrRangeReply": reflect.TypeOf((*Nat64AddDelPoolAddrRangeReply)(nil)).Elem(), - "Nat64AddDelPrefix": reflect.TypeOf((*Nat64AddDelPrefix)(nil)).Elem(), - "Nat64AddDelPrefixReply": reflect.TypeOf((*Nat64AddDelPrefixReply)(nil)).Elem(), - "Nat64AddDelStaticBib": reflect.TypeOf((*Nat64AddDelStaticBib)(nil)).Elem(), - "Nat64AddDelStaticBibReply": reflect.TypeOf((*Nat64AddDelStaticBibReply)(nil)).Elem(), - "Nat64BibDetails": reflect.TypeOf((*Nat64BibDetails)(nil)).Elem(), - "Nat64BibDump": reflect.TypeOf((*Nat64BibDump)(nil)).Elem(), - "Nat64GetTimeouts": reflect.TypeOf((*Nat64GetTimeouts)(nil)).Elem(), - "Nat64GetTimeoutsReply": reflect.TypeOf((*Nat64GetTimeoutsReply)(nil)).Elem(), - "Nat64InterfaceDetails": reflect.TypeOf((*Nat64InterfaceDetails)(nil)).Elem(), - "Nat64InterfaceDump": reflect.TypeOf((*Nat64InterfaceDump)(nil)).Elem(), - "Nat64PoolAddrDetails": reflect.TypeOf((*Nat64PoolAddrDetails)(nil)).Elem(), - "Nat64PoolAddrDump": reflect.TypeOf((*Nat64PoolAddrDump)(nil)).Elem(), - "Nat64PrefixDetails": reflect.TypeOf((*Nat64PrefixDetails)(nil)).Elem(), - "Nat64PrefixDump": reflect.TypeOf((*Nat64PrefixDump)(nil)).Elem(), - "Nat64SetTimeouts": reflect.TypeOf((*Nat64SetTimeouts)(nil)).Elem(), - "Nat64SetTimeoutsReply": reflect.TypeOf((*Nat64SetTimeoutsReply)(nil)).Elem(), - "Nat64StDetails": reflect.TypeOf((*Nat64StDetails)(nil)).Elem(), - "Nat64StDump": reflect.TypeOf((*Nat64StDump)(nil)).Elem(), - "Nat66AddDelInterface": reflect.TypeOf((*Nat66AddDelInterface)(nil)).Elem(), - "Nat66AddDelInterfaceReply": reflect.TypeOf((*Nat66AddDelInterfaceReply)(nil)).Elem(), - "Nat66AddDelStaticMapping": reflect.TypeOf((*Nat66AddDelStaticMapping)(nil)).Elem(), - "Nat66AddDelStaticMappingReply": reflect.TypeOf((*Nat66AddDelStaticMappingReply)(nil)).Elem(), - "Nat66InterfaceDetails": reflect.TypeOf((*Nat66InterfaceDetails)(nil)).Elem(), - "Nat66InterfaceDump": reflect.TypeOf((*Nat66InterfaceDump)(nil)).Elem(), - "Nat66StaticMappingDetails": reflect.TypeOf((*Nat66StaticMappingDetails)(nil)).Elem(), - "Nat66StaticMappingDump": reflect.TypeOf((*Nat66StaticMappingDump)(nil)).Elem(), - "NatControlPing": reflect.TypeOf((*NatControlPing)(nil)).Elem(), - "NatControlPingReply": reflect.TypeOf((*NatControlPingReply)(nil)).Elem(), - "NatDetAddDelMap": reflect.TypeOf((*NatDetAddDelMap)(nil)).Elem(), - "NatDetAddDelMapReply": reflect.TypeOf((*NatDetAddDelMapReply)(nil)).Elem(), - "NatDetCloseSessionIn": reflect.TypeOf((*NatDetCloseSessionIn)(nil)).Elem(), - "NatDetCloseSessionInReply": reflect.TypeOf((*NatDetCloseSessionInReply)(nil)).Elem(), - "NatDetCloseSessionOut": reflect.TypeOf((*NatDetCloseSessionOut)(nil)).Elem(), - "NatDetCloseSessionOutReply": reflect.TypeOf((*NatDetCloseSessionOutReply)(nil)).Elem(), - "NatDetForward": reflect.TypeOf((*NatDetForward)(nil)).Elem(), - "NatDetForwardReply": reflect.TypeOf((*NatDetForwardReply)(nil)).Elem(), - "NatDetGetTimeouts": reflect.TypeOf((*NatDetGetTimeouts)(nil)).Elem(), - "NatDetGetTimeoutsReply": reflect.TypeOf((*NatDetGetTimeoutsReply)(nil)).Elem(), - "NatDetMapDetails": reflect.TypeOf((*NatDetMapDetails)(nil)).Elem(), - "NatDetMapDump": reflect.TypeOf((*NatDetMapDump)(nil)).Elem(), - "NatDetReverse": reflect.TypeOf((*NatDetReverse)(nil)).Elem(), - "NatDetReverseReply": reflect.TypeOf((*NatDetReverseReply)(nil)).Elem(), - "NatDetSessionDetails": reflect.TypeOf((*NatDetSessionDetails)(nil)).Elem(), - "NatDetSessionDump": reflect.TypeOf((*NatDetSessionDump)(nil)).Elem(), - "NatDetSetTimeouts": reflect.TypeOf((*NatDetSetTimeouts)(nil)).Elem(), - "NatDetSetTimeoutsReply": reflect.TypeOf((*NatDetSetTimeoutsReply)(nil)).Elem(), - "NatGetReass": reflect.TypeOf((*NatGetReass)(nil)).Elem(), - "NatGetReassReply": reflect.TypeOf((*NatGetReassReply)(nil)).Elem(), - "NatIpfixEnableDisable": reflect.TypeOf((*NatIpfixEnableDisable)(nil)).Elem(), - "NatIpfixEnableDisableReply": reflect.TypeOf((*NatIpfixEnableDisableReply)(nil)).Elem(), - "NatReassDetails": reflect.TypeOf((*NatReassDetails)(nil)).Elem(), - "NatReassDump": reflect.TypeOf((*NatReassDump)(nil)).Elem(), - "NatSetReass": reflect.TypeOf((*NatSetReass)(nil)).Elem(), - "NatSetReassReply": reflect.TypeOf((*NatSetReassReply)(nil)).Elem(), - "NatSetWorkers": reflect.TypeOf((*NatSetWorkers)(nil)).Elem(), - "NatSetWorkersReply": reflect.TypeOf((*NatSetWorkersReply)(nil)).Elem(), - "NatShowConfig": reflect.TypeOf((*NatShowConfig)(nil)).Elem(), - "NatShowConfigReply": reflect.TypeOf((*NatShowConfigReply)(nil)).Elem(), - "NatWorkerDetails": reflect.TypeOf((*NatWorkerDetails)(nil)).Elem(), - "NatWorkerDump": reflect.TypeOf((*NatWorkerDump)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewDsliteAddDelPoolAddrRange": reflect.ValueOf(NewDsliteAddDelPoolAddrRange), - "NewDsliteAddDelPoolAddrRangeReply": reflect.ValueOf(NewDsliteAddDelPoolAddrRangeReply), - "NewDsliteGetAftrAddr": reflect.ValueOf(NewDsliteGetAftrAddr), - "NewDsliteGetAftrAddrReply": reflect.ValueOf(NewDsliteGetAftrAddrReply), - "NewDsliteGetB4Addr": reflect.ValueOf(NewDsliteGetB4Addr), - "NewDsliteGetB4AddrReply": reflect.ValueOf(NewDsliteGetB4AddrReply), - "NewDsliteSetAftrAddr": reflect.ValueOf(NewDsliteSetAftrAddr), - "NewDsliteSetAftrAddrReply": reflect.ValueOf(NewDsliteSetAftrAddrReply), - "NewDsliteSetB4Addr": reflect.ValueOf(NewDsliteSetB4Addr), - "NewDsliteSetB4AddrReply": reflect.ValueOf(NewDsliteSetB4AddrReply), - "NewNat44AddDelAddressRange": reflect.ValueOf(NewNat44AddDelAddressRange), - "NewNat44AddDelAddressRangeReply": reflect.ValueOf(NewNat44AddDelAddressRangeReply), - "NewNat44AddDelIdentityMapping": reflect.ValueOf(NewNat44AddDelIdentityMapping), - "NewNat44AddDelIdentityMappingReply": reflect.ValueOf(NewNat44AddDelIdentityMappingReply), - "NewNat44AddDelInterfaceAddr": reflect.ValueOf(NewNat44AddDelInterfaceAddr), - "NewNat44AddDelInterfaceAddrReply": reflect.ValueOf(NewNat44AddDelInterfaceAddrReply), - "NewNat44AddDelLbStaticMapping": reflect.ValueOf(NewNat44AddDelLbStaticMapping), - "NewNat44AddDelLbStaticMappingReply": reflect.ValueOf(NewNat44AddDelLbStaticMappingReply), - "NewNat44AddDelStaticMapping": reflect.ValueOf(NewNat44AddDelStaticMapping), - "NewNat44AddDelStaticMappingReply": reflect.ValueOf(NewNat44AddDelStaticMappingReply), - "NewNat44AddressDetails": reflect.ValueOf(NewNat44AddressDetails), - "NewNat44AddressDump": reflect.ValueOf(NewNat44AddressDump), - "NewNat44DelSession": reflect.ValueOf(NewNat44DelSession), - "NewNat44DelSessionReply": reflect.ValueOf(NewNat44DelSessionReply), - "NewNat44ForwardingEnableDisable": reflect.ValueOf(NewNat44ForwardingEnableDisable), - "NewNat44ForwardingEnableDisableReply": reflect.ValueOf(NewNat44ForwardingEnableDisableReply), - "NewNat44ForwardingIsEnabled": reflect.ValueOf(NewNat44ForwardingIsEnabled), - "NewNat44ForwardingIsEnabledReply": reflect.ValueOf(NewNat44ForwardingIsEnabledReply), - "NewNat44IdentityMappingDetails": reflect.ValueOf(NewNat44IdentityMappingDetails), - "NewNat44IdentityMappingDump": reflect.ValueOf(NewNat44IdentityMappingDump), - "NewNat44InterfaceAddDelFeature": reflect.ValueOf(NewNat44InterfaceAddDelFeature), - "NewNat44InterfaceAddDelFeatureReply": reflect.ValueOf(NewNat44InterfaceAddDelFeatureReply), - "NewNat44InterfaceAddDelOutputFeature": reflect.ValueOf(NewNat44InterfaceAddDelOutputFeature), - "NewNat44InterfaceAddDelOutputFeatureReply": reflect.ValueOf(NewNat44InterfaceAddDelOutputFeatureReply), - "NewNat44InterfaceAddrDetails": reflect.ValueOf(NewNat44InterfaceAddrDetails), - "NewNat44InterfaceAddrDump": reflect.ValueOf(NewNat44InterfaceAddrDump), - "NewNat44InterfaceDetails": reflect.ValueOf(NewNat44InterfaceDetails), - "NewNat44InterfaceDump": reflect.ValueOf(NewNat44InterfaceDump), - "NewNat44InterfaceOutputFeatureDetails": reflect.ValueOf(NewNat44InterfaceOutputFeatureDetails), - "NewNat44InterfaceOutputFeatureDump": reflect.ValueOf(NewNat44InterfaceOutputFeatureDump), - "NewNat44LbStaticMappingDetails": reflect.ValueOf(NewNat44LbStaticMappingDetails), - "NewNat44LbStaticMappingDump": reflect.ValueOf(NewNat44LbStaticMappingDump), - "NewNat44StaticMappingDetails": reflect.ValueOf(NewNat44StaticMappingDetails), - "NewNat44StaticMappingDump": reflect.ValueOf(NewNat44StaticMappingDump), - "NewNat44UserDetails": reflect.ValueOf(NewNat44UserDetails), - "NewNat44UserDump": reflect.ValueOf(NewNat44UserDump), - "NewNat44UserSessionDetails": reflect.ValueOf(NewNat44UserSessionDetails), - "NewNat44UserSessionDump": reflect.ValueOf(NewNat44UserSessionDump), - "NewNat64AddDelInterface": reflect.ValueOf(NewNat64AddDelInterface), - "NewNat64AddDelInterfaceAddr": reflect.ValueOf(NewNat64AddDelInterfaceAddr), - "NewNat64AddDelInterfaceAddrReply": reflect.ValueOf(NewNat64AddDelInterfaceAddrReply), - "NewNat64AddDelInterfaceReply": reflect.ValueOf(NewNat64AddDelInterfaceReply), - "NewNat64AddDelPoolAddrRange": reflect.ValueOf(NewNat64AddDelPoolAddrRange), - "NewNat64AddDelPoolAddrRangeReply": reflect.ValueOf(NewNat64AddDelPoolAddrRangeReply), - "NewNat64AddDelPrefix": reflect.ValueOf(NewNat64AddDelPrefix), - "NewNat64AddDelPrefixReply": reflect.ValueOf(NewNat64AddDelPrefixReply), - "NewNat64AddDelStaticBib": reflect.ValueOf(NewNat64AddDelStaticBib), - "NewNat64AddDelStaticBibReply": reflect.ValueOf(NewNat64AddDelStaticBibReply), - "NewNat64BibDetails": reflect.ValueOf(NewNat64BibDetails), - "NewNat64BibDump": reflect.ValueOf(NewNat64BibDump), - "NewNat64GetTimeouts": reflect.ValueOf(NewNat64GetTimeouts), - "NewNat64GetTimeoutsReply": reflect.ValueOf(NewNat64GetTimeoutsReply), - "NewNat64InterfaceDetails": reflect.ValueOf(NewNat64InterfaceDetails), - "NewNat64InterfaceDump": reflect.ValueOf(NewNat64InterfaceDump), - "NewNat64PoolAddrDetails": reflect.ValueOf(NewNat64PoolAddrDetails), - "NewNat64PoolAddrDump": reflect.ValueOf(NewNat64PoolAddrDump), - "NewNat64PrefixDetails": reflect.ValueOf(NewNat64PrefixDetails), - "NewNat64PrefixDump": reflect.ValueOf(NewNat64PrefixDump), - "NewNat64SetTimeouts": reflect.ValueOf(NewNat64SetTimeouts), - "NewNat64SetTimeoutsReply": reflect.ValueOf(NewNat64SetTimeoutsReply), - "NewNat64StDetails": reflect.ValueOf(NewNat64StDetails), - "NewNat64StDump": reflect.ValueOf(NewNat64StDump), - "NewNat66AddDelInterface": reflect.ValueOf(NewNat66AddDelInterface), - "NewNat66AddDelInterfaceReply": reflect.ValueOf(NewNat66AddDelInterfaceReply), - "NewNat66AddDelStaticMapping": reflect.ValueOf(NewNat66AddDelStaticMapping), - "NewNat66AddDelStaticMappingReply": reflect.ValueOf(NewNat66AddDelStaticMappingReply), - "NewNat66InterfaceDetails": reflect.ValueOf(NewNat66InterfaceDetails), - "NewNat66InterfaceDump": reflect.ValueOf(NewNat66InterfaceDump), - "NewNat66StaticMappingDetails": reflect.ValueOf(NewNat66StaticMappingDetails), - "NewNat66StaticMappingDump": reflect.ValueOf(NewNat66StaticMappingDump), - "NewNatControlPing": reflect.ValueOf(NewNatControlPing), - "NewNatControlPingReply": reflect.ValueOf(NewNatControlPingReply), - "NewNatDetAddDelMap": reflect.ValueOf(NewNatDetAddDelMap), - "NewNatDetAddDelMapReply": reflect.ValueOf(NewNatDetAddDelMapReply), - "NewNatDetCloseSessionIn": reflect.ValueOf(NewNatDetCloseSessionIn), - "NewNatDetCloseSessionInReply": reflect.ValueOf(NewNatDetCloseSessionInReply), - "NewNatDetCloseSessionOut": reflect.ValueOf(NewNatDetCloseSessionOut), - "NewNatDetCloseSessionOutReply": reflect.ValueOf(NewNatDetCloseSessionOutReply), - "NewNatDetForward": reflect.ValueOf(NewNatDetForward), - "NewNatDetForwardReply": reflect.ValueOf(NewNatDetForwardReply), - "NewNatDetGetTimeouts": reflect.ValueOf(NewNatDetGetTimeouts), - "NewNatDetGetTimeoutsReply": reflect.ValueOf(NewNatDetGetTimeoutsReply), - "NewNatDetMapDetails": reflect.ValueOf(NewNatDetMapDetails), - "NewNatDetMapDump": reflect.ValueOf(NewNatDetMapDump), - "NewNatDetReverse": reflect.ValueOf(NewNatDetReverse), - "NewNatDetReverseReply": reflect.ValueOf(NewNatDetReverseReply), - "NewNatDetSessionDetails": reflect.ValueOf(NewNatDetSessionDetails), - "NewNatDetSessionDump": reflect.ValueOf(NewNatDetSessionDump), - "NewNatDetSetTimeouts": reflect.ValueOf(NewNatDetSetTimeouts), - "NewNatDetSetTimeoutsReply": reflect.ValueOf(NewNatDetSetTimeoutsReply), - "NewNatGetReass": reflect.ValueOf(NewNatGetReass), - "NewNatGetReassReply": reflect.ValueOf(NewNatGetReassReply), - "NewNatIpfixEnableDisable": reflect.ValueOf(NewNatIpfixEnableDisable), - "NewNatIpfixEnableDisableReply": reflect.ValueOf(NewNatIpfixEnableDisableReply), - "NewNatReassDetails": reflect.ValueOf(NewNatReassDetails), - "NewNatReassDump": reflect.ValueOf(NewNatReassDump), - "NewNatSetReass": reflect.ValueOf(NewNatSetReass), - "NewNatSetReassReply": reflect.ValueOf(NewNatSetReassReply), - "NewNatSetWorkers": reflect.ValueOf(NewNatSetWorkers), - "NewNatSetWorkersReply": reflect.ValueOf(NewNatSetWorkersReply), - "NewNatShowConfig": reflect.ValueOf(NewNatShowConfig), - "NewNatShowConfigReply": reflect.ValueOf(NewNatShowConfigReply), - "NewNatWorkerDetails": reflect.ValueOf(NewNatWorkerDetails), - "NewNatWorkerDump": reflect.ValueOf(NewNatWorkerDump), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/session/pkgreflect.go b/plugins/defaultplugins/common/bin_api/session/pkgreflect.go deleted file mode 100644 index 3f4a045d99..0000000000 --- a/plugins/defaultplugins/common/bin_api/session/pkgreflect.go +++ /dev/null @@ -1,95 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package session - -import "reflect" - -var Types = map[string]reflect.Type{ - "AcceptSession": reflect.TypeOf((*AcceptSession)(nil)).Elem(), - "AcceptSessionReply": reflect.TypeOf((*AcceptSessionReply)(nil)).Elem(), - "AppNamespaceAddDel": reflect.TypeOf((*AppNamespaceAddDel)(nil)).Elem(), - "AppNamespaceAddDelReply": reflect.TypeOf((*AppNamespaceAddDelReply)(nil)).Elem(), - "ApplicationAttach": reflect.TypeOf((*ApplicationAttach)(nil)).Elem(), - "ApplicationAttachReply": reflect.TypeOf((*ApplicationAttachReply)(nil)).Elem(), - "ApplicationDetach": reflect.TypeOf((*ApplicationDetach)(nil)).Elem(), - "ApplicationDetachReply": reflect.TypeOf((*ApplicationDetachReply)(nil)).Elem(), - "ApplicationTLSCertAdd": reflect.TypeOf((*ApplicationTLSCertAdd)(nil)).Elem(), - "ApplicationTLSCertAddReply": reflect.TypeOf((*ApplicationTLSCertAddReply)(nil)).Elem(), - "ApplicationTLSKeyAdd": reflect.TypeOf((*ApplicationTLSKeyAdd)(nil)).Elem(), - "ApplicationTLSKeyAddReply": reflect.TypeOf((*ApplicationTLSKeyAddReply)(nil)).Elem(), - "BindSock": reflect.TypeOf((*BindSock)(nil)).Elem(), - "BindSockReply": reflect.TypeOf((*BindSockReply)(nil)).Elem(), - "BindURI": reflect.TypeOf((*BindURI)(nil)).Elem(), - "BindURIReply": reflect.TypeOf((*BindURIReply)(nil)).Elem(), - "ConnectSession": reflect.TypeOf((*ConnectSession)(nil)).Elem(), - "ConnectSessionReply": reflect.TypeOf((*ConnectSessionReply)(nil)).Elem(), - "ConnectSock": reflect.TypeOf((*ConnectSock)(nil)).Elem(), - "ConnectSockReply": reflect.TypeOf((*ConnectSockReply)(nil)).Elem(), - "ConnectURI": reflect.TypeOf((*ConnectURI)(nil)).Elem(), - "ConnectURIReply": reflect.TypeOf((*ConnectURIReply)(nil)).Elem(), - "DisconnectSession": reflect.TypeOf((*DisconnectSession)(nil)).Elem(), - "DisconnectSessionReply": reflect.TypeOf((*DisconnectSessionReply)(nil)).Elem(), - "MapAnotherSegment": reflect.TypeOf((*MapAnotherSegment)(nil)).Elem(), - "MapAnotherSegmentReply": reflect.TypeOf((*MapAnotherSegmentReply)(nil)).Elem(), - "ResetSession": reflect.TypeOf((*ResetSession)(nil)).Elem(), - "ResetSessionReply": reflect.TypeOf((*ResetSessionReply)(nil)).Elem(), - "SessionEnableDisable": reflect.TypeOf((*SessionEnableDisable)(nil)).Elem(), - "SessionEnableDisableReply": reflect.TypeOf((*SessionEnableDisableReply)(nil)).Elem(), - "SessionRuleAddDel": reflect.TypeOf((*SessionRuleAddDel)(nil)).Elem(), - "SessionRuleAddDelReply": reflect.TypeOf((*SessionRuleAddDelReply)(nil)).Elem(), - "SessionRulesDetails": reflect.TypeOf((*SessionRulesDetails)(nil)).Elem(), - "SessionRulesDump": reflect.TypeOf((*SessionRulesDump)(nil)).Elem(), - "UnbindSock": reflect.TypeOf((*UnbindSock)(nil)).Elem(), - "UnbindSockReply": reflect.TypeOf((*UnbindSockReply)(nil)).Elem(), - "UnbindURI": reflect.TypeOf((*UnbindURI)(nil)).Elem(), - "UnbindURIReply": reflect.TypeOf((*UnbindURIReply)(nil)).Elem(), - "UnmapSegment": reflect.TypeOf((*UnmapSegment)(nil)).Elem(), - "UnmapSegmentReply": reflect.TypeOf((*UnmapSegmentReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewAcceptSession": reflect.ValueOf(NewAcceptSession), - "NewAcceptSessionReply": reflect.ValueOf(NewAcceptSessionReply), - "NewAppNamespaceAddDel": reflect.ValueOf(NewAppNamespaceAddDel), - "NewAppNamespaceAddDelReply": reflect.ValueOf(NewAppNamespaceAddDelReply), - "NewApplicationAttach": reflect.ValueOf(NewApplicationAttach), - "NewApplicationAttachReply": reflect.ValueOf(NewApplicationAttachReply), - "NewApplicationDetach": reflect.ValueOf(NewApplicationDetach), - "NewApplicationDetachReply": reflect.ValueOf(NewApplicationDetachReply), - "NewApplicationTLSCertAdd": reflect.ValueOf(NewApplicationTLSCertAdd), - "NewApplicationTLSCertAddReply": reflect.ValueOf(NewApplicationTLSCertAddReply), - "NewApplicationTLSKeyAdd": reflect.ValueOf(NewApplicationTLSKeyAdd), - "NewApplicationTLSKeyAddReply": reflect.ValueOf(NewApplicationTLSKeyAddReply), - "NewBindSock": reflect.ValueOf(NewBindSock), - "NewBindSockReply": reflect.ValueOf(NewBindSockReply), - "NewBindURI": reflect.ValueOf(NewBindURI), - "NewBindURIReply": reflect.ValueOf(NewBindURIReply), - "NewConnectSession": reflect.ValueOf(NewConnectSession), - "NewConnectSessionReply": reflect.ValueOf(NewConnectSessionReply), - "NewConnectSock": reflect.ValueOf(NewConnectSock), - "NewConnectSockReply": reflect.ValueOf(NewConnectSockReply), - "NewConnectURI": reflect.ValueOf(NewConnectURI), - "NewConnectURIReply": reflect.ValueOf(NewConnectURIReply), - "NewDisconnectSession": reflect.ValueOf(NewDisconnectSession), - "NewDisconnectSessionReply": reflect.ValueOf(NewDisconnectSessionReply), - "NewMapAnotherSegment": reflect.ValueOf(NewMapAnotherSegment), - "NewMapAnotherSegmentReply": reflect.ValueOf(NewMapAnotherSegmentReply), - "NewResetSession": reflect.ValueOf(NewResetSession), - "NewResetSessionReply": reflect.ValueOf(NewResetSessionReply), - "NewSessionEnableDisable": reflect.ValueOf(NewSessionEnableDisable), - "NewSessionEnableDisableReply": reflect.ValueOf(NewSessionEnableDisableReply), - "NewSessionRuleAddDel": reflect.ValueOf(NewSessionRuleAddDel), - "NewSessionRuleAddDelReply": reflect.ValueOf(NewSessionRuleAddDelReply), - "NewSessionRulesDetails": reflect.ValueOf(NewSessionRulesDetails), - "NewSessionRulesDump": reflect.ValueOf(NewSessionRulesDump), - "NewUnbindSock": reflect.ValueOf(NewUnbindSock), - "NewUnbindSockReply": reflect.ValueOf(NewUnbindSockReply), - "NewUnbindURI": reflect.ValueOf(NewUnbindURI), - "NewUnbindURIReply": reflect.ValueOf(NewUnbindURIReply), - "NewUnmapSegment": reflect.ValueOf(NewUnmapSegment), - "NewUnmapSegmentReply": reflect.ValueOf(NewUnmapSegmentReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/sr/pkgreflect.go b/plugins/defaultplugins/common/bin_api/sr/pkgreflect.go deleted file mode 100644 index 2a8b4bdbcc..0000000000 --- a/plugins/defaultplugins/common/bin_api/sr/pkgreflect.go +++ /dev/null @@ -1,43 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package sr - -import "reflect" - -var Types = map[string]reflect.Type{ - "SrLocalsidAddDel": reflect.TypeOf((*SrLocalsidAddDel)(nil)).Elem(), - "SrLocalsidAddDelReply": reflect.TypeOf((*SrLocalsidAddDelReply)(nil)).Elem(), - "SrLocalsidsDetails": reflect.TypeOf((*SrLocalsidsDetails)(nil)).Elem(), - "SrLocalsidsDump": reflect.TypeOf((*SrLocalsidsDump)(nil)).Elem(), - "SrPolicyAdd": reflect.TypeOf((*SrPolicyAdd)(nil)).Elem(), - "SrPolicyAddReply": reflect.TypeOf((*SrPolicyAddReply)(nil)).Elem(), - "SrPolicyDel": reflect.TypeOf((*SrPolicyDel)(nil)).Elem(), - "SrPolicyDelReply": reflect.TypeOf((*SrPolicyDelReply)(nil)).Elem(), - "SrPolicyMod": reflect.TypeOf((*SrPolicyMod)(nil)).Elem(), - "SrPolicyModReply": reflect.TypeOf((*SrPolicyModReply)(nil)).Elem(), - "SrSetEncapSource": reflect.TypeOf((*SrSetEncapSource)(nil)).Elem(), - "SrSetEncapSourceReply": reflect.TypeOf((*SrSetEncapSourceReply)(nil)).Elem(), - "SrSteeringAddDel": reflect.TypeOf((*SrSteeringAddDel)(nil)).Elem(), - "SrSteeringAddDelReply": reflect.TypeOf((*SrSteeringAddDelReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewSrLocalsidAddDel": reflect.ValueOf(NewSrLocalsidAddDel), - "NewSrLocalsidAddDelReply": reflect.ValueOf(NewSrLocalsidAddDelReply), - "NewSrLocalsidsDetails": reflect.ValueOf(NewSrLocalsidsDetails), - "NewSrLocalsidsDump": reflect.ValueOf(NewSrLocalsidsDump), - "NewSrPolicyAdd": reflect.ValueOf(NewSrPolicyAdd), - "NewSrPolicyAddReply": reflect.ValueOf(NewSrPolicyAddReply), - "NewSrPolicyDel": reflect.ValueOf(NewSrPolicyDel), - "NewSrPolicyDelReply": reflect.ValueOf(NewSrPolicyDelReply), - "NewSrPolicyMod": reflect.ValueOf(NewSrPolicyMod), - "NewSrPolicyModReply": reflect.ValueOf(NewSrPolicyModReply), - "NewSrSetEncapSource": reflect.ValueOf(NewSrSetEncapSource), - "NewSrSetEncapSourceReply": reflect.ValueOf(NewSrSetEncapSourceReply), - "NewSrSteeringAddDel": reflect.ValueOf(NewSrSteeringAddDel), - "NewSrSteeringAddDelReply": reflect.ValueOf(NewSrSteeringAddDelReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/stats/pkgreflect.go b/plugins/defaultplugins/common/bin_api/stats/pkgreflect.go deleted file mode 100644 index a61abc18ef..0000000000 --- a/plugins/defaultplugins/common/bin_api/stats/pkgreflect.go +++ /dev/null @@ -1,103 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package stats - -import "reflect" - -var Types = map[string]reflect.Type{ - "IP4FibCounter": reflect.TypeOf((*IP4FibCounter)(nil)).Elem(), - "IP4MfibCounter": reflect.TypeOf((*IP4MfibCounter)(nil)).Elem(), - "IP4NbrCounter": reflect.TypeOf((*IP4NbrCounter)(nil)).Elem(), - "IP6FibCounter": reflect.TypeOf((*IP6FibCounter)(nil)).Elem(), - "IP6MfibCounter": reflect.TypeOf((*IP6MfibCounter)(nil)).Elem(), - "IP6NbrCounter": reflect.TypeOf((*IP6NbrCounter)(nil)).Elem(), - "StatsGetPollerDelay": reflect.TypeOf((*StatsGetPollerDelay)(nil)).Elem(), - "StatsGetPollerDelayReply": reflect.TypeOf((*StatsGetPollerDelayReply)(nil)).Elem(), - "UDPEncapCounter": reflect.TypeOf((*UDPEncapCounter)(nil)).Elem(), - "VlibCounter": reflect.TypeOf((*VlibCounter)(nil)).Elem(), - "VnetCombinedCounter": reflect.TypeOf((*VnetCombinedCounter)(nil)).Elem(), - "VnetGetSummaryStats": reflect.TypeOf((*VnetGetSummaryStats)(nil)).Elem(), - "VnetGetSummaryStatsReply": reflect.TypeOf((*VnetGetSummaryStatsReply)(nil)).Elem(), - "VnetIP4FibCounters": reflect.TypeOf((*VnetIP4FibCounters)(nil)).Elem(), - "VnetIP4MfibCounters": reflect.TypeOf((*VnetIP4MfibCounters)(nil)).Elem(), - "VnetIP4NbrCounters": reflect.TypeOf((*VnetIP4NbrCounters)(nil)).Elem(), - "VnetIP6FibCounters": reflect.TypeOf((*VnetIP6FibCounters)(nil)).Elem(), - "VnetIP6MfibCounters": reflect.TypeOf((*VnetIP6MfibCounters)(nil)).Elem(), - "VnetIP6NbrCounters": reflect.TypeOf((*VnetIP6NbrCounters)(nil)).Elem(), - "VnetInterfaceCombinedCounters": reflect.TypeOf((*VnetInterfaceCombinedCounters)(nil)).Elem(), - "VnetInterfaceSimpleCounters": reflect.TypeOf((*VnetInterfaceSimpleCounters)(nil)).Elem(), - "VnetPerInterfaceCombinedCounters": reflect.TypeOf((*VnetPerInterfaceCombinedCounters)(nil)).Elem(), - "VnetPerInterfaceSimpleCounters": reflect.TypeOf((*VnetPerInterfaceSimpleCounters)(nil)).Elem(), - "VnetSimpleCounter": reflect.TypeOf((*VnetSimpleCounter)(nil)).Elem(), - "VnetUDPEncapCounters": reflect.TypeOf((*VnetUDPEncapCounters)(nil)).Elem(), - "WantIP4FibStats": reflect.TypeOf((*WantIP4FibStats)(nil)).Elem(), - "WantIP4FibStatsReply": reflect.TypeOf((*WantIP4FibStatsReply)(nil)).Elem(), - "WantIP4MfibStats": reflect.TypeOf((*WantIP4MfibStats)(nil)).Elem(), - "WantIP4MfibStatsReply": reflect.TypeOf((*WantIP4MfibStatsReply)(nil)).Elem(), - "WantIP4NbrStats": reflect.TypeOf((*WantIP4NbrStats)(nil)).Elem(), - "WantIP4NbrStatsReply": reflect.TypeOf((*WantIP4NbrStatsReply)(nil)).Elem(), - "WantIP6FibStats": reflect.TypeOf((*WantIP6FibStats)(nil)).Elem(), - "WantIP6FibStatsReply": reflect.TypeOf((*WantIP6FibStatsReply)(nil)).Elem(), - "WantIP6MfibStats": reflect.TypeOf((*WantIP6MfibStats)(nil)).Elem(), - "WantIP6MfibStatsReply": reflect.TypeOf((*WantIP6MfibStatsReply)(nil)).Elem(), - "WantIP6NbrStats": reflect.TypeOf((*WantIP6NbrStats)(nil)).Elem(), - "WantIP6NbrStatsReply": reflect.TypeOf((*WantIP6NbrStatsReply)(nil)).Elem(), - "WantInterfaceCombinedStats": reflect.TypeOf((*WantInterfaceCombinedStats)(nil)).Elem(), - "WantInterfaceCombinedStatsReply": reflect.TypeOf((*WantInterfaceCombinedStatsReply)(nil)).Elem(), - "WantInterfaceSimpleStats": reflect.TypeOf((*WantInterfaceSimpleStats)(nil)).Elem(), - "WantInterfaceSimpleStatsReply": reflect.TypeOf((*WantInterfaceSimpleStatsReply)(nil)).Elem(), - "WantPerInterfaceCombinedStats": reflect.TypeOf((*WantPerInterfaceCombinedStats)(nil)).Elem(), - "WantPerInterfaceCombinedStatsReply": reflect.TypeOf((*WantPerInterfaceCombinedStatsReply)(nil)).Elem(), - "WantPerInterfaceSimpleStats": reflect.TypeOf((*WantPerInterfaceSimpleStats)(nil)).Elem(), - "WantPerInterfaceSimpleStatsReply": reflect.TypeOf((*WantPerInterfaceSimpleStatsReply)(nil)).Elem(), - "WantStats": reflect.TypeOf((*WantStats)(nil)).Elem(), - "WantStatsReply": reflect.TypeOf((*WantStatsReply)(nil)).Elem(), - "WantUDPEncapStats": reflect.TypeOf((*WantUDPEncapStats)(nil)).Elem(), - "WantUDPEncapStatsReply": reflect.TypeOf((*WantUDPEncapStatsReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewStatsGetPollerDelay": reflect.ValueOf(NewStatsGetPollerDelay), - "NewStatsGetPollerDelayReply": reflect.ValueOf(NewStatsGetPollerDelayReply), - "NewVnetGetSummaryStats": reflect.ValueOf(NewVnetGetSummaryStats), - "NewVnetGetSummaryStatsReply": reflect.ValueOf(NewVnetGetSummaryStatsReply), - "NewVnetIP4FibCounters": reflect.ValueOf(NewVnetIP4FibCounters), - "NewVnetIP4MfibCounters": reflect.ValueOf(NewVnetIP4MfibCounters), - "NewVnetIP4NbrCounters": reflect.ValueOf(NewVnetIP4NbrCounters), - "NewVnetIP6FibCounters": reflect.ValueOf(NewVnetIP6FibCounters), - "NewVnetIP6MfibCounters": reflect.ValueOf(NewVnetIP6MfibCounters), - "NewVnetIP6NbrCounters": reflect.ValueOf(NewVnetIP6NbrCounters), - "NewVnetInterfaceCombinedCounters": reflect.ValueOf(NewVnetInterfaceCombinedCounters), - "NewVnetInterfaceSimpleCounters": reflect.ValueOf(NewVnetInterfaceSimpleCounters), - "NewVnetPerInterfaceCombinedCounters": reflect.ValueOf(NewVnetPerInterfaceCombinedCounters), - "NewVnetPerInterfaceSimpleCounters": reflect.ValueOf(NewVnetPerInterfaceSimpleCounters), - "NewVnetUDPEncapCounters": reflect.ValueOf(NewVnetUDPEncapCounters), - "NewWantIP4FibStats": reflect.ValueOf(NewWantIP4FibStats), - "NewWantIP4FibStatsReply": reflect.ValueOf(NewWantIP4FibStatsReply), - "NewWantIP4MfibStats": reflect.ValueOf(NewWantIP4MfibStats), - "NewWantIP4MfibStatsReply": reflect.ValueOf(NewWantIP4MfibStatsReply), - "NewWantIP4NbrStats": reflect.ValueOf(NewWantIP4NbrStats), - "NewWantIP4NbrStatsReply": reflect.ValueOf(NewWantIP4NbrStatsReply), - "NewWantIP6FibStats": reflect.ValueOf(NewWantIP6FibStats), - "NewWantIP6FibStatsReply": reflect.ValueOf(NewWantIP6FibStatsReply), - "NewWantIP6MfibStats": reflect.ValueOf(NewWantIP6MfibStats), - "NewWantIP6MfibStatsReply": reflect.ValueOf(NewWantIP6MfibStatsReply), - "NewWantIP6NbrStats": reflect.ValueOf(NewWantIP6NbrStats), - "NewWantIP6NbrStatsReply": reflect.ValueOf(NewWantIP6NbrStatsReply), - "NewWantInterfaceCombinedStats": reflect.ValueOf(NewWantInterfaceCombinedStats), - "NewWantInterfaceCombinedStatsReply": reflect.ValueOf(NewWantInterfaceCombinedStatsReply), - "NewWantInterfaceSimpleStats": reflect.ValueOf(NewWantInterfaceSimpleStats), - "NewWantInterfaceSimpleStatsReply": reflect.ValueOf(NewWantInterfaceSimpleStatsReply), - "NewWantPerInterfaceCombinedStats": reflect.ValueOf(NewWantPerInterfaceCombinedStats), - "NewWantPerInterfaceCombinedStatsReply": reflect.ValueOf(NewWantPerInterfaceCombinedStatsReply), - "NewWantPerInterfaceSimpleStats": reflect.ValueOf(NewWantPerInterfaceSimpleStats), - "NewWantPerInterfaceSimpleStatsReply": reflect.ValueOf(NewWantPerInterfaceSimpleStatsReply), - "NewWantStats": reflect.ValueOf(NewWantStats), - "NewWantStatsReply": reflect.ValueOf(NewWantStatsReply), - "NewWantUDPEncapStats": reflect.ValueOf(NewWantUDPEncapStats), - "NewWantUDPEncapStatsReply": reflect.ValueOf(NewWantUDPEncapStatsReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/stn/pkgreflect.go b/plugins/defaultplugins/common/bin_api/stn/pkgreflect.go deleted file mode 100644 index 7e3a4dde62..0000000000 --- a/plugins/defaultplugins/common/bin_api/stn/pkgreflect.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package stn - -import "reflect" - -var Types = map[string]reflect.Type{ - "StnAddDelRule": reflect.TypeOf((*StnAddDelRule)(nil)).Elem(), - "StnAddDelRuleReply": reflect.TypeOf((*StnAddDelRuleReply)(nil)).Elem(), - "StnRulesDetails": reflect.TypeOf((*StnRulesDetails)(nil)).Elem(), - "StnRulesDump": reflect.TypeOf((*StnRulesDump)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewStnAddDelRule": reflect.ValueOf(NewStnAddDelRule), - "NewStnAddDelRuleReply": reflect.ValueOf(NewStnAddDelRuleReply), - "NewStnRulesDetails": reflect.ValueOf(NewStnRulesDetails), - "NewStnRulesDump": reflect.ValueOf(NewStnRulesDump), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/tap/pkgreflect.go b/plugins/defaultplugins/common/bin_api/tap/pkgreflect.go deleted file mode 100644 index d1a74a0524..0000000000 --- a/plugins/defaultplugins/common/bin_api/tap/pkgreflect.go +++ /dev/null @@ -1,31 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package tap - -import "reflect" - -var Types = map[string]reflect.Type{ - "SwInterfaceTapDetails": reflect.TypeOf((*SwInterfaceTapDetails)(nil)).Elem(), - "SwInterfaceTapDump": reflect.TypeOf((*SwInterfaceTapDump)(nil)).Elem(), - "TapConnect": reflect.TypeOf((*TapConnect)(nil)).Elem(), - "TapConnectReply": reflect.TypeOf((*TapConnectReply)(nil)).Elem(), - "TapDelete": reflect.TypeOf((*TapDelete)(nil)).Elem(), - "TapDeleteReply": reflect.TypeOf((*TapDeleteReply)(nil)).Elem(), - "TapModify": reflect.TypeOf((*TapModify)(nil)).Elem(), - "TapModifyReply": reflect.TypeOf((*TapModifyReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewSwInterfaceTapDetails": reflect.ValueOf(NewSwInterfaceTapDetails), - "NewSwInterfaceTapDump": reflect.ValueOf(NewSwInterfaceTapDump), - "NewTapConnect": reflect.ValueOf(NewTapConnect), - "NewTapConnectReply": reflect.ValueOf(NewTapConnectReply), - "NewTapDelete": reflect.ValueOf(NewTapDelete), - "NewTapDeleteReply": reflect.ValueOf(NewTapDeleteReply), - "NewTapModify": reflect.ValueOf(NewTapModify), - "NewTapModifyReply": reflect.ValueOf(NewTapModifyReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/tapv2/pkgreflect.go b/plugins/defaultplugins/common/bin_api/tapv2/pkgreflect.go deleted file mode 100644 index c2a6bce6be..0000000000 --- a/plugins/defaultplugins/common/bin_api/tapv2/pkgreflect.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package tapv2 - -import "reflect" - -var Types = map[string]reflect.Type{ - "SwInterfaceTapV2Details": reflect.TypeOf((*SwInterfaceTapV2Details)(nil)).Elem(), - "SwInterfaceTapV2Dump": reflect.TypeOf((*SwInterfaceTapV2Dump)(nil)).Elem(), - "TapCreateV2": reflect.TypeOf((*TapCreateV2)(nil)).Elem(), - "TapCreateV2Reply": reflect.TypeOf((*TapCreateV2Reply)(nil)).Elem(), - "TapDeleteV2": reflect.TypeOf((*TapDeleteV2)(nil)).Elem(), - "TapDeleteV2Reply": reflect.TypeOf((*TapDeleteV2Reply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewSwInterfaceTapV2Details": reflect.ValueOf(NewSwInterfaceTapV2Details), - "NewSwInterfaceTapV2Dump": reflect.ValueOf(NewSwInterfaceTapV2Dump), - "NewTapCreateV2": reflect.ValueOf(NewTapCreateV2), - "NewTapCreateV2Reply": reflect.ValueOf(NewTapCreateV2Reply), - "NewTapDeleteV2": reflect.ValueOf(NewTapDeleteV2), - "NewTapDeleteV2Reply": reflect.ValueOf(NewTapDeleteV2Reply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/vpe/pkgreflect.go b/plugins/defaultplugins/common/bin_api/vpe/pkgreflect.go deleted file mode 100644 index dde901b3d6..0000000000 --- a/plugins/defaultplugins/common/bin_api/vpe/pkgreflect.go +++ /dev/null @@ -1,47 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package vpe - -import "reflect" - -var Types = map[string]reflect.Type{ - "AddNodeNext": reflect.TypeOf((*AddNodeNext)(nil)).Elem(), - "AddNodeNextReply": reflect.TypeOf((*AddNodeNextReply)(nil)).Elem(), - "Cli": reflect.TypeOf((*Cli)(nil)).Elem(), - "CliInband": reflect.TypeOf((*CliInband)(nil)).Elem(), - "CliInbandReply": reflect.TypeOf((*CliInbandReply)(nil)).Elem(), - "CliReply": reflect.TypeOf((*CliReply)(nil)).Elem(), - "ControlPing": reflect.TypeOf((*ControlPing)(nil)).Elem(), - "ControlPingReply": reflect.TypeOf((*ControlPingReply)(nil)).Elem(), - "GetNextIndex": reflect.TypeOf((*GetNextIndex)(nil)).Elem(), - "GetNextIndexReply": reflect.TypeOf((*GetNextIndexReply)(nil)).Elem(), - "GetNodeGraph": reflect.TypeOf((*GetNodeGraph)(nil)).Elem(), - "GetNodeGraphReply": reflect.TypeOf((*GetNodeGraphReply)(nil)).Elem(), - "GetNodeIndex": reflect.TypeOf((*GetNodeIndex)(nil)).Elem(), - "GetNodeIndexReply": reflect.TypeOf((*GetNodeIndexReply)(nil)).Elem(), - "ShowVersion": reflect.TypeOf((*ShowVersion)(nil)).Elem(), - "ShowVersionReply": reflect.TypeOf((*ShowVersionReply)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewAddNodeNext": reflect.ValueOf(NewAddNodeNext), - "NewAddNodeNextReply": reflect.ValueOf(NewAddNodeNextReply), - "NewCli": reflect.ValueOf(NewCli), - "NewCliInband": reflect.ValueOf(NewCliInband), - "NewCliInbandReply": reflect.ValueOf(NewCliInbandReply), - "NewCliReply": reflect.ValueOf(NewCliReply), - "NewControlPing": reflect.ValueOf(NewControlPing), - "NewControlPingReply": reflect.ValueOf(NewControlPingReply), - "NewGetNextIndex": reflect.ValueOf(NewGetNextIndex), - "NewGetNextIndexReply": reflect.ValueOf(NewGetNextIndexReply), - "NewGetNodeGraph": reflect.ValueOf(NewGetNodeGraph), - "NewGetNodeGraphReply": reflect.ValueOf(NewGetNodeGraphReply), - "NewGetNodeIndex": reflect.ValueOf(NewGetNodeIndex), - "NewGetNodeIndexReply": reflect.ValueOf(NewGetNodeIndexReply), - "NewShowVersion": reflect.ValueOf(NewShowVersion), - "NewShowVersionReply": reflect.ValueOf(NewShowVersionReply), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/bin_api/vxlan/pkgreflect.go b/plugins/defaultplugins/common/bin_api/vxlan/pkgreflect.go deleted file mode 100644 index de4c767c2d..0000000000 --- a/plugins/defaultplugins/common/bin_api/vxlan/pkgreflect.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by github.com/ungerik/pkgreflect DO NOT EDIT. - -package vxlan - -import "reflect" - -var Types = map[string]reflect.Type{ - "SwInterfaceSetVxlanBypass": reflect.TypeOf((*SwInterfaceSetVxlanBypass)(nil)).Elem(), - "SwInterfaceSetVxlanBypassReply": reflect.TypeOf((*SwInterfaceSetVxlanBypassReply)(nil)).Elem(), - "VxlanAddDelTunnel": reflect.TypeOf((*VxlanAddDelTunnel)(nil)).Elem(), - "VxlanAddDelTunnelReply": reflect.TypeOf((*VxlanAddDelTunnelReply)(nil)).Elem(), - "VxlanTunnelDetails": reflect.TypeOf((*VxlanTunnelDetails)(nil)).Elem(), - "VxlanTunnelDump": reflect.TypeOf((*VxlanTunnelDump)(nil)).Elem(), -} - -var Functions = map[string]reflect.Value{ - "NewSwInterfaceSetVxlanBypass": reflect.ValueOf(NewSwInterfaceSetVxlanBypass), - "NewSwInterfaceSetVxlanBypassReply": reflect.ValueOf(NewSwInterfaceSetVxlanBypassReply), - "NewVxlanAddDelTunnel": reflect.ValueOf(NewVxlanAddDelTunnel), - "NewVxlanAddDelTunnelReply": reflect.ValueOf(NewVxlanAddDelTunnelReply), - "NewVxlanTunnelDetails": reflect.ValueOf(NewVxlanTunnelDetails), - "NewVxlanTunnelDump": reflect.ValueOf(NewVxlanTunnelDump), -} - -var Variables = map[string]reflect.Value{} - -var Consts = map[string]reflect.Value{} diff --git a/plugins/defaultplugins/common/model/acl/keys_agent_acl.go b/plugins/defaultplugins/common/model/acl/keys_agent_acl.go deleted file mode 100644 index 5505051f3b..0000000000 --- a/plugins/defaultplugins/common/model/acl/keys_agent_acl.go +++ /dev/null @@ -1,14 +0,0 @@ -package acl - -const aclPrefix = "vpp/config/v1/acl/" - -// KeyPrefix returns the prefix used in ETCD to store vpp ACLs config. -func KeyPrefix() string { - return aclPrefix -} - -// Key returns the prefix used in ETCD to store vpp ACL config -// of a particular ACL in selected vpp instance. -func Key(aclName string) string { - return aclPrefix + aclName -} diff --git a/plugins/defaultplugins/defaultplugins.conf b/plugins/defaultplugins/defaultplugins.conf deleted file mode 100644 index 0941106153..0000000000 --- a/plugins/defaultplugins/defaultplugins.conf +++ /dev/null @@ -1,9 +0,0 @@ -# maximum transmission unit value for an interface, used by interface plugin. This value is preferred before ifplugin -# default value -mtu: 1478 -# turn on/off stopwatch measuring binary API duration during resync -stopwatch: true -# choose VPP resync stratedy from 'full' or 'optimize' -strategy: full -# select status publishers (etcd, redis) -status-publishers: [redis] \ No newline at end of file diff --git a/plugins/defaultplugins/doc.go b/plugins/defaultplugins/doc.go deleted file mode 100644 index fc61d5e311..0000000000 --- a/plugins/defaultplugins/doc.go +++ /dev/null @@ -1,3 +0,0 @@ -// Package defaultplugins is the parent package for all "default" VPP-related -// plugins. -package defaultplugins diff --git a/plugins/defaultplugins/ifplugin/vppcalls/vpp_channel.go b/plugins/defaultplugins/ifplugin/vppcalls/vpp_channel.go deleted file mode 100644 index 4f766b8fd7..0000000000 --- a/plugins/defaultplugins/ifplugin/vppcalls/vpp_channel.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2017 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vppcalls - -import ( - govppapi "git.fd.io/govpp.git/api" -) - -// VPPChannel is interface for send request to VPP channel -type VPPChannel interface { - SendRequest(msg govppapi.Message) *govppapi.RequestCtx - - SendMultiRequest(msg govppapi.Message) *govppapi.MultiRequestCtx - - CheckMessageCompatibility(messages ...govppapi.Message) error - - SubscribeNotification(notifChan chan govppapi.Message, msgFactory func() govppapi.Message) (*govppapi.NotifSubscription, error) - - UnsubscribeNotification(subscription *govppapi.NotifSubscription) error -} - -func boolToUint(value bool) uint8 { - if value { - return 1 - } - return 0 -} diff --git a/plugins/defaultplugins/ipsecplugin/data_resync.go b/plugins/defaultplugins/ipsecplugin/data_resync.go deleted file mode 100644 index b780a8cc59..0000000000 --- a/plugins/defaultplugins/ipsecplugin/data_resync.go +++ /dev/null @@ -1,40 +0,0 @@ -package ipsecplugin - -import "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - -// Resync writes missing IPSec configs to the VPP and removes obsolete ones. -func (plugin *IPSecConfigurator) Resync(spds []*ipsec.SecurityPolicyDatabases_SPD, sas []*ipsec.SecurityAssociations_SA, tunnels []*ipsec.TunnelInterfaces_Tunnel) error { - plugin.Log.Debug("RESYNC IPSec begin.") - - defer func() { - if plugin.Stopwatch != nil { - plugin.Stopwatch.PrintLog() - } - }() - - // TODO: dump existing configuration from VPP - - for _, sa := range sas { - if err := plugin.ConfigureSA(sa); err != nil { - plugin.Log.Error(err) - continue - } - } - - for _, spd := range spds { - if err := plugin.ConfigureSPD(spd); err != nil { - plugin.Log.Error(err) - continue - } - } - - for _, tunnel := range tunnels { - if err := plugin.ConfigureTunnel(tunnel); err != nil { - plugin.Log.Error(err) - continue - } - } - - plugin.Log.Debug("RESYNC IPSec end.") - return nil -} diff --git a/plugins/defaultplugins/ipsecplugin/ipsec_config.go b/plugins/defaultplugins/ipsecplugin/ipsec_config.go deleted file mode 100644 index 930f3e02c7..0000000000 --- a/plugins/defaultplugins/ipsecplugin/ipsec_config.go +++ /dev/null @@ -1,408 +0,0 @@ -// Copyright (c) 2017 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:generate protoc --proto_path=../common/model/ipsec --gogo_out=../common/model/ipsec ../common/model/ipsec/ipsec.proto - -//go:generate binapi-generator --input-file=/usr/share/vpp/api/ipsec.api.json --output-dir=../common/bin_api - -// Package ipsecplugin implements the IPSec plugin that handles management of IPSec for VPP. -package ipsecplugin - -import ( - govppapi "git.fd.io/govpp.git/api" - "github.com/ligato/cn-infra/logging" - "github.com/ligato/cn-infra/logging/measure" - "github.com/ligato/cn-infra/utils/addrs" - "github.com/ligato/cn-infra/utils/safeclose" - "github.com/ligato/vpp-agent/idxvpp" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/model/ipsec" - "github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/ifaceidx" - iface_vppcalls "github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/vppcalls" - "github.com/ligato/vpp-agent/plugins/defaultplugins/ipsecplugin/ipsecidx" - vppcalls "github.com/ligato/vpp-agent/plugins/defaultplugins/ipsecplugin/vppcalls" - "github.com/ligato/vpp-agent/plugins/govppmux" -) - -// SPDIfCacheEntry contains info about cached assignment of interface to SPD -type SPDIfCacheEntry struct { - spdID uint32 - ifaceName string -} - -// IPSecConfigurator 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/ipsec/ipsec.proto" -// and stored in ETCD under the key "/vnf-agent/{vnf-agent}/vpp/config/v1/ipsec". -// Updates received from the northbound API are compared with the VPP run-time configuration and differences -// are applied through the VPP binary API. -type IPSecConfigurator struct { - Log logging.Logger - Stopwatch *measure.Stopwatch // timer used to measure and store time - - GoVppmux govppmux.API - vppCh *govppapi.Channel - - SwIfIndexes ifaceidx.SwIfIndexRW - - SaIndexSeq uint32 - SaIndexes idxvpp.NameToIdxRW - SpdIndexSeq uint32 - SpdIndexes ipsecidx.SPDIndexRW - CachedSpdIndexes ipsecidx.SPDIndexRW - - SPDIfCache []SPDIfCacheEntry -} - -// Init members (channels...) and start go routines -func (plugin *IPSecConfigurator) Init() (err error) { - plugin.Log.Debug("Initializing IPSec configurator") - - plugin.vppCh, err = plugin.GoVppmux.NewAPIChannel() - if err != nil { - return err - } - if err := vppcalls.CheckMsgCompatibilityForIPSec(plugin.vppCh); err != nil { - return err - } - - return nil -} - -// Close GOVPP channel -func (plugin *IPSecConfigurator) Close() error { - return safeclose.Close(plugin.vppCh) -} - -// ConfigureSPD configures Security Policy Database in VPP -func (plugin *IPSecConfigurator) ConfigureSPD(spd *ipsec.SecurityPolicyDatabases_SPD) error { - plugin.Log.Debugf("Configuring SPD %v", spd.Name) - - spdID := plugin.SpdIndexSeq - plugin.SpdIndexSeq++ - - for _, entry := range spd.PolicyEntries { - if entry.Sa != "" { - if _, _, exists := plugin.SaIndexes.LookupIdx(entry.Sa); !exists { - plugin.Log.Warnf("SA %q for SPD %q not found, caching SPD configuration", entry.Sa, spd.Name) - plugin.CachedSpdIndexes.RegisterName(spd.Name, spdID, spd) - return nil - } - } - } - - return plugin.configureSPD(spdID, spd) -} - -func (plugin *IPSecConfigurator) configureSPD(spdID uint32, spd *ipsec.SecurityPolicyDatabases_SPD) error { - plugin.Log.Debugf("configuring SPD %v (%d)", spd.Name, spdID) - - if err := vppcalls.AddSPD(spdID, plugin.vppCh, plugin.Stopwatch); err != nil { - return err - } - - plugin.SpdIndexes.RegisterName(spd.Name, spdID, spd) - plugin.Log.Infof("Registered SPD %v (%d)", spd.Name, spdID) - - for _, iface := range spd.Interfaces { - plugin.Log.Debugf("Assigning SPD to interface %v", iface) - - swIfIdx, _, exists := plugin.SwIfIndexes.LookupIdx(iface.Name) - if !exists { - plugin.Log.Infof("Interface %q for SPD %q not found, caching assignment of interface to SPD", iface.Name, spd.Name) - plugin.cacheSPDInterfaceAssignment(spdID, iface.Name) - continue - } - - if err := vppcalls.InterfaceAddSPD(spdID, swIfIdx, plugin.vppCh, plugin.Stopwatch); err != nil { - plugin.Log.Errorf("assigning interface to SPD failed: %v", err) - continue - } - - plugin.Log.Infof("Assigned SPD %q to interface %q", spd.Name, iface.Name) - } - - for _, entry := range spd.PolicyEntries { - plugin.Log.Infof("Adding SPD policy entry %v", entry) - - var saID uint32 - if entry.Sa != "" { - var exists bool - if saID, _, exists = plugin.SaIndexes.LookupIdx(entry.Sa); !exists { - plugin.Log.Warnf("SA %q for SPD %q not found, skipping SPD policy entry configuration", entry.Sa, spd.Name) - continue - } - } - - if err := vppcalls.AddSPDEntry(spdID, saID, entry, plugin.vppCh, plugin.Stopwatch); err != nil { - plugin.Log.Errorf("adding SPD policy entry failed: %v", err) - continue - } - - plugin.Log.Infof("Added SPD policy entry") - } - - plugin.Log.Infof("Configured SPD %v", spd.Name) - - return nil -} - -// ModifySPD modifies Security Policy Database in VPP -func (plugin *IPSecConfigurator) ModifySPD(oldSpd *ipsec.SecurityPolicyDatabases_SPD, newSpd *ipsec.SecurityPolicyDatabases_SPD) error { - plugin.Log.Debugf("Modifying SPD %v", oldSpd.Name) - - if err := plugin.DeleteSPD(oldSpd); err != nil { - plugin.Log.Error("deleting old SPD failed:", err) - return err - } - if err := plugin.ConfigureSPD(newSpd); err != nil { - plugin.Log.Error("configuring new SPD failed:", err) - return err - } - - return nil -} - -// DeleteSPD deletes Security Policy Database in VPP -func (plugin *IPSecConfigurator) DeleteSPD(oldSpd *ipsec.SecurityPolicyDatabases_SPD) error { - plugin.Log.Debugf("Deleting SPD %v", oldSpd.Name) - - if spdID, _, found := plugin.CachedSpdIndexes.LookupIdx(oldSpd.Name); found { - plugin.Log.Debugf("removing cached SPD %v", spdID) - plugin.CachedSpdIndexes.UnregisterName(oldSpd.Name) - return nil - } - - spdID, _, exists := plugin.SpdIndexes.LookupIdx(oldSpd.Name) - if !exists { - plugin.Log.Warnf("SPD %q not found", oldSpd.Name) - return nil - } - if err := vppcalls.DelSPD(spdID, plugin.vppCh, plugin.Stopwatch); err != nil { - return err - } - - // remove cache entries related to the SPD - for i, entry := range plugin.SPDIfCache { - if entry.spdID == spdID { - plugin.Log.Debugf("Removing cache entry for assignment of SPD %q to interface %q", entry.spdID, entry.ifaceName) - plugin.SPDIfCache = append(plugin.SPDIfCache[:i], plugin.SPDIfCache[i+1:]...) - } - } - - plugin.SpdIndexes.UnregisterName(oldSpd.Name) - plugin.Log.Infof("Deleted SPD %v", oldSpd.Name) - - return nil -} - -// ConfigureSA configures Security Association in VPP -func (plugin *IPSecConfigurator) ConfigureSA(sa *ipsec.SecurityAssociations_SA) error { - plugin.Log.Debugf("Configuring SA %v", sa.Name) - - saID := plugin.SaIndexSeq - plugin.SaIndexSeq++ - - if err := vppcalls.AddSAEntry(saID, sa, plugin.vppCh, plugin.Stopwatch); err != nil { - return err - } - - plugin.SaIndexes.RegisterName(sa.Name, saID, nil) - plugin.Log.Infof("Registered SA %v (%d)", sa.Name, saID) - - for _, cached := range plugin.CachedSpdIndexes.LookupBySA(sa.Name) { - for _, entry := range cached.SPD.PolicyEntries { - if entry.Sa != "" { - if _, _, exists := plugin.SaIndexes.LookupIdx(entry.Sa); !exists { - plugin.Log.Warnf("SA %q for SPD %q not found, keeping SPD in cache", entry.Sa, cached.SPD.Name) - return nil - } - } - } - if err := plugin.configureSPD(cached.SpdID, cached.SPD); err != nil { - plugin.Log.Errorf("configuring cached SPD failed: %v", err) - } else { - plugin.CachedSpdIndexes.UnregisterName(cached.SPD.Name) - } - } - - return nil -} - -// ModifySA modifies Security Association in VPP -func (plugin *IPSecConfigurator) ModifySA(oldSa *ipsec.SecurityAssociations_SA, newSa *ipsec.SecurityAssociations_SA) error { - plugin.Log.Debugf("Modifying SA %v", oldSa.Name) - - // TODO: check if only keys change and use IpsecSaSetKey vpp call - - if err := plugin.DeleteSA(oldSa); err != nil { - plugin.Log.Error("deleting old SPD failed:", err) - return err - } - if err := plugin.ConfigureSA(newSa); err != nil { - plugin.Log.Error("configuring new SPD failed:", err) - return err - } - - return nil -} - -// DeleteSA deletes Security Association in VPP -func (plugin *IPSecConfigurator) DeleteSA(oldSa *ipsec.SecurityAssociations_SA) error { - plugin.Log.Debugf("Deleting SA %v", oldSa.Name) - - saID, _, exists := plugin.SaIndexes.LookupIdx(oldSa.Name) - if !exists { - plugin.Log.Warnf("SA %q not found", oldSa.Name) - return nil - } - - for _, entry := range plugin.SpdIndexes.LookupBySA(oldSa.Name) { - if err := plugin.DeleteSPD(entry.SPD); err != nil { - plugin.Log.Errorf("deleting SPD to be cached failed: %v", err) - continue - } - plugin.CachedSpdIndexes.RegisterName(entry.SPD.Name, entry.SpdID, entry.SPD) - plugin.Log.Warnf("caching SPD %v due removed SA %v", entry.SPD.Name, oldSa.Name) - } - - if err := vppcalls.DelSAEntry(saID, oldSa, plugin.vppCh, plugin.Stopwatch); err != nil { - return err - } - - plugin.SaIndexes.UnregisterName(oldSa.Name) - plugin.Log.Infof("Deleted SA %v", oldSa.Name) - - return nil -} - -// ConfigureTunnel configures Tunnel interface in VPP -func (plugin *IPSecConfigurator) ConfigureTunnel(tunnel *ipsec.TunnelInterfaces_Tunnel) error { - plugin.Log.Debugf("Configuring Tunnel %v", tunnel.Name) - - ifIdx, err := vppcalls.AddTunnelInterface(tunnel, plugin.vppCh, plugin.Stopwatch) - if err != nil { - return err - } - - plugin.SwIfIndexes.RegisterName(tunnel.Name, ifIdx, nil) - plugin.Log.Infof("Registered Tunnel %v (%d)", tunnel.Name, ifIdx) - - if err := iface_vppcalls.SetInterfaceVRF(ifIdx, tunnel.Vrf, plugin.Log, plugin.vppCh); err != nil { - return err - } - - ipAddrs, err := addrs.StrAddrsToStruct(tunnel.IpAddresses) - if err != nil { - return err - } - for _, ip := range ipAddrs { - if err := iface_vppcalls.AddInterfaceIP(ifIdx, ip, plugin.vppCh, plugin.Stopwatch); err != nil { - plugin.Log.Errorf("adding interface IP address failed: %v", err) - return err - } - } - - if tunnel.Enabled { - if err := iface_vppcalls.InterfaceAdminUp(ifIdx, plugin.vppCh, plugin.Stopwatch); err != nil { - plugin.Log.Debugf("setting interface up failed: %v", err) - return err - } - } - - return nil -} - -// ModifyTunnel modifies Tunnel interface in VPP -func (plugin *IPSecConfigurator) ModifyTunnel(oldTunnel *ipsec.TunnelInterfaces_Tunnel, newTunnel *ipsec.TunnelInterfaces_Tunnel) error { - plugin.Log.Debugf("Modifying Tunnel %v", oldTunnel.Name) - - if err := plugin.DeleteTunnel(oldTunnel); err != nil { - plugin.Log.Error("deleting old Tunnel failed:", err) - return err - } - if err := plugin.ConfigureTunnel(newTunnel); err != nil { - plugin.Log.Error("configuring new Tunnel failed:", err) - return err - } - - return nil -} - -// DeleteTunnel deletes Tunnel interface in VPP -func (plugin *IPSecConfigurator) DeleteTunnel(oldTunnel *ipsec.TunnelInterfaces_Tunnel) error { - plugin.Log.Debugf("Deleting Tunnel %v", oldTunnel.Name) - - ifIdx, _, exists := plugin.SwIfIndexes.LookupIdx(oldTunnel.Name) - if !exists { - plugin.Log.Warnf("Tunnel %q not found", oldTunnel.Name) - return nil - } - - if err := vppcalls.DelTunnelInterface(ifIdx, oldTunnel, plugin.vppCh, plugin.Stopwatch); err != nil { - return err - } - - plugin.SwIfIndexes.UnregisterName(oldTunnel.Name) - plugin.Log.Infof("Deleted Tunnel %v", oldTunnel.Name) - - return nil -} - -// ResolveCreatedInterface is responsible for reconfiguring cached assignments -func (plugin *IPSecConfigurator) ResolveCreatedInterface(ifName string, swIfIdx uint32) { - for i, entry := range plugin.SPDIfCache { - if entry.ifaceName == ifName { - plugin.Log.Infof("Assigning SPD %v to interface %q", entry.spdID, ifName) - - // TODO: loop through stored deletes, this is now needed because old assignment might still exist - if err := vppcalls.InterfaceDelSPD(entry.spdID, swIfIdx, plugin.vppCh, plugin.Stopwatch); err != nil { - plugin.Log.Errorf("unassigning interface from SPD failed: %v", err) - } else { - plugin.Log.Infof("Unassigned SPD %v from interface %q", entry.spdID, ifName) - } - - if err := vppcalls.InterfaceAddSPD(entry.spdID, swIfIdx, plugin.vppCh, plugin.Stopwatch); err != nil { - plugin.Log.Errorf("assigning interface to SPD failed: %v", err) - continue - } else { - plugin.Log.Infof("Assigned SPD %v to interface %q", entry.spdID, entry.ifaceName) - } - - plugin.SPDIfCache = append(plugin.SPDIfCache[:i], plugin.SPDIfCache[i+1:]...) - } - } -} - -// ResolveDeletedInterface is responsible for caching assignments for future reconfiguration -func (plugin *IPSecConfigurator) ResolveDeletedInterface(ifName string, swIfIdx uint32) { - for _, assign := range plugin.SpdIndexes.LookupByInterface(ifName) { - plugin.Log.Infof("Unassigning SPD %v from interface %q", assign.SpdID, ifName) - - // TODO: just store this for future, because this will fail since swIfIdx no longer exists - if err := vppcalls.InterfaceDelSPD(assign.SpdID, swIfIdx, plugin.vppCh, plugin.Stopwatch); err != nil { - plugin.Log.Errorf("unassigning interface from SPD failed: %v", err) - } else { - plugin.Log.Infof("Unassigned SPD %v from interface %q", assign.SpdID, ifName) - } - - plugin.cacheSPDInterfaceAssignment(assign.SpdID, ifName) - } -} - -func (plugin *IPSecConfigurator) cacheSPDInterfaceAssignment(spdID uint32, ifaceName string) { - plugin.Log.Debugf("caching SPD %v interface assignment to %v", spdID, ifaceName) - plugin.SPDIfCache = append(plugin.SPDIfCache, SPDIfCacheEntry{ - ifaceName: ifaceName, - spdID: spdID, - }) -} diff --git a/plugins/defaultplugins/l2plugin/vppcalls/vpp_channel.go b/plugins/defaultplugins/l2plugin/vppcalls/vpp_channel.go deleted file mode 100644 index d7ba0c53b4..0000000000 --- a/plugins/defaultplugins/l2plugin/vppcalls/vpp_channel.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2017 Cisco and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vppcalls - -import ( - govppapi "git.fd.io/govpp.git/api" -) - -// VPPChannel is interface for send request to VPP channel -type VPPChannel interface { - SendRequest(msg govppapi.Message) *govppapi.RequestCtx - - SendMultiRequest(msg govppapi.Message) *govppapi.MultiRequestCtx - - CheckMessageCompatibility(messages ...govppapi.Message) error -} - -// TODO: maybe add other function of VPP channel. - -func boolToUint(value bool) uint8 { - if value { - return 1 - } - return 0 -} diff --git a/plugins/defaultplugins/srplugin/vppcalls/vpp_channel.go b/plugins/defaultplugins/srplugin/vppcalls/vpp_channel.go deleted file mode 100644 index 2eb1c2e528..0000000000 --- a/plugins/defaultplugins/srplugin/vppcalls/vpp_channel.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2018 Bell Canada, Pantheon Technologies and/or its affiliates. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package vppcalls - -import ( - govppapi "git.fd.io/govpp.git/api" -) - -// VPPChannel is interface for send request to VPP channel -type VPPChannel interface { - SendRequest(msg govppapi.Message) *govppapi.RequestCtx - - SendMultiRequest(msg govppapi.Message) *govppapi.MultiRequestCtx - - CheckMessageCompatibility(messages ...govppapi.Message) error - - SubscribeNotification(notifChan chan govppapi.Message, msgFactory func() govppapi.Message) (*govppapi.NotifSubscription, error) - - UnsubscribeNotification(subscription *govppapi.NotifSubscription) error -} diff --git a/plugins/govppmux/README.md b/plugins/govppmux/README.md index b38f718d68..cdf3e9bc71 100644 --- a/plugins/govppmux/README.md +++ b/plugins/govppmux/README.md @@ -8,9 +8,9 @@ to get its own, potentially customized, communication channel to running VPP ins Behind the scenes, all channels share the same connection created during the plugin initialization using govpp core. -**API** +## API -*Connection* +### Connection By default, GoVPP connects to that instance of VPP which uses the default shared memory segment prefix. This is because it is assumed that there is only a single VPP running in a sand-boxed environment @@ -19,7 +19,7 @@ or there are several VPP instances running, GoVPP needs to know the prefix in or correct VPP instance - the prefix has to be put in the govppmux configuration file (govpp.conf) with key `shm-prefix` and value matching VPP shared memory prefix. -*Multiplexing* +### Multiplexing `NewAPIChannel` returns a new API channel for communication with VPP via govpp core. It uses default buffer sizes for the request and reply Go channels (by default both are 100 messages long). @@ -32,7 +32,7 @@ is also used to carry VPP notifications and statistics which may temporarily rap and frequency. By increasing the reply channel size, the probability of dropping messages from VPP decreases at the cost of increased memory footprint. -**Example** +### Example The following example shows how to dump VPP interfaces using a multi-response request: ``` @@ -65,7 +65,7 @@ for { ``` -**Configuration** +## Configuration The plugin allows to configure parameters of vpp health-check probe. The items that can be configured are: @@ -78,14 +78,4 @@ until an error is reported elapses, the request fails - *shm-prefix* - used for connection to a VPP instance which is not using default shared memory prefix - - -Example govpp.conf: - -``` -health-check-probe-interval: 1000000000 -health-check-reply-timeout: 100000000 -health-check-threshold: 1 -reply-timeout: 1000000000 -shm-prefix: vpp1 -``` +- *resync-after-reconnect* - allows to run resync after recoonection diff --git a/plugins/govppmux/govpp.conf b/plugins/govppmux/govpp.conf index be5b3a7bbc..8692ee3502 100644 --- a/plugins/govppmux/govpp.conf +++ b/plugins/govppmux/govpp.conf @@ -1,2 +1,6 @@ # set custom shared memory prefix for VPP shm-prefix: vpp + +# If VPP lost connection, this flag allows to automatically run the whole resync procedure +# for all registered plugins after reconnection +resync-after-reconnect: false diff --git a/plugins/govppmux/plugin_api_govppmux.go b/plugins/govppmux/plugin_api_govppmux.go index 41dd0ecd77..a9878d6891 100644 --- a/plugins/govppmux/plugin_api_govppmux.go +++ b/plugins/govppmux/plugin_api_govppmux.go @@ -15,7 +15,7 @@ package govppmux import ( - "git.fd.io/govpp.git/api" + govppapi "git.fd.io/govpp.git/api" ) // API for other plugins to get connectivity to VPP. @@ -26,7 +26,7 @@ type API interface { // Example of binary API call from some plugin using GOVPP: // ch, _ := govpp_mux.NewAPIChannel() // ch.SendRequest(req).ReceiveReply - NewAPIChannel() (*api.Channel, error) + NewAPIChannel() (govppapi.Channel, error) // NewAPIChannelBuffered returns a new API channel for communication with VPP via govpp core. // It allows to specify custom buffer sizes for the request and reply Go channels. @@ -34,5 +34,5 @@ type API interface { // Example of binary API call from some plugin using GOVPP: // ch, _ := govpp_mux.NewAPIChannelBuffered(100, 100) // ch.SendRequest(req).ReceiveReply - NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (*api.Channel, error) + NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (govppapi.Channel, error) } diff --git a/plugins/govppmux/plugin_impl_govppmux.go b/plugins/govppmux/plugin_impl_govppmux.go index d420472c53..ce8518023b 100644 --- a/plugins/govppmux/plugin_impl_govppmux.go +++ b/plugins/govppmux/plugin_impl_govppmux.go @@ -21,10 +21,11 @@ import ( "time" "git.fd.io/govpp.git/adapter" - "git.fd.io/govpp.git/api" - govpp "git.fd.io/govpp.git/core" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/vpe" + govppapi "git.fd.io/govpp.git/api" + "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpe" + govpp "git.fd.io/govpp.git/core" + "github.com/ligato/cn-infra/datasync/resync" "github.com/ligato/cn-infra/flavors/local" "github.com/ligato/cn-infra/health/statuscheck" "github.com/ligato/cn-infra/logging" @@ -44,7 +45,9 @@ type GOVPPPlugin struct { vppAdapter adapter.VppAdapter vppConChan chan govpp.ConnectionEvent - replyTimeout time.Duration + replyTimeout time.Duration + reconnectResync bool + lastConnErr error // Cancel can be used to cancel all goroutines and their jobs inside of the plugin. cancel context.CancelFunc @@ -56,6 +59,7 @@ type GOVPPPlugin struct { // so that they do not mix with other plugin fields. type Deps struct { local.PluginInfraDeps // inject + Resync *resync.Plugin } // Config groups the configurable parameter of GoVpp. @@ -66,7 +70,8 @@ type Config struct { ReplyTimeout time.Duration `json:"reply-timeout"` // The prefix prepended to the name used for shared memory (SHM) segments. If not set, // shared memory segments are created directly in the SHM directory /dev/shm. - ShmPrefix string `json:"shm-prefix"` + ShmPrefix string `json:"shm-prefix"` + ReconnectResync bool `json:"resync-after-reconnect"` } func defaultConfig() Config { @@ -109,6 +114,7 @@ func (plugin *GOVPPPlugin) Init() error { govpp.SetHealthCheckReplyTimeout(cfg.HealthCheckReplyTimeout) govpp.SetHealthCheckThreshold(cfg.HealthCheckThreshold) plugin.replyTimeout = cfg.ReplyTimeout + plugin.reconnectResync = cfg.ReconnectResync shmPrefix = cfg.ShmPrefix plugin.Log.Debug("Setting govpp parameters", cfg) } @@ -167,7 +173,7 @@ func (plugin *GOVPPPlugin) Close() error { // Example of binary API call from some plugin using GOVPP: // ch, _ := govpp_mux.NewAPIChannel() // ch.SendRequest(req).ReceiveReply -func (plugin *GOVPPPlugin) NewAPIChannel() (*api.Channel, error) { +func (plugin *GOVPPPlugin) NewAPIChannel() (govppapi.Channel, error) { ch, err := plugin.vppConn.NewAPIChannel() if err != nil { return nil, err @@ -184,7 +190,7 @@ func (plugin *GOVPPPlugin) NewAPIChannel() (*api.Channel, error) { // Example of binary API call from some plugin using GOVPP: // ch, _ := govpp_mux.NewAPIChannelBuffered(100, 100) // ch.SendRequest(req).ReceiveReply -func (plugin *GOVPPPlugin) NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (*api.Channel, error) { +func (plugin *GOVPPPlugin) NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize int) (govppapi.Channel, error) { ch, err := plugin.vppConn.NewAPIChannelBuffered(reqChanBufSize, replyChanBufSize) if err != nil { return nil, err @@ -200,16 +206,24 @@ func (plugin *GOVPPPlugin) handleVPPConnectionEvents(ctx context.Context) { plugin.wg.Add(1) defer plugin.wg.Done() - // TODO: support for VPP reconnect - for { select { case status := <-plugin.vppConChan: if status.State == govpp.Connected { plugin.retrieveVersion() + if plugin.reconnectResync && plugin.lastConnErr != nil { + plugin.Log.Info("Starting resync after VPP reconnect") + if plugin.Resync != nil { + plugin.Resync.DoResync() + plugin.lastConnErr = nil + } else { + plugin.Log.Warn("Expected resync after VPP reconnect could not start because of missing Resync plugin") + } + } plugin.StatusCheck.ReportStateChange(plugin.PluginName, statuscheck.OK, nil) } else { - plugin.StatusCheck.ReportStateChange(plugin.PluginName, statuscheck.Error, errors.New("VPP disconnected")) + plugin.lastConnErr = errors.New("VPP disconnected") + plugin.StatusCheck.ReportStateChange(plugin.PluginName, statuscheck.Error, plugin.lastConnErr) } case <-ctx.Done(): diff --git a/plugins/govppmux/vppcalls/vpe_vppcalls.go b/plugins/govppmux/vppcalls/vpe_vppcalls.go index e642ee3e30..3c142576f0 100644 --- a/plugins/govppmux/vppcalls/vpe_vppcalls.go +++ b/plugins/govppmux/vppcalls/vpe_vppcalls.go @@ -22,7 +22,7 @@ import ( "strings" govppapi "git.fd.io/govpp.git/api" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/vpe" + "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpe" ) // VersionInfo contains values returned from ShowVersion @@ -34,7 +34,7 @@ type VersionInfo struct { } // GetVersionInfo retrieves version info -func GetVersionInfo(vppChan VPPChannel) (*VersionInfo, error) { +func GetVersionInfo(vppChan govppapi.Channel) (*VersionInfo, error) { req := &vpe.ShowVersion{} reply := &vpe.ShowVersionReply{} @@ -55,7 +55,7 @@ func GetVersionInfo(vppChan VPPChannel) (*VersionInfo, error) { } // RunCliCommand executes CLI command and returns output -func RunCliCommand(vppChan VPPChannel, cmd string) ([]byte, error) { +func RunCliCommand(vppChan govppapi.Channel, cmd string) ([]byte, error) { req := &vpe.CliInband{ Cmd: []byte(cmd), Length: uint32(len(cmd)), @@ -91,11 +91,11 @@ type MemoryThread struct { var ( // Regular expression to parse output from `show memory` - memoryRe = regexp.MustCompile(`Thread\s+(\d+)\s+(\w+).?\s+(\d+) objects, ([\dkm\.]+) of ([\dkm\.]+) used, ([\dkm\.]+) free, ([\dkm\.]+) reclaimed, ([\dkm\.]+) overhead, ([\dkm\.]+) capacity`) + memoryRe = regexp.MustCompile(`Thread\s+(\d+)\s+(\w+).?\s+(\d+) objects, ([\dkmg\.]+) of ([\dkmg\.]+) used, ([\dkmg\.]+) free, ([\dkmg\.]+) reclaimed, ([\dkmg\.]+) overhead, ([\dkmg\.]+) capacity`) ) // GetNodeCounters retrieves node counters info -func GetMemory(vppChan VPPChannel) (*MemoryInfo, error) { +func GetMemory(vppChan govppapi.Channel) (*MemoryInfo, error) { data, err := RunCliCommand(vppChan, "show memory") if err != nil { return nil, err @@ -148,12 +148,11 @@ type NodeCounter struct { var ( // Regular expression to parse output from `show node counters` - nodeCountersRe = regexp.MustCompile( - `^\s+(\d+)\s+([\w-]+)\s+([\w- ]+)$`) + nodeCountersRe = regexp.MustCompile(`^\s+(\d+)\s+([\w-\/]+)\s+([\w- ]+)$`) ) // GetNodeCounters retrieves node counters info -func GetNodeCounters(vppChan VPPChannel) (*NodeCounterInfo, error) { +func GetNodeCounters(vppChan govppapi.Channel) (*NodeCounterInfo, error) { data, err := RunCliCommand(vppChan, "show node counters") if err != nil { return nil, err @@ -240,7 +239,7 @@ var ( ) // GetNodeCounters retrieves node counters info -func GetRuntimeInfo(vppChan VPPChannel) (*RuntimeInfo, error) { +func GetRuntimeInfo(vppChan govppapi.Channel) (*RuntimeInfo, error) { data, err := RunCliCommand(vppChan, "show runtime") if err != nil { return nil, err @@ -314,11 +313,11 @@ type BuffersItem struct { var ( // Regular expression to parse output from `show buffers` - buffersRe = regexp.MustCompile(`^\s+(\d+)\s+(\w+(?:[ \-]\w+)*)\s+(\d+)\s+(\d+)\s+([\dkm\.]+)\s+([\dkm\.]+)\s+(\d+)\s+(\d+).*$`) + buffersRe = regexp.MustCompile(`^\s+(\d+)\s+(\w+(?:[ \-]\w+)*)\s+(\d+)\s+(\d+)\s+([\dkmg\.]+)\s+([\dkmg\.]+)\s+(\d+)\s+(\d+).*$`) ) // GetBuffersInfo retrieves buffers info -func GetBuffersInfo(vppChan VPPChannel) (*BuffersInfo, error) { +func GetBuffersInfo(vppChan govppapi.Channel) (*BuffersInfo, error) { data, err := RunCliCommand(vppChan, "show buffers") if err != nil { return nil, err @@ -371,6 +370,7 @@ func strToFloat64(s string) float64 { // Replace 'k' (thousands) with 'e3' to make it parsable with strconv s = strings.Replace(s, "k", "e3", 1) s = strings.Replace(s, "m", "e6", 1) + s = strings.Replace(s, "g", "e9", 1) num, err := strconv.ParseFloat(s, 10) if err != nil { @@ -386,8 +386,3 @@ func strToUint64(s string) uint64 { func cleanBytes(b []byte) []byte { return bytes.SplitN(b, []byte{0x00}, 2)[0] } - -// VPPChannel is interface for send request to VPP channel -type VPPChannel interface { - SendRequest(msg govppapi.Message) *govppapi.RequestCtx -} diff --git a/plugins/govppmux/vppcalls/vpe_vppcalls_test.go b/plugins/govppmux/vppcalls/vpe_vppcalls_test.go index 8be510dbbb..fae483b9bc 100644 --- a/plugins/govppmux/vppcalls/vpe_vppcalls_test.go +++ b/plugins/govppmux/vppcalls/vpe_vppcalls_test.go @@ -12,12 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -package vppcalls +package vppcalls_test import ( "testing" - "github.com/ligato/vpp-agent/plugins/defaultplugins/common/bin_api/vpe" + "github.com/ligato/vpp-agent/plugins/govppmux/vppcalls" + "github.com/ligato/vpp-agent/plugins/vpp/binapi/vpe" "github.com/ligato/vpp-agent/tests/vppcallmock" . "github.com/onsi/gomega" ) @@ -29,7 +30,7 @@ func TestGetBuffers(t *testing.T) { const reply = `Thread Name Index Size Alloc Free #Alloc #Free 0 default 0 2048 576k 42.75k 256 19 0 lacp-ethernet 1 256 1.13m 27k 512 12 - 0 marker-ethernet 2 256 0 0 0 0 + 0 marker-ethernet 2 256 1.11g 0 0 0 0 ip4 arp 3 256 0 0 0 0 0 ip6 neighbor discovery 4 256 0 0 0 0 0 cdp-ethernet 5 256 0 0 0 0 @@ -41,11 +42,11 @@ func TestGetBuffers(t *testing.T) { Length: uint32(len(reply)), }) - info, err := GetBuffersInfo(ctx.MockChannel) + info, err := vppcalls.GetBuffersInfo(ctx.MockChannel) Expect(err).ShouldNot(HaveOccurred()) Expect(info.Items).To(HaveLen(9)) - Expect(info.Items[0]).To(Equal(BuffersItem{ + Expect(info.Items[0]).To(Equal(vppcalls.BuffersItem{ ThreadID: 0, Name: "default", Index: 0, @@ -55,7 +56,7 @@ func TestGetBuffers(t *testing.T) { NumAlloc: 256, NumFree: 19, })) - Expect(info.Items[1]).To(Equal(BuffersItem{ + Expect(info.Items[1]).To(Equal(vppcalls.BuffersItem{ ThreadID: 0, Name: "lacp-ethernet", Index: 1, @@ -65,6 +66,16 @@ func TestGetBuffers(t *testing.T) { NumAlloc: 512, NumFree: 12, })) + Expect(info.Items[2]).To(Equal(vppcalls.BuffersItem{ + ThreadID: 0, + Name: "marker-ethernet", + Index: 2, + Size: 256, + Alloc: 1110000000, + Free: 0, + NumAlloc: 0, + NumFree: 0, + })) } func TestGetRuntime(t *testing.T) { @@ -129,12 +140,12 @@ unix-epoll-input polling 20563870 0 Length: uint32(len(reply)), }) - info, err := GetRuntimeInfo(ctx.MockChannel) + info, err := vppcalls.GetRuntimeInfo(ctx.MockChannel) Expect(err).ShouldNot(HaveOccurred()) Expect(info.Threads).To(HaveLen(3)) Expect(info.Threads[0].Items).To(HaveLen(36)) - Expect(info.Threads[0].Items[0]).To(Equal(RuntimeItem{ + Expect(info.Threads[0].Items[0]).To(Equal(vppcalls.RuntimeItem{ Name: "acl-plugin-fa-cleaner-process", State: "event wait", Calls: 0, @@ -161,11 +172,11 @@ Thread 2 vpp_wk_1 Length: uint32(len(reply)), }) - info, err := GetMemory(ctx.MockChannel) + info, err := vppcalls.GetMemory(ctx.MockChannel) Expect(err).ShouldNot(HaveOccurred()) Expect(info.Threads).To(HaveLen(3)) - Expect(info.Threads[0]).To(Equal(MemoryThread{ + Expect(info.Threads[0]).To(Equal(vppcalls.MemoryThread{ ID: 0, Name: "vpp_main", Objects: 22991, @@ -176,7 +187,7 @@ Thread 2 vpp_wk_1 Overhead: 361000, Capacity: 1048572000, })) - Expect(info.Threads[1]).To(Equal(MemoryThread{ + Expect(info.Threads[1]).To(Equal(vppcalls.MemoryThread{ ID: 1, Name: "vpp_wk_0", Objects: 22991, @@ -202,29 +213,35 @@ func TestGetNodeCounters(t *testing.T) { 14 ethernet-input l3 mac mismatch 1 arp-input ARP replies sent 4 ip4-input ip4 spoofed local-address packet drops + 2 memif1/1-output interface is down ` ctx.MockVpp.MockReply(&vpe.CliInbandReply{ Reply: []byte(reply), Length: uint32(len(reply)), }) - info, err := GetNodeCounters(ctx.MockChannel) + info, err := vppcalls.GetNodeCounters(ctx.MockChannel) Expect(err).ShouldNot(HaveOccurred()) - Expect(info.Counters).To(HaveLen(8)) - Expect(info.Counters[0]).To(Equal(NodeCounter{ + Expect(info.Counters).To(HaveLen(9)) + Expect(info.Counters[0]).To(Equal(vppcalls.NodeCounter{ Count: 32, Node: "ipsec-output-ip4", Reason: "IPSec policy protect", })) - Expect(info.Counters[6]).To(Equal(NodeCounter{ + Expect(info.Counters[6]).To(Equal(vppcalls.NodeCounter{ Count: 1, Node: "arp-input", Reason: "ARP replies sent", })) - Expect(info.Counters[7]).To(Equal(NodeCounter{ + Expect(info.Counters[7]).To(Equal(vppcalls.NodeCounter{ Count: 4, Node: "ip4-input", Reason: "ip4 spoofed local-address packet drops", })) + Expect(info.Counters[8]).To(Equal(vppcalls.NodeCounter{ + Count: 2, + Node: "memif1/1-output", + Reason: "interface is down", + })) } diff --git a/plugins/linux/README.md b/plugins/linux/README.md new file mode 100644 index 0000000000..35e99b0008 --- /dev/null +++ b/plugins/linux/README.md @@ -0,0 +1,22 @@ +# Linux Plugin + +The `linuxplugin` is a core Agent Plugin for the management of a subset of the Linux +network configuration. Configuration of VETH (virtual ethernet pair) interfaces, linux routes and ARP entries +is currently supported. Detailed description can be found in particular READMEs: + - [ifplugin](ifplugin) + - [l3plugin](l3plugin) + - [nsplugin](nsplugin) + +In general, the northbound configuration is translated to a sequence of Netlink API +calls (using `github.com/vishvananda/netlink` and `github.com/vishvananda/netns` libraries). + +## Config file + +*Stopwatch* + +Duration of the linux netlink procedure can be measured using stopwatch feature. These data are logged after +every event(any resync, interfaces, routes, etc.). Enable stopwatch in linux.conf: + +`stopwatch: true` or `stopwatch: false` + +Stopwatch is disabled by default (if there is no config available). \ No newline at end of file diff --git a/plugins/linuxplugin/data_change.go b/plugins/linux/data_change.go similarity index 95% rename from plugins/linuxplugin/data_change.go rename to plugins/linux/data_change.go index dc8ab950dc..54287b1be6 100644 --- a/plugins/linuxplugin/data_change.go +++ b/plugins/linux/data_change.go @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package linuxplugin +package linux import ( "strings" "github.com/ligato/cn-infra/datasync" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + "github.com/ligato/vpp-agent/plugins/linux/model/l3" ) func (plugin *Plugin) changePropagateRequest(dataChng datasync.ChangeEvent) error { diff --git a/plugins/linuxplugin/data_resync.go b/plugins/linux/data_resync.go similarity index 96% rename from plugins/linuxplugin/data_resync.go rename to plugins/linux/data_resync.go index 81362f999a..2d86fff851 100644 --- a/plugins/linuxplugin/data_resync.go +++ b/plugins/linux/data_resync.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package linuxplugin +package linux import ( "fmt" @@ -20,8 +20,8 @@ import ( "github.com/ligato/cn-infra/datasync" "github.com/ligato/cn-infra/logging" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/l3" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + "github.com/ligato/vpp-agent/plugins/linux/model/l3" ) // DataResyncReq is used to transfer expected configuration of the Linux network stack to the plugins. @@ -49,6 +49,7 @@ func NewDataResyncReq() *DataResyncReq { // DataResync delegates resync request linuxplugin configurators. func (plugin *Plugin) resyncPropageRequest(req *DataResyncReq) error { plugin.Log.Info("resync the Linux Configuration") + // store all resync errors var resyncErrs []error diff --git a/plugins/linuxplugin/README.md b/plugins/linux/ifplugin/README.md similarity index 66% rename from plugins/linuxplugin/README.md rename to plugins/linux/ifplugin/README.md index 918c8d130f..230b606cec 100644 --- a/plugins/linuxplugin/README.md +++ b/plugins/linux/ifplugin/README.md @@ -1,18 +1,14 @@ -# Linux Plugin +# Linux interface Plugin -The `linuxplugin` is a core Agent Plugin for the management of a subset of the Linux -network configuration. Currently, only the VETH (virtual ethernet pair) interface is supported. The plugin watches the northbound configuration of Linux network interfaces, -which is modelled by [interfaces proto file](common/model/interfaces/interfaces.proto) +which is modelled by [interfaces proto file](../model/interfaces/interfaces.proto) and stored in ETCD under the following key: ``` /vnf-agent//linux/config/v1/interface/ ``` -This northbound configuration is translated to a sequence of Netlink API -calls (using `github.com/vishvananda/netlink` and `github.com/vishvananda/netns` libraries). Linux interface is uniquely identified in the northbound configuration by its name. The same string is also used in the Linux network stack to label the interface and it has to be unique across all network namespaces. It is therefore recommended for the northbound applications to prefix interface names with namespace @@ -31,32 +27,6 @@ are always created *after* the associated host interfaces. If the host interface afpacket. `ifplugin` will keep the afpacket configuration in the cache and re-create it once the host interface is available again. To enable this feature, `linuxplugin` must be loaded *before* VPP default plugins. - -*Namespaces* - -Agent has full support for Linux network namespaces. It is possible to attach Linux interface into a new, existing -or even yet-to-be-created network namespace via the `namespace` configuration section inside the `LinuxInterfaces` configuration data model. - -Namespace can be referenced in multiple ways. The most low-level link to a namespace is -a file descriptor associated with the symbolic link automatically created in the `proc` filesystem, pointing to the definition -of the namespace used by a given process (`/proc//ns/net`) or by a task of a given process (`/proc//task//ns/net`). -A more common approach to reference namespace is to use just the PID of the process whose -namespace we want to attach to, or to create a bind-mount of the symbolic link into `/var/run/netns` directory and use the -filename of that mount. The latter is called `named` namespace and it is created and managed for example by -the `ip netns` command line tool from the `iproute2` package. The advantage of `named` namespace -is that it can outlive the process it was originally created by. - -`namespace` configuration section should be seen as a union of values. First, set the type and then store the reference -into the appropriate field (`pid` vs. `name` vs `microservice`). -Agent supports both PID-based references as well as `named` namespaces. - -Additionally, we provide a non-standard namespace reference, denoted as `MICROSERVICE_REF_NS`, which is specific to ecosystems -with microservices. It is possible to attach interface into the namespace of a container that runs microservice with a given label. -To make it even simpler, it is not required to start the microservice before the interface is configured. The agent will postpone -interface (re)configuration until the referenced microservice gets launched. Behind the scenes, the agent communicates with -the docker daemon to construct and maintain an up-to-date map of microservice labels to PIDs and IDs of their corresponding -containers. Whenever a new microservice is detected, all pending interfaces are moved to its namespace. - *VETH* Virtual Ethernet interfaces come in pairs, and they are connected like a tube — whatever comes in one VETH @@ -91,9 +61,9 @@ to the destination and originally opposite VPP through a `AF_PACKET` socket once **JSON configuration example with vpp-agent-ctl** An example configuration for both ends of VETH in JSON format can -be found [here](../../cmd/vpp-agent-ctl/json/veth1.json) and [here](../../cmd/vpp-agent-ctl/json/veth2.json). +be found [here](../../../cmd/vpp-agent-ctl/json/veth1.json) and [here](../../../cmd/vpp-agent-ctl/json/veth2.json). -To insert config into etcd in JSON format [vpp-agent-ctl](../../cmd/vpp-agent-ctl) +To insert config into etcd in JSON format [vpp-agent-ctl](../../../cmd/vpp-agent-ctl) can be used. For example, to configure interface `veth1`, use the configuration in the `veth1.json` file and run the following `vpp-agent-ctl` command: ``` @@ -118,4 +88,4 @@ vpp-agent-ctl -vethd Run `vpp-agent-ctl` with no arguments to get the list of all available commands and options. The documentation for `vpp-agent-ctl` is incomplete right now, and the only way to find out -what a given command does is to [study the source code itself](../../cmd/vpp-agent-ctl). \ No newline at end of file +what a given command does is to [study the source code itself](../../../cmd/vpp-agent-ctl). \ No newline at end of file diff --git a/plugins/linuxplugin/ifplugin/data_resync.go b/plugins/linux/ifplugin/data_resync.go similarity index 81% rename from plugins/linuxplugin/ifplugin/data_resync.go rename to plugins/linux/ifplugin/data_resync.go index b96d1b9784..1d6f83f91e 100644 --- a/plugins/linuxplugin/ifplugin/data_resync.go +++ b/plugins/linux/ifplugin/data_resync.go @@ -22,10 +22,9 @@ import ( "strings" "time" - "github.com/ligato/cn-infra/logging/measure" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/linuxplugin/ifplugin/ifaceidx" - "github.com/ligato/vpp-agent/plugins/linuxplugin/nsplugin" + "github.com/ligato/vpp-agent/plugins/linux/ifplugin/ifaceidx" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + "github.com/ligato/vpp-agent/plugins/linux/nsplugin" "github.com/vishvananda/netlink" ) @@ -48,15 +47,11 @@ type LinuxDataPair struct { // 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. func (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterfaces_Interface) (errs []error) { - plugin.Log.Debugf("RESYNC Linux interface begin.") + plugin.log.Debugf("RESYNC Linux interface begin.") - start := time.Now() - defer func() { - if plugin.Stopwatch != nil { - timeLog := measure.GetTimeLog("linux-interface resync", plugin.Stopwatch) - timeLog.LogTimeEntry(time.Since(start)) - } - }() + defer func(t time.Time) { + plugin.stopwatch.TimeLog("resync-linux-interfaces").LogTimeEntry(time.Since(t)) + }(time.Now()) nsMgmtCtx := nsplugin.NewNamespaceMgmtCtx() @@ -76,14 +71,14 @@ func (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterf } if linkIf != nil { // If interface was found, it will be compared and modified in the next step - plugin.Log.Debugf("RESYNC Linux interface %v: interface found in namespace", nbIf.Name) + plugin.log.Debugf("RESYNC Linux interface %v: interface found in namespace", nbIf.Name) linkMap[nbIf.Name] = &LinuxDataPair{ linuxIfData: linkIf, nbIfData: nbIf, } } else { // If not, configure it - plugin.Log.Debugf("RESYNC Linux interface %v: interface not found and will be configured", nbIf.Name) + plugin.log.Debugf("RESYNC Linux interface %v: interface not found and will be configured", nbIf.Name) if err := plugin.ConfigureLinuxInterface(nbIf); err != nil { errs = append(errs, err) } @@ -98,7 +93,7 @@ func (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterf if linkDataPair.nbIfData.Type == interfaces.LinuxInterfaces_VETH { // Search registered config for peer var found bool - for _, cachedIfCfg := range plugin.intfByName { + for _, cachedIfCfg := range plugin.ifByName { if cachedIfCfg.config != nil && cachedIfCfg.config.Type == interfaces.LinuxInterfaces_VETH { if cachedIfCfg.config.Veth != nil && cachedIfCfg.config.Veth.PeerIfName == linuxIf.HostIfName { found = true @@ -109,7 +104,7 @@ func (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterf } } if found { - plugin.Log.Debugf("RESYNC Linux interface %v: found peer %v", linkName, linuxIf.Veth.PeerIfName) + plugin.log.Debugf("RESYNC Linux interface %v: found peer %v", linkName, linuxIf.Veth.PeerIfName) } else { // No info about the peer, use the same as in the NB config linuxIf.Veth = &interfaces.LinuxInterfaces_Interface_Veth{ @@ -119,19 +114,19 @@ func (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterf } // Check if interface needs to be modified if plugin.isLinuxIfModified(linkDataPair.nbIfData, linuxIf) { - plugin.Log.Debugf("RESYNC Linux interface %s: configuration changed, interface will be modified", linkName) + plugin.log.Debugf("RESYNC Linux interface %s: configuration changed, interface will be modified", linkName) if err := plugin.ModifyLinuxInterface(linkDataPair.nbIfData, linuxIf); err != nil { errs = append(errs, err) } } else { - plugin.Log.Debugf("RESYNC Linux interface %s: data was not changed", linkName) + plugin.log.Debugf("RESYNC Linux interface %s: data was not changed", linkName) } } // Register all interfaces in default namespace which were not already registered linkList, err := netlink.LinkList() if err != nil { - plugin.Log.Errorf("Failed to read linux interfaces: %v", err) + plugin.log.Errorf("Failed to read linux interfaces: %v", err) errs = append(errs, err) } for _, link := range linkList { @@ -139,7 +134,7 @@ func (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterf continue } attrs := link.Attrs() - _, _, found := plugin.IfIndexes.LookupIdx(attrs.Name) + _, _, found := plugin.ifIndexes.LookupIdx(attrs.Name) if !found { // If interface is veth, do not register it. Agent does not know where the other // end is or if it even exists. @@ -147,18 +142,18 @@ func (plugin *LinuxInterfaceConfigurator) Resync(nbIfs []*interfaces.LinuxInterf continue } // Register interface with name (other parameters can be read if needed) - plugin.IfIndexes.RegisterName(attrs.Name, plugin.IfIdxSeq, &ifaceidx.IndexedLinuxInterface{ + plugin.ifIndexes.RegisterName(attrs.Name, plugin.ifIdxSeq, &ifaceidx.IndexedLinuxInterface{ Index: uint32(attrs.Index), Data: &interfaces.LinuxInterfaces_Interface{ Name: attrs.Name, HostIfName: attrs.Name, }, }) - plugin.IfIdxSeq++ + plugin.ifIdxSeq++ } } - plugin.Log.WithField("cfg", plugin).Debug("RESYNC Interface end. ", errs) + plugin.log.WithField("cfg", plugin).Debug("RESYNC Interface end. ", errs) return } @@ -196,14 +191,14 @@ func (plugin *LinuxInterfaceConfigurator) reconstructIfConfig(linuxIf netlink.Li func (plugin *LinuxInterfaceConfigurator) getLinuxInterfaces(linuxIf netlink.Link, ns *interfaces.LinuxInterfaces_Interface_Namespace) (addresses []string) { // Move to proper namespace if ns != nil { - if !plugin.NsHandler.IsNamespaceAvailable(ns) { - plugin.Log.Errorf("RESYNC Linux interface %s: namespace is not available", linuxIf.Attrs().Name) + if !plugin.nsHandler.IsNamespaceAvailable(ns) { + plugin.log.Errorf("RESYNC Linux interface %s: namespace is not available", linuxIf.Attrs().Name) return } // Switch to namespace - revertNs, err := plugin.NsHandler.SwitchToNamespace(nsplugin.NewNamespaceMgmtCtx(), ns) + revertNs, err := plugin.nsHandler.SwitchToNamespace(nsplugin.NewNamespaceMgmtCtx(), ns) if err != nil { - plugin.Log.Errorf("RESYNC Linux interface %s: failed to switch to namespace %s: %v", + plugin.log.Errorf("RESYNC Linux interface %s: failed to switch to namespace %s: %v", linuxIf.Attrs().Name, ns.Name, err) return } @@ -212,7 +207,7 @@ func (plugin *LinuxInterfaceConfigurator) getLinuxInterfaces(linuxIf netlink.Lin addressList, err := netlink.AddrList(linuxIf, netlink.FAMILY_ALL) if err != nil { - plugin.Log.Errorf("failed to read linux interface %s address list: %v", linuxIf.Attrs().Name, err) + plugin.log.Errorf("failed to read linux interface %s address list: %v", linuxIf.Attrs().Name, err) return } @@ -227,17 +222,17 @@ func (plugin *LinuxInterfaceConfigurator) getLinuxInterfaces(linuxIf netlink.Lin // Compare interface fields in order to find differences. func (plugin *LinuxInterfaceConfigurator) isLinuxIfModified(nbIf, linuxIf *interfaces.LinuxInterfaces_Interface) bool { - plugin.Log.Debugf("Linux interface RESYNC comparison started for interface %s", nbIf.Name) + plugin.log.Debugf("Linux interface RESYNC comparison started for interface %s", nbIf.Name) // Type if nbIf.Type != linuxIf.Type { - plugin.Log.Debugf("Linux interface RESYNC comparison: type changed (NB: %v, Linux: %v)", + plugin.log.Debugf("Linux interface RESYNC comparison: type changed (NB: %v, Linux: %v)", nbIf.Type, linuxIf.Type) return true } // Enabled if nbIf.Enabled != linuxIf.Enabled { - plugin.Log.Debugf("Linux interface RESYNC comparison: enabled value changed (NB: %t, Linux: %t)", + plugin.log.Debugf("Linux interface RESYNC comparison: enabled value changed (NB: %t, Linux: %t)", nbIf.Enabled, linuxIf.Enabled) return true } @@ -249,7 +244,7 @@ func (plugin *LinuxInterfaceConfigurator) isLinuxIfModified(nbIf, linuxIf *inter } // IP address count if len(nbIf.IpAddresses) != len(linuxIf.IpAddresses) { - plugin.Log.Debugf("Linux interface RESYNC comparison: ip address count does not match (NB: %d, Linux: %d)", + plugin.log.Debugf("Linux interface RESYNC comparison: ip address count does not match (NB: %d, Linux: %d)", len(nbIf.IpAddresses), len(linuxIf.IpAddresses)) return true } @@ -259,12 +254,12 @@ func (plugin *LinuxInterfaceConfigurator) isLinuxIfModified(nbIf, linuxIf *inter for _, linuxIP := range linuxIf.IpAddresses { pNbIP, nbIPNet, err := net.ParseCIDR(nbIP) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) continue } pVppIP, vppIPNet, err := net.ParseCIDR(linuxIP) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) continue } if nbIPNet.Mask.String() == vppIPNet.Mask.String() && bytes.Compare(pNbIP, pVppIP) == 0 { @@ -273,33 +268,33 @@ func (plugin *LinuxInterfaceConfigurator) isLinuxIfModified(nbIf, linuxIf *inter } } if !ipFound { - plugin.Log.Debugf("Interface RESYNC comparison: linux interface %v does not contain IP %s", nbIf.Name, nbIP) + plugin.log.Debugf("Interface RESYNC comparison: linux interface %v does not contain IP %s", nbIf.Name, nbIP) return true } } // Physical address if nbIf.PhysAddress != "" && nbIf.PhysAddress != linuxIf.PhysAddress { - plugin.Log.Debugf("Interface RESYNC comparison: MAC address changed (NB: %s, Linux: %s)", + plugin.log.Debugf("Interface RESYNC comparison: MAC address changed (NB: %s, Linux: %s)", nbIf.PhysAddress, linuxIf.PhysAddress) return true } // MTU (if NB value is set) if nbIf.Mtu != 0 && nbIf.Mtu != linuxIf.Mtu { - plugin.Log.Debugf("Interface RESYNC comparison: MTU changed (NB: %d, Linux: %d)", + plugin.log.Debugf("Interface RESYNC comparison: MTU changed (NB: %d, Linux: %d)", nbIf.Mtu, linuxIf.Mtu) return true } switch nbIf.Type { case interfaces.LinuxInterfaces_VETH: if nbIf.Veth == nil && linuxIf.Veth != nil || nbIf.Veth != nil && linuxIf.Veth == nil { - plugin.Log.Debugf("Interface RESYNC comparison: VETH setup changed (NB: %v, VPP: %v)", + plugin.log.Debugf("Interface RESYNC comparison: VETH setup changed (NB: %v, VPP: %v)", nbIf.Veth, linuxIf.Veth) return true } if nbIf.Veth != nil && linuxIf.Veth != nil { // VETH peer name if nbIf.Veth.PeerIfName != linuxIf.Veth.PeerIfName { - plugin.Log.Debugf("Interface RESYNC comparison: VETH peer name changed (NB: %s, VPP: %s)", + plugin.log.Debugf("Interface RESYNC comparison: VETH peer name changed (NB: %s, VPP: %s)", nbIf.Veth.PeerIfName, linuxIf.Veth.PeerIfName) return true } @@ -307,7 +302,7 @@ func (plugin *LinuxInterfaceConfigurator) isLinuxIfModified(nbIf, linuxIf *inter case interfaces.LinuxInterfaces_AUTO_TAP: // Host name for TAP if nbIf.HostIfName != linuxIf.HostIfName { - plugin.Log.Debugf("Interface RESYNC comparison: TAP host name changed (NB: %d, Linux: %d)", + plugin.log.Debugf("Interface RESYNC comparison: TAP host name changed (NB: %d, Linux: %d)", nbIf.HostIfName, linuxIf.HostIfName) return true } @@ -319,18 +314,18 @@ func (plugin *LinuxInterfaceConfigurator) isLinuxIfModified(nbIf, linuxIf *inter // Looks for linux interface. Returns net.Link object if found func (plugin *LinuxInterfaceConfigurator) findLinuxInterface(nbIf *interfaces.LinuxInterfaces_Interface, nsMgmtCtx *nsplugin.NamespaceMgmtCtx) (netlink.Link, error) { - plugin.Log.Debugf("Looking for Linux interface %v", nbIf.HostIfName) + plugin.log.Debugf("Looking for Linux interface %v", nbIf.HostIfName) // Move to proper namespace if nbIf.Namespace != nil { - if !plugin.NsHandler.IsNamespaceAvailable(nbIf.Namespace) { + if !plugin.nsHandler.IsNamespaceAvailable(nbIf.Namespace) { // Not and error - plugin.Log.Debugf("Interface %s is not ready to be configured, namespace %s is not available", + plugin.log.Debugf("Interface %s is not ready to be configured, namespace %s is not available", nbIf.Name, nbIf.Namespace.Name) return nil, nil } // Switch to namespace - revertNs, err := plugin.NsHandler.SwitchToNamespace(nsMgmtCtx, nbIf.Namespace) + revertNs, err := plugin.nsHandler.SwitchToNamespace(nsMgmtCtx, nbIf.Namespace) if err != nil { return nil, fmt.Errorf("RESYNC Linux interface %s: failed to switch to namespace %s: %v", nbIf.HostIfName, nbIf.Namespace.Name, err) @@ -361,11 +356,11 @@ func (plugin *LinuxInterfaceConfigurator) findLinuxInterface(nbIf *interfaces.Li // Register linux interface func (plugin *LinuxInterfaceConfigurator) registerLinuxInterface(linuxIfIdx uint32, nbIf *interfaces.LinuxInterfaces_Interface) { // Register interface with its name - plugin.IfIndexes.RegisterName(nbIf.Name, plugin.IfIdxSeq, &ifaceidx.IndexedLinuxInterface{ + plugin.ifIndexes.RegisterName(nbIf.Name, plugin.ifIdxSeq, &ifaceidx.IndexedLinuxInterface{ Index: linuxIfIdx, Data: nbIf, }) - plugin.IfIdxSeq++ + plugin.ifIdxSeq++ } // Add interface to cache diff --git a/plugins/linuxplugin/ifplugin/ifaceidx/doc.go b/plugins/linux/ifplugin/ifaceidx/doc.go similarity index 100% rename from plugins/linuxplugin/ifplugin/ifaceidx/doc.go rename to plugins/linux/ifplugin/ifaceidx/doc.go diff --git a/plugins/linuxplugin/ifplugin/ifaceidx/iface_cache.go b/plugins/linux/ifplugin/ifaceidx/iface_cache.go similarity index 95% rename from plugins/linuxplugin/ifplugin/ifaceidx/iface_cache.go rename to plugins/linux/ifplugin/ifaceidx/iface_cache.go index 2699ebda6b..a68d8c38aa 100644 --- a/plugins/linuxplugin/ifplugin/ifaceidx/iface_cache.go +++ b/plugins/linux/ifplugin/ifaceidx/iface_cache.go @@ -22,7 +22,7 @@ import ( "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/vpp-agent/idxvpp/cacheutil" "github.com/ligato/vpp-agent/idxvpp/nametoidx" - linux_ifaces "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" + linux_ifaces "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" ) // Cache the VETH interfaces of a particular agent by watching transport. diff --git a/plugins/linuxplugin/ifplugin/ifaceidx/linux_if_index.go b/plugins/linux/ifplugin/ifaceidx/linux_if_index.go similarity index 99% rename from plugins/linuxplugin/ifplugin/ifaceidx/linux_if_index.go rename to plugins/linux/ifplugin/ifaceidx/linux_if_index.go index 1d19f3cbc6..256179be6d 100644 --- a/plugins/linuxplugin/ifplugin/ifaceidx/linux_if_index.go +++ b/plugins/linux/ifplugin/ifaceidx/linux_if_index.go @@ -19,7 +19,7 @@ import ( log "github.com/ligato/cn-infra/logging/logrus" "github.com/ligato/vpp-agent/idxvpp" "github.com/ligato/vpp-agent/idxvpp/nametoidx" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" ) // DefNs is name for default namespace diff --git a/plugins/linuxplugin/ifplugin/interface_config.go b/plugins/linux/ifplugin/interface_config.go similarity index 53% rename from plugins/linuxplugin/ifplugin/interface_config.go rename to plugins/linux/ifplugin/interface_config.go index 9e52925772..d3ebceefd5 100644 --- a/plugins/linuxplugin/ifplugin/interface_config.go +++ b/plugins/linux/ifplugin/interface_config.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:generate protoc --proto_path=../common/model/interfaces --gogo_out=../common/model/interfaces ../common/model/interfaces/interfaces.proto +//go:generate protoc --proto_path=../model/interfaces --gogo_out=../model/interfaces ../model/interfaces/interfaces.proto package ifplugin @@ -22,17 +22,19 @@ import ( "net" "sync" - "github.com/ligato/cn-infra/utils/safeclose" - vppIfIdx "github.com/ligato/vpp-agent/plugins/defaultplugins/ifplugin/ifaceidx" - "github.com/ligato/vpp-agent/plugins/linuxplugin/nsplugin" + "github.com/ligato/vpp-agent/plugins/linux/nsplugin" "github.com/vishvananda/netlink" + "bytes" + "github.com/ligato/cn-infra/logging" "github.com/ligato/cn-infra/logging/measure" "github.com/ligato/cn-infra/utils/addrs" - "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" - "github.com/ligato/vpp-agent/plugins/linuxplugin/ifplugin/ifaceidx" - "github.com/ligato/vpp-agent/plugins/linuxplugin/ifplugin/linuxcalls" + "github.com/ligato/vpp-agent/idxvpp/nametoidx" + "github.com/ligato/vpp-agent/plugins/linux/ifplugin/ifaceidx" + "github.com/ligato/vpp-agent/plugins/linux/ifplugin/linuxcalls" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + vppIf "github.com/ligato/vpp-agent/plugins/vpp/model/interfaces" ) // LinuxInterfaceConfig is used to cache the configuration of Linux interfaces. @@ -47,68 +49,92 @@ type LinuxInterfaceConfig struct { // Updates received from the northbound API are compared with the Linux network configuration and differences // are applied through the Netlink API. type LinuxInterfaceConfigurator struct { - Log logging.Logger - - cfgLock sync.Mutex - - /* logical interface name -> Linux interface index (both managed and unmanaged interfaces) */ - IfIndexes ifaceidx.LinuxIfIndexRW - IfIdxSeq uint32 - - /* interface caches (managed interfaces only) */ - intfByName map[string]*LinuxInterfaceConfig /* interface name -> interface configuration */ - intfsByMicroservice map[string][]*LinuxInterfaceConfig /* microservice label -> list of interfaces attached to this microservice */ + log logging.Logger - ///* docker client - used to convert microservice label into the PID and ID of the container */ - //dockerClient *docker.Client + // In-memory mappings + ifIndexes ifaceidx.LinuxIfIndexRW + ifIdxSeq uint32 + ifByName map[string]*LinuxInterfaceConfig // interface name -> interface configuration + ifsByMs map[string][]*LinuxInterfaceConfig // microservice label -> list of interfaces attached to this microservice - /* management of go routines */ - ctx context.Context // Context within which all goroutines are running - cancel context.CancelFunc // Cancel can be used to cancel all goroutines and their jobs inside of the plugin. - wg sync.WaitGroup // Wait group allows to wait until all goroutines of the plugin have finished. + ifCachedConfigs ifaceidx.LinuxIfIndexRW + pIfCachedConfigSeq uint32 - ifMicroserviceNotif chan *nsplugin.MicroserviceEvent + // Channels + ifMsNotif chan *nsplugin.MicroserviceEvent - /* interface state */ - ifStateChan chan *LinuxInterfaceStateNotification - - /* VPP interface indices */ - VppIfIndices vppIfIdx.SwIfIndex + // Go routine management + cfgLock sync.Mutex + ctx context.Context // Context within which all goroutines are running + cancel context.CancelFunc // Cancel can be used to cancel all goroutines and their jobs inside of the plugin. + wg sync.WaitGroup // Wait group allows to wait until all goroutines of the plugin have finished. - NsHandler *nsplugin.NsHandler + // Linux namespace/calls handler + ifHandler linuxcalls.NetlinkAPI + nsHandler nsplugin.NamespaceAPI - /* time measurement */ - Stopwatch *measure.Stopwatch // timer used to measure and store time + //Timer used to measure and store time + stopwatch *measure.Stopwatch } -// Init linuxplugin and start go routines. -func (plugin *LinuxInterfaceConfigurator) Init(stateChan chan *LinuxInterfaceStateNotification, ifNotif chan *nsplugin.MicroserviceEvent) (err error) { - plugin.Log.Debug("Initializing Linux Interface configurator") +// Init linux plugin and start go routines. +func (plugin *LinuxInterfaceConfigurator) Init(logging logging.PluginLogger, ifHandler linuxcalls.NetlinkAPI, nsHandler nsplugin.NamespaceAPI, + ifIndexes ifaceidx.LinuxIfIndexRW, ifNotif chan *nsplugin.MicroserviceEvent, stopwatch *measure.Stopwatch) (err error) { + // Logger + plugin.log = logging.NewLogger("-if-conf") + plugin.log.Debug("Initializing Linux Interface configurator") + + // Mappings + plugin.ifIndexes = ifIndexes + plugin.ifByName = make(map[string]*LinuxInterfaceConfig) + plugin.ifsByMs = make(map[string][]*LinuxInterfaceConfig) + plugin.ifIdxSeq = 1 + plugin.ifCachedConfigs = ifaceidx.NewLinuxIfIndex(nametoidx.NewNameToIdx(plugin.log, "linux_if_cache", nil)) + plugin.pIfCachedConfigSeq = 1 // Init channel - plugin.ifStateChan = stateChan - plugin.ifMicroserviceNotif = ifNotif - - // Allocate caches. - plugin.intfByName = make(map[string]*LinuxInterfaceConfig) - plugin.intfsByMicroservice = make(map[string][]*LinuxInterfaceConfig) + plugin.ifMsNotif = ifNotif plugin.ctx, plugin.cancel = context.WithCancel(context.Background()) - go plugin.watchMicroservices(plugin.ctx) - // Start watching on state updater events - go plugin.watchLinuxStateUpdater() + // Interface and namespace handlers + plugin.ifHandler = ifHandler + plugin.nsHandler = nsHandler + + // Configurator-wide stopwatch instance + plugin.stopwatch = stopwatch + + // Start watching on microservice events + go plugin.watchMicroservices(plugin.ctx) return err } -// Close stops all goroutines started by linuxplugin +// Close does nothing for linux interface configurator. State and notification channels are closed in linux plugin. func (plugin *LinuxInterfaceConfigurator) Close() error { - safeclose.Close(plugin.ifStateChan) - return nil } +// GetLinuxInterfaceIndexes returns in-memory mapping of linux inerfaces +func (plugin *LinuxInterfaceConfigurator) GetLinuxInterfaceIndexes() ifaceidx.LinuxIfIndex { + return plugin.ifIndexes +} + +// GetInterfaceByNameCache returns cache of interface <-> config entries +func (plugin *LinuxInterfaceConfigurator) GetInterfaceByNameCache() map[string]*LinuxInterfaceConfig { + return plugin.ifByName +} + +// GetInterfaceByMsCache returns cache of microservice <-> interface list +func (plugin *LinuxInterfaceConfigurator) GetInterfaceByMsCache() map[string][]*LinuxInterfaceConfig { + return plugin.ifsByMs +} + +// GetCachedLinuxIfIndexes gives access to mapping of not configurated interface indexes. +func (plugin *LinuxInterfaceConfigurator) GetCachedLinuxIfIndexes() ifaceidx.LinuxIfIndex { + return plugin.ifCachedConfigs +} + // ConfigureLinuxInterface reacts to a new northbound Linux interface config by creating and configuring // the interface in the host network stack through Netlink API. func (plugin *LinuxInterfaceConfigurator) ConfigureLinuxInterface(linuxIf *interfaces.LinuxInterfaces_Interface) error { @@ -116,7 +142,7 @@ func (plugin *LinuxInterfaceConfigurator) ConfigureLinuxInterface(linuxIf *inter defer plugin.cfgLock.Unlock() plugin.handleOptionalHostIfName(linuxIf) - plugin.Log.Infof("Configuring new Linux interface %v", linuxIf.HostIfName) + plugin.log.Infof("Configuring new Linux interface %v", linuxIf.HostIfName) // Linux interface type resolution switch linuxIf.Type { @@ -130,10 +156,11 @@ func (plugin *LinuxInterfaceConfigurator) ConfigureLinuxInterface(linuxIf *inter return plugin.configureVethInterface(ifConfig, peerConfig) case interfaces.LinuxInterfaces_AUTO_TAP: - // TAP (auto) interface looks for existing interface with the same host name or temp name (cached without peer) - ifConfig := plugin.addToCache(linuxIf, nil) - - return plugin.configureTapInterface(ifConfig) + if linuxIf.Tap != nil && linuxIf.Tap.TempIfName != "" { + return plugin.configureTapInterface(linuxIf.Tap.TempIfName, linuxIf) + } else { + return plugin.configureTapInterface(linuxIf.HostIfName, linuxIf) + } default: return fmt.Errorf("unknown linux interface type: %v", linuxIf.Type) } @@ -145,7 +172,7 @@ func (plugin *LinuxInterfaceConfigurator) ModifyLinuxInterface(newLinuxIf, oldLi // If host names are not defined, name == host name plugin.handleOptionalHostIfName(newLinuxIf) plugin.handleOptionalHostIfName(oldLinuxIf) - plugin.Log.Infof("Modifying Linux interface %v", newLinuxIf.HostIfName) + plugin.log.Infof("Modifying Linux interface %v", newLinuxIf.HostIfName) if oldLinuxIf.Type != newLinuxIf.Type { return fmt.Errorf("%v: linux interface type change not allowed", newLinuxIf.Name) @@ -165,8 +192,8 @@ func (plugin *LinuxInterfaceConfigurator) ModifyLinuxInterface(newLinuxIf, oldLi } // Prepare namespace objects of new and old interfaces - newIfaceNs := plugin.NsHandler.IfNsToGeneric(newLinuxIf.Namespace) - oldIfaceNs := plugin.NsHandler.IfNsToGeneric(oldLinuxIf.Namespace) + newIfaceNs := plugin.nsHandler.IfNsToGeneric(newLinuxIf.Namespace) + oldIfaceNs := plugin.nsHandler.IfNsToGeneric(oldLinuxIf.Namespace) if newPeer != oldPeer || newLinuxIf.HostIfName != oldLinuxIf.HostIfName || newIfaceNs.CompareNamespaces(oldIfaceNs) != 0 { // Change of the peer interface (VETH) or host (TAP) or the namespace requires to create the interface from the scratch. err := plugin.DeleteLinuxInterface(oldLinuxIf) @@ -185,8 +212,8 @@ func (plugin *LinuxInterfaceConfigurator) ModifyLinuxInterface(newLinuxIf, oldLi plugin.addToCache(newLinuxIf, peer) // Verify required namespace - if !plugin.NsHandler.IsNamespaceAvailable(newLinuxIf.Namespace) { - plugin.Log.Errorf("unable to configure linux interface %v: interface namespace is not available", + if !plugin.nsHandler.IsNamespaceAvailable(newLinuxIf.Namespace) { + plugin.log.Errorf("unable to configure linux interface %v: interface namespace is not available", newLinuxIf.HostIfName) return nil } @@ -195,28 +222,28 @@ func (plugin *LinuxInterfaceConfigurator) ModifyLinuxInterface(newLinuxIf, oldLi if newLinuxIf.Type == interfaces.LinuxInterfaces_VETH { if peer == nil { // Interface doesn't actually exist physically. - plugin.Log.Infof("cannot configure linux interface %v: peer interface %v is not configured yet", + plugin.log.Infof("cannot configure linux interface %v: peer interface %v is not configured yet", newLinuxIf.HostIfName, newPeer) return nil } - if !plugin.NsHandler.IsNamespaceAvailable(oldLinuxIf.Namespace) { - plugin.Log.Warnf("unable to modify linux interface %v: peer interface namespace is not available", + if !plugin.nsHandler.IsNamespaceAvailable(oldLinuxIf.Namespace) { + plugin.log.Warnf("unable to modify linux interface %v: peer interface namespace is not available", oldLinuxIf.HostIfName) return nil } - if !plugin.NsHandler.IsNamespaceAvailable(newLinuxIf.Namespace) { - plugin.Log.Warnf("unable to modify linux interface %v: interface namespace is not available", + if !plugin.nsHandler.IsNamespaceAvailable(newLinuxIf.Namespace) { + plugin.log.Warnf("unable to modify linux interface %v: interface namespace is not available", newLinuxIf.HostIfName) return nil } } else if newLinuxIf.Type == interfaces.LinuxInterfaces_AUTO_TAP { - if !plugin.NsHandler.IsNamespaceAvailable(newLinuxIf.Namespace) { + if !plugin.nsHandler.IsNamespaceAvailable(newLinuxIf.Namespace) { // Interface doesn't actually exist physically. - plugin.Log.WithField("ifName", newLinuxIf.Name).Debug("Linux interface is not ready to be re-configured") + plugin.log.WithField("ifName", newLinuxIf.Name).Debug("Linux interface is not ready to be re-configured") return nil } } else { - plugin.Log.Warnf("Unknown interface type %v", newLinuxIf.Type) + plugin.log.Warnf("Unknown interface type %v", newLinuxIf.Type) return nil } @@ -233,7 +260,7 @@ func (plugin *LinuxInterfaceConfigurator) DeleteLinuxInterface(linuxIf *interfac defer plugin.cfgLock.Unlock() plugin.handleOptionalHostIfName(linuxIf) - plugin.Log.Infof("Removing Linux interface %v", linuxIf.HostIfName) + plugin.log.Infof("Removing Linux interface %v", linuxIf.HostIfName) oldConfig := plugin.removeFromCache(linuxIf) var peerConfig *LinuxInterfaceConfig @@ -242,31 +269,38 @@ func (plugin *LinuxInterfaceConfigurator) DeleteLinuxInterface(linuxIf *interfac } if linuxIf.Type == interfaces.LinuxInterfaces_AUTO_TAP { + if _, _, exists := plugin.ifCachedConfigs.LookupIdx(linuxIf.HostIfName); exists { + // Unregister TAP from the in-memory map + plugin.log.Infof("Removing Linux Tap interface %v from cache", linuxIf.HostIfName) + plugin.ifCachedConfigs.UnregisterName(linuxIf.HostIfName) + return nil + } + return plugin.deleteTapInterface(oldConfig) } else if linuxIf.Type == interfaces.LinuxInterfaces_VETH { return plugin.deleteVethInterface(oldConfig, peerConfig) } - plugin.Log.Warnf("Unknown type of interface: %v", linuxIf.Type) + plugin.log.Warnf("Unknown type of interface: %v", linuxIf.Type) return nil } // Validate, create and configure VETH type linux interface func (plugin *LinuxInterfaceConfigurator) configureVethInterface(ifConfig, peerConfig *LinuxInterfaceConfig) error { - plugin.Log.WithFields(logging.Fields{"name": ifConfig.config.Name, "hostName": ifConfig.config.HostIfName, + plugin.log.WithFields(logging.Fields{"name": ifConfig.config.Name, "hostName": ifConfig.config.HostIfName, "peer": ifConfig.config.Veth.PeerIfName}).Debug("Configuring new Veth interface") // Create VETH after both end's configs and target namespaces are available. if peerConfig == nil { - plugin.Log.Infof("cannot configure linux interface %v: peer interface %v is not configured yet", + plugin.log.Infof("cannot configure linux interface %v: peer interface %v is not configured yet", ifConfig.config.HostIfName, ifConfig.config.Veth.PeerIfName) return nil } - if !plugin.NsHandler.IsNamespaceAvailable(ifConfig.config.Namespace) { - plugin.Log.Warnf("unable to configure linux interface %v: interface namespace is not available", + if !plugin.nsHandler.IsNamespaceAvailable(ifConfig.config.Namespace) { + plugin.log.Warnf("unable to configure linux interface %v: interface namespace is not available", ifConfig.config.HostIfName) return nil } - if !plugin.NsHandler.IsNamespaceAvailable(peerConfig.config.Namespace) { - plugin.Log.Warnf("unable to configure linux interface %v: peer namespace is not available", + if !plugin.nsHandler.IsNamespaceAvailable(peerConfig.config.Namespace) { + plugin.log.Warnf("unable to configure linux interface %v: peer namespace is not available", ifConfig.config.HostIfName) return nil } @@ -274,10 +308,10 @@ func (plugin *LinuxInterfaceConfigurator) configureVethInterface(ifConfig, peerC nsMgmtCtx := nsplugin.NewNamespaceMgmtCtx() // Prepare generic veth config namespace object - vethNs := plugin.NsHandler.IfNsToGeneric(plugin.NsHandler.GetConfigNamespace()) + vethNs := plugin.nsHandler.IfNsToGeneric(plugin.nsHandler.GetConfigNamespace()) // Switch to veth cfg namespace - revertNs, err := plugin.NsHandler.SwitchNamespace(vethNs, nsMgmtCtx, plugin.Log) + revertNs, err := plugin.nsHandler.SwitchNamespace(vethNs, nsMgmtCtx) if err != nil { return err } @@ -294,27 +328,49 @@ func (plugin *LinuxInterfaceConfigurator) configureVethInterface(ifConfig, peerC return err } - plugin.Log.Infof("Linux interface %v with hostIfName %v configured", ifConfig.config.Name, ifConfig.config.HostIfName) + plugin.log.Infof("Linux interface %v with hostIfName %v configured", ifConfig.config.Name, ifConfig.config.HostIfName) return nil } // Validate and apply linux TAP configuration to the interface. The interface is not created here, it is added // to the default namespace when it's VPP end is configured -func (plugin *LinuxInterfaceConfigurator) configureTapInterface(ifConfig *LinuxInterfaceConfig) error { - plugin.Log.WithFields(logging.Fields{"name": ifConfig.config.Name, +func (plugin *LinuxInterfaceConfigurator) configureTapInterface(hostIfName string, linuxIf *interfaces.LinuxInterfaces_Interface) error { + // TAP (auto) interface looks for existing interface with the same host name or temp name (cached without peer) + var ifConfig *LinuxInterfaceConfig + _, ifConfigData, exists := plugin.ifCachedConfigs.LookupIdx(hostIfName) + if exists { + ifConfig = plugin.addToCache(ifConfigData.Data, nil) + ifConfig.config = ifConfigData.Data + plugin.log.Infof("Using existing Linux Tap interface %v configuration entry %v", hostIfName, ifConfig.config) + } else { + if linuxIf != nil { + ifConfig = plugin.addToCache(linuxIf, nil) + plugin.ifCachedConfigs.RegisterName(hostIfName, plugin.pIfCachedConfigSeq, &ifaceidx.IndexedLinuxInterface{ + Index: plugin.pIfCachedConfigSeq, + Data: ifConfig.config, + }) + plugin.pIfCachedConfigSeq++ + plugin.log.Infof("Creating new Linux Tap interface %v configuration entry %v", hostIfName, ifConfig.config) + } else { + plugin.log.Infof("There is no Linux Tap configuration entry for interface %v", hostIfName) + return nil + } + } + + plugin.log.WithFields(logging.Fields{"name": ifConfig.config.Name, "hostName": ifConfig.config.HostIfName}).Debug("Applying new Linux TAP interface configuration") // Tap interfaces can be processed directly using config and also via linux interface events. This check // should prevent to process the same interface multiple times. - _, _, exists := plugin.IfIndexes.LookupIdx(ifConfig.config.Name) + _, _, exists = plugin.ifIndexes.LookupIdx(ifConfig.config.Name) if exists { - plugin.Log.Debugf("TAP interface %v already processed", ifConfig.config.Name) + plugin.log.Debugf("TAP interface %v already processed", ifConfig.config.Name) return nil } // Search default namespace for appropriate interface - linuxIfs, err := netlink.LinkList() + linuxIfs, err := plugin.ifHandler.GetLinkList() if err != nil { return fmt.Errorf("failed to read linux interfaces: %v", err) } @@ -322,15 +378,15 @@ func (plugin *LinuxInterfaceConfigurator) configureTapInterface(ifConfig *LinuxI nsMgmtCtx := nsplugin.NewNamespaceMgmtCtx() // Verify availability of namespace from configuration - if !plugin.NsHandler.IsNamespaceAvailable(ifConfig.config.Namespace) { - plugin.Log.Errorf("unable to apply linux TAP configuration %v: destination namespace is not available", + if !plugin.nsHandler.IsNamespaceAvailable(ifConfig.config.Namespace) { + plugin.log.Errorf("unable to apply linux TAP configuration %v: destination namespace is not available", ifConfig.config.Name, ifConfig.config.HostIfName) return nil } // Check if TAP temporary name is defined if ifConfig.config.Tap == nil || ifConfig.config.Tap.TempIfName == "" { - plugin.Log.Debugf("Tap interface %v temporary name not defined", ifConfig.config.HostIfName) + plugin.log.Debugf("Tap interface %v temporary name not defined", ifConfig.config.HostIfName) // In such a case, set temp name as host (look for interface named as host name) ifConfig.config.Tap = &interfaces.LinuxInterfaces_Interface_Tap{ TempIfName: ifConfig.config.HostIfName, @@ -345,16 +401,18 @@ func (plugin *LinuxInterfaceConfigurator) configureTapInterface(ifConfig *LinuxI found = true break } - plugin.Log.Debugf("Linux TAP config %v found linux interface %v, but it is not the TAP interface type", + plugin.log.Debugf("Linux TAP config %v found linux interface %v, but it is not the TAP interface type", ifConfig.config.Name, ifConfig.config.HostIfName) } } if !found { - plugin.Log.Debugf("Linux TAP config %v did not found the linux interface with name %v", ifConfig.config.Name, + plugin.log.Debugf("Linux TAP config %v did not found the linux interface with name %v", ifConfig.config.Name, ifConfig.config.Tap.TempIfName) return nil } + plugin.ifCachedConfigs.UnregisterName(ifConfig.config.HostIfName) + return plugin.configureLinuxInterface(nsMgmtCtx, ifConfig.config) } @@ -366,18 +424,18 @@ func (plugin *LinuxInterfaceConfigurator) configureLinuxInterface(nsMgmtCtx *nsp // Use temporary/host name (according to type) to set interface to different namespace if ifConfig.Type == interfaces.LinuxInterfaces_AUTO_TAP { - err = plugin.NsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.Tap.TempIfName, ifConfig.Namespace, plugin.Log, plugin.Stopwatch) + err = plugin.nsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.Tap.TempIfName, ifConfig.Namespace) if err != nil { return fmt.Errorf("failed to set TAP interface %s to namespace %s: %v", ifConfig.Tap.TempIfName, ifConfig.Namespace, err) } } else { - err = plugin.NsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.HostIfName, ifConfig.Namespace, plugin.Log, plugin.Stopwatch) + err = plugin.nsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.HostIfName, ifConfig.Namespace) if err != nil { return fmt.Errorf("failed to set interface %s to namespace %s: %v", ifConfig.HostIfName, ifConfig.Namespace, err) } } // Continue configuring interface in its namespace. - revertNs, err := plugin.NsHandler.SwitchToNamespace(nsMgmtCtx, ifConfig.Namespace) + revertNs, err := plugin.nsHandler.SwitchToNamespace(nsMgmtCtx, ifConfig.Namespace) if err != nil { return fmt.Errorf("failed to switch network namespace: %v", err) } @@ -386,14 +444,13 @@ func (plugin *LinuxInterfaceConfigurator) configureLinuxInterface(nsMgmtCtx *nsp // For TAP interfaces only - rename interface to the actual host name if needed if ifConfig.Type == interfaces.LinuxInterfaces_AUTO_TAP { if ifConfig.HostIfName != ifConfig.Tap.TempIfName { - if err := linuxcalls.RenameInterface(ifConfig.Tap.TempIfName, ifConfig.HostIfName, - measure.GetTimeLog("rename-linux-interface", plugin.Stopwatch)); err != nil { - plugin.Log.Errorf("Failed to rename TAP interface from %s to %s: %v", ifConfig.Tap.TempIfName, + if err := plugin.ifHandler.RenameInterface(ifConfig.Tap.TempIfName, ifConfig.HostIfName); err != nil { + plugin.log.Errorf("Failed to rename TAP interface from %s to %s: %v", ifConfig.Tap.TempIfName, ifConfig.HostIfName, err) return err } } else { - plugin.Log.Debugf("Renaming of TAP interface %v skipped, host name is the same as temporary", ifConfig.HostIfName) + plugin.log.Debugf("Renaming of TAP interface %v skipped, host name is the same as temporary", ifConfig.HostIfName) } } @@ -401,57 +458,69 @@ func (plugin *LinuxInterfaceConfigurator) configureLinuxInterface(nsMgmtCtx *nsp // Set interface up. if ifConfig.Enabled { - err := linuxcalls.InterfaceAdminUp(ifConfig.HostIfName, measure.GetTimeLog("iface_admin_up", plugin.Stopwatch)) + err := plugin.ifHandler.SetInterfaceUp(ifConfig.HostIfName) if nil != err { wasErr = fmt.Errorf("failed to enable Linux interface: %v", err) - plugin.Log.Error(wasErr) + plugin.log.Error(wasErr) } } // Set interface MAC address if ifConfig.PhysAddress != "" { - err = linuxcalls.SetInterfaceMac(ifConfig.HostIfName, ifConfig.PhysAddress, nil) + err = plugin.ifHandler.SetInterfaceMac(ifConfig.HostIfName, ifConfig.PhysAddress) if err != nil { wasErr = fmt.Errorf("cannot assign MAC '%s': %v", ifConfig.PhysAddress, err) - plugin.Log.Error(wasErr) + plugin.log.Error(wasErr) } - plugin.Log.Debugf("MAC '%s' set to interface %s", ifConfig.PhysAddress, ifConfig.HostIfName) + plugin.log.Debugf("MAC '%s' set to interface %s", ifConfig.PhysAddress, ifConfig.HostIfName) } // Set interface IP addresses ipAddresses, err := addrs.StrAddrsToStruct(ifConfig.IpAddresses) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) + wasErr = err + } + // Get all configured interface addresses + confAddresses, err := plugin.ifHandler.GetAddressList(ifConfig.HostIfName) + if err != nil { + plugin.log.Error(err) wasErr = err } for i, ipAddress := range ipAddresses { - err = linuxcalls.AddInterfaceIP(plugin.Log, ifConfig.HostIfName, ipAddresses[i], nil) + // Check link local addresses which cannot be reassigned + if addressExists(confAddresses, ipAddresses[i]) { + plugin.log.Debugf("Cannot assign %s to interface %s, IP already exists", + ipAddresses[i].IP.String(), ifConfig.HostIfName) + continue + } + err = plugin.ifHandler.AddInterfaceIP(ifConfig.HostIfName, ipAddresses[i]) if err != nil { err = fmt.Errorf("cannot assign IP address '%s': %v", ipAddress, err) - plugin.Log.Error(err) + plugin.log.Error(err) wasErr = err } else { - plugin.Log.Debugf("IP address '%s' set to interface %s", ipAddress, ifConfig.HostIfName) + plugin.log.Debugf("IP address '%s' set to interface %s", ipAddress, ifConfig.HostIfName) } } if ifConfig.Mtu != 0 { - linuxcalls.SetInterfaceMTU(ifConfig.HostIfName, int(ifConfig.Mtu), nil) - plugin.Log.Debugf("MTU %d set to interface %s", ifConfig.Mtu, ifConfig.HostIfName) + plugin.ifHandler.SetInterfaceMTU(ifConfig.HostIfName, int(ifConfig.Mtu)) + plugin.log.Debugf("MTU %d set to interface %s", ifConfig.Mtu, ifConfig.HostIfName) } - idx := GetLinuxInterfaceIndex(ifConfig.HostIfName) - if idx < 0 { - return fmt.Errorf("failed to get index of the Linux interface %s", ifConfig.HostIfName) + netIf, err := plugin.ifHandler.GetInterfaceByName(ifConfig.HostIfName) + if err != nil { + return fmt.Errorf("failed to get index of the Linux interface %s: %v", ifConfig.HostIfName, err) } // Register interface with its original name and store host name in metadata - plugin.IfIndexes.RegisterName(ifConfig.Name, plugin.IfIdxSeq, &ifaceidx.IndexedLinuxInterface{ - Index: uint32(idx), + plugin.ifIndexes.RegisterName(ifConfig.Name, plugin.ifIdxSeq, &ifaceidx.IndexedLinuxInterface{ + Index: uint32(netIf.Index), Data: ifConfig, }) - plugin.IfIdxSeq++ - plugin.Log.WithFields(logging.Fields{"ifName": ifConfig.Name, "ifIdx": idx}). + plugin.ifIdxSeq++ + plugin.log.WithFields(logging.Fields{"ifName": ifConfig.Name, "ifIdx": netIf.Index}). Info("An entry added into ifState.") return wasErr @@ -461,16 +530,16 @@ func (plugin *LinuxInterfaceConfigurator) configureLinuxInterface(nsMgmtCtx *nsp func (plugin *LinuxInterfaceConfigurator) modifyLinuxInterface(nsMgmtCtx *nsplugin.NamespaceMgmtCtx, oldIfConfig, newIfConfig *interfaces.LinuxInterfaces_Interface) error { // Switch to required namespace - revertNs, err := plugin.NsHandler.SwitchToNamespace(nsMgmtCtx, oldIfConfig.Namespace) + revertNs, err := plugin.nsHandler.SwitchToNamespace(nsMgmtCtx, oldIfConfig.Namespace) if err != nil { return fmt.Errorf("failed to switch network namespace: %v", err) } defer revertNs() // Verify that the interface already exists in the Linux namespace. - idx := GetLinuxInterfaceIndex(oldIfConfig.HostIfName) - if idx < 0 { - plugin.Log.Debugf("Host interface %v was not found", oldIfConfig.HostIfName) + _, err = plugin.ifHandler.GetInterfaceByName(oldIfConfig.HostIfName) + if err != nil { + plugin.log.Debugf("Host interface %v was not found", oldIfConfig.HostIfName) // If host does not exist, configure new setup as a new one return plugin.ConfigureLinuxInterface(newIfConfig) } @@ -480,9 +549,9 @@ func (plugin *LinuxInterfaceConfigurator) modifyLinuxInterface(nsMgmtCtx *nsplug // Set admin status. if newIfConfig.Enabled != oldIfConfig.Enabled { if newIfConfig.Enabled { - err = linuxcalls.InterfaceAdminUp(newIfConfig.HostIfName, measure.GetTimeLog("iface_admin_up", plugin.Stopwatch)) + err = plugin.ifHandler.SetInterfaceUp(newIfConfig.HostIfName) } else { - err = linuxcalls.InterfaceAdminDown(newIfConfig.HostIfName, measure.GetTimeLog("iface_admin_down", plugin.Stopwatch)) + err = plugin.ifHandler.SetInterfaceDown(newIfConfig.HostIfName) } if nil != err { wasErr = fmt.Errorf("failed to enable/disable Linux interface: %v", err) @@ -491,44 +560,56 @@ func (plugin *LinuxInterfaceConfigurator) modifyLinuxInterface(nsMgmtCtx *nsplug // Configure new MAC address if set. if newIfConfig.PhysAddress != "" && newIfConfig.PhysAddress != oldIfConfig.PhysAddress { - plugin.Log.WithFields(logging.Fields{"PhysAddress": newIfConfig.PhysAddress, "hostIfName": newIfConfig.HostIfName}). + plugin.log.WithFields(logging.Fields{"PhysAddress": newIfConfig.PhysAddress, "hostIfName": newIfConfig.HostIfName}). Debug("MAC address re-configured.") - err := linuxcalls.SetInterfaceMac(newIfConfig.HostIfName, newIfConfig.PhysAddress, measure.GetTimeLog("set_iface_mac", plugin.Stopwatch)) + err := plugin.ifHandler.SetInterfaceMac(newIfConfig.HostIfName, newIfConfig.PhysAddress) if err != nil { wasErr = fmt.Errorf("failed to assign physical address to a Linux interface: %v", err) - plugin.Log.Error(wasErr) + plugin.log.Error(wasErr) } } // IP addresses newAddrs, err := addrs.StrAddrsToStruct(newIfConfig.IpAddresses) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) wasErr = err } oldAddrs, err := addrs.StrAddrsToStruct(oldIfConfig.IpAddresses) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) wasErr = err } var del, add []*net.IPNet del, add = addrs.DiffAddr(newAddrs, oldAddrs) for i := range del { - plugin.Log.WithFields(logging.Fields{"IP address": del[i], "hostIfName": newIfConfig.HostIfName}).Debug("IP address deleted.") - err := linuxcalls.DelInterfaceIP(newIfConfig.HostIfName, del[i], measure.GetTimeLog("del_iface_ip", plugin.Stopwatch)) + plugin.log.WithFields(logging.Fields{"IP address": del[i], "hostIfName": newIfConfig.HostIfName}).Debug("IP address deleted.") + err := plugin.ifHandler.DelInterfaceIP(newIfConfig.HostIfName, del[i]) if nil != err { wasErr = fmt.Errorf("failed to unassign IPv4 address from a Linux interface: %v", err) - plugin.Log.Error(wasErr) + plugin.log.Error(wasErr) } } + // Get all configured interface addresses + confAddresses, err := plugin.ifHandler.GetAddressList(newIfConfig.HostIfName) + if err != nil { + plugin.log.Error(err) + wasErr = err + } for i := range add { - plugin.Log.WithFields(logging.Fields{"IP address": add[i], "hostIfName": newIfConfig.HostIfName}).Debug("IP address added.") - err := linuxcalls.AddInterfaceIP(plugin.Log, newIfConfig.HostIfName, add[i], measure.GetTimeLog("add_iface_ip", plugin.Stopwatch)) + plugin.log.WithFields(logging.Fields{"IP address": add[i], "hostIfName": newIfConfig.HostIfName}).Debug("IP address added.") + // Check link local addresses which cannot be reassigned + if addressExists(confAddresses, add[i]) { + plugin.log.Debugf("Cannot assign %s to interface %s, IP already exists", + add[i].IP.String(), newIfConfig.HostIfName) + continue + } + err := plugin.ifHandler.AddInterfaceIP(newIfConfig.HostIfName, add[i]) if nil != err { wasErr = fmt.Errorf("failed to assign IPv4 address to a Linux interface: %v", err) - plugin.Log.Error(wasErr) + plugin.log.Error(wasErr) } } @@ -536,73 +617,66 @@ func (plugin *LinuxInterfaceConfigurator) modifyLinuxInterface(nsMgmtCtx *nsplug if newIfConfig.Mtu != oldIfConfig.Mtu { mtu := newIfConfig.Mtu if mtu > 0 { - plugin.Log.WithFields(logging.Fields{"MTU": mtu, "hostIfName": newIfConfig.HostIfName}).Debug("MTU re-configured.") - err := linuxcalls.SetInterfaceMTU(newIfConfig.HostIfName, int(mtu), measure.GetTimeLog("set_iface_mtu", plugin.Stopwatch)) + plugin.log.WithFields(logging.Fields{"MTU": mtu, "hostIfName": newIfConfig.HostIfName}).Debug("MTU re-configured.") + err := plugin.ifHandler.SetInterfaceMTU(newIfConfig.HostIfName, int(mtu)) if nil != err { wasErr = fmt.Errorf("failed to set MTU of a Linux interface: %v", err) - plugin.Log.Error(wasErr) + plugin.log.Error(wasErr) } } } - plugin.Log.Infof("Linux interface %v modified", newIfConfig.Name) + plugin.log.Infof("Linux interface %v modified", newIfConfig.Name) return wasErr } // Remove VETH type interface func (plugin *LinuxInterfaceConfigurator) deleteVethInterface(ifConfig, peerConfig *LinuxInterfaceConfig) error { - plugin.Log.Debugf("Removing VETH interface %v ", ifConfig.config.HostIfName) + plugin.log.Debugf("Removing VETH interface %v ", ifConfig.config.HostIfName) // Veth interface removal - if ifConfig == nil || ifConfig.config == nil || !plugin.NsHandler.IsNamespaceAvailable(ifConfig.config.Namespace) || - peerConfig == nil || peerConfig.config == nil || !plugin.NsHandler.IsNamespaceAvailable(peerConfig.config.Namespace) { + if ifConfig == nil || ifConfig.config == nil || !plugin.nsHandler.IsNamespaceAvailable(ifConfig.config.Namespace) || + peerConfig == nil || peerConfig.config == nil || !plugin.nsHandler.IsNamespaceAvailable(peerConfig.config.Namespace) { name := "" if ifConfig != nil && ifConfig.config != nil { name = ifConfig.config.Name } - plugin.Log.WithField("ifName", name).Debug("VETH interface doesn't exist") + plugin.log.WithField("ifName", name).Debug("VETH interface doesn't exist") return nil } // Move to the namespace with the interface. nsMgmtCtx := nsplugin.NewNamespaceMgmtCtx() - revertNs, err := plugin.NsHandler.SwitchToNamespace(nsMgmtCtx, ifConfig.config.Namespace) + revertNs, err := plugin.nsHandler.SwitchToNamespace(nsMgmtCtx, ifConfig.config.Namespace) if err != nil { return fmt.Errorf("failed to switch network namespace: %v", err) } defer revertNs() - err = linuxcalls.DelVethInterfacePair(ifConfig.config.HostIfName, peerConfig.config.HostIfName, - plugin.Log, measure.GetTimeLog("del_veth_iface", plugin.Stopwatch)) + err = plugin.ifHandler.DelVethInterfacePair(ifConfig.config.HostIfName, peerConfig.config.HostIfName) if err != nil { return fmt.Errorf("failed to delete VETH interface: %v", err) } // Unregister both VETH ends from the in-memory map (following triggers notifications for all subscribers). - plugin.IfIndexes.UnregisterName(ifConfig.config.Name) - plugin.IfIndexes.UnregisterName(peerConfig.config.Name) + plugin.ifIndexes.UnregisterName(ifConfig.config.Name) + plugin.ifIndexes.UnregisterName(peerConfig.config.Name) - plugin.Log.Infof("Linux Interface %v removed", ifConfig.config.Name) + plugin.log.Infof("Linux Interface %v removed", ifConfig.config.Name) return nil } -// Un-configure TAP interface, set original name and return it to the default namespace (do not delete, -// the interface will be removed together with the peer (VPP TAP)) -func (plugin *LinuxInterfaceConfigurator) deleteTapInterface(ifConfig *LinuxInterfaceConfig) error { - if ifConfig == nil || ifConfig.config == nil { - plugin.Log.Warn("Unable to remove linux TAP configuration: no data available") - return nil - } - plugin.Log.Debugf("Removing Linux TAP configuration %v from interface %v ", ifConfig.config.Name, ifConfig.config.HostIfName) - if !plugin.NsHandler.IsNamespaceAvailable(ifConfig.config.Namespace) { - plugin.Log.Warnf("Unable to remove linux TAP configuration: cannot access namespace %v", ifConfig.config.Namespace.Name) +func (plugin *LinuxInterfaceConfigurator) moveTapInterfaceToDefaultNamespace(ifConfig *interfaces.LinuxInterfaces_Interface) error { + plugin.log.Infof("moving linux tap interface %v to default namespace", ifConfig.HostIfName) + if !plugin.nsHandler.IsNamespaceAvailable(ifConfig.Namespace) { + plugin.log.Warnf("Unable to remove linux TAP configuration: cannot access namespace %v", ifConfig.Namespace.Name) return nil } // Move to the namespace with the interface. nsMgmtCtx := nsplugin.NewNamespaceMgmtCtx() - revertNs, err := plugin.NsHandler.SwitchToNamespace(nsMgmtCtx, ifConfig.config.Namespace) + revertNs, err := plugin.nsHandler.SwitchToNamespace(nsMgmtCtx, ifConfig.Namespace) if err != nil { return fmt.Errorf("failed to switch network namespace: %v", err) } @@ -611,10 +685,10 @@ func (plugin *LinuxInterfaceConfigurator) deleteTapInterface(ifConfig *LinuxInte // Get all IP addresses currently configured on the interface. It is not enough to just remove all IP addresses // present in the ifConfig object, there can be default IP address which needs to be removed as well. var ipAddresses []*net.IPNet - link, err := netlink.LinkList() + link, err := plugin.ifHandler.GetLinkList() for _, linuxIf := range link { - if linuxIf.Attrs().Name == ifConfig.config.HostIfName { - IPlist, err := netlink.AddrList(linuxIf, netlink.FAMILY_ALL) + if linuxIf.Attrs().Name == ifConfig.HostIfName { + IPlist, err := plugin.ifHandler.GetAddressList(linuxIf.Attrs().Name) if err != nil { return err } @@ -627,94 +701,107 @@ func (plugin *LinuxInterfaceConfigurator) deleteTapInterface(ifConfig *LinuxInte // Remove all IP addresses from the TAP var wasErr error for _, ipAddress := range ipAddresses { - if err := linuxcalls.DelInterfaceIP(ifConfig.config.HostIfName, ipAddress, nil); err != nil { - plugin.Log.Error(err) + if err := plugin.ifHandler.DelInterfaceIP(ifConfig.HostIfName, ipAddress); err != nil { + plugin.log.Error(err) wasErr = err } } // Move back to default namespace - if ifConfig.config.Type == interfaces.LinuxInterfaces_AUTO_TAP { + if ifConfig.Type == interfaces.LinuxInterfaces_AUTO_TAP { // Rename to its original name (if possible) - if ifConfig.config.Tap == nil || ifConfig.config.Tap.TempIfName == "" { - plugin.Log.Warnf("Cannot restore linux TAP %v interface state, original name (temp) is not available", ifConfig.config.HostIfName) - ifConfig.config.Tap = &interfaces.LinuxInterfaces_Interface_Tap{ - TempIfName: ifConfig.config.HostIfName, + if ifConfig.Tap == nil || ifConfig.Tap.TempIfName == "" { + plugin.log.Warnf("Cannot restore linux TAP %v interface state, original name (temp) is not available", ifConfig.HostIfName) + ifConfig.Tap = &interfaces.LinuxInterfaces_Interface_Tap{ + TempIfName: ifConfig.HostIfName, } } - if ifConfig.config.Tap.TempIfName == ifConfig.config.HostIfName { - plugin.Log.Debugf("Renaming of TAP interface %v skipped, host name is the same as temporary", ifConfig.config.HostIfName) + if ifConfig.Tap.TempIfName == ifConfig.HostIfName { + plugin.log.Debugf("Renaming of TAP interface %v skipped, host name is the same as temporary", ifConfig.HostIfName) } else { - if err := linuxcalls.RenameInterface(ifConfig.config.HostIfName, ifConfig.config.Tap.TempIfName, - measure.GetTimeLog("rename-linux-interface", plugin.Stopwatch)); err != nil { + if err := plugin.ifHandler.RenameInterface(ifConfig.HostIfName, ifConfig.Tap.TempIfName); err != nil { - plugin.Log.Errorf("Failed to rename TAP interface from %s to %s: %v", ifConfig.config.HostIfName, - ifConfig.config.Tap.TempIfName, err) + plugin.log.Errorf("Failed to rename TAP interface from %s to %s: %v", ifConfig.HostIfName, + ifConfig.Tap.TempIfName, err) wasErr = err } } - err = plugin.NsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.config.Tap.TempIfName, &interfaces.LinuxInterfaces_Interface_Namespace{}, - plugin.Log, plugin.Stopwatch) + err = plugin.nsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.Tap.TempIfName, &interfaces.LinuxInterfaces_Interface_Namespace{}) if err != nil { - return fmt.Errorf("failed to set Linux TAP interface %s to namespace %s: %v", ifConfig.config.Tap.TempIfName, "default", err) + return fmt.Errorf("failed to set Linux TAP interface %s to namespace %s: %v", ifConfig.Tap.TempIfName, "default", err) } } else { - err = plugin.NsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.config.HostIfName, &interfaces.LinuxInterfaces_Interface_Namespace{}, - plugin.Log, plugin.Stopwatch) + err = plugin.nsHandler.SetInterfaceNamespace(nsMgmtCtx, ifConfig.HostIfName, &interfaces.LinuxInterfaces_Interface_Namespace{}) if err != nil { - return fmt.Errorf("failed to set Linux TAP interface %s to namespace %s: %v", ifConfig.config.HostIfName, "default", err) + return fmt.Errorf("failed to set Linux TAP interface %s to namespace %s: %v", ifConfig.HostIfName, "default", err) } } + return wasErr +} + +// Un-configure TAP interface, set original name and return it to the default namespace (do not delete, +// the interface will be removed together with the peer (VPP TAP)) +func (plugin *LinuxInterfaceConfigurator) deleteTapInterface(ifConfig *LinuxInterfaceConfig) error { + if ifConfig == nil || ifConfig.config == nil { + plugin.log.Warn("Unable to remove linux TAP configuration: no data available") + return nil + } + plugin.log.Debugf("Removing Linux TAP configuration %v from interface %v ", ifConfig.config.Name, ifConfig.config.HostIfName) - // Unregister TAP from the in-memory map - plugin.IfIndexes.UnregisterName(ifConfig.config.Name) + // Move to default namespace + err := plugin.moveTapInterfaceToDefaultNamespace(ifConfig.config) - return wasErr + if err == nil { + // Unregister TAP from the in-memory map + plugin.ifIndexes.UnregisterName(ifConfig.config.Name) + } + + return err } // removeObsoleteVeth deletes VETH interface which should no longer exist. func (plugin *LinuxInterfaceConfigurator) removeObsoleteVeth(nsMgmtCtx *nsplugin.NamespaceMgmtCtx, vethName string, hostIfName string, ns *interfaces.LinuxInterfaces_Interface_Namespace) error { - plugin.Log.WithFields(logging.Fields{"vethName": vethName, "hostIfName": hostIfName, "ns": plugin.NsHandler.IfaceNsToString(ns)}). + plugin.log.WithFields(logging.Fields{"vethName": vethName, "hostIfName": hostIfName, "ns": plugin.nsHandler.IfaceNsToString(ns)}). Debug("Attempting to remove obsolete VETH") - revertNs, err := plugin.NsHandler.SwitchToNamespace(nsMgmtCtx, ns) + revertNs, err := plugin.nsHandler.SwitchToNamespace(nsMgmtCtx, ns) defer revertNs() if err != nil { // Already removed as namespace no longer exists. - plugin.IfIndexes.UnregisterName(vethName) + plugin.ifIndexes.UnregisterName(vethName) return nil } - exists, err := linuxcalls.InterfaceExists(hostIfName, measure.GetTimeLog("iface_exists", plugin.Stopwatch)) + exists, err := plugin.ifHandler.InterfaceExists(hostIfName) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) return err } if !exists { // already removed - plugin.IfIndexes.UnregisterName(vethName) + plugin.ifIndexes.UnregisterName(vethName) return nil } - ifType, err := linuxcalls.GetInterfaceType(hostIfName, measure.GetTimeLog("get_iface_type", plugin.Stopwatch)) + ifType, err := plugin.ifHandler.GetInterfaceType(hostIfName) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) return err } if ifType != veth { return fmt.Errorf("interface '%s' already exists and is not VETH", vethName) } - peerName, err := linuxcalls.GetVethPeerName(hostIfName, measure.GetTimeLog("get_veth_peer", plugin.Stopwatch)) + peerName, err := plugin.ifHandler.GetVethPeerName(hostIfName) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) return err } - plugin.Log.WithFields(logging.Fields{"ifName": vethName, "peerName": peerName}). + plugin.log.WithFields(logging.Fields{"ifName": vethName, "peerName": peerName}). Debug("Removing obsolete VETH interface") - err = linuxcalls.DelVethInterfacePair(hostIfName, peerName, plugin.Log, measure.GetTimeLog("del_veth_iface", plugin.Stopwatch)) + err = plugin.ifHandler.DelVethInterfacePair(hostIfName, peerName) if err != nil { - plugin.Log.Error(err) + plugin.log.Error(err) return err } - plugin.IfIndexes.UnregisterName(vethName) + plugin.ifIndexes.UnregisterName(vethName) return nil } @@ -730,15 +817,15 @@ func (plugin *LinuxInterfaceConfigurator) addVethInterfacePair(nsMgmtCtx *nsplug return err } // VETH is first created in its own cfg namespace so it has to be removed there as well. - err = plugin.removeObsoleteVeth(nsMgmtCtx, iface.Name, iface.HostIfName, plugin.NsHandler.GetConfigNamespace()) + err = plugin.removeObsoleteVeth(nsMgmtCtx, iface.Name, iface.HostIfName, plugin.nsHandler.GetConfigNamespace()) if err != nil { return err } - err = plugin.removeObsoleteVeth(nsMgmtCtx, peer.Name, peer.HostIfName, plugin.NsHandler.GetConfigNamespace()) + err = plugin.removeObsoleteVeth(nsMgmtCtx, peer.Name, peer.HostIfName, plugin.nsHandler.GetConfigNamespace()) if err != nil { return err } - err = linuxcalls.AddVethInterfacePair(iface.HostIfName, peer.HostIfName, plugin.Log, measure.GetTimeLog("add_veth_iface", plugin.Stopwatch)) + err = plugin.ifHandler.AddVethInterfacePair(iface.HostIfName, peer.HostIfName) if err != nil { return fmt.Errorf("failed to create new VETH: %v", err) } @@ -746,75 +833,9 @@ func (plugin *LinuxInterfaceConfigurator) addVethInterfacePair(nsMgmtCtx *nsplug return nil } -// Watcher receives events from state updater about created/removed linux interfaces and performs appropriate actions -func (plugin *LinuxInterfaceConfigurator) watchLinuxStateUpdater() { - plugin.Log.Debugf("Linux interface state watcher started") - - for { - linuxIf := <-plugin.ifStateChan - linuxIfName := linuxIf.attributes.Name - - switch { - case linuxIf.interfaceType == tap: - if linuxIf.interfaceState == netlink.OperDown { - // Find whether it is a registered tap interface and un-register it. Otherwise the change is ignored. - for _, indexedName := range plugin.IfIndexes.GetMapping().ListNames() { - _, ifConfigMeta, found := plugin.IfIndexes.LookupIdx(indexedName) - if !found { - // Should not happen - plugin.Log.Warnf("Interface %v not found in the mapping", indexedName) - continue - } - if ifConfigMeta == nil { - // Should not happen - plugin.Log.Warnf("Interface %v metadata does not exist", indexedName) - continue - } - if ifConfigMeta.Data.HostIfName == "" { - plugin.Log.Warnf("No info about host name for %v", indexedName) - continue - } - if ifConfigMeta.Data.HostIfName == linuxIfName { - // Registered Linux TAP interface was removed. However it should not be removed from cache - // because the configuration still exists in the VPP - plugin.IfIndexes.UnregisterName(linuxIfName) - } - } - } else { - // Event that TAP interface was created. - plugin.Log.Debugf("Received data about linux TAP interface %s", linuxIfName) - - // Look for TAP which is using this interface as the other end - for _, ifConfig := range plugin.intfByName { - if ifConfig == nil || ifConfig.config == nil { - plugin.Log.Warnf("Cached config for interface %v is empty", linuxIfName) - continue - } - - if (ifConfig.config.Tap != nil && ifConfig.config.Tap.TempIfName == linuxIfName) || - ifConfig.config.HostIfName == linuxIfName { - // Skip processed interfaces - _, _, exists := plugin.IfIndexes.LookupIdx(ifConfig.config.Name) - if exists { - continue - } - // Host interface was found, configure linux TAP - err := plugin.ConfigureLinuxInterface(ifConfig.config) - if err != nil { - plugin.Log.Error(err) - } - } - } - } - default: - plugin.Log.Debugf("Linux interface type %v state processing skipped", linuxIf.interfaceType) - } - } -} - // getInterfaceConfig returns cached configuration of a given interface. func (plugin *LinuxInterfaceConfigurator) getInterfaceConfig(ifName string) *LinuxInterfaceConfig { - config, ok := plugin.intfByName[ifName] + config, ok := plugin.ifByName[ifName] if ok { return config } @@ -824,39 +845,39 @@ func (plugin *LinuxInterfaceConfigurator) getInterfaceConfig(ifName string) *Lin // addToCache adds interface configuration into the cache. func (plugin *LinuxInterfaceConfigurator) addToCache(iface *interfaces.LinuxInterfaces_Interface, peerIface *LinuxInterfaceConfig) *LinuxInterfaceConfig { config := &LinuxInterfaceConfig{config: iface, peer: peerIface} - plugin.intfByName[iface.Name] = config + plugin.ifByName[iface.Name] = config if peerIface != nil { peerIface.peer = config } if iface.Namespace != nil && iface.Namespace.Type == interfaces.LinuxInterfaces_Interface_Namespace_MICROSERVICE_REF_NS { - if _, ok := plugin.intfsByMicroservice[iface.Namespace.Microservice]; ok { - plugin.intfsByMicroservice[iface.Namespace.Microservice] = append(plugin.intfsByMicroservice[iface.Namespace.Microservice], config) + if _, ok := plugin.ifsByMs[iface.Namespace.Microservice]; ok { + plugin.ifsByMs[iface.Namespace.Microservice] = append(plugin.ifsByMs[iface.Namespace.Microservice], config) } else { - plugin.intfsByMicroservice[iface.Namespace.Microservice] = []*LinuxInterfaceConfig{config} + plugin.ifsByMs[iface.Namespace.Microservice] = []*LinuxInterfaceConfig{config} } } - plugin.Log.Debugf("Linux interface with name %v added to cache (peer: %v)", + plugin.log.Debugf("Linux interface with name %v added to cache (peer: %v)", iface.Name, peerIface) return config } // removeFromCache removes interfaces configuration from the cache. func (plugin *LinuxInterfaceConfigurator) removeFromCache(iface *interfaces.LinuxInterfaces_Interface) *LinuxInterfaceConfig { - if config, ok := plugin.intfByName[iface.Name]; ok { + if config, ok := plugin.ifByName[iface.Name]; ok { if config.peer != nil { config.peer.peer = nil } if iface.Namespace != nil && iface.Namespace.Type == interfaces.LinuxInterfaces_Interface_Namespace_MICROSERVICE_REF_NS { var filtered []*LinuxInterfaceConfig - for _, intf := range plugin.intfsByMicroservice[iface.Namespace.Microservice] { + for _, intf := range plugin.ifsByMs[iface.Namespace.Microservice] { if intf.config.Name != iface.Name { filtered = append(filtered, intf) } } - plugin.intfsByMicroservice[iface.Namespace.Microservice] = filtered + plugin.ifsByMs[iface.Namespace.Microservice] = filtered } - delete(plugin.intfByName, iface.Name) - plugin.Log.Debugf("Linux interface with name %v was removed from cache", iface.Name) + delete(plugin.ifByName, iface.Name) + plugin.log.Debugf("Linux interface with name %v was removed from cache", iface.Name) return config } return nil @@ -871,15 +892,18 @@ func (plugin *LinuxInterfaceConfigurator) watchMicroservices(ctx context.Context for { select { - case msEvent := <-plugin.ifMicroserviceNotif: + case msEvent := <-plugin.ifMsNotif: + if msEvent == nil { + continue + } microservice := msEvent.Microservice if microservice == nil { - plugin.Log.Error("Empty microservice event") + plugin.log.Error("Empty microservice event") continue } if msEvent.EventType == nsplugin.NewMicroservice { skip := make(map[string]struct{}) /* interfaces to be skipped in subsequent iterations */ - for _, iface := range plugin.intfsByMicroservice[microservice.Label] { + for _, iface := range plugin.ifsByMs[microservice.Label] { if _, toSkip := skip[iface.config.Name]; toSkip { continue } @@ -888,12 +912,12 @@ func (plugin *LinuxInterfaceConfigurator) watchMicroservices(ctx context.Context // peer will be processed in this iteration and skipped in the subsequent ones. skip[peer.config.Name] = struct{}{} } - if peer != nil && plugin.NsHandler.IsNamespaceAvailable(peer.config.Namespace) { + if peer != nil && plugin.nsHandler.IsNamespaceAvailable(peer.config.Namespace) { // Prepare generic vet cfg namespace object - ifaceNs := plugin.NsHandler.IfNsToGeneric(plugin.NsHandler.GetConfigNamespace()) + ifaceNs := plugin.nsHandler.IfNsToGeneric(plugin.nsHandler.GetConfigNamespace()) // Switch to veth cfg namespace - revertNs, err := plugin.NsHandler.SwitchNamespace(ifaceNs, nsMgmtCtx, plugin.Log) + revertNs, err := plugin.nsHandler.SwitchNamespace(ifaceNs, nsMgmtCtx) if err != nil { return } @@ -901,32 +925,31 @@ func (plugin *LinuxInterfaceConfigurator) watchMicroservices(ctx context.Context // VETH is ready to be created and configured err = plugin.addVethInterfacePair(nsMgmtCtx, iface.config, peer.config) if err != nil { - plugin.Log.Error(err.Error()) + plugin.log.Error(err.Error()) continue } if err := plugin.configureLinuxInterface(nsMgmtCtx, iface.config); err != nil { - plugin.Log.Warnf("failed to configure VETH interface %s: %v", iface.config.Name, err) + plugin.log.Warnf("failed to configure VETH interface %s: %v", iface.config.Name, err) } else if err := plugin.configureLinuxInterface(nsMgmtCtx, peer.config); err != nil { - plugin.Log.Warnf("failed to configure VETH interface %s: %v", peer.config.Name, err) + plugin.log.Warnf("failed to configure VETH interface %s: %v", peer.config.Name, err) } revertNs() } else { - plugin.Log.Debugf("peer VETH %v is not ready yet, microservice: %+v", iface.config.Name, microservice) + plugin.log.Debugf("peer VETH %v is not ready yet, microservice: %+v", iface.config.Name, microservice) } } } else if msEvent.EventType == nsplugin.TerminatedMicroservice { - for _, iface := range plugin.intfsByMicroservice[microservice.Label] { + for _, iface := range plugin.ifsByMs[microservice.Label] { plugin.removeObsoleteVeth(nsMgmtCtx, iface.config.Name, iface.config.HostIfName, iface.config.Namespace) if iface.peer != nil && iface.peer.config != nil { plugin.removeObsoleteVeth(nsMgmtCtx, iface.peer.config.Name, iface.peer.config.HostIfName, iface.peer.config.Namespace) } else { - plugin.Log.Warnf("Obsolete peer for %s not removed, no peer data", iface.config.Name) + plugin.log.Warnf("Obsolete peer for %s not removed, no peer data", iface.config.Name) } - } } else { - plugin.Log.Errorf("Unknown microservice event type: %s", msEvent.EventType) + plugin.log.Errorf("Unknown microservice event type: %s", msEvent.EventType) } case <-plugin.ctx.Done(): return @@ -940,3 +963,92 @@ func (plugin *LinuxInterfaceConfigurator) handleOptionalHostIfName(config *inter config.HostIfName = config.Name } } + +func addressExists(configured []netlink.Addr, provided *net.IPNet) bool { + for _, confAddr := range configured { + if bytes.Equal(confAddr.IP, provided.IP) { + return true + } + } + return false +} + +// ResolveCreatedInterface resolves a new vpp interfaces +func (plugin *LinuxInterfaceConfigurator) ResolveCreatedVPPInterface(ifConfigMetaData *vppIf.Interfaces_Interface) error { + plugin.log.Infof("Linux IF configurator: resolve created vpp interface %v", ifConfigMetaData) + + if ifConfigMetaData == nil { + plugin.log.Warn("Unable to resolve created VPP interfaces, no Linux TAP configuration data available") + return nil + } + + if ifConfigMetaData.Type != vppIf.InterfaceType_TAP_INTERFACE { + return nil + } + + var hostIfName string + if ifConfigMetaData.Tap != nil { + hostIfName = ifConfigMetaData.GetTap().GetHostIfName() + } + if hostIfName == "" { + hostIfName = ifConfigMetaData.GetName() + } + if hostIfName == "" { + plugin.log.Warn("Unable to resolve created VPP interfaces, incomplete Linux TAP configuration data") + return nil + } + + var linuxIf *interfaces.LinuxInterfaces_Interface + _, data, exists := plugin.ifCachedConfigs.LookupIdx(hostIfName) + if exists && data != nil { + linuxIf = data.Data + } + + return plugin.configureTapInterface(hostIfName, linuxIf) +} + +// ResolveDeletedInterface resolves removed vpp interfaces +func (plugin *LinuxInterfaceConfigurator) ResolveDeletedVPPInterface(ifConfigMetaData *vppIf.Interfaces_Interface) error { + plugin.log.Infof("Linux IF configurator: resolve deleted vpp interface %v", ifConfigMetaData) + + if ifConfigMetaData == nil { + plugin.log.Warn("Unable to resolve deleted VPP interfaces, no Linux TAP configuration data available") + return nil + } + + if ifConfigMetaData.Type != vppIf.InterfaceType_TAP_INTERFACE { + return nil + } + + var hostIfName string + if ifConfigMetaData.Tap != nil { + hostIfName = ifConfigMetaData.GetTap().GetHostIfName() + } + if hostIfName == "" { + hostIfName = ifConfigMetaData.GetName() + } + if hostIfName == "" { + plugin.log.Warn("Unable to resolve deleted VPP interfaces, incomplete Linux TAP configuration data") + return nil + } + + plugin.log.Infof("Resolving linux tap interface host(%v), name(%v)", hostIfName, ifConfigMetaData.Name) + _, ifConfig, exists := plugin.ifIndexes.LookupIdx(ifConfigMetaData.Name) + if exists { + // Move linux tap configuration to cache + plugin.log.Infof("Registering linux tap interface configuration %v", ifConfig.Data.Name) + plugin.ifCachedConfigs.RegisterName(hostIfName, plugin.pIfCachedConfigSeq, &ifaceidx.IndexedLinuxInterface{ + Index: plugin.pIfCachedConfigSeq, + Data: ifConfig.Data, + }) + // Unregister TAP from the in-memory map + plugin.log.Infof("Unregistering linux tap interface %v", ifConfig.Data.Name) + plugin.ifIndexes.UnregisterName(ifConfig.Data.Name) + + plugin.log.Infof("Linux interface configuration entry %v moved to cache : %v", ifConfig.Data.Name, ifConfig.Data) + plugin.pIfCachedConfigSeq++ + plugin.moveTapInterfaceToDefaultNamespace(ifConfig.Data) + } + + return nil +} diff --git a/plugins/linux/ifplugin/interface_config_test.go b/plugins/linux/ifplugin/interface_config_test.go new file mode 100644 index 0000000000..4846eb333f --- /dev/null +++ b/plugins/linux/ifplugin/interface_config_test.go @@ -0,0 +1,577 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package ifplugin_test + +import ( + "fmt" + "net" + "testing" + + "github.com/ligato/cn-infra/logging" + "github.com/ligato/cn-infra/logging/logrus" + "github.com/ligato/cn-infra/logging/measure" + "github.com/ligato/cn-infra/utils/safeclose" + "github.com/ligato/vpp-agent/idxvpp/nametoidx" + "github.com/ligato/vpp-agent/plugins/linux/ifplugin" + "github.com/ligato/vpp-agent/plugins/linux/ifplugin/ifaceidx" + "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" + "github.com/ligato/vpp-agent/plugins/linux/nsplugin" + "github.com/ligato/vpp-agent/tests/linuxmock" + . "github.com/onsi/gomega" +) + +/* Linux interface configurator init and close */ + +// Test init function +func TestLinuxInterfaceConfiguratorInit(t *testing.T) { + plugin, _, _, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + // Base fields + Expect(plugin).ToNot(BeNil()) + Expect(msChan).ToNot(BeNil()) + // Mappings & cache + Expect(plugin.GetLinuxInterfaceIndexes()).ToNot(BeNil()) + Expect(plugin.GetLinuxInterfaceIndexes().GetMapping().ListNames()).To(HaveLen(0)) + Expect(plugin.GetInterfaceByNameCache()).ToNot(BeNil()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveLen(0)) + Expect(plugin.GetInterfaceByMsCache()).ToNot(BeNil()) + Expect(plugin.GetInterfaceByMsCache()).To(HaveLen(0)) +} + +/* Linux interface configurator test cases */ + +// Configure simple Veth without peer +func TestLinuxConfiguratorAddSingleVeth(t *testing.T) { + plugin, _, _, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + data := getVethInterface("veth1", "peer1", 1) + err := plugin.ConfigureLinuxInterface(data) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) +} + +// Configure Veth with missing data +func TestLinuxConfiguratorAddSingleVethWithoutData(t *testing.T) { + plugin, _, _, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + data := getVethInterface("veth1", "peer1", 1) + data.HostIfName = "" + data.Veth = nil + err := plugin.ConfigureLinuxInterface(data) + Expect(err).Should(HaveOccurred()) +} + +// Configure simple Veth with peer +func TestLinuxConfiguratorAddVethPair(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 1, + }) + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 2, + }) + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 0)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 0)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) + // Verify registration + _, meta, found := plugin.GetLinuxInterfaceIndexes().LookupIdx("veth1") + Expect(found).To(BeTrue()) + Expect(meta).ToNot(BeNil()) + _, meta, found = plugin.GetLinuxInterfaceIndexes().LookupIdx("veth2") + Expect(found).To(BeTrue()) + Expect(meta).ToNot(BeNil()) + // Verify interface by name config + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) + // Verify interface by microservice cache + Expect(plugin.GetInterfaceByNameCache()).ToNot(HaveKeyWithValue("veth1-ms", BeNil())) + Expect(plugin.GetInterfaceByNameCache()).ToNot(HaveKeyWithValue("veth1-ms", BeNil())) +} + +// Configure simple Veth with peer in microservice-type namespace +func TestLinuxConfiguratorAddVethPairInMicroserviceNs(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 1, + }) + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 2, + }) + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) + // Verify registration + _, meta, found := plugin.GetLinuxInterfaceIndexes().LookupIdx("veth1") + Expect(found).To(BeTrue()) + Expect(meta).ToNot(BeNil()) + _, meta, found = plugin.GetLinuxInterfaceIndexes().LookupIdx("veth2") + Expect(found).To(BeTrue()) + Expect(meta).ToNot(BeNil()) + // Verify interface by name config + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) + // Verify interface by microservice cache + ms, ok := plugin.GetInterfaceByMsCache()["veth1-ms"] + Expect(ok).To(BeTrue()) + Expect(ms).To(HaveLen(1)) + ms, ok = plugin.GetInterfaceByMsCache()["veth2-ms"] + Expect(ok).To(BeTrue()) + Expect(ms).To(HaveLen(1)) +} + +// Configure simple Veth with peer while Veth ns is not available +func TestLinuxConfiguratorAddVethPairVethNsNotAvailable(t *testing.T) { + plugin, _, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(false) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + data, found := plugin.GetInterfaceByNameCache()["veth1"] + Expect(found).To(BeTrue()) + Expect(data).ToNot(BeNil()) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).ShouldNot(HaveOccurred()) + data, found = plugin.GetInterfaceByNameCache()["veth2"] + Expect(found).To(BeTrue()) + Expect(data).ToNot(BeNil()) + // Verify registration + _, _, found = plugin.GetLinuxInterfaceIndexes().LookupIdx("veth1") + Expect(found).To(BeFalse()) + _, _, found = plugin.GetLinuxInterfaceIndexes().LookupIdx("veth2") + Expect(found).To(BeFalse()) + // Verify interface by name config + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while peer ns is not available +func TestLinuxConfiguratorAddVethPairPeerNsNotAvailable(t *testing.T) { + plugin, _, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(false) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + data, found := plugin.GetInterfaceByNameCache()["veth1"] + Expect(found).To(BeTrue()) + Expect(data).ToNot(BeNil()) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).ShouldNot(HaveOccurred()) + data, found = plugin.GetInterfaceByNameCache()["veth2"] + Expect(found).To(BeTrue()) + Expect(data).ToNot(BeNil()) + // Verify registration + _, _, found = plugin.GetLinuxInterfaceIndexes().LookupIdx("veth1") + Expect(found).To(BeFalse()) + _, _, found = plugin.GetLinuxInterfaceIndexes().LookupIdx("veth2") + Expect(found).To(BeFalse()) + // Verify interface by name config + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while switching ns returns error +func TestLinuxConfiguratorAddVethPairSwitchNsError(t *testing.T) { + plugin, _, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("SwitchNamespace").ThenReturn(fmt.Errorf("switch-namespace error")) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + data, found := plugin.GetInterfaceByNameCache()["veth1"] + Expect(found).To(BeTrue()) + Expect(data).ToNot(BeNil()) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).Should(HaveOccurred()) +} + +// Configure simple Veth with peer while peer ns is not available +func TestLinuxConfiguratorAddVethPairPeerSwitchToNsWhileRemovingObsoleteErr(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("SwitchToNamespace").ThenReturn(fmt.Errorf("remove-obsolete-1-err")) + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 1, + }) + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 2, + }) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while there is an obsolete veth which needs to be removed. Covers all 4 cases. +func TestLinuxConfiguratorAddVethPairPeerRemoveObsolete(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + // First obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth1-ms-obsolete-peer") + // Second obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth2-ms-obsolete-peer") + // Third obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth1-cfg-obsolete-peer") + // Fourth obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth2-cfg-obsolete-peer") + // Complete + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 1, + }) + ifMock.When("GetInterfaceByName").ThenReturn(&net.Interface{ + Index: 2, + }) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while there is an obsolete veth - interface exists error +func TestLinuxConfiguratorAddVethPairPeerRemoveObsoleteIfExistsError(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + // First obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(fmt.Errorf("interface-exists-err")) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).Should(HaveOccurred()) // Expect error + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while there is an obsolete veth - interface type error +func TestLinuxConfiguratorAddVethPairPeerRemoveObsoleteIfTypeError(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + // First obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn(fmt.Errorf("interface-type-err")) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).Should(HaveOccurred()) // Expect error + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while there is an obsolete veth - interface type does not match error +func TestLinuxConfiguratorAddVethPairPeerRemoveObsoleteIfTypeMatchError(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + // First obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth1-ms-obsolete-peer") + // Second obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("tap") // instead of veth + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).Should(HaveOccurred()) // Expect error + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while there is an obsolete veth - get peer name error +func TestLinuxConfiguratorAddVethPairPeerRemoveObsoleteGetPeerNameError(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + // First obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth1-ms-obsolete-peer") + // Second obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth2-ms-obsolete-peer") + // Third obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn(fmt.Errorf("get-veth-peer-err")) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).Should(HaveOccurred()) // Expect error + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer while there is an obsolete veth - delete obsotele interface error +func TestLinuxConfiguratorAddVethPairPeerRemoveObsoleteDeletePeerNameError(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + // First obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth1-ms-obsolete-peer") + ifMock.When("DelVethInterfacePair").ThenReturn() + // Second obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth2-ms-obsolete-peer") + ifMock.When("DelVethInterfacePair").ThenReturn() + // Third obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth1-cfg-obsolete-peer") + ifMock.When("DelVethInterfacePair").ThenReturn() + // Fourth obsolete veth removal + ifMock.When("InterfaceExists").ThenReturn(true) + ifMock.When("GetInterfaceType").ThenReturn("veth") + ifMock.When("GetVethPeerName").ThenReturn("veth1-ms-obsolete-peer") + ifMock.When("DelVethInterfacePair").ThenReturn(fmt.Errorf("del-veth-interface-pair-error")) + + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 1)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 1)) + Expect(err).Should(HaveOccurred()) // Expect error + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth2", Not(BeNil()))) +} + +// Configure simple Veth with peer - add veth pair error +func TestLinuxConfiguratorAddVethPairError(t *testing.T) { + plugin, ifMock, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + ifMock.When("AddVethInterfacePair").ThenReturn(fmt.Errorf("add-veth-interface-pair-err")) + // Configure first veth + err := plugin.ConfigureLinuxInterface(getVethInterface("veth1", "veth2", 0)) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetInterfaceByNameCache()).To(HaveKeyWithValue("veth1", Not(BeNil()))) + // Configure second veth + err = plugin.ConfigureLinuxInterface(getVethInterface("veth2", "veth1", 0)) + Expect(err).Should(HaveOccurred()) +} + +// Configure Tap with hostIfName +func TestLinuxConfiguratorAddTap_TempIfName(t *testing.T) { + plugin, _, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + + data := getTapInterface("tap1", "", "TempIfName") + err := plugin.ConfigureLinuxInterface(data) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetLinuxInterfaceIndexes().GetMapping().ListNames()).To(HaveLen(0)) + Expect(plugin.GetCachedLinuxIfIndexes().GetMapping().ListNames()).To(HaveLen(1)) + // Verify registration + _, metadata, found := plugin.GetCachedLinuxIfIndexes().LookupIdx("TempIfName") + Expect(found).To(BeTrue()) + Expect(metadata).ToNot(BeNil()) +} + +// Configure Tap with hostIfName +func TestLinuxConfiguratorAddTap_HostIfName(t *testing.T) { + plugin, _, nsMock, msChan, msNotif := ifTestSetup(t) + defer ifTestTeardown(plugin, msChan, msNotif) + + // Linux/namespace calls + nsMock.When("IsNamespaceAvailable").ThenReturn(true) + + data := getTapInterface("tap1", "HostIfName", "") + err := plugin.ConfigureLinuxInterface(data) + Expect(err).ShouldNot(HaveOccurred()) + Expect(plugin.GetLinuxInterfaceIndexes().GetMapping().ListNames()).To(HaveLen(0)) + Expect(plugin.GetCachedLinuxIfIndexes().GetMapping().ListNames()).To(HaveLen(1)) + // Verify registration + _, metadata, found := plugin.GetCachedLinuxIfIndexes().LookupIdx("HostIfName") + Expect(found).To(BeTrue()) + Expect(metadata).ToNot(BeNil()) +} + +// Todo + +/* Interface Test Setup */ + +func ifTestSetup(t *testing.T) (*ifplugin.LinuxInterfaceConfigurator, *linuxmock.IfNetlinkHandlerMock, *linuxmock.NamespacePluginMock, + chan *nsplugin.MicroserviceCtx, chan *nsplugin.MicroserviceEvent) { + RegisterTestingT(t) + + // Loggers + pluginLog := logging.ForPlugin("linux-if-log", logrus.NewLogRegistry()) + pluginLog.SetLevel(logging.DebugLevel) + nsHandleLog := logging.ForPlugin("ns-handle-log", logrus.NewLogRegistry()) + nsHandleLog.SetLevel(logging.DebugLevel) + // Linux interface indexes + swIfIndexes := ifaceidx.NewLinuxIfIndex(nametoidx.NewNameToIdx(pluginLog, "if", nil)) + msChan := make(chan *nsplugin.MicroserviceCtx, 100) + ifMicroserviceNotif := make(chan *nsplugin.MicroserviceEvent, 100) + // Configurator + plugin := &ifplugin.LinuxInterfaceConfigurator{} + linuxMock := linuxmock.NewIfNetlinkHandlerMock() + nsMock := linuxmock.NewNamespacePluginMock() + err := plugin.Init(pluginLog, linuxMock, nsMock, swIfIndexes, + ifMicroserviceNotif, measure.NewStopwatch("LinuxIfTest", pluginLog)) + Expect(err).To(BeNil()) + + return plugin, linuxMock, nsMock, msChan, ifMicroserviceNotif +} + +func ifTestTeardown(plugin *ifplugin.LinuxInterfaceConfigurator, + msChan chan *nsplugin.MicroserviceCtx, msNotif chan *nsplugin.MicroserviceEvent) { + err := safeclose.Close(msNotif) + Expect(err).To(BeNil()) + err = safeclose.Close(msChan) + Expect(err).To(BeNil()) + err = plugin.Close() + Expect(err).To(BeNil()) +} + +/* Linux interface Test Data */ + +func getVethInterface(ifName, peerName string, namespaceType interfaces.LinuxInterfaces_Interface_Namespace_NamespaceType) *interfaces.LinuxInterfaces_Interface { + return &interfaces.LinuxInterfaces_Interface{ + Name: ifName, + Enabled: true, + HostIfName: ifName + "-host", + Type: interfaces.LinuxInterfaces_VETH, + Namespace: func(namespaceType interfaces.LinuxInterfaces_Interface_Namespace_NamespaceType) *interfaces.LinuxInterfaces_Interface_Namespace { + if namespaceType < 4 { + return &interfaces.LinuxInterfaces_Interface_Namespace{ + Type: namespaceType, + Microservice: ifName + "-ms", + } + } + return nil + }(namespaceType), + Veth: &interfaces.LinuxInterfaces_Interface_Veth{ + PeerIfName: peerName, + }, + } +} + +func getTapInterface(ifName, hostIfName string, tempIfName string) *interfaces.LinuxInterfaces_Interface { + return &interfaces.LinuxInterfaces_Interface{ + Name: ifName, + Enabled: true, + Type: interfaces.LinuxInterfaces_AUTO_TAP, + PhysAddress: "12:E4:0E:D5:BC:DC", + IpAddresses: []string{ + "192.168.20.3/24", + }, + HostIfName: hostIfName, + Tap: &interfaces.LinuxInterfaces_Interface_Tap{ + TempIfName: tempIfName, + }, + } +} diff --git a/plugins/linuxplugin/ifplugin/interface_state.go b/plugins/linux/ifplugin/interface_stage.go similarity index 79% rename from plugins/linuxplugin/ifplugin/interface_state.go rename to plugins/linux/ifplugin/interface_stage.go index 907dd4d1d1..1dd5f207aa 100644 --- a/plugins/linuxplugin/ifplugin/interface_state.go +++ b/plugins/linux/ifplugin/interface_stage.go @@ -20,7 +20,7 @@ import ( "github.com/ligato/cn-infra/logging" "github.com/ligato/cn-infra/utils/safeclose" - "github.com/ligato/vpp-agent/plugins/linuxplugin/ifplugin/ifaceidx" + "github.com/ligato/vpp-agent/plugins/linux/ifplugin/ifaceidx" "github.com/vishvananda/netlink" ) @@ -35,11 +35,11 @@ type LinuxInterfaceStateNotification struct { // LinuxInterfaceStateUpdater processes all linux interface state data type LinuxInterfaceStateUpdater struct { - Log logging.Logger + log logging.Logger cfgLock sync.Mutex // Go routine management - wg sync.WaitGroup // Wait group allows to wait until all goroutines of the plugin have finished. + wg sync.WaitGroup // Linux interface state stateWatcherRunning bool @@ -49,25 +49,27 @@ type LinuxInterfaceStateUpdater struct { } // Init channels for interface state watcher, start it in separate go routine and subscribe to default namespace -func (plugin *LinuxInterfaceStateUpdater) Init(ctx context.Context, ifIndexes ifaceidx.LinuxIfIndexRW, - stateChan chan *LinuxInterfaceStateNotification, notifChan chan netlink.LinkUpdate, notifDone chan struct{}) error { - plugin.Log.Debug("Initializing Linux Interface State Updater") +func (plugin *LinuxInterfaceStateUpdater) Init(logger logging.PluginLogger, ctx context.Context, ifIndexes ifaceidx.LinuxIfIndexRW, + stateChan chan *LinuxInterfaceStateNotification) error { + // Logger + plugin.log = logger.NewLogger("-if-state") + plugin.log.Debug("Initializing Linux Interface State Updater") // Channels plugin.ifStateChan = stateChan - plugin.ifWatcherNotifCh = notifChan - plugin.ifWatcherDoneCh = notifDone + plugin.ifWatcherNotifCh = make(chan netlink.LinkUpdate, 10) + plugin.ifWatcherDoneCh = make(chan struct{}) // Start watch on linux interfaces go plugin.watchLinuxInterfaces(ctx) + // Subscribe to default linux namespace return plugin.subscribeInterfaceState() } // Close watcher channel (state chan is closed in LinuxInterfaceConfigurator) func (plugin *LinuxInterfaceStateUpdater) Close() error { - _, err := safeclose.CloseAll(plugin.ifWatcherNotifCh, plugin.ifWatcherDoneCh) - return err + return safeclose.Close(plugin.ifWatcherNotifCh, plugin.ifWatcherDoneCh) } // Subscribe to linux default namespace @@ -84,7 +86,7 @@ func (plugin *LinuxInterfaceStateUpdater) subscribeInterfaceState() error { // Watch linux interfaces and send events to processing func (plugin *LinuxInterfaceStateUpdater) watchLinuxInterfaces(ctx context.Context) { - plugin.Log.Debugf("Watching on linux link notifications") + plugin.log.Debugf("Watching on linux link notifications") plugin.wg.Add(1) defer plugin.wg.Done() @@ -112,7 +114,7 @@ func (plugin *LinuxInterfaceStateUpdater) processLinkNotification(link netlink.L plugin.cfgLock.Lock() defer plugin.cfgLock.Unlock() - plugin.Log.Debugf("Processing Linux link update: Name=%v Type=%v OperState=%v Index=%v HwAddr=%v", + plugin.log.Debugf("Processing Linux link update: Name=%v Type=%v OperState=%v Index=%v HwAddr=%v", linkAttrs.Name, link.Type(), linkAttrs.OperState, linkAttrs.Index, linkAttrs.HardwareAddr) // Prepare linux link notification @@ -126,6 +128,6 @@ func (plugin *LinuxInterfaceStateUpdater) processLinkNotification(link netlink.L case plugin.ifStateChan <- linkNotif: // Notification sent default: - plugin.Log.Warn("Unable to send to the linux if state notification channel - buffer is full.") + plugin.log.Warn("Unable to send to the linux if state notification channel - buffer is full.") } } diff --git a/plugins/linux/ifplugin/linuxcalls/admin_linuxcalls.go b/plugins/linux/ifplugin/linuxcalls/admin_linuxcalls.go new file mode 100644 index 0000000000..5202313815 --- /dev/null +++ b/plugins/linux/ifplugin/linuxcalls/admin_linuxcalls.go @@ -0,0 +1,63 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !windows,!darwin + +// Copyright (c) 2017 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linuxcalls + +import ( + "time" + + "github.com/vishvananda/netlink" +) + +// SetInterfaceDown calls Netlink API LinkSetDown. +func (handler *netLinkHandler) SetInterfaceDown(ifName string) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("interface-admin-down").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return err + } + return netlink.LinkSetDown(link) +} + +// SetInterfaceUp calls Netlink API LinkSetUp. +func (handler *netLinkHandler) SetInterfaceUp(ifName string) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("interface-admin-up").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return err + } + return netlink.LinkSetUp(link) +} diff --git a/plugins/linuxplugin/ifplugin/linuxcalls/doc.go b/plugins/linux/ifplugin/linuxcalls/doc.go similarity index 100% rename from plugins/linuxplugin/ifplugin/linuxcalls/doc.go rename to plugins/linux/ifplugin/linuxcalls/doc.go diff --git a/plugins/linux/ifplugin/linuxcalls/ip_linuxcalls.go b/plugins/linux/ifplugin/linuxcalls/ip_linuxcalls.go new file mode 100644 index 0000000000..8e6890dc32 --- /dev/null +++ b/plugins/linux/ifplugin/linuxcalls/ip_linuxcalls.go @@ -0,0 +1,93 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !windows,!darwin + +// Copyright (c) 2017 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linuxcalls + +import ( + "net" + "time" + + "github.com/vishvananda/netlink" +) + +// GetAddressList calls AddrList netlink API +func (handler *netLinkHandler) GetAddressList(ifName string) ([]netlink.Addr, error) { + defer func(t time.Time) { + handler.stopwatch.TimeLog("get-address-list").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return nil, err + } + + return netlink.AddrList(link, netlink.FAMILY_ALL) +} + +// AddInterfaceIP calls AddrAdd Netlink API. +func (handler *netLinkHandler) AddInterfaceIP(ifName string, addr *net.IPNet) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("add-interface-ip").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return err + } + + return netlink.AddrAdd(link, &netlink.Addr{IPNet: addr}) +} + +// DelInterfaceIP calls AddrDel Netlink API. +func (handler *netLinkHandler) DelInterfaceIP(ifName string, addr *net.IPNet) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("del-interface-ip").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return err + } + + return netlink.AddrDel(link, &netlink.Addr{IPNet: addr}) +} + +// SetInterfaceMTU calls LinkSetMTU Netlink API. +func (handler *netLinkHandler) SetInterfaceMTU(ifName string, mtu int) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("set-interface-mtu").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return err + } + return netlink.LinkSetMTU(link, mtu) +} diff --git a/plugins/linux/ifplugin/linuxcalls/link_linuxcalls.go b/plugins/linux/ifplugin/linuxcalls/link_linuxcalls.go new file mode 100644 index 0000000000..d967d513d3 --- /dev/null +++ b/plugins/linux/ifplugin/linuxcalls/link_linuxcalls.go @@ -0,0 +1,119 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !windows,!darwin + +// Copyright (c) 2017 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linuxcalls + +import ( + "net" + "time" + + "github.com/vishvananda/netlink" +) + +// GetLinkByName calls netlink API to get Link type from interface name +func (handler *netLinkHandler) GetLinkByName(ifName string) (netlink.Link, error) { + defer func(t time.Time) { + handler.stopwatch.TimeLog("get-link-from-interface").LogTimeEntry(time.Since(t)) + }(time.Now()) + + return netlink.LinkByName(ifName) +} + +// GetLinkList calls netlink API to get all Links in namespace +func (handler *netLinkHandler) GetLinkList() ([]netlink.Link, error) { + defer func(t time.Time) { + handler.stopwatch.TimeLog("get-link-list").LogTimeEntry(time.Since(t)) + }(time.Now()) + + return netlink.LinkList() +} + +// GetInterfaceType returns the type (string representation) of a given interface. +func (handler *netLinkHandler) GetInterfaceType(ifName string) (string, error) { + defer func(t time.Time) { + handler.stopwatch.TimeLog("get-interface-type").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return "", err + } + return link.Type(), nil +} + +// InterfaceExists checks if interface with a given name exists. +func (handler *netLinkHandler) InterfaceExists(ifName string) (bool, error) { + defer func(t time.Time) { + handler.stopwatch.TimeLog("interface-exists").LogTimeEntry(time.Since(t)) + }(time.Now()) + + _, err := handler.GetLinkByName(ifName) + if err == nil { + return true, nil + } + if _, notFound := err.(netlink.LinkNotFoundError); notFound { + return false, nil + } + return false, err +} + +// RenameInterface changes the name of the interface to . +func (handler *netLinkHandler) RenameInterface(ifName string, newName string) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("rename-interface").LogTimeEntry(time.Since(t)) + }(time.Now()) + + link, err := handler.GetLinkByName(ifName) + if err != nil { + return err + } + err = handler.SetInterfaceDown(ifName) + if err != nil { + return err + } + err = netlink.LinkSetName(link, newName) + if err != nil { + return err + } + err = handler.SetInterfaceUp(newName) + if err != nil { + return err + } + return nil +} + +// GetInterfaceByName return *net.Interface type from interface name +func (handler *netLinkHandler) GetInterfaceByName(ifName string) (*net.Interface, error) { + defer func(t time.Time) { + handler.stopwatch.TimeLog("get-interface-by-name").LogTimeEntry(time.Since(t)) + }(time.Now()) + + return net.InterfaceByName(ifName) +} diff --git a/plugins/linuxplugin/ifplugin/linuxcalls/mac_linuxcalls.go b/plugins/linux/ifplugin/linuxcalls/mac_linuxcalls.go similarity index 51% rename from plugins/linuxplugin/ifplugin/linuxcalls/mac_linuxcalls.go rename to plugins/linux/ifplugin/linuxcalls/mac_linuxcalls.go index de92f80739..ed5a0c504f 100644 --- a/plugins/linuxplugin/ifplugin/linuxcalls/mac_linuxcalls.go +++ b/plugins/linux/ifplugin/linuxcalls/mac_linuxcalls.go @@ -1,3 +1,17 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // +build !windows,!darwin // Copyright (c) 2017 Cisco and/or its affiliates. @@ -18,23 +32,18 @@ package linuxcalls import ( "net" - "time" - "github.com/ligato/cn-infra/logging/measure" "github.com/vishvananda/netlink" ) // SetInterfaceMac calls LinkSetHardwareAddr netlink API. -func SetInterfaceMac(ifName string, macAddress string, timeLog measure.StopWatchEntry) error { - start := time.Now() - defer func() { - if timeLog != nil { - timeLog.LogTimeEntry(time.Since(start)) - } - }() +func (handler *netLinkHandler) SetInterfaceMac(ifName string, macAddress string) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("set-interface-mac").LogTimeEntry(time.Since(t)) + }(time.Now()) - link, err := netlink.LinkByName(ifName) + link, err := handler.GetLinkByName(ifName) if err != nil { return err } diff --git a/plugins/linuxplugin/ifplugin/linuxcalls/mock_linuxcalls.go b/plugins/linux/ifplugin/linuxcalls/mock_linuxcalls.go similarity index 86% rename from plugins/linuxplugin/ifplugin/linuxcalls/mock_linuxcalls.go rename to plugins/linux/ifplugin/linuxcalls/mock_linuxcalls.go index 784dea486a..1396e48d1e 100644 --- a/plugins/linuxplugin/ifplugin/linuxcalls/mock_linuxcalls.go +++ b/plugins/linux/ifplugin/linuxcalls/mock_linuxcalls.go @@ -1,3 +1,17 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // +build windows darwin // Copyright (c) 2017 Cisco and/or its affiliates. @@ -19,7 +33,7 @@ package linuxcalls import ( "net" - intf "github.com/ligato/vpp-agent/plugins/linuxplugin/common/model/interfaces" + intf "github.com/ligato/vpp-agent/plugins/linux/model/interfaces" ) // NamespaceMgmtCtx is a mock type definition of the real NamespaceMgmtCtx from ns_linuxcalls.go. diff --git a/plugins/linux/ifplugin/linuxcalls/netlink_api.go b/plugins/linux/ifplugin/linuxcalls/netlink_api.go new file mode 100644 index 0000000000..873635ff88 --- /dev/null +++ b/plugins/linux/ifplugin/linuxcalls/netlink_api.go @@ -0,0 +1,70 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package linuxcalls + +import ( + "net" + + "github.com/ligato/cn-infra/logging/measure" + "github.com/vishvananda/netlink" +) + +// NetlinkAPI interface covers all methods inside linux calls package needed to manage linux interfaces. +type NetlinkAPI interface { + // AddVethInterfacePair configures two connected VETH interfaces + AddVethInterfacePair(ifName, peerIfName string) error + // DelVethInterfacePair removes VETH pair + DelVethInterfacePair(ifName, peerIfName string) error + // SetInterfaceUp sets interface state to 'up' + SetInterfaceUp(ifName string) error + // SetInterfaceDown sets interface state to 'down' + SetInterfaceDown(ifName string) error + // AddInterfaceIP adds new IP address + AddInterfaceIP(ifName string, addr *net.IPNet) error + // DelInterfaceIP removes IP address from linux interface + DelInterfaceIP(ifName string, addr *net.IPNet) error + // SetInterfaceMac sets MAC address + SetInterfaceMac(ifName string, macAddress string) error + // SetInterfaceMTU set maximum transmission unit for interface + SetInterfaceMTU(ifName string, mtu int) error + // RenameInterface changes interface host name + RenameInterface(ifName string, newName string) error + // GetLinkByName returns netlink interface type + GetLinkByName(ifName string) (netlink.Link, error) + // GetLinkList return all links from namespace + GetLinkList() ([]netlink.Link, error) + // GetAddressList reads all IP addresses + GetAddressList(ifName string) ([]netlink.Addr, error) + // InterfaceExists verifies interface existence + InterfaceExists(ifName string) (bool, error) + // GetInterfaceType returns linux interface type + GetInterfaceType(ifName string) (string, error) + // GetVethPeerName returns VETH's peer name + GetVethPeerName(ifName string) (string, error) + // GetInterfaceByName returns *net.Interface type from name + GetInterfaceByName(ifName string) (*net.Interface, error) +} + +// netLinkHandler is accessor for netlink methods +type netLinkHandler struct { + stopwatch *measure.Stopwatch +} + +// NewNetLinkHandler creates new instance of netlink handler +func NewNetLinkHandler(stopwatch *measure.Stopwatch) *netLinkHandler { + return &netLinkHandler{ + stopwatch: stopwatch, + } +} diff --git a/plugins/linuxplugin/ifplugin/linuxcalls/veth_linuxcalls.go b/plugins/linux/ifplugin/linuxcalls/veth_linuxcalls.go similarity index 55% rename from plugins/linuxplugin/ifplugin/linuxcalls/veth_linuxcalls.go rename to plugins/linux/ifplugin/linuxcalls/veth_linuxcalls.go index 5da80b7e3d..34b1630e52 100644 --- a/plugins/linuxplugin/ifplugin/linuxcalls/veth_linuxcalls.go +++ b/plugins/linux/ifplugin/linuxcalls/veth_linuxcalls.go @@ -1,3 +1,17 @@ +// Copyright (c) 2018 Cisco and/or its affiliates. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // +build !windows,!darwin // Copyright (c) 2017 Cisco and/or its affiliates. @@ -18,23 +32,16 @@ package linuxcalls import ( "fmt" - "time" - "github.com/ligato/cn-infra/logging" - "github.com/ligato/cn-infra/logging/measure" "github.com/vishvananda/netlink" ) // AddVethInterfacePair calls LinkAdd Netlink API for the Netlink.Veth interface type. -func AddVethInterfacePair(ifName, peerIfName string, log logging.Logger, timeLog measure.StopWatchEntry) error { - log.WithFields(logging.Fields{"ifName": ifName, "peerIfName": peerIfName}).Debug("Creating new Linux VETH pair") - start := time.Now() - defer func() { - if timeLog != nil { - timeLog.LogTimeEntry(time.Since(start)) - } - }() +func (handler *netLinkHandler) AddVethInterfacePair(ifName, peerIfName string) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("add-veth-iface-pair").LogTimeEntry(time.Since(t)) + }(time.Now()) // Veth pair params veth := &netlink.Veth{ @@ -51,14 +58,10 @@ func AddVethInterfacePair(ifName, peerIfName string, log logging.Logger, timeLog } // DelVethInterfacePair calls LinkDel Netlink API for the Netlink.Veth interface type. -func DelVethInterfacePair(ifName, peerIfName string, log logging.Logger, timeLog measure.StopWatchEntry) error { - log.WithFields(logging.Fields{"ifName": ifName, "peerIfName": peerIfName}).Debug("Deleting Linux VETH pair") - start := time.Now() - defer func() { - if timeLog != nil { - timeLog.LogTimeEntry(time.Since(start)) - } - }() +func (handler *netLinkHandler) DelVethInterfacePair(ifName, peerIfName string) error { + defer func(t time.Time) { + handler.stopwatch.TimeLog("del-veth-iface-pair").LogTimeEntry(time.Since(t)) + }(time.Now()) // Veth pair params. veth := &netlink.Veth{ @@ -75,15 +78,12 @@ func DelVethInterfacePair(ifName, peerIfName string, log logging.Logger, timeLog } // GetVethPeerName return the peer name for a given VETH interface. -func GetVethPeerName(ifName string, timeLog measure.StopWatchEntry) (string, error) { - start := time.Now() - defer func() { - if timeLog != nil { - timeLog.LogTimeEntry(time.Since(start)) - } - }() +func (handler *netLinkHandler) GetVethPeerName(ifName string) (string, error) { + defer func(t time.Time) { + handler.stopwatch.TimeLog("get-veth-peer-name").LogTimeEntry(time.Since(t)) + }(time.Now()) - link, err := netlink.LinkByName(ifName) + link, err := handler.GetLinkByName(ifName) if err != nil { return "", err } diff --git a/plugins/linux/l3plugin/README.md b/plugins/linux/l3plugin/README.md new file mode 100644 index 0000000000..d77125cf1b --- /dev/null +++ b/plugins/linux/l3plugin/README.md @@ -0,0 +1,62 @@ +# Linux L3 plugin + +The linux l3plugin is a Core Agent Plugin that is designed to configure ARP entries and routes in the +linux environment. Configuration managed by this plugin is modelled by the [proto file](../model/l3/l3.proto). + +## ARP entries + +The configuration must be stored in ETCD using the following key: + +``` +/vnf-agent//linux/config/v1/arp/