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

Fix to use IPv6 linklocal address as snmp agent address #18350

Merged
merged 3 commits into from
May 12, 2024

Conversation

SuvarnaMeenakshi
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi commented Mar 13, 2024

Why I did it

  1. fix [snmp] Snmpd fails to start when mgmt or Loopback interface is configured with Link local IPv6 address #16001
  2. fix Timeout error while fetching response using snmpget #17807

#17045 modified minigraph parser to use management and loopback IPs to support SNMP query over IPv6. With this fix, if mgmt or loopback IP contains link local IP, that will not work as link local IP has to be appended with scope id associating the IP address to a specific interface. This PR change is to ensure that snmp works with link local IPv6 address.

Work item tracking
  • Microsoft ADO (number only):

How I did it

  1. Modify minigraph parser to append the Ip address with % scope id if snmp agent address being used is link local IP address.
  2. Modify snmpd.conf.j2 to take this change while checking if an IP address is ipv4 or ipv6.

How to verify it

Verified by configuring link local ipv6 address.
Last login: Wed Mar 13 01:45:09 2024 from 10.1.84.57
admin@<>:~$ sudo netstat -tulnp | grep 161
...
udp6 0 0 fe80::f6ee:31ff:fe9:161 :::* 70355/snmpd
..

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
@keboliu
Copy link
Collaborator

keboliu commented Mar 18, 2024

@SuvarnaMeenakshi seems the current unit test was broken, would you please check?

Signed-off-by: Suvarna Meenakshi <sumeenak@microsoft.com>
@SuvarnaMeenakshi
Copy link
Contributor Author

  1. parser to append the Ip address with % scope id if snmp agent address being used is l

done, please help review the changes. thank you.

for intf in list(mgmt_intf.keys()) + list(lo_intfs.keys()):
ip_addr = ipaddress.ip_address(UNICODE_TYPE(intf[1].split('/')[0]))
if ip_addr.version == 6 and ip_addr.is_link_local:
agent_addr = str(ip_addr) + '%' + intf[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%

  1. Is it a config schema disruptive change?
  2. Do you need to change yang model?
  3. We try hard to prevent minigraph parser behavior change since we will deploy config_db.json directly in production. So backward-compatible config schema change is preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is not a config_db schema change
  2. Yang change is already in place
  3. this change is mainly to append %(zone) if the IP address is a link local IP Address, inside the SNMP_AGENT_ADDRESS_CONFIG table which is used here: https://github.com/sonic-net/sonic-buildimage/blob/master/dockers/docker-snmp/snmpd.conf.j2#L29
    We cannot make this change in the template directly, because "zone" refers to the "interface name" to which the respective IP address belongs to, so we need to know what is the interface name while adding the IP address.

@bingwang-ms
Copy link
Contributor

@qiluo-msft Can you please review?

@lguohan lguohan merged commit a0ff20e into sonic-net:master May 12, 2024
19 checks passed
@lguohan lguohan added the snmp label May 12, 2024
@yxieca
Copy link
Contributor

yxieca commented May 13, 2024

@qiluo-msft , @SuvarnaMeenakshi is it safe to merge/cherry-pick this change?

@bingwang-ms
Copy link
Contributor

@SuvarnaMeenakshi Please raise a new PR for 202405 branch to address the conflict. Thanks

SuvarnaMeenakshi added a commit to sonic-net/sonic-utilities that referenced this pull request Aug 5, 2024
What I did
If link local IPv6 address is added as SNMP agent address, it will fail.
This PR requires changes in snmpd.conf.j2 template here sonic-net/sonic-buildimage#18350

How I did it
Append scope id to ipv6 link local IP address.

How to verify it
Able to configure link local ipv6 address as snmp agent address
sudo config snmpagentaddress add fe80::a%eth0
@dprital
Copy link
Collaborator

dprital commented Aug 8, 2024

@SuvarnaMeenakshi , Do we have already PR Vs. 202405 ?
Thanks.

@SuvarnaMeenakshi
Copy link
Contributor Author

@SuvarnaMeenakshi , Do we have already PR Vs. 202405 ? Thanks.

@dprital yes, the changes are already merged to 202405.
@bingwang-ms fixed the tags to reflect that the changes are merged in 202405.

 git log --oneline origin/202405 | grep "linklocal"
a0ff20edf [snmpd]: Fix to use IPv6 linklocal address as snmp agent address (#18350)

mssonicbld pushed a commit to mssonicbld/sonic-utilities that referenced this pull request Aug 12, 2024
What I did
If link local IPv6 address is added as SNMP agent address, it will fail.
This PR requires changes in snmpd.conf.j2 template here sonic-net/sonic-buildimage#18350

How I did it
Append scope id to ipv6 link local IP address.

How to verify it
Able to configure link local ipv6 address as snmp agent address
sudo config snmpagentaddress add fe80::a%eth0
mssonicbld pushed a commit to sonic-net/sonic-utilities that referenced this pull request Aug 12, 2024
What I did
If link local IPv6 address is added as SNMP agent address, it will fail.
This PR requires changes in snmpd.conf.j2 template here sonic-net/sonic-buildimage#18350

How I did it
Append scope id to ipv6 link local IP address.

How to verify it
Able to configure link local ipv6 address as snmp agent address
sudo config snmpagentaddress add fe80::a%eth0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants