diff options
| -rw-r--r-- | interface-definitions/lldp.xml.in | 1 | ||||
| -rw-r--r-- | python/vyos/validate.py | 6 | ||||
| -rwxr-xr-x | src/conf_mode/lldp.py | 17 | 
3 files changed, 21 insertions, 3 deletions
diff --git a/interface-definitions/lldp.xml.in b/interface-definitions/lldp.xml.in index b44f4baf6..774c15116 100644 --- a/interface-definitions/lldp.xml.in +++ b/interface-definitions/lldp.xml.in @@ -295,6 +295,7 @@                <constraint>                  <validator name="ip-address"/>                </constraint> +              <multi/>              </properties>            </leafNode>            <node name="snmp"> diff --git a/python/vyos/validate.py b/python/vyos/validate.py index 3f3166022..1ce5a8467 100644 --- a/python/vyos/validate.py +++ b/python/vyos/validate.py @@ -112,6 +112,12 @@ def is_addr_assigned(addr):      return False +def is_loopback_addr(addr): +    """ +    Check if supplied IPv4/IPv6 address is a loopback address +    """ +    return ipaddress.ip_address(addr).is_loopback +  def is_subnet_connected(subnet, primary=False):      """      Verify is the given IPv4/IPv6 subnet is connected to any interface on this diff --git a/src/conf_mode/lldp.py b/src/conf_mode/lldp.py index d8b8cb77e..51425aaaf 100755 --- a/src/conf_mode/lldp.py +++ b/src/conf_mode/lldp.py @@ -21,6 +21,7 @@ import jinja2  from copy import deepcopy  from vyos.config import Config +from vyos.validate import is_addr_assigned,is_loopback_addr  from vyos import ConfigError  # Please be careful if you edit the template. @@ -40,8 +41,8 @@ configure system description "VyOS {{ options.description }}"  {%- if listen_on -%}  configure system interface pattern "{{ options.listen_on | join(",") }}"  {%- endif %} -{% if options.addr -%} -configure system ip management pattern "{{ options.addr }}" +{% if options.mgmt_addr -%} +configure system ip management pattern {{ options.mgmt_addr | join(",") }}  {%- endif %}  {%- for loc in location -%}  {%- if loc.elin %} @@ -66,7 +67,17 @@ def get_options(config):      config.set_level('service lldp')      options['listen_vlan'] = config.exists('listen-vlan') -    options['addr'] = config.return_value('management-address') +    options['mgmt_addr'] = [] +    for addr in config.return_values('management-address'): +        if is_addr_assigned(addr) and not is_loopback_addr(addr): +            options['mgmt_addr'].append(addr) +        else: +            message = 'WARNING: LLDP management address {0} invalid - '.format(addr) +            if is_loopback_addr(addr): +                message += '(loopback address).' +            else: +                message += 'address not found.' +            print(message)      snmp = config.exists('snmp enable')      options["snmp"] = snmp  | 
