From c5cf7afa643e1b7679d7eabfbde8201964f634ff Mon Sep 17 00:00:00 2001 From: Dante Su Date: Fri, 22 Apr 2022 02:26:09 +0000 Subject: [PATCH] error out when invalid LT mode is specified Signed-off-by: Dante Su --- scripts/portconfig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/portconfig b/scripts/portconfig index a937ed98c3..2352c54bda 100755 --- a/scripts/portconfig +++ b/scripts/portconfig @@ -132,8 +132,11 @@ class portconfig(object): def set_link_training(self, port, mode): if self.verbose: print("Setting link-training %s on port %s" % (mode, port)) - if mode not in ['on', 'off']: - mode = 'off' + lt_modes = ['on', 'off'] + if mode not in lt_modes: + print('Invalid mode specified: {}'.format(mode)) + print('Valid modes: {}'.format(','.join(lt_modes))) + exit(1) self.db.mod_entry(PORT_TABLE_NAME, port, {PORT_LINK_TRAINING_CONFIG_FIELD_NAME: mode}) def set_autoneg(self, port, mode):