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

Add function to retrieve docker0 ipv4 and ipv6 addresses #15606

Closed
wants to merge 3 commits into from

Conversation

SuvarnaMeenakshi
Copy link
Contributor

@SuvarnaMeenakshi SuvarnaMeenakshi commented Jun 23, 2023

Why I did it

#15487 this PR modifies snmpd to listen on specific IPs.
By default, snmpd will listen on management and loopback0 ipv4 and ipv6 addresses for single asic platform.
snmpd will listen will listen on management and docker0 ip address for multi asic platforn.
This PR is to add function to retrieve docker0 ip addresses for multi-asic platform, which could be used generically.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Add a new function get_docker0_ip() in sonic_py_common to get docker0 ipv4 and ipv6 address on multi-asic platform.

How to verify it

on multi-asic platform

>>> from sonic_py_common.multi_asic import get_docker0_ip
>>> get_docker0_ip()
('240.127.1.1', 'fd00::1')
>>> 

on single-asic platform

>>> from sonic_py_common.multi_asic import get_docker0_ip
>>> get_docker0_ip()
(None, None)

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>
@@ -484,3 +485,26 @@ def get_asic_presence_list():
# asic is asid id: asic0, asic1.... asicN. Get the numeric value.
asics_list.append(int(get_asic_id_from_name(asic)))
return asics_list

def get_docker0_ip():
Copy link
Collaborator

Choose a reason for hiding this comment

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

get_docker0_ip

get_docker0_ips

docker0_v6 = None

# return (None, None) for single asic platform
if not is_multi_asic():
Copy link
Collaborator

Choose a reason for hiding this comment

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

is_multi_asic

Is it harmful to let single-asic return the proper ips?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helper function is added so that we could use this to get docker0 ip for multi-asic platform.
Most likely we will need docker0 information only for multi-asic platform.
For example, we want to update SNMP_AGENT_ADDRESS_CONFIG table in config_db with docker0 and mgmt IP in miniraph parser and we could avoid adding the single/multi-asic in minigraph parser if we ensure that required IP is passed from this helped function.

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

Do not plan to use this change.

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.

2 participants