diff mbox series

[iproute2-next,4/4] devlink: Add error print when unknown values specified

Message ID 20210301105654.291949-5-parav@nvidia.com
State New
Headers show
Series devlink: Use utils helpers | expand

Commit Message

Parav Pandit March 1, 2021, 10:56 a.m. UTC
When user specifies either unknown flavour or unknown state during
devlink port commands, return appropriate error message.

Signed-off-by: Parav Pandit <parav@nvidia.com>
---
 devlink/devlink.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/devlink/devlink.c b/devlink/devlink.c
index eaac1806..16eca4f9 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1372,8 +1372,10 @@  static int port_flavour_parse(const char *flavour, uint16_t *value)
 	int num;
 
 	num = str_map_lookup_str(port_flavour_map, flavour);
-	if (num < 0)
+	if (num < 0) {
+		invarg("unknown flavour", flavour);
 		return num;
+	}
 	*value = num;
 	return 0;
 }
@@ -1383,8 +1385,10 @@  static int port_fn_state_parse(const char *statestr, uint8_t *state)
 	int num;
 
 	num = str_map_lookup_str(port_fn_state_map, statestr);
-	if (num < 0)
+	if (num < 0) {
+		invarg("unknown state", statestr);
 		return num;
+	}
 	*state = num;
 	return 0;
 }