librmnetctl: Fix incorrect handling of messages with return type data
When an message with return type data fails in kernel, the error
is handled incorrectly.
Consider a scenario when we try to query the vnd name corresponding
to a non existent vnd id.
/ # rmnetcli getvndname 25
rmnetcli getvndname 25
LIBRARY ERROR: Return type is invalid
We appear to be getting a library error even though the actual
error originates from the kernel. The actual error for this case
should be a kernel error and the return code should be Invalid
request / Unsupported scenario.
Fix this by checking for return codes in case there is an error
when a return data type fails.
Change-Id: Ideb765f786cf19e29f3f496a6c8d7da92e769111
diff --git a/rmnetctl/src/librmnetctl.c b/rmnetctl/src/librmnetctl.c
index b0f98a7..835798e 100644
--- a/rmnetctl/src/librmnetctl.c
+++ b/rmnetctl/src/librmnetctl.c
@@ -438,8 +438,14 @@
!= RMNETCTL_SUCCESS)
break;
- if (_rmnetctl_check_data(response.crd, error_code) != RMNETCTL_SUCCESS)
+ if (_rmnetctl_check_data(response.crd, error_code)
+ != RMNETCTL_SUCCESS) {
+ if (_rmnetctl_check_code(response.crd, error_code)
+ == RMNETCTL_SUCCESS)
+ return_code = _rmnetctl_set_codes(response.return_code,
+ error_code);
break;
+ }
*register_status = response.return_code;
return_code = RMNETCTL_SUCCESS;
@@ -517,8 +523,14 @@
!= RMNETCTL_SUCCESS)
break;
- if (_rmnetctl_check_data(response.crd, error_code) != RMNETCTL_SUCCESS)
+ if (_rmnetctl_check_data(response.crd, error_code)
+ != RMNETCTL_SUCCESS) {
+ if (_rmnetctl_check_code(response.crd, error_code)
+ == RMNETCTL_SUCCESS)
+ return_code = _rmnetctl_set_codes(response.return_code,
+ error_code);
break;
+ }
*egress_flags = response.data_format.flags;
*agg_size = response.data_format.agg_size;
@@ -595,8 +607,14 @@
!= RMNETCTL_SUCCESS)
break;
- if (_rmnetctl_check_data(response.crd, error_code) != RMNETCTL_SUCCESS)
+ if (_rmnetctl_check_data(response.crd, error_code)
+ != RMNETCTL_SUCCESS) {
+ if (_rmnetctl_check_code(response.crd, error_code)
+ == RMNETCTL_SUCCESS)
+ return_code = _rmnetctl_set_codes(response.return_code,
+ error_code);
break;
+ }
if (ingress_flags)
*ingress_flags = response.data_format.flags;
@@ -727,8 +745,15 @@
if ((*error_code = rmnetctl_transact(hndl, &request, &response))
!= RMNETCTL_SUCCESS)
break;
- if (_rmnetctl_check_data(response.crd, error_code) != RMNETCTL_SUCCESS)
+
+ if (_rmnetctl_check_data(response.crd, error_code)
+ != RMNETCTL_SUCCESS) {
+ if (_rmnetctl_check_code(response.crd, error_code)
+ == RMNETCTL_SUCCESS)
+ return_code = _rmnetctl_set_codes(response.return_code,
+ error_code);
break;
+ }
str_len = strlcpy(*next_dev,
(char *)(response.local_ep_config.next_dev),
@@ -819,8 +844,15 @@
if ((*error_code = rmnetctl_transact(hndl, &request, &response))
!= RMNETCTL_SUCCESS)
break;
- if (_rmnetctl_check_data(response.crd, error_code) != RMNETCTL_SUCCESS)
+
+ if (_rmnetctl_check_data(response.crd, error_code)
+ != RMNETCTL_SUCCESS) {
+ if (_rmnetctl_check_code(response.crd, error_code)
+ == RMNETCTL_SUCCESS)
+ return_code = _rmnetctl_set_codes(response.return_code,
+ error_code);
break;
+ }
str_len = (uint32_t)strlcpy(buf,
(char *)(response.vnd.vnd_name),