diff mbox series

[v8,06/25] net/tls,core: export get_netdev_for_sock

Message ID 20230109133116.20801-7-aaptel@nvidia.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series nvme-tcp receive offloads | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count fail Series longer than 15 patches (and no cover letter)
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 4353 this patch: 4354
netdev/cc_maintainers warning 4 maintainers not CCed: edumazet@google.com pabeni@redhat.com petrm@nvidia.com john.fastabend@gmail.com
netdev/build_clang fail Errors and warnings before: 1020 this patch: 1021
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 4563 this patch: 4564
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 71 lines checked
netdev/kdoc fail Errors and warnings before: 1 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

Aurelien Aptel Jan. 9, 2023, 1:30 p.m. UTC
* remove netdev_sk_get_lowest_dev() from net/core
* move get_netdev_for_sock() from net/tls to net/core

get_netdev_for_sock() is a utility that is used to obtain
the net_device structure from a connected socket.

Later patches will use this for nvme-tcp DDP and DDP DDGST offloads.

Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ben Ben-Ishay <benishay@nvidia.com>
Signed-off-by: Shai Malin <smalin@nvidia.com>
Signed-off-by: Aurelien Aptel <aaptel@nvidia.com>
---
 include/linux/netdevice.h |  3 +--
 net/core/dev.c            | 26 +++++++++++++-------------
 net/tls/tls_device.c      | 16 ----------------
 3 files changed, 14 insertions(+), 31 deletions(-)

Comments

kernel test robot Jan. 9, 2023, 5:49 p.m. UTC | #1
Hi Aurelien,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]
[also build test WARNING on net-next/master linus/master v6.2-rc3 next-20230109]
[cannot apply to hch-configfs/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aurelien-Aptel/net-Introduce-direct-data-placement-tcp-offload/20230109-213850
patch link:    https://lore.kernel.org/r/20230109133116.20801-7-aaptel%40nvidia.com
patch subject: [PATCH v8 06/25] net/tls,core: export get_netdev_for_sock
config: m68k-allmodconfig
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/7a172487455cb4d34676606dad25db474fbea682
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Aurelien-Aptel/net-Introduce-direct-data-placement-tcp-offload/20230109-213850
        git checkout 7a172487455cb4d34676606dad25db474fbea682
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash net/core/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> net/core/dev.c:8162: warning: expecting prototype for netdev_sk_get_lowest_dev(). Prototype was for get_netdev_for_sock() instead


vim +8162 net/core/dev.c

719a402cf60311 Tariq Toukan   2021-01-17  8153  
719a402cf60311 Tariq Toukan   2021-01-17  8154  /**
7a172487455cb4 Aurelien Aptel 2023-01-09  8155   * netdev_sk_get_lowest_dev - Get the lowest device in socket
719a402cf60311 Tariq Toukan   2021-01-17  8156   * @sk: the socket
719a402cf60311 Tariq Toukan   2021-01-17  8157   *
7a172487455cb4 Aurelien Aptel 2023-01-09  8158   * Assumes that the socket is already connected.
7a172487455cb4 Aurelien Aptel 2023-01-09  8159   * Returns the lower device or %NULL if no lower device is found.
719a402cf60311 Tariq Toukan   2021-01-17  8160   */
7a172487455cb4 Aurelien Aptel 2023-01-09  8161  struct net_device *get_netdev_for_sock(struct sock *sk)
719a402cf60311 Tariq Toukan   2021-01-17 @8162  {
7a172487455cb4 Aurelien Aptel 2023-01-09  8163  	struct dst_entry *dst = sk_dst_get(sk);
7a172487455cb4 Aurelien Aptel 2023-01-09  8164  	struct net_device *dev, *lower;
719a402cf60311 Tariq Toukan   2021-01-17  8165  
7a172487455cb4 Aurelien Aptel 2023-01-09  8166  	if (unlikely(!dst))
7a172487455cb4 Aurelien Aptel 2023-01-09  8167  		return NULL;
7a172487455cb4 Aurelien Aptel 2023-01-09  8168  	dev = dst->dev;
7a172487455cb4 Aurelien Aptel 2023-01-09  8169  	while ((lower = netdev_sk_get_lower_dev(dev, sk)))
719a402cf60311 Tariq Toukan   2021-01-17  8170  		dev = lower;
7a172487455cb4 Aurelien Aptel 2023-01-09  8171  	dev_hold(dev);
7a172487455cb4 Aurelien Aptel 2023-01-09  8172  	dst_release(dst);
719a402cf60311 Tariq Toukan   2021-01-17  8173  	return dev;
719a402cf60311 Tariq Toukan   2021-01-17  8174  }
7a172487455cb4 Aurelien Aptel 2023-01-09  8175  EXPORT_SYMBOL_GPL(get_netdev_for_sock);
719a402cf60311 Tariq Toukan   2021-01-17  8176
kernel test robot Jan. 9, 2023, 7:10 p.m. UTC | #2
Hi Aurelien,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net/master]
[also build test WARNING on net-next/master linus/master v6.2-rc3]
[cannot apply to hch-configfs/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Aurelien-Aptel/net-Introduce-direct-data-placement-tcp-offload/20230109-213850
patch link:    https://lore.kernel.org/r/20230109133116.20801-7-aaptel%40nvidia.com
patch subject: [PATCH v8 06/25] net/tls,core: export get_netdev_for_sock
config: x86_64-rhel-8.3-rust
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/7a172487455cb4d34676606dad25db474fbea682
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Aurelien-Aptel/net-Introduce-direct-data-placement-tcp-offload/20230109-213850
        git checkout 7a172487455cb4d34676606dad25db474fbea682
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash net/core/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> net/core/dev.c:8162: warning: expecting prototype for netdev_sk_get_lowest_dev(). Prototype was for get_netdev_for_sock() instead


vim +8162 net/core/dev.c

719a402cf60311 Tariq Toukan   2021-01-17  8153  
719a402cf60311 Tariq Toukan   2021-01-17  8154  /**
7a172487455cb4 Aurelien Aptel 2023-01-09  8155   * netdev_sk_get_lowest_dev - Get the lowest device in socket
719a402cf60311 Tariq Toukan   2021-01-17  8156   * @sk: the socket
719a402cf60311 Tariq Toukan   2021-01-17  8157   *
7a172487455cb4 Aurelien Aptel 2023-01-09  8158   * Assumes that the socket is already connected.
7a172487455cb4 Aurelien Aptel 2023-01-09  8159   * Returns the lower device or %NULL if no lower device is found.
719a402cf60311 Tariq Toukan   2021-01-17  8160   */
7a172487455cb4 Aurelien Aptel 2023-01-09  8161  struct net_device *get_netdev_for_sock(struct sock *sk)
719a402cf60311 Tariq Toukan   2021-01-17 @8162  {
7a172487455cb4 Aurelien Aptel 2023-01-09  8163  	struct dst_entry *dst = sk_dst_get(sk);
7a172487455cb4 Aurelien Aptel 2023-01-09  8164  	struct net_device *dev, *lower;
719a402cf60311 Tariq Toukan   2021-01-17  8165  
7a172487455cb4 Aurelien Aptel 2023-01-09  8166  	if (unlikely(!dst))
7a172487455cb4 Aurelien Aptel 2023-01-09  8167  		return NULL;
7a172487455cb4 Aurelien Aptel 2023-01-09  8168  	dev = dst->dev;
7a172487455cb4 Aurelien Aptel 2023-01-09  8169  	while ((lower = netdev_sk_get_lower_dev(dev, sk)))
719a402cf60311 Tariq Toukan   2021-01-17  8170  		dev = lower;
7a172487455cb4 Aurelien Aptel 2023-01-09  8171  	dev_hold(dev);
7a172487455cb4 Aurelien Aptel 2023-01-09  8172  	dst_release(dst);
719a402cf60311 Tariq Toukan   2021-01-17  8173  	return dev;
719a402cf60311 Tariq Toukan   2021-01-17  8174  }
7a172487455cb4 Aurelien Aptel 2023-01-09  8175  EXPORT_SYMBOL_GPL(get_netdev_for_sock);
719a402cf60311 Tariq Toukan   2021-01-17  8176
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index bd270c4bbf97..ba3806a1a11b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3079,8 +3079,7 @@  int init_dummy_netdev(struct net_device *dev);
 struct net_device *netdev_get_xmit_slave(struct net_device *dev,
 					 struct sk_buff *skb,
 					 bool all_slaves);
-struct net_device *netdev_sk_get_lowest_dev(struct net_device *dev,
-					    struct sock *sk);
+struct net_device *get_netdev_for_sock(struct sock *sk);
 struct net_device *dev_get_by_index(struct net *net, int ifindex);
 struct net_device *__dev_get_by_index(struct net *net, int ifindex);
 struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
diff --git a/net/core/dev.c b/net/core/dev.c
index cf78f35bc0b9..ea80f77ba003 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8152,27 +8152,27 @@  static struct net_device *netdev_sk_get_lower_dev(struct net_device *dev,
 }
 
 /**
- * netdev_sk_get_lowest_dev - Get the lowest device in chain given device and socket
- * @dev: device
+ * netdev_sk_get_lowest_dev - Get the lowest device in socket
  * @sk: the socket
  *
- * %NULL is returned if no lower device is found.
+ * Assumes that the socket is already connected.
+ * Returns the lower device or %NULL if no lower device is found.
  */
-
-struct net_device *netdev_sk_get_lowest_dev(struct net_device *dev,
-					    struct sock *sk)
+struct net_device *get_netdev_for_sock(struct sock *sk)
 {
-	struct net_device *lower;
+	struct dst_entry *dst = sk_dst_get(sk);
+	struct net_device *dev, *lower;
 
-	lower = netdev_sk_get_lower_dev(dev, sk);
-	while (lower) {
+	if (unlikely(!dst))
+		return NULL;
+	dev = dst->dev;
+	while ((lower = netdev_sk_get_lower_dev(dev, sk)))
 		dev = lower;
-		lower = netdev_sk_get_lower_dev(dev, sk);
-	}
-
+	dev_hold(dev);
+	dst_release(dst);
 	return dev;
 }
-EXPORT_SYMBOL(netdev_sk_get_lowest_dev);
+EXPORT_SYMBOL_GPL(get_netdev_for_sock);
 
 static void netdev_adjacent_add_links(struct net_device *dev)
 {
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c
index 6c593788dc25..3c298dfb77cb 100644
--- a/net/tls/tls_device.c
+++ b/net/tls/tls_device.c
@@ -120,22 +120,6 @@  static void tls_device_queue_ctx_destruction(struct tls_context *ctx)
 		tls_device_free_ctx(ctx);
 }
 
-/* We assume that the socket is already connected */
-static struct net_device *get_netdev_for_sock(struct sock *sk)
-{
-	struct dst_entry *dst = sk_dst_get(sk);
-	struct net_device *netdev = NULL;
-
-	if (likely(dst)) {
-		netdev = netdev_sk_get_lowest_dev(dst->dev, sk);
-		dev_hold(netdev);
-	}
-
-	dst_release(dst);
-
-	return netdev;
-}
-
 static void destroy_record(struct tls_record_info *record)
 {
 	int i;