coova / coova-chilli

CoovaChilli is an open-source software access controller for captive portal hotspots.
Other
514 stars 257 forks source link

Compilation error when compiling xt_coova #529

Open yifu opened 3 years ago

yifu commented 3 years ago

I'm trying to compile xt_coova, and I get a compilation error:

make -C /lib/modules/5.11.0-27-generic/build M=$PWD;
make[4] : on entre dans le répertoire « /usr/src/linux-headers-5.11.0-27-generic »
  CC [M]  /tmp/coova-chilli/src/linux/xt_coova.o
/tmp/coova-chilli/src/linux/xt_coova.c: In function ‘coova_mt_check’:
/tmp/coova-chilli/src/linux/xt_coova.c:332:11: error: passing argument 4 of ‘proc_create_data’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  332 |           &coova_mt_fops, t);
      |           ^~~~~~~~~~~~~~
      |           |
      |           const struct file_operations *
In file included from /tmp/coova-chilli/src/linux/xt_coova.c:23:
./include/linux/proc_fs.h:104:31: note: expected ‘const struct proc_ops *’ but argument is of type ‘const struct file_operations *’
  104 | extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
      |                               ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

I have the same compilation error, either on main branch or on 1.6 tag.

I'm configuring with :

./configure --prefix=/usr --libdir=/usr/lib64 --localstatedir=/var --sysconfdir=/etc --enable-miniportal --with-openssl --enable-libjson --enable-useragent --enable-sessionstate --enable-sessionid --enable-chilliredir --enable-binstatusfile --enable-statusfile --disable-static --enable-shared --enable-largelimits --enable-proxyvsa --enable-chilliproxy --enable-chilliradsec --with-poll --enable-dhcpopt --enable-sessgarden --enable-ipwhitelist --enable-redirdnsreq --enable-miniconfig --enable-layer3 --enable-chilliscript --enable-eapol --enable-uamdomainfile --enable-modules --enable-multiroute --with-nfcoova

Of course I'm invoking ./bootstrap beforehand.

Does anyone know how to get the kernel module to compile smoothly? :)

yifu commented 3 years ago

I've been able to fix the issue with this diff:

$ git diff
diff --git a/src/linux/xt_coova.c b/src/linux/xt_coova.c
index 00ea2b3..7c3e01c 100644
--- a/src/linux/xt_coova.c
+++ b/src/linux/xt_coova.c
@@ -91,7 +91,7 @@ static DEFINE_MUTEX(coova_mutex);

 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *coova_proc_dir;
-static const struct file_operations coova_old_fops, coova_mt_fops;
+static const struct proc_ops coova_old_fops, coova_mt_fops;
 #endif

 static u_int32_t hash_rnd;
@@ -577,12 +577,12 @@ coova_mt_proc_write(struct file *file, const char __user *input,
        return size + 1;
 }

-static const struct file_operations coova_mt_fops = {
-       .open    = coova_seq_open,
-       .read    = seq_read,
-       .write   = coova_mt_proc_write,
-       .release = seq_release_private,
-       .owner   = THIS_MODULE,
+static const struct proc_ops coova_mt_fops = {
+       .proc_open    = coova_seq_open,
+       .proc_read    = seq_read,
+       .proc_write   = coova_mt_proc_write,
+       .proc_release = seq_release_private,
+       //.owner   = THIS_MODULE,
 };
 #endif /* CONFIG_PROC_FS */

The change looks simple. But I do not know what I'm doing. :)