]> git.openfabrics.org - compat-rdma/compat.git/commitdiff
compat: Added support for SRP on RHEL7.5
authorVladimir Sokolovsky <vlad@mellanox.com>
Thu, 26 Jul 2018 18:44:33 +0000 (13:44 -0500)
committerVladimir Sokolovsky <vlad@mellanox.com>
Thu, 26 Jul 2018 20:02:58 +0000 (15:02 -0500)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
compat/Makefile
compat/compat-4.16.c [new file with mode: 0644]
config/rdma.m4
config/warning_filter.sh
include/linux/compat-2.6.h
include/linux/compat-4.16.h [new file with mode: 0644]
include/linux/inet.h [new file with mode: 0644]
include/linux/netdevice.h
include/scsi/scsi_device.h [new file with mode: 0644]

index 2e1e1da55842c88e1dfab1e221ffca3da3efeeb3..e569ad493a185492873ec9239f2c57507a9a3f89 100644 (file)
@@ -11,3 +11,4 @@ compat-$(CONFIG_COMPAT_KERNEL_3_16) += compat-3.16.o
 compat-$(CONFIG_COMPAT_KERNEL_3_18) += compat-3.18.o
 compat-$(CONFIG_COMPAT_KERNEL_4_0) += compat-4.0.o
 compat-$(CONFIG_COMPAT_KERNEL_4_1) += compat-4.1.o
+compat-$(CONFIG_COMPAT_KERNEL_4_16) += compat-4.16.o
diff --git a/compat/compat-4.16.c b/compat/compat-4.16.c
new file mode 100644 (file)
index 0000000..f09bb06
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef HAVE_KOBJ_NS_DROP_EXPORTED
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * kobject.c - library routines for handling generic kernel objects
+ *
+ * Copyright (c) 2002-2003 Patrick Mochel <mochel@osdl.org>
+ * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (c) 2006-2007 Novell Inc.
+ *
+ * Please see the file Documentation/kobject.txt for critical information
+ * about using the kobject interface.
+ */
+
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/export.h>
+#include <linux/stat.h>
+#include <linux/slab.h>
+#include <linux/random.h>
+
+static DEFINE_SPINLOCK(kobj_ns_type_lock);
+static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
+
+#define kobj_ns_grab_current LINUX_BACKPORT(kobj_ns_grab_current)
+void *kobj_ns_grab_current(enum kobj_ns_type type)
+{
+       void *ns = NULL;
+
+       spin_lock(&kobj_ns_type_lock);
+       if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) &&
+           kobj_ns_ops_tbl[type])
+               ns = kobj_ns_ops_tbl[type]->grab_current_ns();
+       spin_unlock(&kobj_ns_type_lock);
+
+       return ns;
+}
+EXPORT_SYMBOL_GPL(kobj_ns_grab_current);
+
+#define kobj_ns_drop LINUX_BACKPORT(kobj_ns_drop)
+void kobj_ns_drop(enum kobj_ns_type type, void *ns)
+{
+       spin_lock(&kobj_ns_type_lock);
+       if ((type > KOBJ_NS_TYPE_NONE) && (type < KOBJ_NS_TYPES) &&
+           kobj_ns_ops_tbl[type] && kobj_ns_ops_tbl[type]->drop_ns)
+               kobj_ns_ops_tbl[type]->drop_ns(ns);
+       spin_unlock(&kobj_ns_type_lock);
+}
+EXPORT_SYMBOL_GPL(kobj_ns_drop);
+#endif
index 6469093a44d437d6101f07cf56f5022a7c6e9608..75d1a8ac4f3f68d958a4605e92086bf28cd79561 100644 (file)
@@ -6309,6 +6309,74 @@ AC_DEFUN([LINUX_CONFIG_COMPAT],
                [AC_DEFINE(HAVE_BPF_PROG_INC_EXPORTED, 1,
                        [bpf_prog_inc is exported by the kernel])],
        [])
+
+       AC_MSG_CHECKING([if linux/inet.h inet_pton_with_scope])
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/inet.h>
+       ],[
+               inet_pton_with_scope(NULL, 0, NULL, NULL, NULL);
+
+               return 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_INET_PTON_WITH_SCOPE, 1,
+                       [inet_pton_with_scope is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
+       AC_MSG_CHECKING([if scsi_device.h has blist_flags_t])
+       LB_LINUX_TRY_COMPILE([
+               #include <scsi/scsi_device.h>
+    ],[
+               blist_flags_t x = 0;
+
+               return 0;
+    ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_BLIST_FLAGS_T, 1,
+                       [blist_flags_t is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
+       AC_MSG_CHECKING([if scsi_device.h struct scsi_device has member state_mutex])
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/mutex.h>
+               #include <scsi/scsi_device.h>
+       ],[
+               struct scsi_device sdev;
+               mutex_init(&sdev.state_mutex);
+
+               return 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_SCSI_DEVICE_STATE_MUTEX, 1,
+                         [scsi_device.h struct scsi_device has member state_mutex])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
+       AC_MSG_CHECKING([if scsi_device.h has enum scsi_scan_mode])
+       LB_LINUX_TRY_COMPILE([
+               #include <scsi/scsi_device.h>
+       ],[
+               enum scsi_scan_mode xx = SCSI_SCAN_INITIAL;
+
+               return 0;
+       ],[
+               AC_MSG_RESULT(yes)
+               AC_DEFINE(HAVE_ENUM_SCSI_SCAN_MODE, 1,
+                         [enum scsi_scan_mode is defined])
+       ],[
+               AC_MSG_RESULT(no)
+       ])
+
+       LB_CHECK_SYMBOL_EXPORT([kobj_ns_drop],
+               [lib/kobject.c],
+               [AC_DEFINE(HAVE_KOBJ_NS_DROP_EXPORTED, 1,
+                       [kobj_ns_drop is exported by the kernel])],
+       [])
 ])
 #
 # COMPAT_CONFIG_HEADERS
index 7b3e9fc0b058004552ff5b01f53ed74bdcb5bd19..55aeebe85a6617e0b7f47f0643613bd7f5e42ba8 100755 (executable)
@@ -7,7 +7,7 @@ echo_err()
        echo -e "$@" 1>&2
 }
 
-regEx="(from incompatible pointer type|declared inside parameter list|is deprecated)"
+regEx="(from incompatible pointer type|declared inside parameter list|is deprecated|expects argument of type|discards .const. qualifier|but argument is of type|discards qualifiers from pointer target type)"
 
 cat $log_file 1>&2
 
index a31f860f3220e60511443be9cd08cd37320e20c2..593ac25018ba44ac130bf3ccd80e4ccd967f2029 100644 (file)
@@ -55,6 +55,7 @@ void backport_dependency_symbol(void);
 #include <linux/compat-4.1.h>
 #include <linux/compat-4.5.h>
 #include <linux/compat-4.9.h>
+#include <linux/compat-4.16.h>
 #include <linux/compat-4.17.h>
 
 #endif /* CONFIG_COMPAT_RDMA */
diff --git a/include/linux/compat-4.16.h b/include/linux/compat-4.16.h
new file mode 100644 (file)
index 0000000..7cc5416
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef LINUX_4_16_COMPAT_H
+#define LINUX_4_16_COMPAT_H
+
+#include <linux/version.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,16,0))
+
+#ifndef HAVE_KOBJ_NS_DROP_EXPORTED
+#include <linux/kobject_ns.h>
+
+#define kobj_ns_drop LINUX_BACKPORT(kobj_ns_drop)
+void kobj_ns_drop(enum kobj_ns_type type, void *ns);
+
+#define kobj_ns_grab_current LINUX_BACKPORT(kobj_ns_grab_current)
+void *kobj_ns_grab_current(enum kobj_ns_type type);
+#endif
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(4,16,0)) */
+
+#endif /* LINUX_4_16_COMPAT_H */
diff --git a/include/linux/inet.h b/include/linux/inet.h
new file mode 100644 (file)
index 0000000..53ea45f
--- /dev/null
@@ -0,0 +1,122 @@
+#ifndef _COMPAT_LINUX_INET_H
+#define _COMPAT_LINUX_INET_H
+
+#include "../../compat/config.h"
+#include <linux/version.h>
+
+#include_next <linux/inet.h>
+
+#if (defined(RHEL_MAJOR) && RHEL_MAJOR -0 == 7 && RHEL_MINOR -0 >= 2) || \
+       (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+#ifndef HAVE_INET_PTON_WITH_SCOPE
+
+#include <net/net_namespace.h>
+#include <linux/socket.h>
+#include <net/ipv6.h>
+
+
+static int inet4_pton(const char *src, u16 port_num,
+               struct sockaddr_storage *addr)
+{
+       struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
+       int srclen = strlen(src);
+
+       if (srclen > INET_ADDRSTRLEN)
+               return -EINVAL;
+
+       if (in4_pton(src, srclen, (u8 *)&addr4->sin_addr.s_addr,
+                    '\n', NULL) == 0)
+               return -EINVAL;
+
+       addr4->sin_family = AF_INET;
+       addr4->sin_port = htons(port_num);
+
+       return 0;
+}
+
+static int inet6_pton(struct net *net, const char *src, u16 port_num,
+               struct sockaddr_storage *addr)
+{
+       struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
+       const char *scope_delim;
+       int srclen = strlen(src);
+
+       if (srclen > INET6_ADDRSTRLEN)
+               return -EINVAL;
+
+       if (in6_pton(src, srclen, (u8 *)&addr6->sin6_addr.s6_addr,
+                    '%', &scope_delim) == 0)
+               return -EINVAL;
+
+       if (ipv6_addr_type(&addr6->sin6_addr) & IPV6_ADDR_LINKLOCAL &&
+           src + srclen != scope_delim && *scope_delim == '%') {
+               struct net_device *dev;
+               char scope_id[16];
+               size_t scope_len = min_t(size_t, sizeof(scope_id) - 1,
+                                        src + srclen - scope_delim - 1);
+
+               memcpy(scope_id, scope_delim + 1, scope_len);
+               scope_id[scope_len] = '\0';
+
+               dev = dev_get_by_name(net, scope_id);
+               if (dev) {
+                       addr6->sin6_scope_id = dev->ifindex;
+                       dev_put(dev);
+               } else if (kstrtouint(scope_id, 0, &addr6->sin6_scope_id)) {
+                       return -EINVAL;
+               }
+       }
+
+       addr6->sin6_family = AF_INET6;
+       addr6->sin6_port = htons(port_num);
+
+       return 0;
+}
+
+/**
+ * inet_pton_with_scope - convert an IPv4/IPv6 and port to socket address
+ * @net: net namespace (used for scope handling)
+ * @af: address family, AF_INET, AF_INET6 or AF_UNSPEC for either
+ * @src: the start of the address string
+ * @port: the start of the port string (or NULL for none)
+ * @addr: output socket address
+ *
+ * Return zero on success, return errno when any error occurs.
+ */
+static inline int inet_pton_with_scope(struct net *net, __kernel_sa_family_t af,
+               const char *src, const char *port, struct sockaddr_storage *addr)
+{
+       u16 port_num;
+       int ret = -EINVAL;
+
+       if (port) {
+               if (kstrtou16(port, 0, &port_num))
+                       return -EINVAL;
+       } else {
+               port_num = 0;
+       }
+
+       switch (af) {
+       case AF_INET:
+               ret = inet4_pton(src, port_num, addr);
+               break;
+       case AF_INET6:
+               ret = inet6_pton(net, src, port_num, addr);
+               break;
+       case AF_UNSPEC:
+               ret = inet4_pton(src, port_num, addr);
+               if (ret)
+                       ret = inet6_pton(net, src, port_num, addr);
+               break;
+       default:
+               pr_err("unexpected address family %d\n", af);
+       };
+
+       return ret;
+}
+
+#endif /* inet_pton_with_scope */
+
+#endif
+
+#endif /* _COMPAT_LINUX_INET_H */
index cd82256f630191542bd31fa72cdcbf4d1dc18772..332fb2b1f7d357c79be47e850d5271829c1ca351 100644 (file)
 #define ndo_bpf                ndo_xdp
 #endif
 
+#ifndef HAVE_TC_SETUP_QDISC_MQPRIO
+#define TC_SETUP_QDISC_MQPRIO TC_SETUP_MQPRIO
+#endif
+
+#ifndef netdev_WARN_ONCE
 static inline const char *netdev_reg_state(const struct net_device *dev)
 {
        switch (dev->reg_state) {
@@ -35,11 +40,6 @@ static inline const char *netdev_reg_state(const struct net_device *dev)
        return " (unknown)";
 }
 
-#ifndef HAVE_TC_SETUP_QDISC_MQPRIO
-#define TC_SETUP_QDISC_MQPRIO TC_SETUP_MQPRIO
-#endif
-
-#ifndef netdev_WARN_ONCE
 
 #define netdev_level_once(level, dev, fmt, ...)                        \
 do {                                                           \
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
new file mode 100644 (file)
index 0000000..d609c67
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef COMPAT_SCSI_SCSI_DEVICE_H
+#define COMPAT_SCSI_SCSI_DEVICE_H
+
+#include "../../compat/config.h"
+
+#include_next <scsi/scsi_device.h>
+
+#ifndef HAVE_ENUM_SCSI_SCAN_MODE
+enum scsi_scan_mode {
+       SCSI_SCAN_INITIAL = 0,
+       SCSI_SCAN_RESCAN,
+       SCSI_SCAN_MANUAL,
+};
+#endif
+
+#ifndef HAVE_BLIST_FLAGS_T
+       typedef unsigned int __bitwise blist_flags_t;
+#endif
+
+#endif /* COMPAT_SCSI_SCSI_DEVICE_H */