From 490c294014db378c93a34e9b067b096a9c38227e Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Sat, 3 Dec 2022 13:46:30 +0000 Subject: [PATCH] feature: add device-type to the schema This attribute of the 'interface' schema allows the user to prompt what type of PHY they are expecting this interface to be. It will serve an immediate and a future purpose. Immediate: presence of the 'dpdk' device-type in a list of interfaces will help an upcoming vppapy.mockconfig() to generate a cache without having to talk to the API. This is useful to generate a pre-compute a complete vpp.exec based off of an empty VPP dataplane Future: addition of different PHY types, notably RDMA and VirtualEthernet types TESTED: - Added a unit test to ensure that only is_phy() eligable interfaces receive the device-type attribute. - All unit and YAML tests pass. --- vppcfg/config/interface.py | 4 ++ vppcfg/intest/hippo-empty.yaml | 4 ++ vppcfg/intest/hippo1.yaml | 4 ++ vppcfg/intest/hippo10.yaml | 4 ++ vppcfg/intest/hippo11.yaml | 4 ++ vppcfg/intest/hippo12.yaml | 4 ++ vppcfg/intest/hippo13.yaml | 4 ++ vppcfg/intest/hippo14.yaml | 4 ++ vppcfg/intest/hippo2.yaml | 4 ++ vppcfg/intest/hippo3.yaml | 4 ++ vppcfg/intest/hippo4.yaml | 4 ++ vppcfg/intest/hippo5.yaml | 4 ++ vppcfg/intest/hippo6.yaml | 4 ++ vppcfg/intest/hippo7.yaml | 4 ++ vppcfg/intest/hippo8.yaml | 4 ++ vppcfg/intest/hippo9.yaml | 4 ++ vppcfg/schema.yaml | 1 + .../unittest/yaml/error-interface-type.yaml | 44 +++++++++++++++++++ 18 files changed, 109 insertions(+) create mode 100644 vppcfg/unittest/yaml/error-interface-type.yaml diff --git a/vppcfg/config/interface.py b/vppcfg/config/interface.py index be7d3b8..4755a93 100644 --- a/vppcfg/config/interface.py +++ b/vppcfg/config/interface.py @@ -447,6 +447,10 @@ def validate_interfaces(yaml): ) result = False + if "device-type" in iface and not is_phy(yaml, ifname): + msgs.append(f"interface {ifname} is not a PHY, cannot set device-type") + result = False + iface_mtu = get_mtu(yaml, ifname) iface_lcp = get_lcp(yaml, ifname) iface_address = has_address(yaml, ifname) diff --git a/vppcfg/intest/hippo-empty.yaml b/vppcfg/intest/hippo-empty.yaml index 970e046..3095257 100644 --- a/vppcfg/intest/hippo-empty.yaml +++ b/vppcfg/intest/hippo-empty.yaml @@ -1,20 +1,24 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 1500 mac: 00:25:90:0c:05:00 state: down description: Not Used GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 1500 mac: 00:25:90:0c:05:01 state: down description: Not Used HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 1500 mac: b4:96:91:b3:b1:10 state: down description: Not Used HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 1500 mac: b4:96:91:b3:b1:11 state: down diff --git a/vppcfg/intest/hippo1.yaml b/vppcfg/intest/hippo1.yaml index 73790fb..8679471 100644 --- a/vppcfg/intest/hippo1.yaml +++ b/vppcfg/intest/hippo1.yaml @@ -6,13 +6,16 @@ bondethernets: interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 description: "LAG #1" GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 9000 description: "LAG #2" HundredGigabitEthernet13/0/0: + device-type: "dpdk" lcp: "ice0" mtu: 9000 addresses: [ 192.0.2.17/30, 2001:db8:3::1/64 ] @@ -32,6 +35,7 @@ interfaces: exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 2000 description: "Bridged" diff --git a/vppcfg/intest/hippo10.yaml b/vppcfg/intest/hippo10.yaml index eb5f8e0..9d3e135 100644 --- a/vppcfg/intest/hippo10.yaml +++ b/vppcfg/intest/hippo10.yaml @@ -6,16 +6,20 @@ bondethernets: interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 description: "LAG #1" GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 9000 description: "LAG #2" HundredGigabitEthernet13/0/0: + device-type: "dpdk" description: Not Used HundredGigabitEthernet13/0/1: + device-type: "dpdk" description: Not Used BondEthernet0: diff --git a/vppcfg/intest/hippo11.yaml b/vppcfg/intest/hippo11.yaml index f3e804c..25ea07c 100644 --- a/vppcfg/intest/hippo11.yaml +++ b/vppcfg/intest/hippo11.yaml @@ -4,17 +4,21 @@ bondethernets: interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 description: "LAG #1" GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 9000 description: "LAG #2" HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 1500 description: "bridged with tap" HundredGigabitEthernet13/0/1: + device-type: "dpdk" description: Not Used BondEthernet0: diff --git a/vppcfg/intest/hippo12.yaml b/vppcfg/intest/hippo12.yaml index 4652836..4d7dd10 100644 --- a/vppcfg/intest/hippo12.yaml +++ b/vppcfg/intest/hippo12.yaml @@ -6,13 +6,16 @@ bondethernets: interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 description: "LAG #1" GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 9000 description: "LAG #2" HundredGigabitEthernet13/0/0: + device-type: "dpdk" lcp: "ice12-0-0" mtu: 9000 addresses: [ 192.0.2.17/30, 2001:db8:3::1/64 ] @@ -32,6 +35,7 @@ interfaces: exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 2000 description: "Bridged" diff --git a/vppcfg/intest/hippo13.yaml b/vppcfg/intest/hippo13.yaml index 4ee4410..42ea00d 100644 --- a/vppcfg/intest/hippo13.yaml +++ b/vppcfg/intest/hippo13.yaml @@ -5,13 +5,16 @@ bondethernets: interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 description: "LAG #1" GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 9000 description: "LAG #2" HundredGigabitEthernet13/0/0: + device-type: "dpdk" lcp: "ice0" mtu: 9000 addresses: [ 192.0.2.17/30, 2001:db8:3::1/64 ] @@ -31,6 +34,7 @@ interfaces: exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 2000 description: "Bridged" diff --git a/vppcfg/intest/hippo14.yaml b/vppcfg/intest/hippo14.yaml index 81d24bb..33e91b4 100644 --- a/vppcfg/intest/hippo14.yaml +++ b/vppcfg/intest/hippo14.yaml @@ -1,5 +1,6 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 state: up sub-interfaces: @@ -7,16 +8,19 @@ interfaces: mtu: 9000 l2xc: tap100 GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 1500 mac: 00:25:90:0c:05:01 state: down description: Not Used HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 1500 mac: b4:96:91:b3:b1:10 state: down description: Not Used HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 1500 mac: b4:96:91:b3:b1:11 state: down diff --git a/vppcfg/intest/hippo2.yaml b/vppcfg/intest/hippo2.yaml index 75714ee..f0f1d2b 100644 --- a/vppcfg/intest/hippo2.yaml +++ b/vppcfg/intest/hippo2.yaml @@ -1,5 +1,6 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" sub-interfaces: 100: description: "Sub-int" @@ -20,6 +21,7 @@ interfaces: exact-match: true GigabitEthernet3/0/1: + device-type: "dpdk" sub-interfaces: 100: description: "Sub-int" @@ -34,6 +36,7 @@ interfaces: inner-dot1q: 100 HundredGigabitEthernet13/0/0: + device-type: "dpdk" sub-interfaces: 100: description: "Sub-int" @@ -48,6 +51,7 @@ interfaces: inner-dot1q: 100 HundredGigabitEthernet13/0/1: + device-type: "dpdk" sub-interfaces: 100: description: "Sub-int" diff --git a/vppcfg/intest/hippo3.yaml b/vppcfg/intest/hippo3.yaml index b934e27..32c5d4a 100644 --- a/vppcfg/intest/hippo3.yaml +++ b/vppcfg/intest/hippo3.yaml @@ -6,14 +6,18 @@ bondethernets: interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 description: LAG GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 9000 description: LAG HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 2500 HundredGigabitEthernet13/0/1: + device-type: "dpdk" description: Not Used BondEthernet1: diff --git a/vppcfg/intest/hippo4.yaml b/vppcfg/intest/hippo4.yaml index 489c2ea..d221483 100644 --- a/vppcfg/intest/hippo4.yaml +++ b/vppcfg/intest/hippo4.yaml @@ -1,5 +1,6 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mac: 12:00:ba:03:00:00 mtu: 9216 sub-interfaces: @@ -7,8 +8,10 @@ interfaces: mtu: 2000 l2xc: HundredGigabitEthernet13/0/1.100 GigabitEthernet3/0/1: + device-type: "dpdk" description: Not Used HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -20,6 +23,7 @@ interfaces: inner-dot1q: 200 exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: diff --git a/vppcfg/intest/hippo5.yaml b/vppcfg/intest/hippo5.yaml index f255f15..e0e0e3b 100644 --- a/vppcfg/intest/hippo5.yaml +++ b/vppcfg/intest/hippo5.yaml @@ -1,5 +1,6 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -9,9 +10,11 @@ interfaces: mtu: 1500 l2xc: vxlan_tunnel1 GigabitEthernet3/0/1: + device-type: "dpdk" lcp: "e3-0-1" addresses: [ 10.0.0.1/24 ] HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -23,6 +26,7 @@ interfaces: inner-dot1q: 200 exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 9216 vxlan_tunnel0: mtu: 2000 diff --git a/vppcfg/intest/hippo6.yaml b/vppcfg/intest/hippo6.yaml index e3af0e4..bdf5167 100644 --- a/vppcfg/intest/hippo6.yaml +++ b/vppcfg/intest/hippo6.yaml @@ -1,5 +1,6 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -8,9 +9,11 @@ interfaces: 101: mtu: 3000 GigabitEthernet3/0/1: + device-type: "dpdk" lcp: "e3-0-1" addresses: [ 10.0.0.1/24 ] HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -22,6 +25,7 @@ interfaces: inner-dot1q: 200 exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 9216 vxlan_tunnel0: mtu: 2000 diff --git a/vppcfg/intest/hippo7.yaml b/vppcfg/intest/hippo7.yaml index c3e8a06..938025b 100644 --- a/vppcfg/intest/hippo7.yaml +++ b/vppcfg/intest/hippo7.yaml @@ -1,5 +1,6 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mac: 02:ff:ba:03:00:00 mtu: 9216 sub-interfaces: @@ -9,8 +10,10 @@ interfaces: 101: mtu: 3000 GigabitEthernet3/0/1: + device-type: "dpdk" description: Not Used HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -22,6 +25,7 @@ interfaces: inner-dot1q: 200 exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 9216 vxlan_tunnel0: mtu: 2000 diff --git a/vppcfg/intest/hippo8.yaml b/vppcfg/intest/hippo8.yaml index d2bfc61..a8a4b95 100644 --- a/vppcfg/intest/hippo8.yaml +++ b/vppcfg/intest/hippo8.yaml @@ -1,5 +1,6 @@ interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -8,8 +9,10 @@ interfaces: 101: mtu: 3000 GigabitEthernet3/0/1: + device-type: "dpdk" description: Not Used HundredGigabitEthernet13/0/0: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: @@ -21,6 +24,7 @@ interfaces: inner-dot1q: 200 exact-match: True HundredGigabitEthernet13/0/1: + device-type: "dpdk" mtu: 9216 sub-interfaces: 100: diff --git a/vppcfg/intest/hippo9.yaml b/vppcfg/intest/hippo9.yaml index beab0ae..17283f7 100644 --- a/vppcfg/intest/hippo9.yaml +++ b/vppcfg/intest/hippo9.yaml @@ -5,17 +5,21 @@ bondethernets: interfaces: GigabitEthernet3/0/0: + device-type: "dpdk" mtu: 9000 description: "LAG #1" GigabitEthernet3/0/1: + device-type: "dpdk" mtu: 9000 description: "LAG #2" HundredGigabitEthernet13/0/0: + device-type: "dpdk" mac: 02:ff:ba:12:00:00 lcp: "ice0" HundredGigabitEthernet13/0/1: + device-type: "dpdk" lcp: "ice1" mtu: 9000 addresses: [ 192.0.2.17/30, 2001:db8:3::1/64 ] diff --git a/vppcfg/schema.yaml b/vppcfg/schema.yaml index e323988..2baadb6 100644 --- a/vppcfg/schema.yaml +++ b/vppcfg/schema.yaml @@ -50,6 +50,7 @@ interface: sub-interfaces: map(include('sub-interface'),key=int(min=1,max=4294967295),required=False) l2xc: str(required=False) state: enum('up', 'down', required=False) + device-type: enum('dpdk', required=False) --- sub-interface: description: str(exclude='\'"',len=64,required=False) diff --git a/vppcfg/unittest/yaml/error-interface-type.yaml b/vppcfg/unittest/yaml/error-interface-type.yaml new file mode 100644 index 0000000..297025d --- /dev/null +++ b/vppcfg/unittest/yaml/error-interface-type.yaml @@ -0,0 +1,44 @@ +test: + description: "Device types can be set on physical interface only" + errors: + expected: + - ".*interface BondEthernet0 is not a PHY, cannot set device-type" + - ".*interface vxlan_tunnel0 is not a PHY, cannot set device-type" + count: 2 +--- +bondethernets: + BondEthernet0: + mac: 00:01:02:03:04:05 + description: "Infra: xsw0.lab.ipng.ch LACP" + interfaces: [ GigabitEthernet2/0/0, GigabitEthernet2/0/1 ] + +interfaces: + GigabitEthernet1/0/0: + device-type: 'dpdk' + + GigabitEthernet2/0/0: + description: "Infra: LAG to xsw0" + + GigabitEthernet2/0/1: + description: "Infra: LAG to xsw1" + + BondEthernet0: + device-type: 'dpdk' ## bond-ethernets cannot have device-type set + description: "Bond, James Bond!" + + vxlan_tunnel0: + device-type: 'dpdk' + mtu: 1500 + +vxlan_tunnels: + vxlan_tunnel0: + local: 192.0.2.1 + remote: 192.0.2.2 + vni: 100 + +loopbacks: + loop0: + description: "Core: example.ipng.ch" + mtu: 9216 + lcp: "loop0" + addresses: [ 192.0.2.1/32, 2001:db8:1::1/128 ]