Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-16-2005, 11:40 AM
|
#1
|
LQ Newbie
Registered: Feb 2005
Posts: 5
Rep:
|
Trouble Compiling Linux Module
I'm trying to get this module called blocker_ip compiled to run on my Smootwall box. Unfortunately, I'm getting quite a few compilation errors relating to the header files. I think I'm missing some dependencies or something. Any help would be greatly appreciated!
Headers:
Code:
#include <linux/ip.h> /* IP Header*/
#include <linux/kernel.h> /* Kernel */
#include <linux/module.h> /* Module */
#include <linux/netdevice.h> /* Interfaces */
#include <linux/netfilter.h> /* Netfilter */^M
#include <linux/netfilter_ipv4.h> /* Netfiletr for IPv4 */
#include <linux/skbuff.h> /* Socket Kernel Buffers */
#include <linux/tcp.h> /* TCP Header */
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <asm/uaccess.h>
Makefile
Code:
TARGET := blocker_ip
#WARN := -W -Wall -Wstrict-prototypes -Wmissing-prototypes
WARN := -W
INCLUDE := -isystem /lib/modules/`uname -r`/build/include
CFLAGS := -O2 -DMODULE -D__KERNEL__ ${WARN} ${INCLUDE}
CC := gcc
${TARGET}.o: ${TARGET}.c
.PHONY: clean
clean:
# rm -rf {TARGET}.o
Build errors:
Code:
gcc -O2 -DMODULE -D__KERNEL__ -W -isystem /lib/modules/`uname -r`/build/include -c -o blocker_ip.o blocker_ip.c
In file included from blocker_ip.c:5:
/usr/gnu/include/linux/ip.h:95: error: parse error before "__u8"
/usr/gnu/include/linux/ip.h:102: error: parse error before "tot_len"
/usr/gnu/include/linux/ip.h:103: error: parse error before "id"
/usr/gnu/include/linux/ip.h:104: error: parse error before "frag_off"
/usr/gnu/include/linux/ip.h:105: error: parse error before "ttl"
/usr/gnu/include/linux/ip.h:106: error: parse error before "protocol"
/usr/gnu/include/linux/ip.h:107: error: parse error before "check"
/usr/gnu/include/linux/ip.h:108: error: parse error before "saddr"
/usr/gnu/include/linux/ip.h:109: error: parse error before "daddr"
In file included from blocker_ip.c:10:
/usr/gnu/include/linux/netfilter_ipv4.h:53: error: `INT_MIN' undeclared here (not in a function)
/usr/gnu/include/linux/netfilter_ipv4.h:53: error: enumerator value for `NF_IP_PRI_FIRST' not integer constant
/usr/gnu/include/linux/netfilter_ipv4.h:59: error: `INT_MAX' undeclared here (not in a function)
/usr/gnu/include/linux/netfilter_ipv4.h:59: error: enumerator value for `NF_IP_PRI_LAST' not integer constant
In file included from /usr/gnu/include/linux/sched.h:13,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/linux/times.h:5: error: parse error before "clock_t"
/usr/gnu/include/linux/times.h:7: error: parse error before "tms_cutime"
/usr/gnu/include/linux/times.h:8: error: parse error before "tms_cstime"
In file included from /usr/gnu/include/linux/sched.h:14,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/linux/timex.h:147: error: field `time' has incomplete type
In file included from /usr/gnu/include/linux/bitops.h:69,
from /usr/gnu/include/asm/system.h:7,
from /usr/gnu/include/linux/sched.h:16,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/asm/bitops.h:327:2: warning: #warning This includefile is not available on all architectures.
/usr/gnu/include/asm/bitops.h:328:2: warning: #warning Using kernel headers in userspace: atomicity not guaranteed
In file included from /usr/gnu/include/linux/signal.h:4,
from /usr/gnu/include/linux/sched.h:25,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/asm/signal.h:107: error: parse error before "sigset_t"
/usr/gnu/include/asm/signal.h:110: error: parse error before '}' token
/usr/gnu/include/asm/signal.h:119: error: parse error before "size_t"
In file included from /usr/gnu/include/linux/signal.h:5,
from /usr/gnu/include/linux/sched.h:25,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/asm/siginfo.h:26: error: parse error before "pid_t"
/usr/gnu/include/asm/siginfo.h:38: error: parse error before "pid_t"
/usr/gnu/include/asm/siginfo.h:41: error: parse error before '}' token
/usr/gnu/include/asm/siginfo.h:45: error: parse error before "pid_t"
/usr/gnu/include/asm/siginfo.h:48: error: parse error before "_utime"
/usr/gnu/include/asm/siginfo.h:49: error: parse error before "_stime"
/usr/gnu/include/asm/siginfo.h:62: error: parse error before '}' token
/usr/gnu/include/asm/siginfo.h:63: error: parse error before '}' token
In file included from /usr/gnu/include/linux/sched.h:78,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/linux/time.h:10: error: parse error before "time_t"
/usr/gnu/include/linux/time.h:12: error: parse error before '}' token
/usr/gnu/include/linux/time.h:18: error: parse error before "time_t"
/usr/gnu/include/linux/time.h:44: error: field `it_interval' has incomplete type
/usr/gnu/include/linux/time.h:45: error: field `it_value' has incomplete type
/usr/gnu/include/linux/time.h:49: error: field `it_interval' has incomplete type
/usr/gnu/include/linux/time.h:50: error: field `it_value' has incomplete type
In file included from /usr/gnu/include/linux/sched.h:80,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/linux/resource.h:22: error: field `ru_utime' has incomplete type
/usr/gnu/include/linux/resource.h:23: error: field `ru_stime' has incomplete type
In file included from /usr/gnu/include/linux/sched.h:81,
from /usr/gnu/include/linux/skbuff.h:19,
from blocker_ip.c:11:
/usr/gnu/include/linux/timer.h:45: error: parse error before "spinlock_t"
/usr/gnu/include/linux/timer.h:53: error: parse error before '}' token
/usr/gnu/include/linux/timer.h:67: error: parse error before "tvec_base_t"
/usr/gnu/include/linux/timer.h:101: error: parse error before "tvec_bases"
/usr/gnu/include/linux/timer.h: In function `init_timer':
/usr/gnu/include/linux/timer.h:105: error: dereferencing pointer to incomplete type
/usr/gnu/include/linux/timer.h:105: error: dereferencing pointer to incomplete type
/usr/gnu/include/linux/timer.h:106: error: dereferencing pointer to incomplete type
/usr/gnu/include/linux/timer.h: In function `timer_pending':
/usr/gnu/include/linux/timer.h:121: error: dereferencing pointer to incomplete type
In file included from /usr/gnu/include/linux/highmem.h:5,
from /usr/gnu/include/linux/skbuff.h:26,
from blocker_ip.c:11:
/usr/gnu/include/asm/pgalloc.h:6:24: asm/fixmap.h: No such file or directory
In file included from /usr/gnu/include/linux/highmem.h:5,
from /usr/gnu/include/linux/skbuff.h:26,
from blocker_ip.c:11:
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:57: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `get_pgd_slow':
/usr/gnu/include/asm/pgalloc.h:59: error: `pgd_t' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:59: error: (Each undeclared identifier is reported only once
/usr/gnu/include/asm/pgalloc.h:59: error: for each function it appears in.)
/usr/gnu/include/asm/pgalloc.h:59: error: `pgd' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:59: error: parse error before ')' token
/usr/gnu/include/asm/pgalloc.h:62: error: `USER_PTRS_PER_PGD' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:63: error: `swapper_pg_dir' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:63: error: `PTRS_PER_PGD' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:70: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `get_pgd_fast':
/usr/gnu/include/asm/pgalloc.h:80: error: `pgd_t' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:80: error: parse error before ')' token
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:83: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `free_pgd_fast':
/usr/gnu/include/asm/pgalloc.h:85: error: `pgd' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:90: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `free_pgd_slow':
/usr/gnu/include/asm/pgalloc.h:99: error: `pgd' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:103: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `pte_alloc_one':
/usr/gnu/include/asm/pgalloc.h:105: error: `pte_t' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:105: error: `pte' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:109: error: parse error before ')' token
/usr/gnu/include/asm/pgalloc.h:113: error: `_SC_CLK_TCK' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:118: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `pte_alloc_one_fast':
/usr/gnu/include/asm/pgalloc.h:127: error: `pte_t' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h:127: error: parse error before ')' token
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:130: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `pte_free_fast':
/usr/gnu/include/asm/pgalloc.h:132: error: `pte' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: At top level:
/usr/gnu/include/asm/pgalloc.h:137: error: parse error before '*' token
/usr/gnu/include/asm/pgalloc.h: In function `pte_free_slow':
/usr/gnu/include/asm/pgalloc.h:139: error: `pte' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: In function `flush_tlb_mm':
/usr/gnu/include/asm/pgalloc.h:183: error: `current' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: In function `flush_tlb_page':
/usr/gnu/include/asm/pgalloc.h:190: error: dereferencing pointer to incomplete type
/usr/gnu/include/asm/pgalloc.h:190: error: `current' undeclared (first use in this function)
/usr/gnu/include/asm/pgalloc.h: In function `flush_tlb_range':
/usr/gnu/include/asm/pgalloc.h:197: error: `current' undeclared (first use in this function)
In file included from blocker_ip.c:11:
/usr/gnu/include/linux/skbuff.h: At top level:
/usr/gnu/include/linux/skbuff.h:100: error: parse error before "spinlock_t"
/usr/gnu/include/linux/skbuff.h:120: error: parse error before "atomic_t"
/usr/gnu/include/linux/skbuff.h:124: error: parse error before '}' token
/usr/gnu/include/linux/skbuff.h:133: error: field `stamp' has incomplete type
/usr/gnu/include/linux/skbuff.h:183: error: parse error before "atomic_t"
/usr/gnu/include/linux/skbuff.h:184: error: conflicting types for `protocol'
/usr/gnu/include/linux/ip.h:106: error: previous declaration of `protocol'
/usr/gnu/include/linux/skbuff.h:215: error: parse error before '}' token
In file included from /usr/gnu/include/linux/tcp.h:21,
from blocker_ip.c:12:
/usr/gnu/include/asm/byteorder.h:6:2: warning: #warning using private kernel header; include <endian.h> instead!
In file included from blocker_ip.c:12:
/usr/gnu/include/linux/tcp.h:105: error: braced-group within expression allowed only inside a function
/usr/gnu/include/linux/tcp.h:105: error: enumerator value for `TCP_FLAG_CWR' not integer constant
/usr/gnu/include/linux/tcp.h:106: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:107: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:108: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:109: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:110: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:111: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:112: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:113: error: parse error before "__u32"
/usr/gnu/include/linux/tcp.h:114: error: parse error before "__u32"
blocker_ip.c:14:27: linux/vmalloc.h: No such file or directory
blocker_ip.c:15:25: asm/uaccess.h: No such file or directory
blocker_ip.c: In function `main_hook':
blocker_ip.c:64: error: dereferencing pointer to incomplete type
blocker_ip.c:69: error: dereferencing pointer to incomplete type
blocker_ip.c:71: error: dereferencing pointer to incomplete type
blocker_ip.c:72: error: dereferencing pointer to incomplete type
blocker_ip.c:73: error: dereferencing pointer to incomplete type
blocker_ip.c:74: error: dereferencing pointer to incomplete type
blocker_ip.c:78: error: dereferencing pointer to incomplete type
blocker_ip.c:80: error: dereferencing pointer to incomplete type
blocker_ip.c:81: error: dereferencing pointer to incomplete type
blocker_ip.c:82: error: dereferencing pointer to incomplete type
blocker_ip.c:83: error: dereferencing pointer to incomplete type
blocker_ip.c:91: error: dereferencing pointer to incomplete type
blocker_ip.c:92: error: dereferencing pointer to incomplete type
blocker_ip.c:93: error: dereferencing pointer to incomplete type
blocker_ip.c:94: error: dereferencing pointer to incomplete type
blocker_ip.c:101: error: dereferencing pointer to incomplete type
blocker_ip.c:103: error: dereferencing pointer to incomplete type
blocker_ip.c:103: error: dereferencing pointer to incomplete type
blocker_ip.c: In function `init_module':
blocker_ip.c:327: error: `current' undeclared (first use in this function)
blocker_ip.c:335: error: incompatible types in assignment
blocker_ip.c:336: error: `KERNEL_DS' undeclared (first use in this function)
blocker_ip.c:342: error: `O_RDONLY' undeclared (first use in this function)
blocker_ip.c:342: warning: assignment makes pointer from integer without a cast
blocker_ip.c:349: error: dereferencing pointer to incomplete type
blocker_ip.c:349: error: dereferencing pointer to incomplete type
blocker_ip.c:352: error: dereferencing pointer to incomplete type
blocker_ip.c:356: error: dereferencing pointer to incomplete type
blocker_ip.c:356: error: dereferencing pointer to incomplete type
blocker_ip.c:371: error: dereferencing pointer to incomplete type
blocker_ip.c:372: error: dereferencing pointer to incomplete type
blocker_ip.c:372: error: dereferencing pointer to incomplete type
blocker_ip.c:430: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:431: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:432: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:433: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:435: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:436: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:437: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:438: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c: At top level:
blocker_ip.c:36: error: storage size of `netfilter_ops_in' isn't known
blocker_ip.c:37: error: storage size of `netfilter_ops_out' isn't known
make: *** [blocker_ip.o] Error 1
I can get rid of some of the errors by adding in:
Code:
#include <linux/init.h>
#include <limits.h>
And I've played around with some other stuff without much success.
|
|
|
02-16-2005, 11:53 AM
|
#2
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
what does this display?
ls -l /lib/modules/`uname -r`/build/include
looks like it's trying to pull the includes out of /usr/gnu/include instead of a kernel directory.
|
|
|
02-16-2005, 11:56 AM
|
#3
|
LQ Newbie
Registered: Feb 2005
Posts: 5
Original Poster
Rep:
|
Yeah, it is. That's on purpose. Forgot to mention that. I've got gcc installed on the Smoothwall box and the includes are located in /usr/gnu/include. Thanks for looking though 
|
|
|
02-16-2005, 12:17 PM
|
#4
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
yeah but trying to compile a module from different includes than the kernel source will not work
|
|
|
02-16-2005, 12:31 PM
|
#5
|
LQ Newbie
Registered: Feb 2005
Posts: 5
Original Poster
Rep:
|
Hm... I see your point... I'm checking it out now.
|
|
|
02-16-2005, 12:50 PM
|
#6
|
LQ Newbie
Registered: Feb 2005
Posts: 5
Original Poster
Rep:
|
Ok, so I took care of that I think. Only one problem left.
Code:
gcc -O2 -DMODULE -D__KERNEL__ -W -isystem /lib/modules/`uname -r`/build/include -c -o blocker_ip.o blocker_ip.c
blocker_ip.c: In function `init_module':
blocker_ip.c:430: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:431: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:432: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:433: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:435: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:436: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:437: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c:438: error: invalid use of undefined type `struct nf_hook_ops'
blocker_ip.c: At top level:
blocker_ip.c:36: error: storage size of `netfilter_ops_in' isn't known
blocker_ip.c:37: error: storage size of `netfilter_ops_out' isn't known
make: *** [blocker_ip.o] Error 1
I see some talk about this when I Google... But I haven't come across anything helpful yet.
|
|
|
02-16-2005, 01:00 PM
|
#7
|
Senior Member
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973
Rep:
|
just taking a guess, looks like the source forgot to include a header if nf_hook_ops is undefined
|
|
|
02-17-2005, 12:43 PM
|
#8
|
LQ Newbie
Registered: Feb 2005
Posts: 5
Original Poster
Rep:
|
nf_hook_ops is defined in the netfilter.h header. I still haven't been able to resolve this error. Anyone else have a suggestion?
|
|
|
03-08-2005, 06:04 PM
|
#9
|
LQ Newbie
Registered: Jun 2003
Posts: 16
Rep:
|
so, I'm running a Linux smoothwall 2.4.29 box pretty much unmodified. and I would LOOVE to get blocker_ip to run on it... BUT I believe I would have to compile it myself... but I was wondering if you already have compiled it with that kernel if there would be any way of me using it. I may be missunderstanding something, but anyway any help would be apprecited =)
|
|
|
03-05-2006, 01:52 PM
|
#10
|
Member
Registered: Mar 2004
Posts: 71
Rep:
|
Hey,
I had the same nf_hook_ops structure problem. I am writing my own kernel module, which compiled fine on Slackware 10.2 with the latest 2.6 kernel. However, im on Suse 10.0 and getting these undefined nf_hook_ops errors. If anyone figures this out, please let me know. The header files are right (included properly and contain all necessary content). Kernel module programming seems to have its issues from one distro to the next.
-GSD
|
|
|
All times are GMT -5. The time now is 11:54 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|