Skip to content

Commit

Permalink
Merge pull request sonic-net#368 from wendani/ecn_master
Browse files Browse the repository at this point in the history
ecnconfig check against invalid argument value (sonic-net#343)
  • Loading branch information
wendani committed Nov 9, 2018
2 parents 200b47f + be595c4 commit f3bb9bd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/ecnconfig
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ class EcnConfig(object):
def set_wred_threshold(self, profile, threshold, value):
if os.geteuid() != 0:
sys.exit("Root privileges required for this operation")

v = int(value)
if v < 0 :
raise Exception("Invalid %s" % (threshold))

field = WRED_CONFIG_FIELDS[threshold]
if self.verbose:
print("Setting %s value to %s" % (field, value))
Expand All @@ -114,6 +119,11 @@ class EcnConfig(object):
def set_wred_prob(self, profile, drop_color, value):
if os.geteuid() != 0:
sys.exit("Root privileges required for this operation")

v = int(value)
if v < 0 or v > 100:
raise Exception("Invalid %s" % (drop_color))

field = WRED_CONFIG_FIELDS[drop_color]
if self.verbose:
print("Setting %s value to %s%%" % (field, value))
Expand Down

0 comments on commit f3bb9bd

Please sign in to comment.