Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Randy Li <ayaka@soulik.info>,  netdev@vger.kernel.org
Cc: willemdebruijn.kernel@gmail.com,  jasowang@redhat.com,
	 davem@davemloft.net,  edumazet@google.com,  kuba@kernel.org,
	 pabeni@redhat.com,  linux-kernel@vger.kernel.org,
	 Randy Li <ayaka@soulik.info>
Subject: Re: [PATCH] net: tuntap: add ioctl() TUNGETQUEUEINDX to fetch queue index
Date: Wed, 31 Jul 2024 10:12:14 -0400	[thread overview]
Message-ID: <66aa463e6bcdf_20b4e4294ea@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <20240731111940.8383-1-ayaka@soulik.info>

Randy Li wrote:
> We need the queue index in qdisc mapping rule. There is no way to
> fetch that.

In which command exactly?

> Signed-off-by: Randy Li <ayaka@soulik.info>
> ---
>  drivers/net/tap.c           | 9 +++++++++
>  drivers/net/tun.c           | 4 ++++
>  include/uapi/linux/if_tun.h | 1 +
>  3 files changed, 14 insertions(+)
> 
> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
> index 77574f7a3bd4..6099f27a0a1f 100644
> --- a/drivers/net/tap.c
> +++ b/drivers/net/tap.c
> @@ -1120,6 +1120,15 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
>  		rtnl_unlock();
>  		return ret;
>  
> +	case TUNGETQUEUEINDEX:
> +		rtnl_lock();
> +		if (!q->enabled)
> +			ret = -EINVAL;
> +

Below will just overwrite the above ret

> +		ret = put_user(q->queue_index, up);
> +		rtnl_unlock();
> +		return ret;
> +
>  	case SIOCGIFHWADDR:
>  		rtnl_lock();
>  		tap = tap_get_tap_dev(q);
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 1d06c560c5e6..5473a0fca2e1 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -3115,6 +3115,10 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
>  		if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
>  			return -EPERM;
>  		return open_related_ns(&net->ns, get_net_ns);
> +	} else if (cmd == TUNGETQUEUEINDEX) {
> +		if (tfile->detached)
> +			return -EINVAL;
> +		return put_user(tfile->queue_index, (unsigned int __user*)argp);

Unless you're certain that these fields can be read without RTNL, move
below rtnl_lock() statement.

>  	}
>  
>  	rtnl_lock();
> diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> index 287cdc81c939..2668ca3b06a5 100644
> --- a/include/uapi/linux/if_tun.h
> +++ b/include/uapi/linux/if_tun.h
> @@ -61,6 +61,7 @@
>  #define TUNSETFILTEREBPF _IOR('T', 225, int)
>  #define TUNSETCARRIER _IOW('T', 226, int)
>  #define TUNGETDEVNETNS _IO('T', 227)
> +#define TUNGETQUEUEINDEX _IOR('T', 228, unsigned int)
>  
>  /* TUNSETIFF ifr flags */
>  #define IFF_TUN		0x0001
> -- 
> 2.45.2
> 



  reply	other threads:[~2024-07-31 14:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 11:19 [PATCH] net: tuntap: add ioctl() TUNGETQUEUEINDX to fetch queue index Randy Li
2024-07-31 14:12 ` Willem de Bruijn [this message]
2024-07-31 16:45   ` Randy Li
2024-07-31 21:57     ` Willem de Bruijn
2024-08-01  9:15       ` Randy Li
2024-08-01 13:04         ` Willem de Bruijn
2024-08-01 13:36           ` Randy Li
2024-08-01 14:17             ` Willem de Bruijn
2024-08-01 19:52               ` Randy Li
2024-08-02 15:10                 ` Willem de Bruijn
2024-08-07 18:54                   ` Randy Li
2024-08-08  2:10                     ` Willem de Bruijn
2024-08-08  2:49                       ` Jason Wang
2024-08-08  3:11                         ` Willem de Bruijn
2024-08-08  3:36                           ` Jason Wang
2024-08-08  4:16                           ` ayaka
2024-08-08 18:48                             ` Willem de Bruijn
2024-08-09  4:45                               ` ayaka
2024-08-09 14:55                                 ` Willem de Bruijn
2024-08-12  6:05                                   ` Jason Wang
2024-08-12 17:10                                     ` Willem de Bruijn
2024-08-13  3:53                                       ` Jason Wang
2024-08-13 13:22                                         ` Willem de Bruijn
  -- strict thread matches above, loose matches on Subject: below --
2024-08-09  4:50 ayaka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=66aa463e6bcdf_20b4e4294ea@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=ayaka@soulik.info \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox