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
--- /dev/null
+#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
[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
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
#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 */
--- /dev/null
+#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 */
--- /dev/null
+#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 */
#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) {
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 { \
--- /dev/null
+#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 */