Commit Graph

29 Commits

Author SHA1 Message Date
eee718c77c Refactor and clean up some repetitive code 2022-04-12 11:04:13 +00:00
594e21afa4 Remove redundant code - remove_interface() already removes TAP cache entries 2022-04-12 10:47:45 +00:00
6637820021 Add TAP support
- based on previously submitted schema and validation, can add a TAP
  with host netns, bridge and MTU.
- detect diffs in __tap_has_diff(), used to prune TAPs that must change
- add prune_taps() and create_taps() in the reconciler
- add Dumper() logic to emit YAML config for TAPs
- Move tap_is_lcp() into the VPPApi() class, so it can be reused

Add lots of test cases in intest/*.yaml and example.yaml - full
regression and integration and unit/YAML tests pass on this change.
2022-04-12 08:57:05 +00:00
da7765569f Refactor VPPApi
VPPApiDumper() is its own file, preparing for VPPApiApplier() in an
upcoming commit. VPPApi() itself remains read-only. No need for an empty
__init__.py file.

Update vppcfg to use the correct vpp/dumper.py import
2022-04-10 14:47:37 +00:00
a7545ac5af Add ability to manipulate MACs
Special care is taken for bondethernet, where the MAC changes when
the first member is added to it. BondEthernet requires its MAC to
be set in the bondethernets section, disallowing the MAC of individual
members to be set.

Also write a dumper for MACs of all types. Update integration test
cases to stress the MAC changes on loops, bonds, and phys.
2022-04-10 09:54:51 +00:00
8971c325c0 Allow bondethernet members list to be empty, and omitted from the YAML config 2022-04-05 16:08:51 +00:00
0a755a0745 Add bond/bridge YAML emitter
Add int_to_mode() and int_to_lb() in config/bondethernet.py to map back
the retrieved values from VPP into their config strings.

Implement bond and bridge settings dumper, dumping all settings even if
they are default. This helps the user understand the configurable
options.
2022-04-05 15:53:26 +00:00
f53f7d5095 Remove linux-cp / lcpng specialcase, the API exposed by lcpng and linux-cp is now identical 2022-04-05 11:08:58 +00:00
b461ef49bb Add 'state' field to interfaces and sub-interfaces
Assert that children cannot be 'up' of their parent is 'down'. Add tests. Update user-guide.
2022-04-05 11:06:33 +00:00
65de792e35 Implement workaround for endianness issue in linux-cp 2022-04-03 22:24:59 +00:00
a4a91d1f5e Replace dumper with an actual YAML emitter 2022-04-03 21:37:48 +00:00
dfd8c8b8a9 Add user guide for 'vppcfg dump' command 2022-04-03 13:01:31 +00:00
2b98d57fd2 Move VPPAPIDumper into its own class.
Create a 'dump' command that calls it and exits vppcfg.
Add help strings to each of the commands.
2022-04-03 11:53:51 +00:00
50581f7171 Rename 'config' to 'cache' in the VPPApi.
This makes it clearer what its purpose is, in preparation of actual VPP
dataplane configuration changes. For example remove_lcp() refers
currently to the removal of the LCP from the cache, not the VPP
dataplane itself, so rename it and its siblings cache_remove_*()
instead.

In a future commit, the call remove_*() will refer to the removal of an
object _in VPP_.
2022-04-03 11:21:29 +00:00
f786a00e9a Check for the existence of LCP config statements, and if so, require linux-cp or lcpng plugins are enabled in VPP 2022-04-02 20:16:51 +00:00
f70bff400f Introduce a CLI object
Instead of writing the CLI calls to stderr as INFO loglines, now add
them to a list of messages by prune/create/sync.

Always close the VPP connection after finishing, by adding a destructor
to the VPPApi class.

At the end of each phase, print out what was gathered to stdout. Later,
I will make this more advanced (output to file, output directly to a
pipe of a running vppctl binary, etc).
2022-03-29 14:04:53 +00:00
850b982f2a First part of a BVI refactor
The handling of BVI is awkward, with the autoderived interface name
"bviXX" based on the bridgedomain bd_id. Lots of special casing happens
on account of this decision, and to make matters worse there is poor
interaction (leading to VPP crashes) when BVIs and Loopbacks are used
at the same time: https://lists.fd.io/g/vpp-dev/message/21116

This is step one of a refactor of the logic. In this commit, I'm
removing all of the BVI logic from the codebase, rendering bridgedomains
unable to have IP interfaces. In the next commit, I will introduce new
behavior in the schema, allowing for 'bvi' to be a loopback
interfacename which will be used as BVI for a bridgedomain, restoring
the ability to use bridgedomains with IP interfaces (using a loop).
2022-03-27 20:09:22 +00:00
176fd297aa Refactor phys_exist() into phys_exist_in_{config,vpp}(); Correct vppapi.get_phys() 2022-03-26 23:07:49 +00:00
e9bbd47407 Sync Phase: Implement bondethernets
Include special caveat on LCP MAC changes, for which I'll put in a
TODO for now with a VPP comment {} with the to be run command.

Also make the user aware of a quick in BondEthernets not being able
to have link_mtu != 9000 so if a packet MTU > 9000 is set, this will
work but is an undesirable configuration. Issue a warning in this
case.
2022-03-26 15:14:49 +00:00
f2784ce5d0 Remove spurious logline 2022-03-26 12:26:57 +00:00
54bb45f03d typofix on interface_names and sw_if_index 2022-03-26 12:20:19 +00:00
d5a7c59f4e Remove sub-ints before VXLANs. Report on interfaces thare are deleted before their addresses are. 2022-03-25 23:20:57 +00:00
661c7fc16c Implement pruning in config as well
After pruning elements from the VPP configuration, also remove them
from the configuration. The purpose of this is to leave a reasonable
representation of the VPP state in the configuration, so that subsequent
creates and syncs do not have to query the VPP API repeatedly.

The goal of this change is to be able to plan a complete path from
prune, create and sync, with only reading the initial VPP configuration
once, not multiple times.
2022-03-25 23:04:28 +00:00
1d7fd268e0 Add ability to delete sub-ints on BVI + Loopback
- Add a get_sub_interfaces() call to fetch all DPDK / Bond sub-ints
- In prune_bvis(), prune_loopbacks() and prune_sub_interfaces(),
  use sub_number_of_tags to go out-to-in (qinx, dot1x, untagged)
2022-03-25 18:43:46 +00:00
9aeb60ad98 Also bring down BVIs and Loopbacks if they do not exist in the config 2022-03-25 14:15:40 +00:00
fe2e63ac0e Prune Step1: remove addresses and set down, any interface not in the YAML config 2022-03-24 17:16:29 +00:00
e8e41098be Assert that all PHYs in the config also exist in VPP 2022-03-24 12:29:16 +00:00
8129235031 Clean up logging a little bit 2022-03-24 12:14:26 +00:00
ac5b8fcc8f Simple VPPApi abstraction, which fetches the necessary info from VPP, and a few dumpers 2022-03-23 23:29:19 +00:00