32a832a8ac
Fix #5812 LLDP conf Jinja2 Template does not verify IPv4 address and can use IPv6 version. This issue does not effect control LLDP daemon. Issue can be reproduced via `test_snmp_lldp` test. LLDP conf Jinja2 Template selects first item from the list of mgmt interfaces. TESTBED_1 LLDP conf ``` # cat /etc/lldpd.conf configure ports eth0 lldp portidsubtype local eth0 configure system ip management pattern FC00:3::32 configure system hostname dut-1 ``` TESTBED_2 LLDP conf ``` # cat /etc/lldpd.conf configure ports eth0 lldp portidsubtype local eth0 configure system ip management pattern 10.22.24.61 configure system hostname dut-2 ``` TESTBED_1 MGMT_INTERFACE ``` $ redis-cli -n 4 keys "*" | grep MGMT_INTERFACE MGMT_INTERFACE|eth0|10.22.24.53/23 MGMT_INTERFACE|eth0|FC00:3::32/64 ``` TESTBED_2 MGMT_INTERFACE ``` $ redis-cli -n 4 keys "*" | grep MGMT_INTERFACE MGMT_INTERFACE|eth0|FC00:3::32/64 MGMT_INTERFACE|eth0|10.22.24.61/23 ``` Signed-off-by: Petro Bratash <petrox.bratash@intel.com>
22 lines
935 B
Django/Jinja
22 lines
935 B
Django/Jinja
{% set mgmt_if = {} %}
|
|
{% if MGMT_INTERFACE %}
|
|
{% for (mgmt_name, mgmt_prefix) in MGMT_INTERFACE|pfx_filter %}
|
|
{% if mgmt_prefix|ipv4 %}
|
|
{% if mgmt_if.update({'port_name' : mgmt_name}) %} {% endif %}
|
|
{% if mgmt_if.update({'ipv4' : mgmt_prefix|ip}) %} {% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if mgmt_if %}
|
|
{# If MGMT port alias is available, use it for port ID subtype, otherwise use port name #}
|
|
{% if MGMT_PORT and MGMT_PORT[mgmt_if.port_name] and MGMT_PORT[mgmt_if.port_name].alias %}
|
|
configure ports eth0 lldp portidsubtype local {{ MGMT_PORT[mgmt_if.port_name].alias }}
|
|
{% else %}
|
|
configure ports eth0 lldp portidsubtype local {{ mgmt_if.port_name }}
|
|
{% endif %}
|
|
configure system ip management pattern {{ mgmt_if.ipv4 }}
|
|
{% endif %}
|
|
configure system hostname {{ DEVICE_METADATA['localhost']['hostname'] }}
|
|
{# pause lldpd operations until all interfaces are well configured, resume command will run in lldpmgrd #}
|
|
pause
|