diff mbox series

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

Message ID 20210301105654.291949-5-parav@nvidia.com (mailing list archive)
State Accepted
Commit c54e7bd60547d74bb89b99fd63f4c3e04fdf1d75
Delegated to: David Ahern
Headers show
Series devlink: Use utils helpers | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

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;
 }