net/af_xdp: fix xdp_get_channels_info return value

Message ID CAP=P++CjQQX3hWb0Nck8JaJuGcy_SHmsjN0g3+f1Ns9r9fDBjA@mail.gmail.com (mailing list archive)
State Superseded, archived
Headers
Series net/af_xdp: fix xdp_get_channels_info return value |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail apply issues

Commit Message

Július Milan July 12, 2019, 7:40 a.m. UTC
  Procedure xdp_get_channels_info was returning error code -1 in case of
unsupported ioctl command SIOCETHTOOL. This patch sets return
value back to 0 as it is valid case.

Fixes: 339b88c6a9 ("net/af_xdp: support multi-queue")

Signed-off-by: Július Milan <jmilan.dev@gmail.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
  

Comments

Stephen Hemminger July 12, 2019, 3:09 p.m. UTC | #1
On Fri, 12 Jul 2019 09:40:37 +0200
Július Milan <jmilan.dev@gmail.com> wrote:

> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index ff8e90589..33352e10a 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -852,9 +852,13 @@ xdp_get_channels_info(const char *if_name, int *max_queues,
>      ifr.ifr_data = (void *)&channels;
>      strncpy(ifr.ifr_name, if_name, IFNAMSIZ);
>      ret = ioctl(fd, SIOCETHTOOL, &ifr);
> -    if (ret && errno != EOPNOTSUPP) {
> -        ret = -errno;
> -        goto out;
> +    if (ret) {
> +        if (errno == EOPNOTSUPP) {
> +            ret = 0;
> +        } else {
> +            ret = -errno;
> +            goto out;
> +        }
>      }


Why not do close first and avoid the goto?
With your code, max_queues and combined_queues would never get set.


	ret = ioctl(fd, SIOCETHTOOL, &ifr);
	close(fd);
	if (ret < 0 && errno != EOPNOTSUPP)
		return -errno;

	if (errno == EOPNOTSUPP || channels.max_combined == 0) {
...
  

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
b/drivers/net/af_xdp/rte_eth_af_xdp.c
index ff8e90589..33352e10a 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -852,9 +852,13 @@  xdp_get_channels_info(const char *if_name, int *max_queues,
     ifr.ifr_data = (void *)&channels;
     strncpy(ifr.ifr_name, if_name, IFNAMSIZ);
     ret = ioctl(fd, SIOCETHTOOL, &ifr);
-    if (ret && errno != EOPNOTSUPP) {
-        ret = -errno;
-        goto out;
+    if (ret) {
+        if (errno == EOPNOTSUPP) {
+            ret = 0;
+        } else {
+            ret = -errno;
+            goto out;
+        }
     }

     if (channels.max_combined == 0 || errno == EOPNOTSUPP) {