<?xml version="1.0" encoding="utf-8"?><!DOCTYPE article  PUBLIC '-//OASIS//DTD DocBook XML V4.4//EN'  'http://www.docbook.org/xml/4.4/docbookx.dtd'><article><articleinfo><title>AddNetfilterExtensionToOpenWRT</title><revhistory><revision><revnumber>2</revnumber><date>2009-10-21 11:44:22</date><authorinitials>ClauzClauz</authorinitials></revision><revision><revnumber>1</revnumber><date>2009-10-21 11:38:38</date><authorinitials>ClauzClauz</authorinitials></revision></revhistory></articleinfo><section><title>How to Add a Netfilter Extension to the firmware</title><para>Some Netfilter Extension are not in the OpenWRT toolchain. </para><para>In this example we explain how to add the hashlimit Netfilter Extension to the OpenWRT firmware we are building. </para><para>To add an extension first edit the file include/netfilter.mk from your OpenWRT svn checkout </para><para>browse the file to the section  <code>#extra</code> </para><para>Here each line adds a Netfilter extension when the kmod-netfilter-extra package is selected </para><para>To add the hashlimit kernel module we add this line: </para><screen><![CDATA[$(eval $(call nf_add,IPT_EXTRA,CONFIG_NETFILTER_XT_MATCH_HASHLIMIT, $(P_XT)xt_hashlimit))]]></screen><para>Where CONFIG_NETFILTER_XT_MATCH_HASHLIMIT is the symbol of the kernel module we are adding. </para><para>To find this name for another module get a recent Vanilla Kernel, browse the ncurses menus that appear after &quot;make menuconfig&quot; and when the module you are looking for is highlighetd select the &quot;help&quot; button. You will have a screen saying something like: Symbol: NETFILTER_XT_MATCH_HASHLIMIT </para><para>To find the right string where we have put xt_hashlimit we need to know the filename of the object created when we compile the module in the kernel. I did like this: I compiled the normal Kernel and then I went into &quot;net/netfilter&quot; to see the file name. In my case it was xt_hashlimit.o </para><para>So after all we just have to add 1 line to the file: include/netfilter.mk </para><para>Let's check if everything is ok: </para><screen><![CDATA[make menuconfig]]></screen><para>select &quot;iptables-mod-extra&quot; from &quot;base-system -&gt; iptables&quot; select &quot;kmod-ipt-extra&quot; from &quot;kernel-modules -&gt; Netfilter Extensions&quot; </para><para>compile now to see if there are no errors </para><screen><![CDATA[make package/kernel-clean V=99
make package/kernel-compile V=99
make package/iptables-clean V=99
make package/iptables-compile V=99]]></screen><para>if there are no errors you can compile the firmware with the &quot;make&quot; command </para></section></article>