Whamcloud - gitweb
LU-9456 lnd: Change sock_create() to sock_create_kern() 58/26958/6
authorDoug Oucharek <doug.s.oucharek@intel.com>
Thu, 4 May 2017 23:29:59 +0000 (16:29 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 12 May 2017 05:06:50 +0000 (05:06 +0000)
Changing all calls in the ksocklnd from sock_create() to
sock_create_kern().

Signed-off-by: Doug Oucharek <doug.s.oucharek@intel.com>
Change-Id: Ib8b175e73478b1edfb5e8cd3491e589e8267f52a
Reviewed-on: https://review.whamcloud.com/26958
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/autoconf/lustre-lnet.m4
lnet/lnet/lib-socket.c

index b0fb2ee..1123672 100644 (file)
@@ -681,6 +681,27 @@ tcp_sendpage_socket, [
 EXTRA_KCFLAGS="$tmp_flags"
 ]) # LN_CONFIG_TCP_SENDPAGE
 
+# LN_CONFIG_SOCK_CREATE_KERN
+#
+# 4.x sock_create_kern() added a first parameter as 'struct net *'
+# instead of int.
+#
+AC_DEFUN([LN_CONFIG_SOCK_CREATE_KERN], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if 'sock_create_kern' first parameter is net],
+sock_create_kern_net, [
+       #include <linux/net.h>
+       #include <net/net_namespace.h>
+],[
+       sock_create_kern((struct net*)0, 0, 0, 0, NULL);
+],[
+       AC_DEFINE(HAVE_SOCK_CREATE_KERN_USE_NET, 1,
+               [sock_create_kern use net as first parameter])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_CONFIG_SOCK_CREATE_KERN
+
 #
 # LN_CONFIG_SK_DATA_READY
 #
@@ -719,6 +740,8 @@ LN_CONFIG_GNILND
 LN_CONFIG_SK_SLEEP
 # 2.6.36
 LN_CONFIG_TCP_SENDPAGE
+# 4.x
+LN_CONFIG_SOCK_CREATE_KERN
 # 3.15
 LN_CONFIG_SK_DATA_READY
 ]) # LN_PROG_LINUX
index 7d0dcbd..4eaaf6c 100644 (file)
@@ -64,7 +64,11 @@ lnet_sock_ioctl(int cmd, unsigned long arg)
        int             fd = -1;
        int             rc;
 
-       rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock);
+#ifdef HAVE_SOCK_CREATE_KERN_USE_NET
+       rc = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, 0, &sock);
+#else
+       rc = sock_create_kern(PF_INET, SOCK_STREAM, 0, &sock);
+#endif
        if (rc != 0) {
                CERROR("Can't create socket: %d\n", rc);
                return rc;
@@ -413,7 +417,11 @@ lnet_sock_create(struct socket **sockp, int *fatal,
        /* All errors are fatal except bind failure if the port is in use */
        *fatal = 1;
 
-       rc = sock_create(PF_INET, SOCK_STREAM, 0, &sock);
+#ifdef HAVE_SOCK_CREATE_KERN_USE_NET
+       rc = sock_create_kern(&init_net, PF_INET, SOCK_STREAM, 0, &sock);
+#else
+       rc = sock_create_kern(PF_INET, SOCK_STREAM, 0, &sock);
+#endif
        *sockp = sock;
        if (rc != 0) {
                CERROR("Can't create socket: %d\n", rc);