-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 ECMP calculator tool #12482
Add ECMP calculator tool #12482
Conversation
This pull request introduces 1 alert when merging b53de67 into a0661e2 - view on LGTM.com new alerts:
|
This pull request introduces 4 alerts when merging d97f5c0 into 6bed69a - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging 5b6d48c into 6bed69a - view on LGTM.com new alerts:
|
@liorghub is this PR ready for review? anything else is missing? |
@liat-grozovik No, this PR is not ready for review. Rest of the code is ready and reviewed internally, I will publish it once I will get verification approval. |
@liat-grozovik @nazariig |
/azp run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
@liat-grozovik Compilation is failing since SDK does not contain hash calculator debian. PR Add SDK hash calculator debian to SONiC Bullseye should be merged to fix it. Build log error:
|
delete_uint32_t_p(entries_cnt_p) | ||
delete_sx_ip_prefix_t_p(ip_prefix_p) | ||
|
||
def sx_router_operational_ecmp_get(handle, ecmp_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this API to something like sx_router_ecmp_get_nexthops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, API name changed.
delete_sx_router_id_t_p(vrid_p) | ||
|
||
def sx_port_vport_base_get(handle, vport): | ||
""" Get SDK logical index for given vport |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logical index and Vlan?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I updated function documentation.
handle (sx_api_handle_t): SDK handle | ||
rif (sx_port_id_t): SDK vport id | ||
addr (sx_ip_addr_t): Neighbour IP address | ||
type_ipv6 (bool): True for IPv6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type_ipv6 is not used. Please remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable type_ipv6 was removed.
@@ -70,4 +71,10 @@ RUN mkdir -p /etc/supervisor/conf.d/ | |||
RUN sonic-cfggen -a "{\"ENABLE_ASAN\":\"{{ENABLE_ASAN}}\"}" -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf | |||
RUN rm -f /usr/share/sonic/templates/supervisord.conf.j2 | |||
|
|||
RUN mkdir -p /usr/bin/ecmp_calculator | |||
COPY ["ecmp_calculator/ecmp_calc_sdk.py", "/usr/bin/ecmp_calculator"] | |||
COPY ["ecmp_calculator/ecmp_calc.py", "/usr/bin/ecmp_calculator"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from ecmp_calc.py other files are not binaries but libraries.Can we package them accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
def validate_inner_header(self): | ||
inner_header = None | ||
try: | ||
inner_header = self.packet['packet_info']['inner'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead we could do something like inner_header = self.packet['packet_info'].get('inner') instead of doing try except. get will return None if there is no such key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed the code to use get().
if ip in header and is_ip_valid(header[ip], IP_VERSION_IPV6) == False: | ||
raise ValueError("Json validation failed: invalid IP {}".format(header[ip])) | ||
|
||
def validate_layer2_header(self, header): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should ethertype, vlan and other L2 fields be validated as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By design, Ethertype, vlan and other L2 fields are being validated for their types only.
Each field is defined in PACKET_SCHEME as a number or as a string and validation is being performed using python3-jsonschema module.
|
||
raise ValueError("VRF validation failed: VRF {} does not exist".format(self.user_vrf)) | ||
|
||
def get_ecmp_ids(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_ecmp_id* since we will get only one per route
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function name changed to get_ecmp_id().
log_cb_fn = log_cb_type(log_cb) | ||
handle_p = ctypes.pointer(ctypes.c_int64()) | ||
|
||
rc = sx_api.sx_api_open(log_cb_fn, handle_p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During cleanup before the application exits can we invoke sx_api_close?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added call to sx_api_close() in destructor.
This reverts commit f61999a.
/azp run Azure.sonic-buildimage |
Commenter does not have sufficient privileges for PR 12482 in repo sonic-net/sonic-buildimage |
/azpw run Azure.sonic-buildimage |
/AzurePipelines run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
lane_index = get_lane_index(lane_bmap, ASIC_MAX_LANES[chip_type]) | ||
assert lane_index != -1, "Failed to calculate port index" | ||
|
||
sonic_index = label_port * ASIC_MAX_LANES[chip_type] + lane_index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if label port start from 1 or 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label port is the port number printed on the front panel minus one.
On ACS-MSN3700C with 32 ports, first label port is 0 and last is 31 (total of 32 as expected).
out = exec_cmd([HASH_CALC_PATH, '-c', HASH_CALC_INPUT_FILE, '-o', HASH_CALC_OUTPUT_FILE, '-d']) | ||
self.debug_print ("Hash calculator output:\n{}".format(out)) | ||
|
||
with open(HASH_CALC_OUTPUT_FILE, 'r') as openfile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to delete the file after using it. There is no delete for this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added call to temporary files cleanup in destructor.
…compile it (sonic-net#12840) - Why I did it Add SDK hash calculator Debian and update SDK makefile to compile it. - How I did it SDK hash calculator Debian will be used by ECMP calculator (PR sonic-net#12482) - How to verify it Compile sonic-buildimage and verify SDK hash calculator Debian exist in target folder.
- Why I did it Added ECMP calculator tool. - How I did it New files were added. - How to verify it Manual tests performed according to tests chapter in HLD Automated tests will be added by verification.
Cherry-pick PR to 202211: #13301 |
This PR must be merged after PR #12840
Why I did it
Added ECMP calculator tool.
How I did it
New files were added.
How to verify it
Manual tests performed according to tests chapter in HLD
Automated tests will be added by verification.
Which release branch to backport (provide reason below if selected)
Description for the changelog
Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)