Skip to contentSkip to conversation

pom without rebuilding kernel?

DISCUSSION Axel Thimm 3 participants 5 messages Oct 10, 2003 – Oct 21, 2003 netfilter

lore
Share & tools
lore

Axel Thimm

author
#0 lore raw

I am thinking how nice it would be (or already is?) to build only the required kernel modules for a given kernel, without having to rebuild the kernel itself, like a lot of kernel drivers do (e.g. bttv, lirc, lm_sensors etc).

Imagine building only the kernel modules, putting them in a folder like

/lib/modules/uname -r/netfilter

adding the following to the top of /etc/modules.conf:

path[toplevel]=/lib/modules/uname -r/netfilter
path[toplevel]=/lib/modules/uname -r

and being happy ever after. :)

E.g. are there changes in pom patches to the core of the kernel sources, or can pom modules be compiled out of the kernel tree?

I suppose that for a certain kernel version and above no hooks/glue to the core non-modular networking components are required and therefore such a plan could be followed. But I found no hint in any docu to netfilter, not even a similar request.

If there is way to do it, or a netfilter developer thinks it is worth the trouble, I'd rpm-package some modules for RH kernels. :)

Thanks!

Signature · 1 line
[email protected]
#1 lore raw
Quoted 4 lines · Axel Thimm

I am thinking how nice it would be (or already is?) to build only the required kernel modules for a given kernel, without having to rebuild the kernel itself, like a lot of kernel drivers do (e.g. bttv, lirc, lm_sensors etc).

yes, you can do that in 99% of all cases. Just use patch-o-matic like
normal and then do a

cd your_kernel_dir
make MODULE_SUBDIRS=net/ipv4/netfilter modules

then manually copy the modules into your module directory, or better test them via insmod first.

Quoted 2 lines

E.g. are there changes in pom patches to the core of the kernel sources, or can pom modules be compiled out of the kernel tree?

in very rare cases the core network stack needs to be modified. all other patches don't really require to rebuild the kernel. But make sure that you always unload _ALL_ netfilter modules (conntrack, etc) before you load any of your newly-compiled modules.

I suppose your kernel will crash very soon if you keep your old ip_conntrack.o while loading a new ip_conntrack_pptp.o, as an example.

Quoted 2 lines

If there is way to do it, or a netfilter developer thinks it is worth the trouble, I'd rpm-package some modules for RH kernels. :)

no, I am strictly opposing binary distribution. At least not as an official part of the project. Feel free to provide them at a different place, but I just think it's too dangerous (and not really necessarry).

patch-o-matic is for potentially unstable or not generally useful code. If people want to use some of it, they should understand enough and be able to compile them on their own.

Bugfixes shouldn't be in patch-o-matic anyway, we've had a long discussion about that at the netfilter workshop. This will change when the new (2.6 compatible) patch-o-matic will be put in place. I'm working on that now, doing some perl coding for the first time in the last couple of years ;)

Quoted 3 lines

Thanks!

Signature · 1 line
[email protected]
Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#2 lore raw
In reply to Axel Thimm
Quoted 4 lines · Axel Thimm

I am thinking how nice it would be (or already is?) to build only the required kernel modules for a given kernel, without having to rebuild the kernel itself, like a lot of kernel drivers do (e.g. bttv, lirc, lm_sensors etc).

Yes, and that you can do.. just patch the kernel sources and run "make modules", or extract the sources and compile the modules manually.

Quoted 2 lines

E.g. are there changes in pom patches to the core of the kernel sources, or can pom modules be compiled out of the kernel tree?

If you extract the module sources from the pom patches you can in most cases compile the modules out of the kernel tree if you like, assuming you have the correct kernel headers in place for the exact kernel binary you are using (this is a rather tricky part when trying to compile modules to a distro binary kernel)

There is not really any difference between compiling netfilter kernel modules and other kinds of kernel modules, only the packaging is slightly different (patch files to the kernel tree rather than separate source files, but the patch command can extract the files for you)

Regards
Henrik

author
#3 lore raw
Quoted 6 lines · Harald Welte
Quoted 2 lines · Axel Thimm

E.g. are there changes in pom patches to the core of the kernel sources, or can pom modules be compiled out of the kernel tree?

in very rare cases the core network stack needs to be modified. all other patches don't really require to rebuild the kernel.

How can I identify those patches? Most of the patching happens in net/<protocol>/netfilter and include/linux/netfilter_<protocol>. Are those patches safe for building out of the tree (w/o full kernel rebuilds)?

Quoted 7 lines
Quoted 2 lines

If there is way to do it, or a netfilter developer thinks it is worth the trouble, I'd rpm-package some modules for RH kernels. :)

no, I am strictly opposing binary distribution. At least not as an official part of the project. Feel free to provide them at a different place, but I just think it's too dangerous (and not really necessarry).

I am already maintaining some kernel module rpms as well as some non-modularizable patches to RH kernel on atrpms. I am having requests to add some netfilter modules (notably the TARPIT and H323 patches), and I was considering of packaging (parts of) pom as drop in kernel module replacements or enchancements.

Quoted 9 lines

patch-o-matic is for potentially unstable or not generally useful code. If people want to use some of it, they should understand enough and be able to compile them on their own.

Bugfixes shouldn't be in patch-o-matic anyway, we've had a long discussion about that at the netfilter workshop. This will change when the new (2.6 compatible) patch-o-matic will be put in place. I'm working on that now, doing some perl coding for the first time in the last couple of years ;)

Quoted 5 lines · Henrik Nordstrom

If you extract the module sources from the pom patches you can in most cases compile the modules out of the kernel tree if you like, assuming you have the correct kernel headers in place for the exact kernel binary you are using (this is a rather tricky part when trying to compile modules to a distro binary kernel)

Here is what I did to get a working H232 kernel module, is this sane (seems to work for these modules at least)? Thanks.

# Create copies of subparts from the unchanged kernel tree to ./linux
for x in Makefile Documentation/Configure.help include/linux/netfilter_ipv4 include/linux/netfilter_ipv6 net/ipv4/netfilter net/ipv6/netfilter; do
mkdir -p linux/dirname $x
cp -a %{kernelsrcdir}/$x linux/dirname $x
done

# Patch the copy
KERNEL_DIR=linux ./runme --batch extra/h323-conntrack-nat.patch

cd linux
%patch0 -p1 -b .lockhelp
cd ..

make -C %{kernelsrcdir} SUBDIRS=pwd/linux/net/ipv4/netfilter dep
make -C %{kernelsrcdir} SUBDIRS=pwd/linux/net/ipv4/netfilter modules CONFIG_IP_NF_H323=m CONFIG_IP_NF_NAT_H323=m "CPPFLAGS=-D__KERNEL__ -Ipwd/linux/include -I\$(HPATH)" make -C %{kernelsrcdir} SUBDIRS=pwd/linux/net/ipv4/netfilter INSTALL_MOD_PATH=$RPM_BUILD_ROOT MOD_DESTDIR=../netfilter/ipv4/netfilter modules_install CONFIG_IP_NF_H323=m CONFIG_IP_NF_NAT_H323=m

Unfortunately the make dep step is writing to the orginal kernel tree, but i couldn't find a better solution.

Signature · 1 line
[email protected]
#4 lore raw
Quoted 4 lines · Axel Thimm

How can I identify those patches? Most of the patching happens in net/<protocol>/netfilter and include/linux/netfilter_<protocol>. Are those patches safe for building out of the tree (w/o full kernel rebuilds)?

Any patch which modifies only files within the netfilter directories should be safe building netfilter out of the kernel tree.

On patches which only adds files it is safe to just build that new added modules out of the tree.

Patches which modifies files within the netfilter directories requires that all netfilter modules which depends on the modified files are rebuilt. In case of modified C files this is trivial, but if header files are modified a more careful analysis is required to determine which netfilter modules are impacted by this header file modification.

Quoted 5 lines

I am already maintaining some kernel module rpms as well as some non-modularizable patches to RH kernel on atrpms. I am having requests to add some netfilter modules (notably the TARPIT and H323 patches), and I was considering of packaging (parts of) pom as drop in kernel module replacements or enchancements.

On patches which add nat or conntrack helpers you need to verify that the size of the conntrack structure is not modified. If it is then basically every single netfilter module need to be rebuild. If the size of the structures remains the same then it is safe to build the new helpers without rebuilding the rest.

Quoted 8 lines

Here is what I did to get a working H232 kernel module, is this sane (seems to work for these modules at least)? Thanks.

# Create copies of subparts from the unchanged kernel tree to ./linux
for x in Makefile Documentation/Configure.help include/linux/netfilter_ipv4 include/linux/netfilter_ipv6 net/ipv4/netfilter net/ipv6/netfilter; do
mkdir -p linux/dirname $x
cp -a %{kernelsrcdir}/$x linux/dirname $x
done

You could just

rm -rf linux
cp -rpl %{kernelsrcdir} linux

this quickly makes a linked copy of the tree. patch (and p-o-m) works fine with linked source trees.

Quoted 10 lines

# Patch the copy
KERNEL_DIR=linux ./runme --batch extra/h323-conntrack-nat.patch

cd linux
%patch0 -p1 -b .lockhelp
cd ..

make -C %{kernelsrcdir} SUBDIRS=pwd/linux/net/ipv4/netfilter dep
make -C %{kernelsrcdir} SUBDIRS=pwd/linux/net/ipv4/netfilter modules CONFIG_IP_NF_H323=m CONFIG_IP_NF_NAT_H323=m "CPPFLAGS=-D__KERNEL__ -Ipwd/linux/include -I\$(HPATH)" make -C %{kernelsrcdir} SUBDIRS=pwd/linux/net/ipv4/netfilter INSTALL_MOD_PATH=$RPM_BUILD_ROOT MOD_DESTDIR=../netfilter/ipv4/netfilter modules_install CONFIG_IP_NF_H323=m CONFIG_IP_NF_NAT_H323=m

It should be noted that this last step is only safe for installing into a secondary directory. Do not attempt this without specifying a secondary MOD_DESTDIR.. (it will delete all other modules..)

Quoted 2 lines

Unfortunately the make dep step is writing to the orginal kernel tree, but i couldn't find a better solution.

for most (if not all) netfilter patches you do not really need to run "make dep".

Regards
Henrik