Commit Graph

205 Commits

Author SHA1 Message Date
78bd0c4f5a Assert BondEthernet devices also exist as interfaces. Assert MTU of members is equal to that of the BondEthernet interface 2022-03-27 12:29:57 +00:00
176fd297aa Refactor phys_exist() into phys_exist_in_{config,vpp}(); Correct vppapi.get_phys() 2022-03-26 23:07:49 +00:00
4c31541b3e Signal failure/success at the end of the reconciliation run 2022-03-26 22:52:06 +00:00
cb6eafae3e Complete Sync Phase
IP Addresses and Admin State are now applied
2022-03-26 22:51:21 +00:00
084094bb27 Add get_bvis() plus unittest 2022-03-26 22:45:52 +00:00
a2d2476710 Make Sync Phase config-centric
What this means is that the synchronization will run based on loops over
the configuration, rather than over the VPP state. The benefit of this
approach is that no additional API calls have to be made after the
initial VPP configuration is read, making pre-flight checks and diffing
more obvious.

Further, make sync_link_mtu() direction-aware; first we will raise the
link_mtu for interfaces that are growing, and after setting all the
children up/down with sync_mtu_direction() we'll finally shrink
sync_link_mtu() where needed.

We can now do an entire reconciliation run with only one API read at the
beginning!
2022-03-26 22:18:54 +00:00
619c579561 Make vpp_readconfig() explicit again. I want to try to read the VPP config only once, and pathplan the entire prune/create/sync cycle with one set of API reads at the beginning. 2022-03-26 21:08:41 +00:00
f5601765b0 Ignore .swp files 2022-03-26 17:18:25 +00:00
7bb9fa5ac8 Assert that a QinX cannot have higher MTU than its intermediate interface 2022-03-26 17:18:10 +00:00
40c6b2d1c8 Sync Phase: Implement MTU syncing (for both packet MTU and Max Frame Size) 2022-03-26 17:09:07 +00:00
0c747dbfc3 Sync Phase: Implement bridgedomains 2022-03-26 15:43:55 +00:00
0a80801217 Always set interface up after MTU change; otherwise only set it up if it was down 2022-03-26 15:21:09 +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
660cccd14e Assert that bd0 is reserved 2022-03-26 11:25:13 +00:00
abbabcf2d0 Skip deletion of TAP sub-ints belonging to LCP interfaces 2022-03-26 11:19:37 +00:00
90a97a3d7b Add Create Phase
This is rather straight forward: for each object (in correct order),
if the object exists in VPP, we can skip it. We know that it will exist
only if it was valid (ie correct encapsulation, tc). If it does not
exist in VPP, issue the correct creation request to VPP.

Implement the creation of all types, in the following order:
- create_loopbacks() and create_bvis()
- create_bondethernets()
- create_vxlan_tunnels()
- create_sub_interfaces() first 1-tag, then 2-tag
- create_bridgedomains()
- create_lcps() bottomsup: first 0-tag, then 1-tag, then 2-tag names.

Add a placeholder TODO to fix a bug with prune_sub_interfaces() which
should allow for TAPs belonging to LCPs; will fix in followup commit.
2022-03-26 11:14:30 +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
152fa12099 Update to ordering
- Prune bridgedomains before pruning BVIs. The reason for this is that
  prune_bridgedomains() will set the BVI to L3 mode, and if the BVI is
  removed before the bridge is pruned, this is an error.
- When pruning bridge members, use the VPP configuration as the member
  may not exist in the config, upon which the call to interface.is_sub()
  will return False even if it is actually a VPP sub-int.

Update README.md, also take into account the previous change which calls
prune_addresses() before object deletion.
2022-03-25 13:56:04 +00:00
a068f25f19 Re-order the Pruning flow
1. sub-ints have to be removed before their parent, particularly
   bondethernets, because destroying BondEthernet0 will cascade
   destruction of all of its sub-ints. So:
   - first prune_sub_interfaces()
   - then prune_bondethernets()
   - finally prune_phys()
2. for any interface (loop, bvi, sub, phy, bond), prune_addresses()
   before destroying the interface

Update the README with this new flow.
2022-03-25 13:35:14 +00:00
0a31a22e7e Add docstrings, reorder functions. Rename prune_addresses_set_interface_down() to merely prune_interfaces_down(), and make distinction on setting down and pruning addresses, so we don't do it twice. 2022-03-25 11:55:30 +00:00
864c78ddfe Only change link and MTU if they differ from the vpp_iface 2022-03-25 00:29:57 +00:00
250aae5210 Prune step 8: Remove qinx, dot1ad/dot1q, and set phys to default if they are not in the config 2022-03-25 00:15:41 +00:00
33aedd585f Prune Step 7: Remove VXLAN tunnels that either aren't in the config, or have a mismatched src/dst/vni 2022-03-24 23:42:46 +00:00
c381c7cbaa Prune Step 6: Remove BondEthernets and their member interfaces that are not in the config 2022-03-24 23:17:56 +00:00
731f7ecbb4 Implement Prune Step 5: Remove L2XC that are not in the config 2022-03-24 22:50:22 +00:00
721ac690cd Implement Prune Step 4: Remove members from bridgedomains, and remove bridgedomains not in the config 2022-03-24 22:25:37 +00:00
cd4d44a2b1 Implement Prune Step 3 -- remove BVI and Loopback interfaces and IPs that are not in the config 2022-03-24 22:02:31 +00:00
4666ba1611 Ensure bridgedomains exist in the YAML config before trying to look up BVIs in them 2022-03-24 21:57:39 +00:00
3a74a07ee6 Add get_by_bvi_name() and add a few hints on the difference between 'bridgename' (bd*) and 'bvi interfacename' (bvi*) 2022-03-24 21:38:13 +00:00
13f70758da merge conflict 2022-03-24 21:00:08 +00:00
15c54d5e1d Implement Prune Step 2: Remove any mismatched LCP, in correct order 2022-03-24 20:59:28 +00:00
d6e2e9765b Implement Prune Step 2: Remove any mismatched LCP, in correct order 2022-03-24 20:55:28 +00:00
82bcb24d5e Add get_by_lcp_name() + tests 2022-03-24 20:38:28 +00:00
de9ed1730d Add get_by_lcp_name() plus tests. Correct behavior of sub-ints without explicit encap: they are exact-match 2022-03-24 20:14:06 +00:00
95c08bbb29 Print an error if the number of errors is unexpected 2022-03-24 20:12:36 +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
29a8bae899 Add get_bondethernets() 2022-03-24 16:34:45 +00:00
de95e522ab Move VPPApi into a Reconciler class, add (empty) prune() create() and sync() methods. Add --force flag to enable making progress after warnings are issued 2022-03-24 15:57:12 +00:00
2e2f63e1dd Fix reporting of YAML tests; send retval based on the bitflags of tests passing/failing 2022-03-24 15:15:26 +00:00
cfcbec239c Cosmetic rename instance of config/validator class 2022-03-24 15:05:15 +00:00
672dd65f11 Rename validator/ to config/ 2022-03-24 13:56:04 +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
b43d7903fd Add a few additional useful functions
- is_*() returns True if the interface name is of a certain type
  is_bondethernet() is_loopback() is_bvi() is_bridgedomain()
  is_vxlan_tunnel() is_phy()
- get_phys() by process of elimination, returns all interface names
  that are supposed to be physical network interfaces.

Add unit tests for validator/vxlan_tunnel.py
 => Notable: while here, fix a bug in get_by_name()
Add unit tests for all the is_*() and get_phys() functions.
2022-03-24 10:55:33 +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