Skip to contentSkip to conversation

extend ebt_ip6 to allow matching on ipv6-icmp types/codes

PATCH New Florian Westphal 1 participant 1 message Dec 20, 2010

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 extend ebt_ip6 to allow matching on ipv6-icmp types/codes

adds a --ip6-icmp-type option to match on ipv6-icmp types/codes. The ipv6-icmp name list was taken from iptables 1.4.9.

---
Same patch as before, except that this also includes the changes to ebt_ip6.h.

 ebtables.8                               |   11 ++
 extensions/ebt_ip6.c                     |  227 +++++++++++++++++++++++++++++-
 include/ebtables_u.h                     |    4 +
 include/linux/netfilter_bridge/ebt_ip6.h |   18 ++-
 4 files changed, 253 insertions(+), 7 deletions(-)
ebtables.8 +11 -0
index efc284e..465ea56 100644
@@ -700,6 +700,17 @@ If
 The flag
 .B --ip6-dport
 is an alias for this option.
+.TP
+.BR "--ip6-icmp-type " "[!] {\fItype\fP[:\fItype\fP]/\fIcode\fP[:\fIcode\fP]|\fItypename\fP}"
+Specify ipv6\-icmp type and code to match.
+Ranges for both type and code are supported. Type and code are
+separated by a slash. Valid numbers for type and range are 0 to 255.
+To match a single type including all valid codes, symbolic names can
+be used instead of numbers. The list of known type names is shown by the command
+.nf
+  ebtables \-\-help ip6
+.fi
+This option is only valid for \-\-ip6-prococol ipv6-icmp.
 .SS limit
 This module matches at a limited rate using a token bucket filter.
 A rule using this extension will match until this limit is reached.
extensions/ebt_ip6.c +225 -2

291 lines not on this page · raw message

include/ebtables_u.h +4 -0
index 910c213..c29476d 100644
@@ -376,4 +376,8 @@ extern int ebt_printstyle_mac;
 #define PROC_SYS_MODPROBE "/proc/sys/kernel/modprobe"
 #endif
 #define ATOMIC_ENV_VARIABLE "EBTABLES_ATOMIC_FILE"
+
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(x)	(sizeof(x) / sizeof((x)[0]))
+#endif
 #endif /* EBTABLES_U_H */
include/linux/netfilter_bridge/ebt_ip6.h +13 -5
index 2273c3a..22af18a 100644
@@ -18,13 +18,15 @@
 #define EBT_IP6_PROTO 0x08
 #define EBT_IP6_SPORT 0x10
 #define EBT_IP6_DPORT 0x20
+#define EBT_IP6_ICMP6 0x40
+
 #define EBT_IP6_MASK (EBT_IP6_SOURCE | EBT_IP6_DEST | EBT_IP6_TCLASS |\
-		      EBT_IP6_PROTO | EBT_IP6_SPORT | EBT_IP6_DPORT)
+		      EBT_IP6_PROTO | EBT_IP6_SPORT | EBT_IP6_DPORT | \
+		      EBT_IP6_ICMP6)
 #define EBT_IP6_MATCH "ip6"
 
 /* the same values are used for the invflags */
-struct ebt_ip6_info
-{
+struct ebt_ip6_info {
 	struct in6_addr saddr;
 	struct in6_addr daddr;
 	struct in6_addr smsk;
@@ -33,8 +35,14 @@ struct ebt_ip6_info
 	uint8_t  protocol;
 	uint8_t  bitmask;
 	uint8_t  invflags;
-	uint16_t sport[2];
-	uint16_t dport[2];
+	union {
+		uint16_t sport[2];
+		uint8_t icmpv6_type[2];
+	};
+	union {
+		uint16_t dport[2];
+		uint8_t icmpv6_code[2];
+	};
 };
 
 #endif
Signature · 1 line
1.7.2.2