diff --git a/config/bridgedomain.py b/config/bridgedomain.py index b860257..a85e0ac 100644 --- a/config/bridgedomain.py +++ b/config/bridgedomain.py @@ -99,6 +99,10 @@ def validate_bridgedomains(yaml): if instance == 0: msgs.append("bridgedomain %s is reserved" % ifname) result = False + elif instance > 16777215: + msgs.append("bridgedomain %s has instance %d which is too large" % (ifname, instance)) + result = False + if 'bvi' in iface: bviname = iface['bvi'] if (None,None) == loopback.get_by_name(yaml, bviname): diff --git a/config/loopback.py b/config/loopback.py index 09341d2..09fe243 100644 --- a/config/loopback.py +++ b/config/loopback.py @@ -61,8 +61,9 @@ def validate_loopbacks(yaml): for ifname, iface in yaml['loopbacks'].items(): logger.debug("loopback %s" % iface) - if 'addresses' in iface and not 'lcp' in iface: - msgs.append("loopback %s has an address but no LCP" % ifname) + instance = int(ifname[4:]) + if instance > 4095: + msgs.append("loopback %s has instance %d which is too large" % (ifname, instance)) result = False if 'lcp' in iface and not lcp.is_unique(yaml, iface['lcp']): msgs.append("loopback %s does not have a unique LCP name %s" % (ifname, iface['lcp'])) diff --git a/unittest/yaml/error-bridgedomain9.yaml b/unittest/yaml/error-bridgedomain9.yaml new file mode 100644 index 0000000..683bd5e --- /dev/null +++ b/unittest/yaml/error-bridgedomain9.yaml @@ -0,0 +1,15 @@ +test: + description: "BridgeDomain instance must be between 1 and 16M" + errors: + expected: + - "bridgedomain bd0 is reserved" + - "bridgedomain .* has instance .* which is too large" + count: 2 +--- +bridgedomains: + bd0: + description: "Reserved in VPP" + bd16777215: + description: "Cool." + bd16777216: + description: "Not cool." diff --git a/unittest/yaml/error-loopback1.yaml b/unittest/yaml/error-loopback1.yaml index e427da1..c70b88e 100644 --- a/unittest/yaml/error-loopback1.yaml +++ b/unittest/yaml/error-loopback1.yaml @@ -1,12 +1,12 @@ test: - description: "Cannot give an IP address to a loopback without LCP" + description: "Loopback instances must be between 0 and 4095" errors: expected: - - "loopback .* has an address but no LCP" + - "loopback .* has instance 4096 which is too large" count: 1 --- loopbacks: - loop10: - description: "Loopback instance loop10, with address, but no LCP" - mtu: 9216 - addresses: [ 192.0.2.1/29 ] + loop4095: + description: "Cool." + loop4096: + description: "Not cool."