netfilter kernel modules question
I have two netfilter kernel modules (xt_RQS.c, xt_RQD.c, both include a header file with a data structure in it).
Does both kernel modules use the same datastructures or do they use seperate ones (in normal C programming I know that but I'm not sure about the kernel scopes).
If I want to use one datastructure how can I do that (export? - concurrency issues left aside)?
Greetings and thanks
Quoted 6 lines · Tobias Koeck
I have two netfilter kernel modules (
xt_RQS.c,xt_RQD.c, both include a header file with a data structure in it).Does both kernel modules use the same datastructures or do they use seperate ones (in normal C programming I know that but I'm not sure about the kernel scopes).
You decide whether they do. This does not change just because you are in kernel space.
Jan
Quoted 11 lines · Jan Engelhardt
Quoted 6 lines · Tobias Koeck
I have two netfilter kernel modules (
xt_RQS.c,xt_RQD.c, both include a header file with a data structure in it).Does both kernel modules use the same datastructures or do they use seperate ones (in normal C programming I know that but I'm not sure about the kernel scopes).
You decide whether they do. This does not change just because you are in kernel space.
Can you please give a short example how to to it?
Let's say you've got one data structure (int a) in the header file. How can you access it in both c-files? Do you have to export it?
Is there a deeper information how the kernel scope is structured?
Quoted 8 lines · Tobias Koeck
Quoted 8 lines
Quoted 7 lines
I have two netfilter kernel modules (
xt_RQS.c,xt_RQD.c, both include a header
file with a data structure in it).Does both kernel modules use the same datastructures or do they use seperate ones (in normal C programming I know that but I'm not sure about the kernel scopes).
Quoted 7 lines
Quoted 2 lines
You decide whether they do. This does not change just because you are in kernel space.
Can you please give a short example how to to it?
Let's say you've got one data structure (int a) in the header file. How can you access it in both c-files? Do you have to export it?
You can argue what a data structure is or what it is not; a header file should not include any definitions, only declarations. (And perhaps static-inlines, but that's probably too expert for you at this stage.) Various C-related forums or IRC channels can enlighten you towards the reasoning for that.
Quoted 6 lines
You can argue what a data structure is or what it is not; a header file should not include any definitions, only declarations. (And perhaps static-inlines, but that's probably too expert for you at this stage.) Various C-related forums or IRC channels can enlighten you towards the reasoning for that.
'int a' is declaration (only used in a function it's a definition).
Does that mean if I define a (nonstatic) variable in a kernel module and it's accessible in the whole kernel?
Don't worry - last kernel newbie question from myself ;=).
Greetings
tk
Quoted 8 lines · Tobias Koeck
Quoted 6 lines
You can argue what a data structure is or what it is not; a header file should not include any definitions, only declarations. (And perhaps static-inlines, but that's probably too expert for you at this stage.) Various C-related forums or IRC channels can enlighten you towards the reasoning for that.
'int a' is declaration (only used in a function it's a definition).
"int a" is always a definition. Inside a function it makes for an automatic variable, and outside a function it makes for one with static linkage.