Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing lldp issue displaying mac-addr instead of ports #1515

Merged
merged 1 commit into from
Mar 20, 2018

Conversation

rodnymolina
Copy link
Contributor

@rodnymolina rodnymolina commented Mar 20, 2018

Current lldp.conf.j2 template demands the presence of MGMT_INTERFACE attribute in configDB, and by extension, also in config_db.json file. However, MGMT_INTERFACE configuration attribute is optional, so lldp shouldn't bail out if this one isn't provided in configuration.

For this reason, no lldp.conf file is ever created in lldp container in scenarios where MGMT_INTERFACE is not defined, and lldpd defaults to advertise the mac-address of the connected interface, instead of the interface name.

The fix is to simply relax this jinja2 statement to verify if MGMT_INTERFACE attribute is present.

<-- Before

root@lnos-x1-a-asw02:/# sonic-cfggen -d -t /usr/share/sonic/templates/lldpd.conf.j2 > /etc/lldpd.conf
Traceback (most recent call last):
File "/usr/local/bin/sonic-cfggen", line 223, in
main()
File "/usr/local/bin/sonic-cfggen", line 204, in main
print template.render(data)
File
"/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line
1008,
in render return self.environment.handle_exception(exc_info, True)
File
"/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb)
File "/usr/share/sonic/templates/lldpd.conf.j2", line 1, in top-level template code
{% if MGMT_INTERFACE.keys() %}
File
"/usr/local/lib/python2.7/dist-packages/jinja2/environment.py",
line 430, in getattr return getattr(obj, attribute) jinja2.exceptions.UndefinedError: 'MGMT_INTERFACE' is undefined

admin@lnos-x1-a-csw01:~$ show lldp table
Command: sudo lldpshow
Capability codes: (R) Router, (B) Bridge, (O) Other
LocalPort    RemoteDevice     RemotePortID       Capability    RemotePortDescr
-----------  ---------------  -----------------  -----------------------------
Ethernet4    lnos-x1-a-asw02  00:e0:ec:3c:0a:16  BR            Ethernet112
--------------------------------------------------

<-- After

root@lnos-x1-a-asw02:/# sonic-cfggen -d -t /usr/share/sonic/templates/lldpd.conf.j2
...
configure ports Ethernet112 lldp portidsubtype local Eth29/1 description lnos-x1-a-csw01:Ethernet1

admin@lnos-x1-a-csw01:~$ show lldp table
Command: sudo lldpshow
Capability codes: (R) Router, (B) Bridge, (O) Other
LocalPort    RemoteDevice     RemotePortID       Capability    RemotePortDescr
-----------  ---------------  -----------------  -------------------------------------
Ethernet4    lnos-x1-a-asw02  Eth29/1            BR            lnos-x1-a-csw01:Ethernet1
--------------------------------------------------

Current lldp.conf.j2 template demands the presence of MGMT_INTERFACE attribute in configDB, and by extension, also in config_db.json file. However, MGMT_INTERFACE configuration attribute is optional, so lldp shouldn't bail out if this one isn't provided in configuration.

For this reason, no lldp.conf file is ever created in lldp's container, and lldpd defaults to advertise the mac-address of the connected interface, instead of the interface name.

The fix is to simply relax this jinja2 statement to verify if MGMT_INTERFACE attribute is present.

<-- Before

root@lnos-x1-a-asw02:/# sonic-cfggen -d -t /usr/share/sonic/templates/lldpd.conf.j2 > /etc/lldpd.conf
Traceback (most recent call last):
  File "/usr/local/bin/sonic-cfggen", line 223, in <module>
      main()
  File "/usr/local/bin/sonic-cfggen", line 204, in main
      print template.render(data)
  File
      "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line
      1008,
      in render return self.environment.handle_exception(exc_info, True)
  File
      "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 780, in handle_exception  reraise(exc_type, exc_value, tb)
  File "/usr/share/sonic/templates/lldpd.conf.j2", line 1, in top-level template code
      {% if MGMT_INTERFACE.keys() %}
  File
      "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py",
           line 430, in getattr return getattr(obj, attribute) jinja2.exceptions.UndefinedError: 'MGMT_INTERFACE' is undefined

admin@lnos-x1-a-csw01:~$ show lldp table
Command: sudo lldpshow
Capability codes: (R) Router, (B) Bridge, (O) Other
LocalPort    RemoteDevice     RemotePortID       Capability    RemotePortDescr
-----------  ---------------  -----------------  -----------------------------
Ethernet4    lnos-x1-a-asw02  00:e0:ec:3c:0a:16  BR            Ethernet112
--------------------------------------------------

<-- After

root@lnos-x1-a-asw02:/# sonic-cfggen -d -t /usr/share/sonic/templates/lldpd.conf.j2
...
configure ports Ethernet112 lldp portidsubtype local Eth29/1 description lnos-x1-a-csw01:Ethernet1

admin@lnos-x1-a-csw01:~$ show lldp table
Command: sudo lldpshow
Capability codes: (R) Router, (B) Bridge, (O) Other
LocalPort    RemoteDevice     RemotePortID       Capability    RemotePortDescr
-----------  ---------------  -----------------  -------------------------------------
Ethernet4    lnos-x1-a-asw02  Eth29/1            BR            lnos-x1-a-csw01:Ethernet1
--------------------------------------------------

RB=
G=lnos-reviewers
R=ntrianta,pmao,rmolina,sfardeen,zxu
A=
@jleveque jleveque merged commit 957e6c0 into sonic-net:master Mar 20, 2018
@rodnymolina rodnymolina deleted the lldp_template branch March 20, 2018 20:03
yxieca added a commit to yxieca/sonic-buildimage that referenced this pull request Apr 19, 2021
* 72510da 2021-04-19 | [201811] Stop PMON docker before cold boot and soft reboot (sonic-net#1515) (HEAD -> 201811, github/201811) [Aravind Mani]

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
yxieca added a commit that referenced this pull request Apr 20, 2021
* 72510da 2021-04-19 | [201811] Stop PMON docker before cold boot and soft reboot (#1515) (HEAD -> 201811, github/201811) [Aravind Mani]

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
theasianpianist pushed a commit to theasianpianist/sonic-buildimage that referenced this pull request Feb 5, 2022
…c-net#1515)

Signed-off-by: Vasant <vapatil@linkedin.com>
Co-authored-by: Danny Allen <daall@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants