-
Notifications
You must be signed in to change notification settings - Fork 812
[debug dump util] FDB debug dump util changes #1968
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7f20582
[debug dump util]FDB debug dump util changes
dgsudharsan e2c26ca
Adding static entry in test scenario
dgsudharsan dd43eab
Addressing CR
dgsudharsan a60f40c
Addressing code review comment
dgsudharsan 8f45ab8
Correcting typo
dgsudharsan ce21a65
Merge branch 'master' of github.com:Azure/sonic-utilities into fdb_dump
dgsudharsan a1cd9b5
Merge remote-tracking branch 'upstream/master' into fdb_dump
dgsudharsan 0ba1c83
Addressing review comment
dgsudharsan 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 hidden or 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,96 @@ | ||
| from dump.match_infra import MatchRequest | ||
| from dump.helper import create_template_dict | ||
| from .executor import Executor | ||
|
|
||
|
|
||
| class Fdb(Executor): | ||
| """ | ||
| Debug Dump Plugin for FDB Module | ||
| """ | ||
| ARG_NAME = "Vlan:fdb_entry" | ||
|
|
||
| def __init__(self, match_engine=None): | ||
| super().__init__(match_engine) | ||
|
|
||
| def get_all_args(self, ns=""): | ||
| req = MatchRequest(db="STATE_DB", table="FDB_TABLE", key_pattern="*", ns=ns) | ||
| ret = self.match_engine.fetch(req) | ||
| fdb_entries = ret["keys"] | ||
| return [key.split("|")[-1] for key in fdb_entries] | ||
|
|
||
| def execute(self, params): | ||
| self.ret_temp = create_template_dict(dbs=["APPL_DB", "ASIC_DB", "STATE_DB"]) | ||
| fdb_entry = params[Fdb.ARG_NAME] | ||
| self.ns = params["namespace"] | ||
| self.init_fdb_appl_info(fdb_entry) | ||
| self.init_asic_fdb_info(fdb_entry) | ||
| self.init_state_fdb_info(fdb_entry) | ||
| return self.ret_temp | ||
|
|
||
| def init_state_fdb_info(self, fdb_name): | ||
| req = MatchRequest(db="STATE_DB", table="FDB_TABLE", key_pattern=fdb_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
|
|
||
| def init_fdb_appl_info(self, fdb_name): | ||
| req = MatchRequest(db="APPL_DB", table="FDB_TABLE", key_pattern=fdb_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"], False) | ||
| req = MatchRequest(db="APPL_DB", table="VXLAN_FDB_TABLE", key_pattern=fdb_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"], False) | ||
| req = MatchRequest(db="APPL_DB", table="MCLAG_FDB_TABLE", key_pattern=fdb_name, ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"], False) | ||
|
|
||
| def init_asic_fdb_info(self, fdb_name): | ||
| # One colon between Vlan and MAC and 5 colons in mac address are expected in key | ||
| if fdb_name.count(':') != 6: | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY") | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT") | ||
| return | ||
|
|
||
| key_split = fdb_name.split(":",1) | ||
| vlan_name = key_split[0] | ||
| mac = key_split[1] | ||
| if vlan_name[0:4] != "Vlan" or not vlan_name[4:].isnumeric(): | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY") | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT") | ||
| return | ||
|
|
||
| vlan_num = int(vlan_name[4:]) | ||
| # Find the table named "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:*" in which SAI_VLAN_AT'TR_VLAN_ID = vlan_num | ||
| req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_VLAN", key_pattern="*", field="SAI_VLAN_ATTR_VLAN_ID", | ||
| value=str(vlan_num), ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| if not ret["error"] and len(ret["keys"]) == 1: | ||
| vlan_obj = ret["keys"][0].split(":",2)[-1] | ||
| else: | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY") | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT") | ||
| return | ||
|
|
||
| # ASIC_DB FDB format is bvid:vlan_obj + mac:mac_address + switch id which is wildcard here | ||
| fdb_key = '{"bvid":"' + vlan_obj + '","mac":"' + mac.upper() + '"*}' | ||
| req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY", key_pattern=fdb_key, | ||
| return_fields=["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"], ns=self.ns) | ||
| ret = self.match_engine.fetch(req) | ||
| bridge_port_id = "" | ||
| if not ret["error"] and len(ret["keys"]) != 0: | ||
| asic_fdb_key = ret["keys"][0] | ||
| if asic_fdb_key in ret["return_values"] and "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID" in ret["return_values"][asic_fdb_key]: | ||
| bridge_port_id = ret["return_values"][asic_fdb_key]["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"] | ||
| else: | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT") | ||
|
|
||
| if bridge_port_id: | ||
| bridge_port_req = MatchRequest(db="ASIC_DB", table="ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT", | ||
| key_pattern = bridge_port_id, ns = self.ns) | ||
| bridge_ret = self.match_engine.fetch(bridge_port_req) | ||
| if not bridge_ret["error"] and len(bridge_ret["keys"]) != 0: | ||
| self.ret_temp[bridge_port_req.db]["keys"].append(bridge_ret["keys"][0]) | ||
| else: | ||
| self.ret_temp["ASIC_DB"]["tables_not_found"].append("ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT") | ||
|
|
||
|
|
||
| self.add_to_ret_template(req.table, req.db, ret["keys"], ret["error"]) | ||
This file contains hidden or 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,15 @@ | ||
| { | ||
| "FDB_TABLE:Vlan10:04:3f:72:ce:80:8b":{ | ||
| "port" : "Ethernet252", | ||
| "type" : "static" | ||
| }, | ||
| "VXLAN_FDB_TABLE:Vlan10:04:3f:72:ce:80:8c":{ | ||
| "port" : "Ethernet252", | ||
| "type" : "dynamic", | ||
| "end_point_ip" : "192.234.11.233" | ||
| }, | ||
| "MCLAG_FDB_TABLE:Vlan10:04:3f:72:ce:80:8d":{ | ||
| "port" : "Ethernet252", | ||
| "type" : "dynamic" | ||
| } | ||
| } |
This file contains hidden or 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,48 @@ | ||
| { | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bvid\":\"oid:0x26000000000d22\",\"mac\":\"04:3F:72:E3:70:08\",\"switch_id\":\"oid:0x21000000000000\"}":{ | ||
| "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID" : "oid:0x3a000000000d23", | ||
| "SAI_FDB_ENTRY_ATTR_TYPE": "SAI_FDB_ENTRY_TYPE_DYNAMIC", | ||
| "SAI_FDB_ENTRY_ATTR_PACKET_ACTION" : "SAI_PACKET_ACTION_FORWARD" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bvid\":\"oid:0x26000000000d20\",\"mac\":\"04:3F:72:CE:80:8B\",\"switch_id\":\"oid:0x21000000000000\"}":{ | ||
| "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID" : "oid:0x3a000000000d18", | ||
| "SAI_FDB_ENTRY_ATTR_TYPE": "SAI_FDB_ENTRY_TYPE_STATIC", | ||
| "SAI_FDB_ENTRY_ATTR_PACKET_ACTION" : "SAI_PACKET_ACTION_FORWARD" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bvid\":\"oid:0x26000000000d20\",\"mac\":\"04:3F:72:CE:80:8C\",\"switch_id\":\"oid:0x21000000000000\"}":{ | ||
| "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID" : "oid:0x3a000000000d18", | ||
| "SAI_FDB_ENTRY_ATTR_TYPE": "SAI_FDB_ENTRY_TYPE_DYNAMIC", | ||
| "SAI_FDB_ENTRY_ATTR_PACKET_ACTION" : "SAI_PACKET_ACTION_FORWARD" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bvid\":\"oid:0x26000000000d20\",\"mac\":\"04:3F:72:CE:80:8D\",\"switch_id\":\"oid:0x21000000000000\"}":{ | ||
| "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID" : "oid:0x3a000000000d18", | ||
| "SAI_FDB_ENTRY_ATTR_TYPE": "SAI_FDB_ENTRY_TYPE_DYNAMIC", | ||
| "SAI_FDB_ENTRY_ATTR_PACKET_ACTION" : "SAI_PACKET_ACTION_FORWARD" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_FDB_ENTRY:{\"bvid\":\"oid:0x26000000000d1c\",\"mac\":\"04:3F:72:CE:80:8B\",\"switch_id\":\"oid:0x21000000000000\"}":{ | ||
| "SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID" : "oid:0x3a000000000d55", | ||
| "SAI_FDB_ENTRY_ATTR_TYPE": "SAI_FDB_ENTRY_TYPE_DYNAMIC", | ||
| "SAI_FDB_ENTRY_ATTR_PACKET_ACTION" : "SAI_PACKET_ACTION_FORWARD" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x26000000000d22": { | ||
| "SAI_VLAN_ATTR_VLAN_ID" : "50" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x26000000000d20": { | ||
| "SAI_VLAN_ATTR_VLAN_ID" : "10" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x26000000000d1c": { | ||
| "SAI_VLAN_ATTR_VLAN_ID" : "690" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000000d23":{ | ||
| "SAI_BRIDGE_PORT_ATTR_TYPE" : "SAI_BRIDGE_PORT_TYPE_PORT", | ||
| "SAI_BRIDGE_PORT_ATTR_PORT_ID": "oid:0x100000000093e", | ||
| "SAI_BRIDGE_PORT_ATTR_ADMIN_STATE" : "true", | ||
| "SAI_BRIDGE_PORT_ATTR_FDB_LEARNING_MODE" : "SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW" | ||
| }, | ||
| "ASIC_STATE:SAI_OBJECT_TYPE_BRIDGE_PORT:oid:0x3a000000000d18":{ | ||
| "SAI_BRIDGE_PORT_ATTR_TYPE" : "SAI_BRIDGE_PORT_TYPE_PORT", | ||
| "SAI_BRIDGE_PORT_ATTR_PORT_ID": "oid:0x100000000053f", | ||
| "SAI_BRIDGE_PORT_ATTR_ADMIN_STATE" : "true", | ||
| "SAI_BRIDGE_PORT_ATTR_FDB_LEARNING_MODE" : "SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW" | ||
| } | ||
| } |
This file contains hidden or 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,30 @@ | ||
| { | ||
| "FDB_TABLE|Vlan50:04:3f:72:e3:70:08":{ | ||
| "port" : "Ethernet0", | ||
| "type" : "dynamic" | ||
| }, | ||
| "FDB_TABLE|Vlan10:04:3f:72:ce:80:8b":{ | ||
| "port" : "Ethernet252", | ||
| "type" : "static" | ||
| }, | ||
| "FDB_TABLE|Vlan10:04:3f:72:ce:80:8c":{ | ||
| "port" : "Ethernet252", | ||
| "type" : "dynamic" | ||
| }, | ||
| "FDB_TABLE|Vlan10:04:3f:72:ce:80:8d":{ | ||
| "port" : "Ethernet252", | ||
| "type" : "dynamic" | ||
| }, | ||
| "FDB_TABLE|Vlan690:04:3f:72:ce:80:8b":{ | ||
| "port" : "Ethernet248", | ||
| "type" : "dynamic" | ||
| }, | ||
| "FDB_TABLE|Vlan40:04:3f:72:e3:70:09":{ | ||
| "port" : "PortChannel0002", | ||
| "type" : "dynamic" | ||
| }, | ||
| "FDB_TABLE|Vlan691:04:3f:72:ce:80:8b":{ | ||
| "port" : "Ethernet248", | ||
| "type" : "dynamic" | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.