Allow TAP instances to be interfaces

- Cannot have LCP, Address or Sub-Interface
- Cannot be PHY
- Cannot be Bond member
- Can be target of L2XC
- Can be member of Bridge
- interface.mtu must be the same as tap.host.mtu

Add YAML tests for common mistakes. This unblocks taps becoming members
of a bridgedomain, and allowing a very cool feature: slowpath networking!
This commit is contained in:
Pim van Pelt
2022-04-10 16:10:19 +00:00
parent 5fc3b4c42b
commit 06046cd51a
3 changed files with 74 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import config.vxlan_tunnel as vxlan_tunnel
import config.lcp as lcp
import config.address as address
import config.mac as mac
import config.tap as tap
def get_qinx_parent_by_name(yaml, ifname):
""" Returns the sub-interface which matches a QinAD or QinQ outer tag, or None,None
@ -280,6 +281,8 @@ def is_phy(yaml, ifname):
return False
if vxlan_tunnel.is_vxlan_tunnel(yaml, ifname):
return False
if tap.is_tap(yaml, ifname):
return False
return True
@ -434,6 +437,26 @@ def validate_interfaces(yaml):
iface_lcp = get_lcp(yaml, ifname)
iface_address = has_address(yaml, ifname)
if ifname.startswith('tap'):
tap_ifname, tap_iface = tap.get_by_name(yaml, ifname)
if not tap_iface:
msgs.append("interface %s is a TAP but does not exist in taps" % (ifname))
result = False
elif 'mtu' in tap_iface['host']:
host_mtu = tap_iface['host']['mtu']
if host_mtu != iface_mtu:
msgs.append("interface %s is a TAP so its MTU %d must match host MTU %d" % (ifname, host_mtu, iface_mtu))
result = False
if iface_address:
msgs.append("interface %s is a TAP so it cannot have an address" % (ifname))
result = False
if iface_lcp:
msgs.append("interface %s is a TAP so it cannot have an LCP" % (ifname))
result = False
if has_sub(yaml, ifname):
msgs.append("interface %s is a TAP so it cannot have sub-interfaces" % (ifname))
result = False
if is_l2(yaml, ifname) and iface_lcp:
msgs.append("interface %s is in L2 mode but has LCP name %s" % (ifname, iface_lcp))
result = False

View File

@ -69,6 +69,9 @@ interfaces:
vxlan_tunnel1:
mtu: 2000
tap101:
mtu: 1500
loopbacks:
loop0:
lcp: "lo0"
@ -78,6 +81,11 @@ loopbacks:
mtu: 2000
mac: 02:de:ad:01:be:ef
addresses: [ 10.0.1.1/24, 2001:db8:1::1/64 ]
loop11:
lcp: "bvi11"
mtu: 1500
mac: 02:de:ad:11:be:ef
addresses: [ 10.0.2.1/24, 2001:db8:2::1/64 ]
bridgedomains:
bd1:
@ -86,9 +94,26 @@ bridgedomains:
interfaces: [ BondEthernet0.500, BondEthernet0.501, HundredGigabitEthernet12/0/1, vxlan_tunnel1 ]
bd11:
mtu: 1500
bvi: loop11
interfaces: [ tap101 ]
vxlan_tunnels:
vxlan_tunnel1:
local: 192.0.2.1
remote: 192.0.2.2
vni: 101
taps:
tap100:
host:
name: vpp-tap100
mac: 00:01:02:03:04:05
mtu: 9216
bridge: br0
rx-ring-size: 256
tx-ring-size: 256
tap101:
host:
name: vpp-tap101
mtu: 1500
bridge: br1

View File

@ -0,0 +1,26 @@
test:
description: "TAP interfaces cannot have LCP, address or sub-interfaces. MTU must match tap.host.mtu"
errors:
expected:
- "interface .* is a TAP so its MTU .* must match host MTU .*"
- "interface .* is a TAP so it cannot have an address"
- "interface .* is a TAP so it cannot have an LCP"
- "interface .* is a TAP so it cannot have sub-interfaces"
count: 4
---
interfaces:
tap0:
addresses: [ 10.0.0.1/24 ]
lcp: "mytap"
mtu: 9216
sub-interfaces:
100:
description: "TAP is not allowed to have a sub"
taps:
tap0:
host:
mac: 02:00:00:00:00:00
name: vpp-tap0
mtu: 1500
bridge: vpp-br0
namespace: vpp-test