From d42712d0fb90465955088b51ee00ad21cabbae13 Mon Sep 17 00:00:00 2001 From: Subash Abhinov Kasiviswanathan Date: Tue, 14 Apr 2015 13:44:02 -0600 Subject: 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 --- rmnetctl/src/librmnetctl.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) 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 @@ int rmnet_get_network_device_associated(rmnetctl_hndl_t *hndl, != 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 @@ int rmnet_get_link_egress_data_format(rmnetctl_hndl_t *hndl, != 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 @@ int rmnet_get_link_ingress_data_format_tailspace(rmnetctl_hndl_t *hndl, != 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 @@ int rmnet_get_logical_ep_config(rmnetctl_hndl_t *hndl, 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 @@ int rmnet_get_vnd_name(rmnetctl_hndl_t *hndl, 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), -- cgit v1.2.3