Commit Graph

44 Commits

Author SHA1 Message Date
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
27ce2351c7 Cosmetic: use '.. LCP' consistently 2022-03-22 18:49:31 +00:00
7303adb74a Assert is_l2() on sub-ints cannot have address or LCP 2022-03-22 15:02:38 +00:00
077d49cb88 Assert that is_l2() interfaces cannot have LCP or address; Fix consistency on 'be' vs 'have' an LCP. 2022-03-22 14:54:09 +00:00
6688c6b243 Add the case of the ifname being the source of an l2xc to the is_l2() logic1
This is more strict than VPP itself, which does allow a destination to
be L3 while the source is L2:

DBGvpp# show mode
l3 local0
l3 GigabitEthernet3/0/0
l3 GigabitEthernet3/0/1
l3 HundredGigabitEthernet12/0/0
l3 HundredGigabitEthernet12/0/1

DBGvpp# set interface l2 xconnect GigabitEthernet3/0/0 GigabitEthernet3/0/1

DBGvpp# show mode
l3 local0
l2 xconnect GigabitEthernet3/0/0 GigabitEthernet3/0/1
l3 GigabitEthernet3/0/1
l3 HundredGigabitEthernet12/0/0
l3 HundredGigabitEthernet12/0/1

But it seems undesirable to have Gi3/0/1 be in l3 mode even though it's
the target of a cross connect, so I'm going to leave the behavior
stricter than VPP.
2022-03-22 14:21:32 +00:00
907412f49c Fix bug in get_l2xc_interfaces(), and add tests for it 2022-03-22 13:15:21 +00:00
c18f04fa55 Refactor: stop trying to derive implicit LCP names. Make it mandatory and explicitly configured 2022-03-21 11:06:15 +00:00
ba22b1aad8 Refactor for *_get_by_name()
They now all return a list [ifname, iface]. If no interface was found
they return None,None. If one was found, they return the (string) name
and the dictionary with interface contents.
2022-03-21 08:47:05 +00:00
5247e3a241 Add the beginning of a test_qinx() suite, will complete after a refactor in an upcoming commit 2022-03-20 23:32:59 +00:00
e44db47989 Add interface.get_qinx_parent_by_name() 2022-03-20 23:10:54 +00:00
c55fe93e16 Add unit tests for bridgedomain - move is_bridge_interface*() functions to validator/bridgedomain.py 2022-03-20 22:45:07 +00:00
1f07f7eadf Add unit tests for bondethernet 2022-03-20 22:17:41 +00:00
8445140842 Add unittests for validator/interface.py 2022-03-20 21:49:08 +00:00
dbd7bca8f3 Add get_encapsulation; refactor unique_encapsulation to use it. All tests pass. 2022-03-20 16:45:03 +00:00
f921b1721a Expand autocreated LCP namelen to all possible (dot1q, qin*) scenarios. Allow manually set LCP to be 15char in length 2022-03-17 00:15:18 +00:00
3663a04cde Bugfix: check sub_iface instead of iface 2022-03-16 23:57:47 +00:00
6b6207f028 define 'is_l2' the same way VPP does: in a bridge or as an L2XC target. 2022-03-16 23:16:46 +00:00
ccfb51189a A few small refactors, using get_by_name() more, casting boolean return values, etc 2022-03-16 22:20:51 +00:00
1e5b1e49ad Assert that an interface cannot l2 cross connect to itself 2022-03-15 22:36:48 +00:00
e7e3958ceb Assert source/target L2XC are the same MTU 2022-03-15 22:32:55 +00:00
05b3c5c157 Small refactor, to allow for more interface types to be added as l2xc targets later 2022-03-15 21:56:29 +00:00
af90b37a33 bugfix: Use sub-interface name 2022-03-15 21:52:44 +00:00
2947bbfd25 Get rid of ' characters in errors 2022-03-15 21:13:42 +00:00
2bbcff2ca0 Also assert that targets of an L2XC do not have an address or LCP 2022-03-15 21:07:47 +00:00
c5872880fe Add l2xc support, including extensive tests to validate correct usage of the feature 2022-03-15 20:45:27 +00:00
b9a7bb697e Add validator to ensure that bridgedomain interfaces occur in at most one bridgedomain. Ironically, this caught a bug in the bridgedomain5 test, where Gi1/0/0 was added twice. 2022-03-15 19:48:32 +00:00
13f211f27a Make clearer that 'is not allowed' actually means that the address conflicts with another 2022-03-14 00:18:46 +00:00
bb57ed8e52 IP Address validator
Returns True if there is at most one occurence of the ip_interface (an IPv4/IPv6 prefix+len)
in the entire config. That said, we need the 'iface_addresses' because VPP is a bit fickle in
this regard.

IP addresses from the same prefix/len can be added to a given interface (ie 192.0.2.1/24 and
192.0.2.2/24), but other than that, any prefix can not occur as a more-specific or less-specific
of any other interface.

So, we will allow:
- any ip_interface that is of equal network/len of existing one(s) _on the same interface_

And, we will reject
- any ip_interface that is a more specific of any existing one
- any ip_interface that is a less specific of any existing one

Update unit tests to ensure ip_interfaces are allowed in all cases.
2022-03-13 23:50:10 +00:00
5c61259edd Add copyright and license 2022-03-13 21:08:32 +00:00
763c1ca74c Ensure that LCP names are globally unique (between interface/sub-interface/loopback/bridgedomain) 2022-03-13 19:53:13 +00:00
1340e5db42 Remove the attempted plural 'address(es)', and keep it singular. Fix a typo (addd-ress); update unit tests 2022-03-13 19:08:45 +00:00
527b1ca95b Add a set of bridgedomain unit tests, including a fully formed correct one. Fix one bug found along the way! 2022-03-13 18:55:00 +00:00
cc0ec92638 Bugfix - get correct parent MTU 2022-03-13 17:42:16 +00:00
881c0faaab Only pass 'schema' to the validator creation. 2022-03-13 16:48:52 +00:00
0313666f69 Force LCP names to be unique 2022-03-13 13:17:14 +00:00
2ced42e97a Add constraint for unique encapsulation
if any sub-int exists with a certain [dot1q,dot1ad,inner-dot1q], no
other sub-int in the same parent may exist with the same encapsulation.

- refactor sub-int mtu check to use get_mtu()
- if a sub-int has no config, raise a validation error
2022-03-13 13:06:44 +00:00
29fcdaefe9 Add check to ensure combined length of sub-int LCP name is not larger than 15 chars. For the main int, this is ensured already by schema validation 2022-03-13 12:38:54 +00:00
e7e957ed5f Ensure that when the sub-int is L3, exact-match must be true 2022-03-13 12:19:38 +00:00
6b8735bb18 Add bridge-domain support.
Refactor validator main function to avoid 'interface' symbol clash.
Add get_mtu() for interfaces, returns the sub-int's MTU or its parent's MTU, defaulting to 1500.
Ensure MTU for all bridge-domain members is set to the same value.
Ensure all bridge-domain members are L2 (have no LCP, have no address)
2022-03-13 11:20:40 +00:00
3d6903bfdc Rewrite 'exists' to 'get_by_name' 2022-03-13 10:44:59 +00:00
b5d8f03e66 Add MTU validation - sub cannot be higher than parent 2022-03-13 10:12:07 +00:00
9250e07aed Continue validation even after error occurs, catching as many errors as possible for the user 2022-03-13 09:58:29 +00:00
9862129ab0 Initial commit 2022-03-13 09:54:50 +00:00