Add MTU validation - sub cannot be higher than parent
This commit is contained in:
@ -7,14 +7,16 @@ bondethernet:
|
|||||||
---
|
---
|
||||||
interface:
|
interface:
|
||||||
description: str(exclude='\'"',required=False)
|
description: str(exclude='\'"',required=False)
|
||||||
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
|
|
||||||
mac: mac(required=False)
|
mac: mac(required=False)
|
||||||
|
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
|
||||||
|
mtu: int(min=128,max=9216,required=False)
|
||||||
addresses: list(ip_interface(),min=1,max=6,required=False)
|
addresses: list(ip_interface(),min=1,max=6,required=False)
|
||||||
sub-interfaces: map(include('sub-interface'),key=int(min=1,max=4294967295),required=False)
|
sub-interfaces: map(include('sub-interface'),key=int(min=1,max=4294967295),required=False)
|
||||||
---
|
---
|
||||||
sub-interface:
|
sub-interface:
|
||||||
description: str(exclude='\'"',required=False)
|
description: str(exclude='\'"',required=False)
|
||||||
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
|
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
|
||||||
|
mtu: int(min=128,max=9216,required=False)
|
||||||
addresses: list(ip_interface(),required=False)
|
addresses: list(ip_interface(),required=False)
|
||||||
encapsulation: include('encapsulation',required=False)
|
encapsulation: include('encapsulation',required=False)
|
||||||
---
|
---
|
||||||
@ -23,4 +25,3 @@ encapsulation:
|
|||||||
dot1ad: int(min=1,max=4095,required=False)
|
dot1ad: int(min=1,max=4095,required=False)
|
||||||
inner-dot1q: int(min=1,max=4095,required=False)
|
inner-dot1q: int(min=1,max=4095,required=False)
|
||||||
exact-match: bool(required=False)
|
exact-match: bool(required=False)
|
||||||
|
|
||||||
|
@ -121,6 +121,10 @@ def interface(args, yaml):
|
|||||||
msgs.append("interface %s does not exist in bondethernets" % ifname)
|
msgs.append("interface %s does not exist in bondethernets" % ifname)
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
|
if 'mtu' in iface:
|
||||||
|
iface_mtu = iface['mtu']
|
||||||
|
else:
|
||||||
|
iface_mtu = 1500
|
||||||
iface_lcp = has_lcp(yaml, ifname)
|
iface_lcp = has_lcp(yaml, ifname)
|
||||||
iface_address = has_address(yaml, ifname)
|
iface_address = has_address(yaml, ifname)
|
||||||
|
|
||||||
@ -132,6 +136,10 @@ def interface(args, yaml):
|
|||||||
for sub_id, sub_iface in yaml['interfaces'][ifname]['sub-interfaces'].items():
|
for sub_id, sub_iface in yaml['interfaces'][ifname]['sub-interfaces'].items():
|
||||||
sub_ifname = "%s.%d" % (ifname, sub_id)
|
sub_ifname = "%s.%d" % (ifname, sub_id)
|
||||||
logger.debug("sub-interface %s" % sub_iface)
|
logger.debug("sub-interface %s" % sub_iface)
|
||||||
|
if 'mtu' in sub_iface:
|
||||||
|
if sub_iface['mtu'] > iface_mtu:
|
||||||
|
msgs.append("sub-interface %s has MTU %d higher than parent MTU %d" % (sub_ifname, sub_iface['mtu'], iface_mtu))
|
||||||
|
result = False
|
||||||
if has_lcp(yaml, sub_ifname):
|
if has_lcp(yaml, sub_ifname):
|
||||||
if not iface_lcp:
|
if not iface_lcp:
|
||||||
msgs.append("sub-interface %s has LCP but %s does not have LCP" % (sub_ifname, ifname))
|
msgs.append("sub-interface %s has LCP but %s does not have LCP" % (sub_ifname, ifname))
|
||||||
|
Reference in New Issue
Block a user