<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.nftables.org/wiki-nftables/index.php?action=history&amp;feed=atom&amp;title=Queueing_to_userspace</id>
	<title>Queueing to userspace - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.nftables.org/wiki-nftables/index.php?action=history&amp;feed=atom&amp;title=Queueing_to_userspace"/>
	<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Queueing_to_userspace&amp;action=history"/>
	<updated>2026-05-15T08:37:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>http://wiki.nftables.org/wiki-nftables/index.php?title=Queueing_to_userspace&amp;diff=39&amp;oldid=prev</id>
		<title>Pablo: Created page with &quot;= Basic operation =  &#039;&#039;&#039;Important note&#039;&#039;&#039;: You require a Linux kernel 3.14 to enqueue packets to userspace using nftables.  Like in &#039;&#039;iptables&#039;&#039;, you can use the nfqueue infra...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.nftables.org/wiki-nftables/index.php?title=Queueing_to_userspace&amp;diff=39&amp;oldid=prev"/>
		<updated>2016-07-13T17:57:43Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Basic operation =  &amp;#039;&amp;#039;&amp;#039;Important note&amp;#039;&amp;#039;&amp;#039;: You require a Linux kernel 3.14 to enqueue packets to userspace using nftables.  Like in &amp;#039;&amp;#039;iptables&amp;#039;&amp;#039;, you can use the nfqueue infra...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Basic operation =&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Important note&amp;#039;&amp;#039;&amp;#039;: You require a Linux kernel 3.14 to enqueue packets to userspace using nftables.&lt;br /&gt;
&lt;br /&gt;
Like in &amp;#039;&amp;#039;iptables&amp;#039;&amp;#039;, you can use the nfqueue infrastructure to enqueue packet to your userspace application that uses the [http://www.netfilter.org/projects/libnetfilter_queue/ libnetfilter_queue] library.&lt;br /&gt;
&lt;br /&gt;
You can just test this with the example application:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
libnetfilter_queue/utils% ./nfqnl_test&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, you have to add the rule to enqueue packets to userspace. If no queue is specified, the packet are sent to the queue number 0:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add filter input counter queue&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you should start seeing packet when generating some traffic:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
pkt received&lt;br /&gt;
hw_protocol=0x0800 hook=1 id=28 hw_src_addr=00:80:48:52:ff:8a indev=3 uid=1000 gid=1000 payload_len=110 &lt;br /&gt;
entering callback&lt;br /&gt;
pkt received&lt;br /&gt;
hw_protocol=0x0800 hook=1 id=29 hw_src_addr=00:80:48:52:ff:8a indev=3 uid=1000 gid=1000 payload_len=98 &lt;br /&gt;
entering callback&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are up to 65535. You can select a different queue with the following command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add filter input counter queue num 3&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, you have to launch the test application including the argument that indicates the queue number to listen for packets:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
libnetfilter_queue/utils% ./nfqnl_test 3&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Important note&amp;#039;&amp;#039;&amp;#039;: If there is no userspace application listening to that queue, then all packets will be dropped.&lt;br /&gt;
&lt;br /&gt;
= A bit more advanced configuration =&lt;br /&gt;
&lt;br /&gt;
You can also enable the &amp;#039;&amp;#039;bypass&amp;#039;&amp;#039; option which will skip the enqueue of the packet to userspace if no application is listening to the queue. The rule will behave as an &amp;#039;&amp;#039;accept&amp;#039;&amp;#039; rule if there is no application waiting for packet.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add filter input counter queue num 0 bypass&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also load balance traffic to several queues:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add filter input counter queue num 0-3&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Thus, the queue number from 0 to 3 will be used for this. You can run four instances of &amp;#039;&amp;#039;nfqnl_test&amp;#039;&amp;#039; to test this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
libnetfilter_queue/utils% ./nfqnl_test 0 &amp;amp;&lt;br /&gt;
libnetfilter_queue/utils% ./nfqnl_test 1 &amp;amp;&lt;br /&gt;
libnetfilter_queue/utils% ./nfqnl_test 2 &amp;amp;&lt;br /&gt;
libnetfilter_queue/utils% ./nfqnl_test 3 &amp;amp;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When doing load balancing, you can optionally use the &amp;#039;&amp;#039;fanout&amp;#039;&amp;#039; option to use the CPU ID as an index to map packets to the queues. The idea is that you can improve performance if there&amp;#039;s a queue/userspace application per CPU:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add filter input counter queue num 0-3 fanout&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course, the options can be combined, so you can for example use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
% nft add filter input counter queue num 0-3 fanout,bypass&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pablo</name></author>
	</entry>
</feed>