[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230320214942.38395e6e@kicinski-fedora-PC1C0HJN>
Date: Mon, 20 Mar 2023 21:49:46 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Nick Child <nnac123@...ux.ibm.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH net 2/2] netdev: Enforce index cap in
netdev_get_tx_queue
On Fri, 17 Mar 2023 13:19:41 -0500 Nick Child wrote:
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 23b0d7eaaadd..fe88b1a7393d 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2482,6 +2482,13 @@ static inline
> struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
> unsigned int index)
> {
> + if (unlikely(index >= dev->num_tx_queues)) {
> + net_warn_ratelimited("%s selects TX queue %d, but number of TX queues is %d\n",
> + dev->name, index,
> + dev->num_tx_queues);
> + return &dev->_tx[0];
> + }
> +
Should we maybe do DEBUG_NET_WARN_ON_ONCE() instead?
It will likely run multiple times per each Tx packet,
so I wonder if we really want to add a branch for what's
effectively defensive programming...
Powered by blists - more mailing lists