mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
a3f3ab4c9c
This patch adds support for the recent ipset iptables extension to libvirt's nwfilter subsystem. Ipset allows to maintain 'sets' of IP addresses, ports and other packet parameters and allows for faster lookup (in the order of O(1) vs. O(n)) and rule evaluation to achieve higher throughput than what can be achieved with individual iptables rules. On the command line iptables supports ipset using iptables ... -m set --match-set <ipset name> <flags> -j ... where 'ipset name' is the name of a previously created ipset and flags is a comma-separated list of up to 6 flags. Flags use 'src' and 'dst' for selecting IP addresses, ports etc. from the source or destination part of a packet. So a concrete example may look like this: iptables -A INPUT -m set --match-set test src,src -j ACCEPT Since ipset management is quite complex, the idea was to leave ipset management outside of libvirt but still allow users to reference an ipset. The user would have to make sure the ipset is available once the VM is started so that the iptables rule(s) referencing the ipset can be created. Using XML to describe an ipset in an nwfilter rule would then look as follows: <rule action='accept' direction='in'> <all ipset='test' ipsetflags='src,src'/> </rule> The two parameters on the command line are also the two distinct XML attributes 'ipset' and 'ipsetflags'. FYI: Here is the man page for ipset: https://ipset.netfilter.org/ipset.man.html Regards, Stefan
25 lines
979 B
XML
25 lines
979 B
XML
<filter name='testcase' chain='root'>
|
|
<uuid>5c6d49af-b071-6127-b4ec-6f8ed4b55335</uuid>
|
|
<rule action='accept' direction='out' priority='500'>
|
|
<all ipset='test' ipsetflags='src,dst'/>
|
|
</rule>
|
|
<rule action='accept' direction='in' priority='500'>
|
|
<all state='NONE' ipset='test' ipsetflags='src,dst' comment='in+NONE'/>
|
|
</rule>
|
|
<rule action='accept' direction='out' priority='500'>
|
|
<all state='NONE' ipset='test' ipsetflags='src,dst' comment='out+NONE'/>
|
|
</rule>
|
|
<rule action='accept' direction='in' priority='500'>
|
|
<all ipset='test' ipsetflags='src,dst,src'/>
|
|
</rule>
|
|
<rule action='accept' direction='in' priority='500'>
|
|
<all ipset='test:_.-+' ipsetflags='src,dst,src'/>
|
|
</rule>
|
|
<rule action='accept' direction='in' priority='500'>
|
|
<all ipset='$IPSETNAME' ipsetflags='src,dst'/>
|
|
</rule>
|
|
<rule action='accept' direction='inout' priority='500'>
|
|
<all ipset='$IPSETNAME' ipsetflags='src,dst' comment='inout'/>
|
|
</rule>
|
|
</filter>
|