-
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
Merged
Merged
Add ECMP calculator tool #12482
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ffcad80
Add ECMP calculator SDK module
liorghub b53de67
Fix review comments
liorghub 6c4162e
Add SDK hash calculator debian to SONiC
liorghub d97f5c0
Add ECMP calculator to SONiC
liorghub 29a01d0
Revert "Add ECMP calculator to SONiC"
liorghub 5b6d48c
Revert "Add SDK hash calculator debian to SONiC"
liorghub f61999a
Add SDK hash calculator debian to SONiC
liorghub 95d2267
Add ECMP calculator to SONiC
liorghub 3b1215c
Add README file
liorghub 8b27f63
Fix review comments
liorghub 310d546
Fix Sempreg checker issue in subprocess call
liorghub cd3ac8c
Add more validations of packet json
liorghub b32b483
Revert "Add SDK hash calculator debian to SONiC"
liorghub 44e56c8
Do not parse VRF query results if empty string is returned
liorghub ab9af4d
Fix more review comments
liorghub 50f03bf
Remove unused object from packet scheme
liorghub a2be99e
Fix issue in syncd Dockerfile, create needed folder before copy opera…
liorghub b0e372d
Update ECMP calculator README to use CLI command
liorghub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
platform/mellanox/docker-syncd-mlnx/ecmp_calculator/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# SONiC ECMP Calculator | ||
|
||
## Description | ||
An equal cost multipath (ECMP) is formed when routing table contains multiple next hop addresses for the same destination IP address. | ||
ECMP will load balance the outbound traffic between the IP interfaces. | ||
The purpose of ECMP calculator is to calculate which IP interface ECMP will choose and return the physical interface packet will egress from. | ||
Packet is defined by a JSON file given as an argument to the tool. | ||
|
||
## Usage notes | ||
1. ECMP calculator performs its calculations based on the current operational state of the router. In order to calculate the egress port, it fetches routes from HW. Routes exist in HW only for next hops with a resolved ARP. | ||
2. ECMP calculator supports only routed packets. | ||
- IPv4/IPv6 TCP/UDP packets | ||
- IPinIP and VXLAN encapsulated packets | ||
3. Changes done in the packet classification (e.g. ACL, PBR) are not taken into consideration during calculation. | ||
|
||
## Command line interface | ||
1. User shall enter syncd container to run ECMP calculator. | ||
2. User shall provide the following input parameters: | ||
- JSON file describing a packet | ||
- Ingress port (e.g. "Ethernet0", must pe a physical interface) | ||
- Debug option for debug purposes (optional) | ||
- VRF name (optional) | ||
3. Usage example: | ||
``` | ||
$ docker exec -it syncd bash | ||
$ /usr/bin/ecmp_calculator/ecmp_calc.py -i Ethernet0 -p ./packet.json | ||
Egress port: Ethernet4 | ||
``` | ||
|
||
## Packet JSON | ||
1. Numbers in packet JSON must be in base-ten. | ||
2. For packets with single header, outer header shall be provided. | ||
3. The following table defines the structure of a packet JSON file. | ||
|
||
| ecmp_hash | | | | | | | | ||
|-----------|-------------|-------|-------------|-------------|--------|----------------------------------------------------------------------------------| | ||
| | packet_info | | | | object | | | ||
| | | outer | | | object | | | ||
| | | | layer2 | | object | | | ||
| | | | | smac | string | | | ||
| | | | | dmac | string | | | ||
| | | | | ethertype | number | 16bits, needed for IPv4 or IPv6 packet | | ||
| | | | | outer_vid | number | 12bits | | ||
| | | | | outer_pcp | number | 3bits | | ||
| | | | | outer_dei | number | 1bits | | ||
| | | | | inner_vid | number | QinQ | | ||
| | | | | inner_pcp | number | QinQ | | ||
| | | | | inner_dei | number | QinQ | | ||
| | | | ipv4 | | object | | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | proto | number | 8bits | | ||
| | | | | dscp | number | 6bits | | ||
| | | | | ecn | number | 2bits | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | l3_length | number | 16bits | | ||
| | | | ipv6 | | object | should not co-exist with ipv4 field | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | next_header | number | 8bits | | ||
| | | | | dscp | number | 6bits | | ||
| | | | | ecn | number | 2bits | | ||
| | | | | l3_length | number | 16bits | | ||
| | | | | flow_label | number | 20bits | | ||
| | | | tcp_udp | | object | | | ||
| | | | | sport | number | 16bits | | ||
| | | | | dport | number | 16bits | | ||
| | | | vxlan_nvgre | | object | | | ||
| | | | | vni | number | 24bits | | ||
| | | inner | | | object | overlay | | ||
| | | | layer2 | | object | | | ||
| | | | | smac | string | | | ||
| | | | | dmac | string | | | ||
| | | | | ethertype | number | 16bits | | ||
| | | | ipv4 | | object | | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | proto | number | 8bits | | ||
| | | | ipv6 | | object | should not co-exist with ipv4 field | | ||
| | | | | sip | string | | | ||
| | | | | dip | string | | | ||
| | | | | mflag | number | 1bit | | ||
| | | | | next_header | number | 8bits | | ||
| | | | | flow_label | number | 20bits | | ||
| | | | tcp_udp | | object | | | ||
| | | | | sport | number | 16bits | | ||
| | | | | dport | number | 16bits | | ||
|
||
4. Packet JSON file example | ||
|
||
```json | ||
{ | ||
"packet_info": { | ||
"outer": { | ||
"ipv4": { | ||
"sip": "10.10.10.10", | ||
"dip": "3.3.3.3", | ||
"proto": 17 | ||
}, | ||
"layer2": { | ||
"smac": "24:8a:07:1e:82:ed", | ||
"dmac": "1c:34:da:1c:a1:00", | ||
"ethertype": 2048 | ||
}, | ||
"tcp_udp": { | ||
"sport": 100, | ||
"dport": 4789 | ||
}, | ||
"vxlan_nvgre": { | ||
"vni": 100 | ||
} | ||
}, | ||
"inner": { | ||
"layer2": { | ||
"smac": "11:11:11:11:11:11", | ||
"dmac": "22:22:22:22:22:22", | ||
"ethertype": 2048 | ||
}, | ||
"ipv4": { | ||
"sip": "1.1.1.1", | ||
"dip": "2.2.2.3", | ||
"proto": 17, | ||
"mflag": 0 | ||
}, | ||
"tcp_udp": { | ||
"sport": 100, | ||
"dport": 200 | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.