linux-xiaomi-chiron/include/linux/netfilter
Pablo Neira Ayuso 0269ea4937 netfilter: xtables: add cluster match
This patch adds the iptables cluster match. This match can be used
to deploy gateway and back-end load-sharing clusters. The cluster
can be composed of 32 nodes maximum (although I have only tested
this with two nodes, so I cannot tell what is the real scalability
limit of this solution in terms of cluster nodes).

Assuming that all the nodes see all packets (see below for an
example on how to do that if your switch does not allow this), the
cluster match decides if this node has to handle a packet given:

	(jhash(source IP) % total_nodes) & node_mask

For related connections, the master conntrack is used. The following
is an example of its use to deploy a gateway cluster composed of two
nodes (where this is the node 1):

iptables -I PREROUTING -t mangle -i eth1 -m cluster \
	--cluster-total-nodes 2 --cluster-local-node 1 \
	--cluster-proc-name eth1 -j MARK --set-mark 0xffff
iptables -A PREROUTING -t mangle -i eth1 \
	-m mark ! --mark 0xffff -j DROP
iptables -A PREROUTING -t mangle -i eth2 -m cluster \
	--cluster-total-nodes 2 --cluster-local-node 1 \
	--cluster-proc-name eth2 -j MARK --set-mark 0xffff
iptables -A PREROUTING -t mangle -i eth2 \
	-m mark ! --mark 0xffff -j DROP

And the following commands to make all nodes see the same packets:

ip maddr add 01:00:5e:00:01:01 dev eth1
ip maddr add 01:00:5e:00:01:02 dev eth2
arptables -I OUTPUT -o eth1 --h-length 6 \
	-j mangle --mangle-mac-s 01:00:5e:00:01:01
arptables -I INPUT -i eth1 --h-length 6 \
	--destination-mac 01:00:5e:00:01:01 \
	-j mangle --mangle-mac-d 00:zz:yy:xx:5a:27
arptables -I OUTPUT -o eth2 --h-length 6 \
	-j mangle --mangle-mac-s 01:00:5e:00:01:02
arptables -I INPUT -i eth2 --h-length 6 \
	--destination-mac 01:00:5e:00:01:02 \
	-j mangle --mangle-mac-d 00:zz:yy:xx:5a:27

In the case of TCP connections, pickup facility has to be disabled
to avoid marking TCP ACK packets coming in the reply direction as
valid.

echo 0 > /proc/sys/net/netfilter/nf_conntrack_tcp_loose

BTW, some final notes:

 * This match mangles the skbuff pkt_type in case that it detects
PACKET_MULTICAST for a non-multicast address. This may be done in
a PKTTYPE target for this sole purpose.
 * This match supersedes the CLUSTERIP target.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
2009-03-16 17:10:36 +01:00
..
Kbuild netfilter: xtables: add cluster match 2009-03-16 17:10:36 +01:00
nf_conntrack_amanda.h [NETFILTER]: Replace sk_buff ** with sk_buff * 2007-10-15 12:26:29 -07:00
nf_conntrack_common.h netfilter: accounting rework: ct_extend + 64bit counters (v4) 2008-07-21 10:10:58 -07:00
nf_conntrack_dccp.h [NETFILTER]: nf_conntrack: add DCCP protocol support 2008-04-14 11:15:49 +02:00
nf_conntrack_ftp.h [NETFILTER]: Replace sk_buff ** with sk_buff * 2007-10-15 12:26:29 -07:00
nf_conntrack_h323.h [NETFILTER]: Introduce nf_inet_address 2008-01-28 14:59:07 -08:00
nf_conntrack_h323_asn1.h
nf_conntrack_h323_types.h
nf_conntrack_irc.h [NETFILTER]: Replace sk_buff ** with sk_buff * 2007-10-15 12:26:29 -07:00
nf_conntrack_pptp.h [NETFILTER]: nf_{conntrack,nat}_pptp: annotate PPtP helper with const 2008-01-31 19:28:09 -08:00
nf_conntrack_proto_gre.h netfilter: netns nf_conntrack: GRE conntracking in netns 2008-10-08 11:35:10 +02:00
nf_conntrack_sane.h
nf_conntrack_sctp.h [NETFILTER]: nf_conntrack_sctp: remove unused ttag field from conntrack data 2008-01-28 15:02:38 -08:00
nf_conntrack_sip.h netfilter: nf_conntrack_sip: restrict RTP expect flushing on error to last request 2008-05-08 01:15:21 -07:00
nf_conntrack_tcp.h netfilter: nf_conntrack_tcp: decrease timeouts while data in unacknowledged 2008-07-31 00:38:01 -07:00
nf_conntrack_tftp.h [NETFILTER]: Replace sk_buff ** with sk_buff * 2007-10-15 12:26:29 -07:00
nf_conntrack_tuple_common.h
nfnetlink.h netfilter: ctnetlink: remove bogus module dependency between ctnetlink and nf_nat 2008-10-14 11:58:31 -07:00
nfnetlink_compat.h [NETFILTER]: nfnetlink: fix ifdef in nfnetlink_compat.h 2008-03-10 16:41:06 -07:00
nfnetlink_conntrack.h netfilter: ctnetlink: fix missing CTA_NAT_SEQ_UNSPEC 2008-12-16 01:19:41 -08:00
nfnetlink_log.h netfilter: nfnetlink_log: send complete hardware header 2008-07-21 10:11:00 -07:00
nfnetlink_queue.h
x_tables.h netfilter: iptables: lock free counters 2009-02-20 10:35:32 +01:00
xt_CLASSIFY.h
xt_cluster.h netfilter: xtables: add cluster match 2009-03-16 17:10:36 +01:00
xt_comment.h
xt_connbytes.h
xt_connlimit.h [NETFILTER]: Annotate start of kernel fields in NF headers 2008-01-28 15:02:19 -08:00
xt_CONNMARK.h [NETFILTER]: xt_CONNMARK target, revision 1 2008-01-28 15:02:20 -08:00
xt_connmark.h [NETFILTER]: xt_connmark match, revision 1 2008-01-28 15:02:21 -08:00
xt_CONNSECMARK.h
xt_conntrack.h headers_check fix: netfilter/xt_conntrack.h 2009-01-30 20:00:47 +05:30
xt_dccp.h
xt_DSCP.h [NETFILTER]: IPv6 capable xt_TOS v1 target 2008-01-28 14:56:00 -08:00
xt_dscp.h [NETFILTER]: IPv6 capable xt_tos v1 match 2008-01-28 14:56:00 -08:00
xt_esp.h
xt_hashlimit.h [NETFILTER]: xt_hashlimit: remove unneeded struct member 2008-02-19 17:19:44 -08:00
xt_helper.h
xt_iprange.h [NETFILTER]: Rename ipt_iprange to xt_iprange 2008-01-28 15:02:27 -08:00
xt_LED.h netfilter: x_tables: add LED trigger target 2009-02-20 10:55:14 +01:00
xt_length.h
xt_limit.h netfilter: xtables: avoid pointer to self 2009-03-16 15:35:29 +01:00
xt_mac.h
xt_mark.h [NETFILTER]: xt_mark match, revision 1 2008-01-28 15:02:23 -08:00
xt_MARK.h [NETFILTER]: xt_MARK target, revision 2 2008-01-28 15:02:21 -08:00
xt_multiport.h
xt_NFLOG.h
xt_NFQUEUE.h
xt_owner.h [NETFILTER]: xt_owner: allow matching UID/GID ranges 2008-01-31 19:27:43 -08:00
xt_physdev.h
xt_pkttype.h
xt_policy.h [NETFILTER]: xt_policy: use the new union nf_inet_addr 2008-01-28 15:02:25 -08:00
xt_quota.h netfilter: xtables: avoid pointer to self 2009-03-16 15:35:29 +01:00
xt_RATEEST.h [NETFILTER]: Annotate start of kernel fields in NF headers 2008-01-28 15:02:19 -08:00
xt_rateest.h [NETFILTER]: Annotate start of kernel fields in NF headers 2008-01-28 15:02:19 -08:00
xt_realm.h
xt_recent.h netfilter: rename ipt_recent to xt_recent 2008-10-08 11:35:00 +02:00
xt_sctp.h [NETFILTER]: xt_sctp: simplify xt_sctp.h 2008-04-14 09:56:04 +02:00
xt_SECMARK.h
xt_state.h
xt_statistic.h netfilter: xtables: avoid pointer to self 2009-03-16 15:35:29 +01:00
xt_string.h netfilter: fix string extension for case insensitive pattern matching 2008-07-08 02:38:56 -07:00
xt_TCPMSS.h
xt_tcpmss.h
xt_TCPOPTSTRIP.h [NETFILTER]: x_tables: add TCPOPTSTRIP target 2008-01-28 14:55:51 -08:00
xt_tcpudp.h
xt_time.h [NETFILTER]: x_tables: add xt_time match 2007-10-10 16:53:40 -07:00
xt_TPROXY.h netfilter: iptables TPROXY target 2008-10-08 11:35:12 +02:00
xt_u32.h