* [PATCH net-next] net: hide the definition of dev_get_by_napi_id()
@ 2025-01-10 0:49 Jakub Kicinski
2025-01-10 1:29 ` Jacob Keller
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Jakub Kicinski @ 2025-01-10 0:49 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
jdamato
There are no module callers of dev_get_by_napi_id(),
and commit d1cacd747768 ("netdev: prevent accessing NAPI instances
from another namespace") proves that getting NAPI by id
needs to be done with care. So hide dev_get_by_napi_id().
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: jdamato@fastly.com
---
include/linux/netdevice.h | 1 -
net/core/dev.c | 2 --
net/core/dev.h | 1 +
net/socket.c | 2 ++
4 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 1812564b5204..aeb4a6cff171 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3252,7 +3252,6 @@ struct net_device *netdev_get_by_index(struct net *net, int ifindex,
struct net_device *netdev_get_by_name(struct net *net, const char *name,
netdevice_tracker *tracker, gfp_t gfp);
struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
-struct net_device *dev_get_by_napi_id(unsigned int napi_id);
void netdev_copy_name(struct net_device *dev, char *name);
static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
diff --git a/net/core/dev.c b/net/core/dev.c
index 4452ca2c91ea..1a90ed8cc6cc 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -957,7 +957,6 @@ EXPORT_SYMBOL(netdev_get_by_index);
* its reference counter increased so the caller must be careful
* about locking. The caller must hold RCU lock.
*/
-
struct net_device *dev_get_by_napi_id(unsigned int napi_id)
{
struct napi_struct *napi;
@@ -971,7 +970,6 @@ struct net_device *dev_get_by_napi_id(unsigned int napi_id)
return napi ? napi->dev : NULL;
}
-EXPORT_SYMBOL(dev_get_by_napi_id);
static DEFINE_SEQLOCK(netdev_rename_lock);
diff --git a/net/core/dev.h b/net/core/dev.h
index 08812a025a9b..d8966847794c 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h
@@ -23,6 +23,7 @@ struct sd_flow_limit {
extern int netdev_flow_limit_table_len;
struct napi_struct *netdev_napi_by_id(struct net *net, unsigned int napi_id);
+struct net_device *dev_get_by_napi_id(unsigned int napi_id);
#ifdef CONFIG_PROC_FS
int __init dev_proc_init(void);
diff --git a/net/socket.c b/net/socket.c
index 16402b8be5a7..4afe31656a2b 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -110,6 +110,8 @@
#include <linux/ptp_clock_kernel.h>
#include <trace/events/sock.h>
+#include "core/dev.h"
+
#ifdef CONFIG_NET_RX_BUSY_POLL
unsigned int sysctl_net_busy_read __read_mostly;
unsigned int sysctl_net_busy_poll __read_mostly;
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: hide the definition of dev_get_by_napi_id()
2025-01-10 0:49 [PATCH net-next] net: hide the definition of dev_get_by_napi_id() Jakub Kicinski
@ 2025-01-10 1:29 ` Jacob Keller
2025-01-10 3:54 ` Kalesh Anakkur Purayil
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jacob Keller @ 2025-01-10 1:29 UTC (permalink / raw)
To: Jakub Kicinski, davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, jdamato
On 1/9/2025 4:49 PM, Jakub Kicinski wrote:
> There are no module callers of dev_get_by_napi_id(),
> and commit d1cacd747768 ("netdev: prevent accessing NAPI instances
> from another namespace") proves that getting NAPI by id
> needs to be done with care. So hide dev_get_by_napi_id().
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> CC: jdamato@fastly.com
> ---
> include/linux/netdevice.h | 1 -
> net/core/dev.c | 2 --
> net/core/dev.h | 1 +
> net/socket.c | 2 ++
> 4 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 1812564b5204..aeb4a6cff171 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -3252,7 +3252,6 @@ struct net_device *netdev_get_by_index(struct net *net, int ifindex,
> struct net_device *netdev_get_by_name(struct net *net, const char *name,
> netdevice_tracker *tracker, gfp_t gfp);
> struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
> -struct net_device *dev_get_by_napi_id(unsigned int napi_id);
> void netdev_copy_name(struct net_device *dev, char *name);
>
> static inline int dev_hard_header(struct sk_buff *skb, struct net_device *dev,
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4452ca2c91ea..1a90ed8cc6cc 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -957,7 +957,6 @@ EXPORT_SYMBOL(netdev_get_by_index);
> * its reference counter increased so the caller must be careful
> * about locking. The caller must hold RCU lock.
> */
> -
> struct net_device *dev_get_by_napi_id(unsigned int napi_id)
> {
> struct napi_struct *napi;
> @@ -971,7 +970,6 @@ struct net_device *dev_get_by_napi_id(unsigned int napi_id)
>
> return napi ? napi->dev : NULL;
> }
> -EXPORT_SYMBOL(dev_get_by_napi_id);
>
> static DEFINE_SEQLOCK(netdev_rename_lock);
>
> diff --git a/net/core/dev.h b/net/core/dev.h
> index 08812a025a9b..d8966847794c 100644
> --- a/net/core/dev.h
> +++ b/net/core/dev.h
> @@ -23,6 +23,7 @@ struct sd_flow_limit {
> extern int netdev_flow_limit_table_len;
>
> struct napi_struct *netdev_napi_by_id(struct net *net, unsigned int napi_id);
> +struct net_device *dev_get_by_napi_id(unsigned int napi_id);
>
> #ifdef CONFIG_PROC_FS
> int __init dev_proc_init(void);
> diff --git a/net/socket.c b/net/socket.c
> index 16402b8be5a7..4afe31656a2b 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -110,6 +110,8 @@
> #include <linux/ptp_clock_kernel.h>
> #include <trace/events/sock.h>
>
> +#include "core/dev.h"
> +
> #ifdef CONFIG_NET_RX_BUSY_POLL
> unsigned int sysctl_net_busy_read __read_mostly;
> unsigned int sysctl_net_busy_poll __read_mostly;
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: hide the definition of dev_get_by_napi_id()
2025-01-10 0:49 [PATCH net-next] net: hide the definition of dev_get_by_napi_id() Jakub Kicinski
2025-01-10 1:29 ` Jacob Keller
@ 2025-01-10 3:54 ` Kalesh Anakkur Purayil
2025-01-10 18:09 ` Joe Damato
2025-01-11 2:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Kalesh Anakkur Purayil @ 2025-01-10 3:54 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, jdamato
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
On Fri, Jan 10, 2025 at 6:19 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> There are no module callers of dev_get_by_napi_id(),
> and commit d1cacd747768 ("netdev: prevent accessing NAPI instances
> from another namespace") proves that getting NAPI by id
> needs to be done with care. So hide dev_get_by_napi_id().
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
--
Regards,
Kalesh AP
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4239 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: hide the definition of dev_get_by_napi_id()
2025-01-10 0:49 [PATCH net-next] net: hide the definition of dev_get_by_napi_id() Jakub Kicinski
2025-01-10 1:29 ` Jacob Keller
2025-01-10 3:54 ` Kalesh Anakkur Purayil
@ 2025-01-10 18:09 ` Joe Damato
2025-01-11 2:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Joe Damato @ 2025-01-10 18:09 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms
On Thu, Jan 09, 2025 at 04:49:24PM -0800, Jakub Kicinski wrote:
> There are no module callers of dev_get_by_napi_id(),
> and commit d1cacd747768 ("netdev: prevent accessing NAPI instances
> from another namespace") proves that getting NAPI by id
> needs to be done with care. So hide dev_get_by_napi_id().
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
> CC: jdamato@fastly.com
> ---
> include/linux/netdevice.h | 1 -
> net/core/dev.c | 2 --
> net/core/dev.h | 1 +
> net/socket.c | 2 ++
> 4 files changed, 3 insertions(+), 3 deletions(-)
Thanks.
Reviewed-by: Joe Damato <jdamato@fastly.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] net: hide the definition of dev_get_by_napi_id()
2025-01-10 0:49 [PATCH net-next] net: hide the definition of dev_get_by_napi_id() Jakub Kicinski
` (2 preceding siblings ...)
2025-01-10 18:09 ` Joe Damato
@ 2025-01-11 2:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-11 2:50 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, jdamato
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 9 Jan 2025 16:49:24 -0800 you wrote:
> There are no module callers of dev_get_by_napi_id(),
> and commit d1cacd747768 ("netdev: prevent accessing NAPI instances
> from another namespace") proves that getting NAPI by id
> needs to be done with care. So hide dev_get_by_napi_id().
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
>
> [...]
Here is the summary with links:
- [net-next] net: hide the definition of dev_get_by_napi_id()
https://git.kernel.org/netdev/net-next/c/21520e74ba45
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-01-11 2:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-10 0:49 [PATCH net-next] net: hide the definition of dev_get_by_napi_id() Jakub Kicinski
2025-01-10 1:29 ` Jacob Keller
2025-01-10 3:54 ` Kalesh Anakkur Purayil
2025-01-10 18:09 ` Joe Damato
2025-01-11 2:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).