netfilter: arptables: add mcmangle target
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH 1/3 netfilter: arptables: add mcmangle target
This patch adds the mcmangle target for arptables which allows altering the source hardware address in ARP with a multicast hardware address. This target can be used to make a switch flood packets to the ports that use the same MAC multicast address. This is useful to deploy load-sharing clusters in environments in which the switch does not provide a way to flood packets to several ports.
Since all the nodes receives the same packets, each decides if it handles the packet based on hashing approach (See the `cluster' iptables match that comes with this patchset).
Theoretically, the use of the reserved VRRP hardware address should be fine for this, however, switches generally treat this hardware address space as normal unicast hardware address. Thus, in practise, it is not possible to have two nodes with the same VRRP hardware address.
Please, note that this target violates RFC 1812 (section 3.3.2) since an ethernet device must not use a multicast link address.
An example of the use of this target:
arptables -I OUTPUT -o eth0 -j mcmangle --h-length 6 \ --mc-mangle-mac 01:00:5e:00:01:01 --mc-mangle-dev eth0 arptables -I INPUT -i eth0 --h-length 6 --destination-mac \ 01:00:5e:00:01:01 -j mangle --mangle-mac-d 00:zz:yy:xx:5a:27
Where 00:zz:yy:xx:5a:27 is the original hardware address of this node. Note that the mcmangle target registers an entry in the multicast list that is required to get this working:
$ cat /proc/net/dev_mcast | grep eth0 | head -1 2 eth0 1 0 01005e000101
You need the PKTTYPE iptables target (included in this patchset) to set skb->type to PACKET_HOST. Otherwise, you would be only able to ICMP ping nodes in the network ;).
---
include/linux/netfilter_arp/arpt_mcmangle.h | 14 ++++ net/ipv4/netfilter/Kconfig | 12 +++ net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/arpt_mcmangle.c | 98 +++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 0 deletions(-) create mode 100644 include/linux/netfilter_arp/arpt_mcmangle.h create mode 100644 net/ipv4/netfilter/arpt_mcmangle.c
include/linux/netfilter_arp/arpt_mcmangle.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef _ARPT_MCMANGLE_H +#define _ARPT_MCMANGLE_H +#include <linux/netfilter_arp/arp_tables.h> + +struct net_device ; + +struct arpt_mcmangle +{ +char ifname[IFNAMSIZ ]; +char mc_devaddr[ETH_ALEN ]; +struct net_device __attribute__((aligned (8 ))) *dev; +}; + +#endif /* _ARPT_MANGLE_H */
net/ipv4/netfilter/Kconfig +12 -0
@@ -392,6 +392,18 @@ config IP_NF_ARP_MANGLE Allows altering the ARP packet payload: source and destination hardware and network addresses. +config IP_NF_ARP_MCMANGLE + tristate "ARP multicast address mangling" + help + Allows altering the source unicast hardware address in ARP messages + with a multicast hardware address. This target is useful to make a + switch flood to all ports whose ethernet device have a multicast + hardware address. Please, see that this target violates RFC 1812 + (section 3.3.2) since an ethernet device must not use a multicast + link address. + + To compile it as a module, choose M here. If unsure, say N. + endif # IP_NF_ARPTABLES endmenu
net/ipv4/netfilter/Makefile +1 -0
@@ -67,6 +67,7 @@ obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o # generic ARP tables obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o obj-$(CONFIG_IP_NF_ARP_MANGLE) += arpt_mangle.o +obj-$(CONFIG_IP_NF_ARP_MCMANGLE) += arpt_mcmangle.o # just filtering instance of ARP tables for now obj-$(CONFIG_IP_NF_ARPFILTER) += arptable_filter.o
net/ipv4/netfilter/arpt_mcmangle.c new file +98 -0
98 lines not on this page · raw message
Pablo Neira Ayuso
maintainerDamn crap, the smtp server that I'm using is broken. I'll retry later.
Signature · 1 line
"Los honestos son inadaptados sociales" -- Les Luthiers