[PATCH] ebtables pkttype match
Bart De Schuymer <[email protected]>
| Newsgroups | gmane.linux.network.bridge.ebtables.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello David, The patch below adds an ebtables match for the pkt_type member of the skbuff. please apply, Bart --- linux-2.5.68/net/bridge/netfilter/Makefile.old Sat May 3 19:57:55 2003 +++ linux-2.5.68/net/bridge/netfilter/Makefile Mon Apr 28 23:54:12 2003 @@ -6,10 +6,11 @@ obj-$(CONFIG_BRIDGE_EBT_T_FILTER) += ebtable_filter.o obj-$(CONFIG_BRIDGE_EBT_T_NAT) += ebtable_nat.o obj-$(CONFIG_BRIDGE_EBT_BROUTE) += ebtable_broute.o -obj-$(CONFIG_BRIDGE_EBT_IPF) += ebt_ip.o -obj-$(CONFIG_BRIDGE_EBT_ARPF) += ebt_arp.o -obj-$(CONFIG_BRIDGE_EBT_VLANF) += ebt_vlan.o -obj-$(CONFIG_BRIDGE_EBT_MARKF) += ebt_mark_m.o +obj-$(CONFIG_BRIDGE_EBT_IP) += ebt_ip.o +obj-$(CONFIG_BRIDGE_EBT_ARP) += ebt_arp.o +obj-$(CONFIG_BRIDGE_EBT_VLAN) += ebt_vlan.o +obj-$(CONFIG_BRIDGE_EBT_MARK) += ebt_mark_m.o +obj-$(CONFIG_BRIDGE_EBT_PKTTYPE) += ebt_pkttype.o obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o obj-$(CONFIG_BRIDGE_EBT_DNAT) += ebt_dnat.o --- linux-2.5.68/net/bridge/netfilter/Kconfig.old Sat May 3 19:59:38 2003 +++ linux-2.5.68/net/bridge/netfilter/Kconfig Sat May 3 20:08:38 2003 @@ -49,7 +49,7 @@ If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. If unsure, say `N'. -config BRIDGE_EBT_IPF +config BRIDGE_EBT_IP tristate "ebt: IP filter support" depends on BRIDGE_NF_EBTABLES help @@ -59,7 +59,7 @@ If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. If unsure, say `N'. -config BRIDGE_EBT_ARPF +config BRIDGE_EBT_ARP tristate "ebt: ARP filter support" depends on BRIDGE_NF_EBTABLES help @@ -69,7 +69,7 @@ If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. If unsure, say `N'. -config BRIDGE_EBT_VLANF +config BRIDGE_EBT_VLAN tristate "ebt: 802.1Q VLAN filter support" depends on BRIDGE_NF_EBTABLES help @@ -79,7 +79,7 @@ If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. If unsure, say `N'. -config BRIDGE_EBT_MARKF +config BRIDGE_EBT_MARK tristate "ebt: mark filter support" depends on BRIDGE_NF_EBTABLES help @@ -87,6 +87,18 @@ the 'nfmark' value in the frame. This can be set by the mark target. This value is the same as the one used in the iptables mark match and target. + + If you want to compile it as a module, say M here and read + <file:Documentation/modules.txt>. If unsure, say `N'. + +config BRIDGE_EBT_PKTTYPE + tristate "ebt: packet type filter support" + depends on BRIDGE_NF_EBTABLES + help + This option adds the packet type match, which allows matching on the + type of packet based on its Ethernet "class" (as determined by + the generic networking code): broadcast, multicast, + for this host alone or for another host. If you want to compile it as a module, say M here and read <file:Documentation/modules.txt>. If unsure, say `N'. --- /dev/null Thu Aug 24 11:00:32 2000 +++ linux-2.5.68/net/bridge/netfilter/ebt_pkttype.c Thu May 1 15:00:42 2003 @@ -0,0 +1,59 @@ +/* + * ebt_pkttype + * + * Authors: + * Bart De Schuymer <[email protected]> + * + * April, 2003 + * + */ + +#include <linux/netfilter_bridge/ebtables.h> +#include <linux/netfilter_bridge/ebt_pkttype.h> +#include <linux/module.h> + +static int ebt_filter_pkttype(const struct sk_buff *skb, + const struct net_device *in, + const struct net_device *out, + const void *data, + unsigned int datalen) +{ + struct ebt_pkttype_info *info = (struct ebt_pkttype_info *)data; + + return (skb->pkt_type != info->pkt_type) ^ info->invert; +} + +static int ebt_pkttype_check(const char *tablename, unsigned int hookmask, + const struct ebt_entry *e, void *data, unsigned int datalen) +{ + struct ebt_pkttype_info *info = (struct ebt_pkttype_info *)data; + + if (datalen != sizeof(struct ebt_pkttype_info)) + return -EINVAL; + if (info->invert != 0 && info->invert != 1) + return -EINVAL; + /* Allow any pkt_type value */ + return 0; +} + +static struct ebt_match filter_pkttype = +{ + .name = EBT_PKTTYPE_MATCH, + .match = ebt_filter_pkttype, + .check = ebt_pkttype_check, + .me = THIS_MODULE, +}; + +static int __init init(void) +{ + return ebt_register_match(&filter_pkttype); +} + +static void __exit fini(void) +{ + ebt_unregister_match(&filter_pkttype); +} + +module_init(init); +module_exit(fini); +MODULE_LICENSE("GPL"); --- /dev/null Thu Aug 24 11:00:32 2000 +++ linux-2.5.68/include/linux/netfilter_bridge/ebt_pkttype.h Tue Apr 29 00:02:43 2003 @@ -0,0 +1,11 @@ +#ifndef __LINUX_BRIDGE_EBT_PKTTYPE_H +#define __LINUX_BRIDGE_EBT_PKTTYPE_H + +struct ebt_pkttype_info +{ + uint8_t pkt_type; + uint8_t invert; +}; +#define EBT_PKTTYPE_MATCH "pkttype" + +#endif ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf