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

[SNMP][IPv6]: Fix to use link local IPv6 address as snmp agentAddress #16013

Merged
merged 4 commits into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions dockers/docker-snmp/snmpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,27 @@ agentAddress {{ protocol(agentip) }}:[{{ agentip }}]{% if port %}:{{ port }}{% e
{% endfor %}
{% elif NAMESPACE_COUNT is not defined or NAMESPACE_COUNT|int <= 1 %}
{% if MGMT_INTERFACE is defined %}
{% for if, ip in MGMT_INTERFACE %}
{% set agentip = ip.split('/')[0] %}
agentAddress {{ protocol(agentip) }}:[{{ agentip }}]:161
{% for intf, ip in MGMT_INTERFACE %}
{% set agentip = ip.split('/')[0]|lower %}
{% set zoneid = '' %}
# Use interface as zoneid for link local ipv6
{% if agentip.startswith('fe80') %}
Copy link
Collaborator

@qiluo-msft qiluo-msft Aug 3, 2023

Choose a reason for hiding this comment

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

fe80

add test case? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added here sonic-net/sonic-mgmt#9268
Will move out of draft once this is merged in

{% set zoneid = '%' + intf %}
{% endif %}
agentAddress {{ protocol(agentip) }}:[{{ agentip }}{{ zoneid }}]:161
{% endfor %}
{% endif %}
{% if LOOPBACK_INTERFACE is defined %}
{% for lo in LOOPBACK_INTERFACE %}
{% if lo | length == 2 %}
{% set agentip = lo[1].split('/')[0] %}
agentAddress {{ protocol(agentip) }}:[{{ agentip }}]:161
{% set intf = lo[0] %}
{% set agentip = lo[1].split('/')[0]|lower %}
{% set zoneid = '' %}
# Use interface as zoneid for link local ipv6
{% if agentip.startswith('fe80') %}
{% set zoneid = '%' + intf %}
{% endif %}
agentAddress {{ protocol(agentip) }}:[{{ agentip }}{{ zoneid }}]:161
{% endif %}
{% endfor %}
{% endif %}
Expand Down