Skip to content

Commit

Permalink
[dropconfig] Move prefix-handling from CLI to orchagent (sonic-net#785)
Browse files Browse the repository at this point in the history
- Remove prefix-trimming from drop reason capability query
- Remove prefix-trimming from create/add safety checks

Signed-off-by: Danny Allen <daall@microsoft.com>
  • Loading branch information
daall authored Jan 27, 2020
1 parent de31184 commit bafaaed
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
16 changes: 1 addition & 15 deletions scripts/dropconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ drop_counter_config_header = ['Counter',
'Description']
drop_counter_capability_header = ['Counter Type', 'Total']

# Drop Reason Prefixes
in_drop_reason_prefix = 'SAI_IN_DROP_REASON_'
out_drop_reason_prefix = 'SAI_OUT_DROP_REASON_'


class InvalidArgumentError(RuntimeError):
def __init__(self, msg):
Expand Down Expand Up @@ -107,10 +103,6 @@ class DropConfig(object):
if supported_reasons and int(capabilities.get('count', 0)) > 0:
print('\n{}'.format(counter))
for reason in supported_reasons:
if reason.startswith(in_drop_reason_prefix):
reason = reason[len(in_drop_reason_prefix):]
elif reason.startswith(out_drop_reason_prefix):
reason = reason[len(out_drop_reason_prefix):]
print('\t{}'.format(reason))

def create_counter(self, counter_name, alias, group, counter_type,
Expand Down Expand Up @@ -314,13 +306,7 @@ class DropConfig(object):
if not cap_query:
return None

reasons = []
for reason in deserialize_reason_list(cap_query.get('reasons', '')):
if reason.startswith(in_drop_reason_prefix):
reasons.append(reason[len(in_drop_reason_prefix):])
elif reason.startswith(out_drop_reason_prefix):
reasons.append(reason[len(out_drop_reason_prefix):])
return reasons
return deserialize_reason_list(cap_query.get('reasons', ''))


def deserialize_reason_list(list_str):
Expand Down
4 changes: 2 additions & 2 deletions sonic-utilities-tests/mock_tables/state_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
"ACL_ACTION|PACKET_ACTION": "FORWARD"
},
"DEBUG_COUNTER_CAPABILITIES|PORT_INGRESS_DROPS": {
"reasons": "[SAI_IN_DROP_REASON_IP_HEADER_ERROR,SAI_IN_DROP_REASON_NO_L3_HEADER]",
"reasons": "[IP_HEADER_ERROR,NO_L3_HEADER]",
"count": "4"
},
"DEBUG_COUNTER_CAPABILITIES|SWITCH_EGRESS_DROPS": {
"reasons": "[SAI_IN_DROP_REASON_ACL_ANY,SAI_IN_DROP_REASON_L2_ANY,SAI_IN_DROP_REASON_L3_ANY]",
"reasons": "[ACL_ANY,L2_ANY,L3_ANY]",
"count": "2"
}
}

0 comments on commit bafaaed

Please sign in to comment.