In general, how do I know what set of kernel config options are necessary to have some .ko file built?
For example, I need 'xt_conntrack.ko'. What resources are there that let me know whether or not enabling CONFIG_NETFILTER_XT_MATCH_CONNTRACK=m in my kernel config is necessary or even sufficient to result in my built .ko file? How do I find the full set of kconfig options required to yield a kernel module?
http://cateee.net/lkddb/web-lkddb/NETFILTER_XT_MATCH_CONNTRACK.html indicates it will build "xt_conntrack", but I am not seeing it when I =m it and all of its dependencies.
On the other side, there is no set of kconfig flags visible here (http://modules.libres.ch/browse/linux/v3.0/x86_64/xt_conntrack/)
How do I find the full set of kconfig options required to yield a kernel module?
In general, determining set of options for building a kernel module is complex process. Steps described below may guide in that process.
Find a Makefile which builds a kernel module. This file is located in the same directory, where .ko file is produced; this directory usually coincides with a directory of module's source files. This Makefile contains a line which builds a module:
obj-${CONFIG_...} := <module_name>.o
Example:
A module xt_conntrack.ko is built by the line
obj-$(CONFIG_NETFILTER_XT_MATCH_CONNTRACK) += xt_conntrack.o
in file net/netfilter/Makefile.
There are several ways how configuration options may affect on building a module.
The option is used directly in the line, produced the module:
obj-${CONFIG_X} := <module_name>.o
means that option CONFIG_X should be set for the module to be built.
Given Makefile is conditionally included into the upper one:
obj-${CONFIG_Y} := <dir>/
The line produced the module is guarded by "if" clause:
ifeq ($(CONFIG_F),y)
obj-m := <module_name>.o
endif
Alternatively, guard may protect inclusion of the Makefile from the upper one:
ifeq ($(CONFIG_F),y)
obj-m := <dir>/
endif
Example:
A module xt_conntrack depends by rule 1 from CONFIG_NETFILTER_XT_MATCH_CONNTRACK option.
Also it depends by rule 2 from CONFIG_NETFILTER option, because outer net/Makefile includes net/netfilter/Makefile via
obj-$(CONFIG_NETFILTER) += netfilter/
Note: This is the most complicated step, mainly because availability of the option is expressed in terms of other options. It is recommended to use ready-made tools for that. E.g., make menuconfig tool may search options and show their definition.
Every configuration option is defined in one of Kconfig files.
Definition determines:
availability of the option (when the option can be used),
possible values of the option (y/n - boolean, y/m/n - tristate, etc.),
whether the option can be set by a user.
Example:
Option NETFILTER_XT_MATCH_CONNTRACK is defined in net/netfilter/Kconfig as
config NETFILTER_XT_MATCH_CONNTRACK
tristate '"conntrack" connection tracking match support'
depends on NF_CONNTRACK
default m if NETFILTER_ADVANCED=n
help
This is a general conntrack match module, a superset of the state match.
It allows matching on additional conntrack information, which is
useful in complex configurations, such as NAT gateways with multiple
internet links or tunnels.
To compile it as a module, choose M here. If unsure, say N.
That is, the option is available (can be set) only when NF_CONNTRACK option is set.
Documentation for format of Kconfig files is located at Documentation/kbuild/kconfig-language.txt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With