diff mbox series

[net-next] net: hide the definition of dev_get_by_napi_id()

Message ID 20250110004924.3212260-1-kuba@kernel.org (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: hide the definition of dev_get_by_napi_id() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 40 this patch: 40
netdev/build_tools success Errors and warnings before: 0 (+1) this patch: 0 (+1)
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 6615 this patch: 6615
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4097 this patch: 4097
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 119 this patch: 119
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2025-01-10--09-00 (tests: 882)

Commit Message

Jakub Kicinski Jan. 10, 2025, 12:49 a.m. UTC
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(-)

Comments

Jacob Keller Jan. 10, 2025, 1:29 a.m. UTC | #1
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;
Kalesh Anakkur Purayil Jan. 10, 2025, 3:54 a.m. UTC | #2
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>
diff mbox series

Patch

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;