Skip to content

Commit

Permalink
Root priviliege for ecn configuration set commands (#332)
Browse files Browse the repository at this point in the history
Signed-off-by: Wenda <wenni@microsoft.com>
  • Loading branch information
wendani authored and lguohan committed Oct 2, 2018
1 parent 3098b8a commit f1236aa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions scripts/ecnconfig
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,16 @@ class EcnConfig(object):
print("Total profiles: %d" % len(wred_profiles))

def set_wred_threshold(self, profile, threshold, value):
if os.geteuid() != 0:
sys.exit("Root privileges required for this operation")
field = WRED_CONFIG_FIELDS[threshold]
if self.verbose:
print("Setting %s value to %s" % (field, value))
self.db.mod_entry(WRED_PROFILE_TABLE_NAME, profile, {field: value})

def set_wred_prob(self, profile, drop_color, value):
if os.geteuid() != 0:
sys.exit("Root privileges required for this operation")
field = WRED_CONFIG_FIELDS[drop_color]
if self.verbose:
print("Setting %s value to %s%%" % (field, value))
Expand Down Expand Up @@ -151,6 +155,8 @@ class EcnQ(object):
self.ports_key = ','.join(sorted(ports, key = lambda k: int(k[8:])))

def set(self, enable):
if os.geteuid() != 0:
sys.exit("Root privileges required for this operation")
for queue in self.queues:
if self.verbose:
print("%s ECN on %s queue %s" % ("Enable" if enable else "Disable", self.ports_key, queue))
Expand Down

0 comments on commit f1236aa

Please sign in to comment.