ipt-netflow
ipt-netflow copied to clipboard
Issues compiling on Oracle Linux
I am not sure if you support Oracle Linux. Just wanted to bring the following to your attention if you do.
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.4 (Maipo)
$ cat /etc/oracle-release
Oracle Linux Server release 7.4
$ uname -r
4.1.12-112.14.13.el7uek.x86_64
$ cat /usr/include/linux/version.h
#define LINUX_VERSION_CODE 199168
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#define RHEL_MAJOR 7
#define RHEL_MINOR 4
#define RHEL_RELEASE_VERSION(a,b) (((a) << 8) + (b))
#define RHEL_RELEASE_CODE 1796
#define RHEL_RELEASE "693.17.1"
I faced a couple of issues when trying to build on the above system.
First issue was that as the system is using Unbreakable Linux so I had to install the kernel-uek-devel package to get the right kernel headers to compile.
$ yum install kernel-uek-devel
Then, I saw the following issues when trying to compile:
$ make
Compiling for kernel 4.1.12-112.14.13.el7uek.x86_64
make -C /lib/modules/4.1.12-112.14.13.el7uek.x86_64/build M=/home/opc/projects/ipt-netflow modules CONFIG_DEBUG_INFO=y
make[1]: Entering directory `/usr/src/kernels/4.1.12-112.14.13.el7uek.x86_64'
CC [M] /home/opc/projects/ipt-netflow/ipt_NETFLOW.o
/home/opc/projects/ipt-netflow/ipt_NETFLOW.c: In function ‘usock_open_sock’:
/home/opc/projects/ipt-netflow/ipt_NETFLOW.c:1931:2: warning: passing argument 1 of ‘sock_create_kern’ makes pointer from integer without a cast [enabled by default]
if ((error = sock_create_kern(usock->addr.ss_family, SOCK_DGRAM, IPPROTO_UDP, &sock)) < 0) {
^
In file included from include/linux/skbuff.h:29:0,
from /home/opc/projects/ipt-netflow/ipt_NETFLOW.c:23:
include/linux/net.h:211:5: note: expected ‘struct net *’ but argument is of type ‘__kernel_sa_family_t’
int sock_create_kern(struct net *net, int family, int type, int proto,
^
/home/opc/projects/ipt-netflow/ipt_NETFLOW.c:1931:2: warning: passing argument 4 of ‘sock_create_kern’ makes integer from pointer without a cast [enabled by default]
if ((error = sock_create_kern(usock->addr.ss_family, SOCK_DGRAM, IPPROTO_UDP, &sock)) < 0) {
^
In file included from include/linux/skbuff.h:29:0,
from /home/opc/projects/ipt-netflow/ipt_NETFLOW.c:23:
include/linux/net.h:211:5: note: expected ‘int’ but argument is of type ‘struct socket **’
int sock_create_kern(struct net *net, int family, int type, int proto,
^
/home/opc/projects/ipt-netflow/ipt_NETFLOW.c:1931:2: error: too few arguments to function ‘sock_create_kern’
if ((error = sock_create_kern(usock->addr.ss_family, SOCK_DGRAM, IPPROTO_UDP, &sock)) < 0) {
^
In file included from include/linux/skbuff.h:29:0,
from /home/opc/projects/ipt-netflow/ipt_NETFLOW.c:23:
include/linux/net.h:211:5: note: declared here
int sock_create_kern(struct net *net, int family, int type, int proto,
^
make[2]: *** [/home/opc/projects/ipt-netflow/ipt_NETFLOW.o] Error 1
make[1]: *** [_module_/home/opc/projects/ipt-netflow] Error 2
make[1]: Leaving directory `/usr/src/kernels/4.1.12-112.14.13.el7uek.x86_64'
make: *** [ipt_NETFLOW.ko] Error 2
It seems to me that the testing in compat.h for which version of sock_create_kern() to use is failing. /usr/include/linux/version.h defines LINUX_VERSION_CODE as 199168 which based on my calculation is 3.10.0 and I believe that sock_create_kern() was updated in 4.2.0.
The following patch allowed me to compile but obviously it isn't good enough.
$ git diff
diff --git a/compat.h b/compat.h
index 275ff58..7cfb5f7 100644
--- a/compat.h
+++ b/compat.h
@@ -580,9 +580,7 @@ out:
}
#endif /* IN6PTON_XDIGIT */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)
-# define sock_create_kern(f, t, p, s) sock_create_kern(&init_net, f, t, p, s)
-#endif
+#define sock_create_kern(f, t, p, s) sock_create_kern(&init_net, f, t, p, s)
I am not sure what is a good way to figuring out the correct kernel version on Oracle Linux. As far as I can tell, there are at least three interesting version numbers to consider here: version reported by 'uname -r'; version reported in LINUX_VERSION_CODE; and the version where the sock_create_kern() API was updated. All three seem to disagree with each other. I spent some time trying to do Google searches to understand but didn't find any concrete answers. I hope this report is useful to you.
Thanks for a great software!
Thanks! I will look into that.