Can't build kernel module
Get error when build kernel module:
+ make
make all-recursive
make[1]: Entering directory '/builddir/build/BUILD/iptv-analyzer-0.9.4'
Making all in iptables-module
make[2]: Entering directory '/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module'
\n -=-=-=-=- Userspace lib -=-=-=-=-
gcc -DIPTABLES_VERSION=\"1.4.21\" -O2 -ggdb3 -Wall -fPIC -I/usr/include -D_INIT=libxt_mpeg2ts_init -c -o libxt_mpeg2ts.o libxt_mpeg2ts.c;
gcc -shared -o libxt_mpeg2ts.so libxt_mpeg2ts.o;
\n -=-=-=-=- Kernel modules -=-=-=-=-
make -C /usr/src/kernels/4.3.3-303.fc23.x86_64 M=/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module modules
make[3]: Entering directory '/usr/src/kernels/4.3.3-303.fc23.x86_64'
CC [M] /builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.o
/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.c: In function 'mpeg2ts_seq_show_real':
/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.c:1309:6: error: void value not ignored as it ought to be
res = seq_printf(s, "bucket:%d dst:%pI4 src:%pI4 dport:%u sport:%u "
^
/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.c: At top level:
/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.c:835:1: warning: 'conn_htable_get' defined but not used [-Wunused-function]
conn_htable_get(uint32_t rule_id)
^
/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.c:852:1: warning: 'conn_htable_put' defined but not used [-Wunused-function]
conn_htable_put(struct xt_rule_mpeg2ts_conn_htable *hinfo)
^
/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.c:864:1: warning: 'conn_htable_add' defined but not used [-Wunused-function]
conn_htable_add(struct xt_rule_mpeg2ts_conn_htable *hinfo)
^
scripts/Makefile.build:264: recipe for target '/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.o' failed
make[4]: *** [/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module/xt_mpeg2ts.o] Error 1
make[3]: *** [_module_/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module] Error 2
Makefile:1382: recipe for target '_module_/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module' failed
make[3]: Leaving directory '/usr/src/kernels/4.3.3-303.fc23.x86_64'
Makefile:97: recipe for target 'modules' failed
rm libxt_mpeg2ts.o
make[2]: Leaving directory '/builddir/build/BUILD/iptv-analyzer-0.9.4/iptables-module'
make[2]: *** [modules] Error 2
Makefile:394: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/builddir/build/BUILD/iptv-analyzer-0.9.4'
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Makefile:329: recipe for target 'all' failed
How can I fix it?
diff --git a/iptables-module/xt_mpeg2ts.c b/iptables-module/xt_mpeg2ts.c
index 91ae4a0..ca4e5f0 100644
--- a/iptables-module/xt_mpeg2ts.c
+++ b/iptables-module/xt_mpeg2ts.c
@@ -1299,14 +1299,12 @@ static void mpeg2ts_seq_stop(struct seq_file *s, void *v)
static int mpeg2ts_seq_show_real(struct mpeg2ts_stream *stream,
struct seq_file *s, unsigned int bucket)
{
- int res;
-
if (!atomic_inc_not_zero(&stream->use)) {
/* If "use" is zero, then we about to be free'd */
return 0;
}
- res = seq_printf(s, "bucket:%d dst:%pI4 src:%pI4 dport:%u sport:%u "
+ seq_printf(s, "bucket:%d dst:%pI4 src:%pI4 dport:%u sport:%u "
"pids:%d skips:%llu discontinuity:%llu "
"payload_bytes:%llu packets:%llu\n",
bucket,
@@ -1323,7 +1321,7 @@ static int mpeg2ts_seq_show_real(struct mpeg2ts_stream *stream,
atomic_dec(&stream->use);
- return res;
+ return seq_has_overflowed(s);
}
static int mpeg2ts_seq_show(struct seq_file *s, void *v)
The same problem after upgrading the kernel. I'm fixed xt_mpeg2ts.c, but does not work
-=-=-=-=- Kernel modules -=-=-=-=- make -C /lib/modules/4.4.1-sunxi/build M=/root/IPTV-Analyzer/iptables-module modules make[1]: Entering directory '/usr/src/linux-headers-4.4.1-sunxi' CC [M] /root/IPTV-Analyzer/iptables-module/compat_xtables.o /root/IPTV-Analyzer/iptables-module/compat_xtables.c: In function ‘xtnu_ip_route_me_harder’: /root/IPTV-Analyzer/iptables-module/compat_xtables.c:475:28: warning: passing argument 1 of ‘ip_route_me_harder’ from incompatible pointer type return ip_route_me_harder(*pskb, addr_type); In file included from /root/IPTV-Analyzer/iptables-module/compat_xtables.c:17:0: include/linux/netfilter_ipv4.h:9:5: note: expected ‘struct net *’ but argument is of type ‘struct sk_buff *’ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned addr_type); /root/IPTV-Analyzer/iptables-module/compat_xtables.c:475:35: warning: passing argument 2 of ‘ip_route_me_harder’ makes pointer from integer without a cast return ip_route_me_harder(*pskb, addr_type); In file included from /root/IPTV-Analyzer/iptables-module/compat_xtables.c:17:0: include/linux/netfilter_ipv4.h:9:5: note: expected ‘struct sk_buff *’ but argument is of type ‘unsigned int’ int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned addr_type); /root/IPTV-Analyzer/iptables-module/compat_xtables.c:475:9: error: too few arguments to function ‘ip_route_me_harder’ return ip_route_me_harder(*pskb, addr_type); In file included from /root/IPTV-Analyzer/iptables-module/compat_xtables.c:17:0: include/linux/netfilter_ipv4.h:9:5: note: declared here int ip_route_me_harder(struct net *net, struct sk_buff *skb, unsigned addr_type); /root/IPTV-Analyzer/iptables-module/compat_xtables.c:477:1: warning: control reaches end of non-void function [-Wreturn-type] } scripts/Makefile.build:264: recipe for target '/root/IPTV-Analyzer/iptables-module/compat_xtables.o' failed make[2]: *** [/root/IPTV-Analyzer/iptables-module/compat_xtables.o] Error 1 Makefile:1384: recipe for target '_module_/root/IPTV-Analyzer/iptables-module' failed make[1]: *** [_module_/root/IPTV-Analyzer/iptables-module] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-4.4.1-sunxi' Makefile:97: recipe for target 'modules' failed make: *** [modules] Error 2
This patch to get module worked on Debian 8.4, Kernel 4.5.4-1~bpo8+1 (2016-05-13):
- fixed msg_level parm init value set on module load
- fixed compile error:
diff --git a/iptables-module/compat_xtables.c b/iptables-module/compat_xtables.c
index c5b67a4..40f83c8 100644
--- a/iptables-module/compat_xtables.c
+++ b/iptables-module/compat_xtables.c
@@ -464,6 +464,7 @@ struct xt_match *xtnu_request_find_match(unsigned int af, const char *name,
}
EXPORT_SYMBOL_GPL(xtnu_request_find_match);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
int xtnu_ip_route_me_harder(struct sk_buff **pskb, unsigned int addr_type)
{
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 17)
@@ -476,6 +477,7 @@ int xtnu_ip_route_me_harder(struct sk_buff **pskb, unsigned int addr_type)
#endif
}
EXPORT_SYMBOL_GPL(xtnu_ip_route_me_harder);
+#endif
int xtnu_skb_make_writable(struct sk_buff **pskb, unsigned int len)
{
diff --git a/iptables-module/compat_xtnu.h b/iptables-module/compat_xtnu.h
index 02b6575..253e3df 100644
--- a/iptables-module/compat_xtnu.h
+++ b/iptables-module/compat_xtnu.h
@@ -143,7 +143,9 @@ static inline __wsum csum_unfold(__sum16 n)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
extern int xtnu_ip_local_out(struct sk_buff *);
extern int xtnu_ip_route_me_harder(struct sk_buff **, unsigned int);
+#endif
extern int xtnu_skb_make_writable(struct sk_buff **, unsigned int);
extern int xtnu_register_match(struct xtnu_match *);
extern int xtnu_ip_route_output_key(void *, struct rtable **, struct flowi *);
diff --git a/iptables-module/xt_mpeg2ts.c b/iptables-module/xt_mpeg2ts.c
index 91ae4a0..87cfb17 100644
--- a/iptables-module/xt_mpeg2ts.c
+++ b/iptables-module/xt_mpeg2ts.c
@@ -99,7 +99,7 @@ static const struct file_operations dl_file_ops;
#endif
static int debug = -1;
-static int msg_level;
+static int msg_level = MPEG2TS_MSG_DEFAULT;
module_param(debug, int, 0);
module_param(msg_level, int, 0664);
MODULE_PARM_DESC(debug, "Set low N bits of message level");
@@ -1299,14 +1299,12 @@ static void mpeg2ts_seq_stop(struct seq_file *s, void *v)
static int mpeg2ts_seq_show_real(struct mpeg2ts_stream *stream,
struct seq_file *s, unsigned int bucket)
{
- int res;
-
if (!atomic_inc_not_zero(&stream->use)) {
/* If "use" is zero, then we about to be free'd */
return 0;
}
- res = seq_printf(s, "bucket:%d dst:%pI4 src:%pI4 dport:%u sport:%u "
+ seq_printf(s, "bucket:%d dst:%pI4 src:%pI4 dport:%u sport:%u "
"pids:%d skips:%llu discontinuity:%llu "
"payload_bytes:%llu packets:%llu\n",
bucket,
@@ -1323,7 +1321,7 @@ static int mpeg2ts_seq_show_real(struct mpeg2ts_stream *stream,
atomic_dec(&stream->use);
- return res;
+ return seq_has_overflowed(s);
}
static int mpeg2ts_seq_show(struct seq_file *s, void *v)
@@ -1434,7 +1432,7 @@ static int __init mpeg2ts_mt_init(void)
*/
INIT_LIST_HEAD(&conn_htables);
- msg_level = netif_msg_init(debug, MPEG2TS_MSG_DEFAULT);
+ msg_level = netif_msg_init(debug, msg_level);
msg_info(DRV, "Loading: %s", version);
msg_dbg(DRV, "Message level (msg_level): 0x%X", msg_level);
thank you, problem solved!
This does indeed fix the problems with compiling even on 4.9. However, either something in the kernel changed or something in iptables/netfilter changed. When running this stuff on debian stretch (kernel 4.9, iptables 1.6) I get no matches at all for any mpeg2ts rules, while the same rules do work on iptables 1.4, kernel 3.16.
Hi,
I am confronted with the same problem when compiling the module from a Raspberry Pi 4 or 3. Kernel : 4.9 Iptables : 1.6
root@raspberry:/home/pi/IPTV-Analyzer# make
make all-recursive
make[1] : on entre dans le répertoire « /home/pi/IPTV-Analyzer »
Making all in iptables-module
make[2] : on entre dans le répertoire « /home/pi/IPTV-Analyzer/iptables-module »
-=-=-=-=- Userspace lib -=-=-=-=-
gcc -DIPTABLES_VERSION=\"1.6.0\" -O2 -ggdb3 -Wall -fPIC -I/usr/include -D_INIT=libxt_mpeg2ts_init -c -o libxt_mpeg2ts.o libxt_mpeg2ts.c;
gcc -shared -o libxt_mpeg2ts.so libxt_mpeg2ts.o;
-=-=-=-=- Kernel modules -=-=-=-=-
make -C /lib/modules/4.9.0-9-amd64/build M=/home/pi/IPTV-Analyzer/iptables-module modules
make[3] : on entre dans le répertoire « /usr/src/linux-headers-4.9.0-9-amd64 »
CC [M] /home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.o
/home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.c: In function ‘mpeg2ts_seq_show_real’:
/home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.c:1309:6: error: void value not ignored as it ought to be
res = seq_printf(s, "bucket:%d dst:%pI4 src:%pI4 dport:%u sport:%u "
^
At top level:
/home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.c:864:1: warning: ‘conn_htable_add’ defined but not used [-Wunused-function]
conn_htable_add(struct xt_rule_mpeg2ts_conn_htable *hinfo)
^~~~~~~~~~~~~~~
/home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.c:852:1: warning: ‘conn_htable_put’ defined but not used [-Wunused-function]
conn_htable_put(struct xt_rule_mpeg2ts_conn_htable *hinfo)
^~~~~~~~~~~~~~~
/home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.c:835:1: warning: ‘conn_htable_get’ defined but not used [-Wunused-function]
conn_htable_get(uint32_t rule_id)
^~~~~~~~~~~~~~~
/usr/src/linux-headers-4.9.0-9-common/scripts/Makefile.build:315 : la recette pour la cible « /home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.o » a échouée
make[6]: *** [/home/pi/IPTV-Analyzer/iptables-module/xt_mpeg2ts.o] Erreur 1
/usr/src/linux-headers-4.9.0-9-common/Makefile:1544 : la recette pour la cible « _module_/home/pi/IPTV-Analyzer/iptables-module » a échouée
make[5]: *** [_module_/home/pi/IPTV-Analyzer/iptables-module] Erreur 2
Makefile:152 : la recette pour la cible « sub-make » a échouée
make[4]: *** [sub-make] Erreur 2
Makefile:8 : la recette pour la cible « all » a échouée
make[3]: *** [all] Erreur 2
make[3] : on quitte le répertoire « /usr/src/linux-headers-4.9.0-9-amd64 »
Makefile:97 : la recette pour la cible « modules » a échouée
make[2]: *** [modules] Erreur 2
rm libxt_mpeg2ts.o
make[2] : on quitte le répertoire « /home/pi/IPTV-Analyzer/iptables-module »
Makefile:395 : la recette pour la cible « all-recursive » a échouée
make[1]: *** [all-recursive] Erreur 1
make[1] : on quitte le répertoire « /home/pi/IPTV-Analyzer »
Makefile:330 : la recette pour la cible « all » a échouée
make: *** [all] Erreur 2
Any help is appreciated, please.
BR