d8a888d
From f4f26b8d839a8fcd0ae43d2944436e1dbafdfda6 Mon Sep 17 00:00:00 2001
d8a888d
From: Pablo Neira Ayuso <pablo@netfilter.org>
d8a888d
Date: Wed, 1 Apr 2015 12:16:30 +0200
d8a888d
Subject: [PATCH] src: cache in tree and use x_tables.h
d8a888d
d8a888d
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
d8a888d
(cherry picked from commit 5700dbf07266c1ab888dceee75a040eb7af40950)
d8a888d
Signed-off-by: Phil Sutter <psutter@redhat.com>
d8a888d
---
d8a888d
 include/libarptc/libarptc.h              |   1 +
d8a888d
 include/linux/netfilter/x_tables.h       | 185 +++++++++++++++++++
d8a888d
 include/linux/netfilter_arp/arp_tables.h | 222 +++++------------------
d8a888d
 libarptc/libarptc_incl.c                 |  17 +-
d8a888d
 4 files changed, 233 insertions(+), 192 deletions(-)
d8a888d
 create mode 100644 include/linux/netfilter/x_tables.h
d8a888d
d8a888d
diff --git a/include/libarptc/libarptc.h b/include/libarptc/libarptc.h
d8a888d
index e4f11752a201d..ff4606fb9ae16 100644
d8a888d
--- a/include/libarptc/libarptc.h
d8a888d
+++ b/include/libarptc/libarptc.h
d8a888d
@@ -3,6 +3,7 @@
d8a888d
 /* Library which manipulates filtering rules. */
d8a888d
 
d8a888d
 #include <libarptc/arpt_kernel_headers.h>
d8a888d
+#include <linux/netfilter/x_tables.h>
d8a888d
 #include <linux/netfilter_arp/arp_tables.h>
d8a888d
 
d8a888d
 #ifndef ARPT_MIN_ALIGN
d8a888d
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
d8a888d
new file mode 100644
d8a888d
index 0000000000000..4120970072771
d8a888d
--- /dev/null
d8a888d
+++ b/include/linux/netfilter/x_tables.h
d8a888d
@@ -0,0 +1,185 @@
d8a888d
+#ifndef _X_TABLES_H
d8a888d
+#define _X_TABLES_H
d8a888d
+#include <linux/kernel.h>
d8a888d
+#include <linux/types.h>
d8a888d
+
d8a888d
+#define XT_FUNCTION_MAXNAMELEN 30
d8a888d
+#define XT_EXTENSION_MAXNAMELEN 29
d8a888d
+#define XT_TABLE_MAXNAMELEN 32
d8a888d
+
d8a888d
+struct xt_entry_match {
d8a888d
+	union {
d8a888d
+		struct {
d8a888d
+			__u16 match_size;
d8a888d
+
d8a888d
+			/* Used by userspace */
d8a888d
+			char name[XT_EXTENSION_MAXNAMELEN];
d8a888d
+			__u8 revision;
d8a888d
+		} user;
d8a888d
+		struct {
d8a888d
+			__u16 match_size;
d8a888d
+
d8a888d
+			/* Used inside the kernel */
d8a888d
+			struct xt_match *match;
d8a888d
+		} kernel;
d8a888d
+
d8a888d
+		/* Total length */
d8a888d
+		__u16 match_size;
d8a888d
+	} u;
d8a888d
+
d8a888d
+	unsigned char data[0];
d8a888d
+};
d8a888d
+
d8a888d
+struct xt_entry_target {
d8a888d
+	union {
d8a888d
+		struct {
d8a888d
+			__u16 target_size;
d8a888d
+
d8a888d
+			/* Used by userspace */
d8a888d
+			char name[XT_EXTENSION_MAXNAMELEN];
d8a888d
+			__u8 revision;
d8a888d
+		} user;
d8a888d
+		struct {
d8a888d
+			__u16 target_size;
d8a888d
+
d8a888d
+			/* Used inside the kernel */
d8a888d
+			struct xt_target *target;
d8a888d
+		} kernel;
d8a888d
+
d8a888d
+		/* Total length */
d8a888d
+		__u16 target_size;
d8a888d
+	} u;
d8a888d
+
d8a888d
+	unsigned char data[0];
d8a888d
+};
d8a888d
+
d8a888d
+#define XT_TARGET_INIT(__name, __size)					       \
d8a888d
+{									       \
d8a888d
+	.target.u.user = {						       \
d8a888d
+		.target_size	= XT_ALIGN(__size),			       \
d8a888d
+		.name		= __name,				       \
d8a888d
+	},								       \
d8a888d
+}
d8a888d
+
d8a888d
+struct xt_standard_target {
d8a888d
+	struct xt_entry_target target;
d8a888d
+	int verdict;
d8a888d
+};
d8a888d
+
d8a888d
+struct xt_error_target {
d8a888d
+	struct xt_entry_target target;
d8a888d
+	char errorname[XT_FUNCTION_MAXNAMELEN];
d8a888d
+};
d8a888d
+
d8a888d
+/* The argument to IPT_SO_GET_REVISION_*.  Returns highest revision
d8a888d
+ * kernel supports, if >= revision. */
d8a888d
+struct xt_get_revision {
d8a888d
+	char name[XT_EXTENSION_MAXNAMELEN];
d8a888d
+	__u8 revision;
d8a888d
+};
d8a888d
+
d8a888d
+/* CONTINUE verdict for targets */
d8a888d
+#define XT_CONTINUE 0xFFFFFFFF
d8a888d
+
d8a888d
+/* For standard target */
d8a888d
+#define XT_RETURN (-NF_REPEAT - 1)
d8a888d
+
d8a888d
+/* this is a dummy structure to find out the alignment requirement for a struct
d8a888d
+ * containing all the fundamental data types that are used in ipt_entry,
d8a888d
+ * ip6t_entry and arpt_entry.  This sucks, and it is a hack.  It will be my
d8a888d
+ * personal pleasure to remove it -HW
d8a888d
+ */
d8a888d
+struct _xt_align {
d8a888d
+	__u8 u8;
d8a888d
+	__u16 u16;
d8a888d
+	__u32 u32;
d8a888d
+	__u64 u64;
d8a888d
+};
d8a888d
+
d8a888d
+#define XT_ALIGN(s) __ALIGN_KERNEL((s), __alignof__(struct _xt_align))
d8a888d
+
d8a888d
+/* Standard return verdict, or do jump. */
d8a888d
+#define XT_STANDARD_TARGET ""
d8a888d
+/* Error verdict. */
d8a888d
+#define XT_ERROR_TARGET "ERROR"
d8a888d
+
d8a888d
+#define SET_COUNTER(c,b,p) do { (c).bcnt = (b); (c).pcnt = (p); } while(0)
d8a888d
+#define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
d8a888d
+
d8a888d
+struct xt_counters {
d8a888d
+	__u64 pcnt, bcnt;			/* Packet and byte counters */
d8a888d
+};
d8a888d
+
d8a888d
+/* The argument to IPT_SO_ADD_COUNTERS. */
d8a888d
+struct xt_counters_info {
d8a888d
+	/* Which table. */
d8a888d
+	char name[XT_TABLE_MAXNAMELEN];
d8a888d
+
d8a888d
+	unsigned int num_counters;
d8a888d
+
d8a888d
+	/* The counters (actually `number' of these). */
d8a888d
+	struct xt_counters counters[0];
d8a888d
+};
d8a888d
+
d8a888d
+#define XT_INV_PROTO		0x40	/* Invert the sense of PROTO. */
d8a888d
+
d8a888d
+/* fn returns 0 to continue iteration */
d8a888d
+#define XT_MATCH_ITERATE(type, e, fn, args...)			\
d8a888d
+({								\
d8a888d
+	unsigned int __i;					\
d8a888d
+	int __ret = 0;						\
d8a888d
+	struct xt_entry_match *__m;				\
d8a888d
+								\
d8a888d
+	for (__i = sizeof(type);				\
d8a888d
+	     __i < (e)->target_offset;				\
d8a888d
+	     __i += __m->u.match_size) {			\
d8a888d
+		__m = (void *)e + __i;				\
d8a888d
+								\
d8a888d
+		__ret = fn(__m , ## args);			\
d8a888d
+		if (__ret != 0)					\
d8a888d
+			break;					\
d8a888d
+	}							\
d8a888d
+	__ret;							\
d8a888d
+})
d8a888d
+
d8a888d
+/* fn returns 0 to continue iteration */
d8a888d
+#define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \
d8a888d
+({								\
d8a888d
+	unsigned int __i, __n;					\
d8a888d
+	int __ret = 0;						\
d8a888d
+	type *__entry;						\
d8a888d
+								\
d8a888d
+	for (__i = 0, __n = 0; __i < (size);			\
d8a888d
+	     __i += __entry->next_offset, __n++) { 		\
d8a888d
+		__entry = (void *)(entries) + __i;		\
d8a888d
+		if (__n < n)					\
d8a888d
+			continue;				\
d8a888d
+								\
d8a888d
+		__ret = fn(__entry , ## args);			\
d8a888d
+		if (__ret != 0)					\
d8a888d
+			break;					\
d8a888d
+	}							\
d8a888d
+	__ret;							\
d8a888d
+})
d8a888d
+
d8a888d
+/* fn returns 0 to continue iteration */
d8a888d
+#define XT_ENTRY_ITERATE(type, entries, size, fn, args...) \
d8a888d
+	XT_ENTRY_ITERATE_CONTINUE(type, entries, size, 0, fn, args)
d8a888d
+
d8a888d
+
d8a888d
+/* pos is normally a struct ipt_entry/ip6t_entry/etc. */
d8a888d
+#define xt_entry_foreach(pos, ehead, esize) \
d8a888d
+	for ((pos) = (typeof(pos))(ehead); \
d8a888d
+	     (pos) < (typeof(pos))((char *)(ehead) + (esize)); \
d8a888d
+	     (pos) = (typeof(pos))((char *)(pos) + (pos)->next_offset))
d8a888d
+
d8a888d
+/* can only be xt_entry_match, so no use of typeof here */
d8a888d
+#define xt_ematch_foreach(pos, entry) \
d8a888d
+	for ((pos) = (struct xt_entry_match *)entry->elems; \
d8a888d
+	     (pos) < (struct xt_entry_match *)((char *)(entry) + \
d8a888d
+	             (entry)->target_offset); \
d8a888d
+	     (pos) = (struct xt_entry_match *)((char *)(pos) + \
d8a888d
+	             (pos)->u.match_size))
d8a888d
+
d8a888d
+
d8a888d
+#endif /* _X_TABLES_H */
d8a888d
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
d8a888d
index 0acda6620bd19..bb1ec648af257 100644
d8a888d
--- a/include/linux/netfilter_arp/arp_tables.h
d8a888d
+++ b/include/linux/netfilter_arp/arp_tables.h
d8a888d
@@ -9,18 +9,25 @@
d8a888d
 #ifndef _ARPTABLES_H
d8a888d
 #define _ARPTABLES_H
d8a888d
 
d8a888d
-#ifdef __KERNEL__
d8a888d
-#include <linux/if.h>
d8a888d
 #include <linux/types.h>
d8a888d
-#include <linux/in.h>
d8a888d
-#include <linux/if_arp.h>
d8a888d
-#include <linux/skbuff.h>
d8a888d
-#endif
d8a888d
 
d8a888d
 #include <linux/netfilter_arp.h>
d8a888d
 
d8a888d
-#define ARPT_FUNCTION_MAXNAMELEN 30
d8a888d
-#define ARPT_TABLE_MAXNAMELEN 32
d8a888d
+#include <linux/netfilter/x_tables.h>
d8a888d
+
d8a888d
+#define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN
d8a888d
+#define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN
d8a888d
+#define arpt_entry_target xt_entry_target
d8a888d
+#define arpt_standard_target xt_standard_target
d8a888d
+#define arpt_error_target xt_error_target
d8a888d
+#define ARPT_CONTINUE XT_CONTINUE
d8a888d
+#define ARPT_RETURN XT_RETURN
d8a888d
+#define arpt_counters_info xt_counters_info
d8a888d
+#define arpt_counters xt_counters
d8a888d
+#define ARPT_STANDARD_TARGET XT_STANDARD_TARGET
d8a888d
+#define ARPT_ERROR_TARGET XT_ERROR_TARGET
d8a888d
+#define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
d8a888d
+	XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args)
d8a888d
 
d8a888d
 #define ARPT_DEV_ADDR_LEN_MAX 16
d8a888d
 
d8a888d
@@ -37,16 +44,16 @@ struct arpt_arp {
d8a888d
 	struct in_addr smsk, tmsk;
d8a888d
 
d8a888d
 	/* Device hw address length, src+target device addresses */
d8a888d
-	u_int8_t arhln, arhln_mask;
d8a888d
+	__u8 arhln, arhln_mask;
d8a888d
 	struct arpt_devaddr_info src_devaddr;
d8a888d
 	struct arpt_devaddr_info tgt_devaddr;
d8a888d
 
d8a888d
 	/* ARP operation code. */
d8a888d
-	u_int16_t arpop, arpop_mask;
d8a888d
+	__be16 arpop, arpop_mask;
d8a888d
 
d8a888d
 	/* ARP hardware address and protocol address format. */
d8a888d
-	u_int16_t arhrd, arhrd_mask;
d8a888d
-	u_int16_t arpro, arpro_mask;
d8a888d
+	__be16 arhrd, arhrd_mask;
d8a888d
+	__be16 arpro, arpro_mask;
d8a888d
 
d8a888d
 	/* The protocol address length is only accepted if it is 4
d8a888d
 	 * so there is no use in offering a way to do filtering on it.
d8a888d
@@ -56,43 +63,9 @@ struct arpt_arp {
d8a888d
 	unsigned char iniface_mask[IFNAMSIZ], outiface_mask[IFNAMSIZ];
d8a888d
 
d8a888d
 	/* Flags word */
d8a888d
-	u_int8_t flags;
d8a888d
+	__u8 flags;
d8a888d
 	/* Inverse flags */
d8a888d
-	u_int16_t invflags;
d8a888d
-};
d8a888d
-
d8a888d
-struct arpt_entry_target
d8a888d
-{
d8a888d
-	union {
d8a888d
-		struct {
d8a888d
-			u_int16_t target_size;
d8a888d
-
d8a888d
-			/* Used by userspace */
d8a888d
-			char name[ARPT_FUNCTION_MAXNAMELEN];
d8a888d
-		} user;
d8a888d
-		struct {
d8a888d
-			u_int16_t target_size;
d8a888d
-
d8a888d
-			/* Used inside the kernel */
d8a888d
-			struct arpt_target *target;
d8a888d
-		} kernel;
d8a888d
-
d8a888d
-		/* Total length */
d8a888d
-		u_int16_t target_size;
d8a888d
-	} u;
d8a888d
-
d8a888d
-	unsigned char data[0];
d8a888d
-};
d8a888d
-
d8a888d
-struct arpt_standard_target
d8a888d
-{
d8a888d
-	struct arpt_entry_target target;
d8a888d
-	int verdict;
d8a888d
-};
d8a888d
-
d8a888d
-struct arpt_counters
d8a888d
-{
d8a888d
-	u_int64_t pcnt, bcnt;			/* Packet and byte counters */
d8a888d
+	__u16 invflags;
d8a888d
 };
d8a888d
 
d8a888d
 /* Values for "flag" field in struct arpt_ip (general arp structure).
d8a888d
@@ -121,15 +94,15 @@ struct arpt_entry
d8a888d
 	struct arpt_arp arp;
d8a888d
 
d8a888d
 	/* Size of arpt_entry + matches */
d8a888d
-	u_int16_t target_offset;
d8a888d
+	__u16 target_offset;
d8a888d
 	/* Size of arpt_entry + matches + target */
d8a888d
-	u_int16_t next_offset;
d8a888d
+	__u16 next_offset;
d8a888d
 
d8a888d
 	/* Back pointer */
d8a888d
 	unsigned int comefrom;
d8a888d
 
d8a888d
 	/* Packet and byte counters. */
d8a888d
-	struct arpt_counters counters;
d8a888d
+	struct xt_counters counters;
d8a888d
 
d8a888d
 	/* The matches (if any), then the target. */
d8a888d
 	unsigned char elems[0];
d8a888d
@@ -139,8 +112,10 @@ struct arpt_entry
d8a888d
  * New IP firewall options for [gs]etsockopt at the RAW IP level.
d8a888d
  * Unlike BSD Linux inherits IP options so you don't have to use a raw
d8a888d
  * socket for this. Instead we check rights in the calls.
d8a888d
+ *
d8a888d
+ * ATTENTION: check linux/in.h before adding new number here.
d8a888d
  */
d8a888d
-#define ARPT_BASE_CTL		96	/* base for firewall socket options */
d8a888d
+#define ARPT_BASE_CTL		96
d8a888d
 
d8a888d
 #define ARPT_SO_SET_REPLACE		(ARPT_BASE_CTL)
d8a888d
 #define ARPT_SO_SET_ADD_COUNTERS	(ARPT_BASE_CTL + 1)
d8a888d
@@ -148,29 +123,24 @@ struct arpt_entry
d8a888d
 
d8a888d
 #define ARPT_SO_GET_INFO		(ARPT_BASE_CTL)
d8a888d
 #define ARPT_SO_GET_ENTRIES		(ARPT_BASE_CTL + 1)
d8a888d
-#define ARPT_SO_GET_MAX			ARPT_SO_GET_ENTRIES
d8a888d
-
d8a888d
-/* CONTINUE verdict for targets */
d8a888d
-#define ARPT_CONTINUE 0xFFFFFFFF
d8a888d
-
d8a888d
-/* For standard target */
d8a888d
-#define ARPT_RETURN (-NF_REPEAT - 1)
d8a888d
+/* #define ARPT_SO_GET_REVISION_MATCH	(APRT_BASE_CTL + 2) */
d8a888d
+#define ARPT_SO_GET_REVISION_TARGET	(ARPT_BASE_CTL + 3)
d8a888d
+#define ARPT_SO_GET_MAX			(ARPT_SO_GET_REVISION_TARGET)
d8a888d
 
d8a888d
 /* The argument to ARPT_SO_GET_INFO */
d8a888d
-struct arpt_getinfo
d8a888d
-{
d8a888d
+struct arpt_getinfo {
d8a888d
 	/* Which table: caller fills this in. */
d8a888d
-	char name[ARPT_TABLE_MAXNAMELEN];
d8a888d
+	char name[XT_TABLE_MAXNAMELEN];
d8a888d
 
d8a888d
 	/* Kernel fills these in. */
d8a888d
 	/* Which hook entry points are valid: bitmask */
d8a888d
 	unsigned int valid_hooks;
d8a888d
 
d8a888d
 	/* Hook entry points: one per netfilter hook. */
d8a888d
-	unsigned int hook_entry[3];
d8a888d
+	unsigned int hook_entry[NF_ARP_NUMHOOKS];
d8a888d
 
d8a888d
 	/* Underflow points. */
d8a888d
-	unsigned int underflow[3];
d8a888d
+	unsigned int underflow[NF_ARP_NUMHOOKS];
d8a888d
 
d8a888d
 	/* Number of entries */
d8a888d
 	unsigned int num_entries;
d8a888d
@@ -180,10 +150,9 @@ struct arpt_getinfo
d8a888d
 };
d8a888d
 
d8a888d
 /* The argument to ARPT_SO_SET_REPLACE. */
d8a888d
-struct arpt_replace
d8a888d
-{
d8a888d
+struct arpt_replace {
d8a888d
 	/* Which table. */
d8a888d
-	char name[ARPT_TABLE_MAXNAMELEN];
d8a888d
+	char name[XT_TABLE_MAXNAMELEN];
d8a888d
 
d8a888d
 	/* Which hook entry points are valid: bitmask.  You can't
d8a888d
            change this. */
d8a888d
@@ -196,38 +165,25 @@ struct arpt_replace
d8a888d
 	unsigned int size;
d8a888d
 
d8a888d
 	/* Hook entry points. */
d8a888d
-	unsigned int hook_entry[3];
d8a888d
+	unsigned int hook_entry[NF_ARP_NUMHOOKS];
d8a888d
 
d8a888d
 	/* Underflow points. */
d8a888d
-	unsigned int underflow[3];
d8a888d
+	unsigned int underflow[NF_ARP_NUMHOOKS];
d8a888d
 
d8a888d
 	/* Information about old entries: */
d8a888d
 	/* Number of counters (must be equal to current number of entries). */
d8a888d
 	unsigned int num_counters;
d8a888d
 	/* The old entries' counters. */
d8a888d
-	struct arpt_counters *counters;
d8a888d
+	struct xt_counters *counters;
d8a888d
 
d8a888d
 	/* The entries (hang off end: not really an array). */
d8a888d
 	struct arpt_entry entries[0];
d8a888d
 };
d8a888d
 
d8a888d
-/* The argument to ARPT_SO_ADD_COUNTERS. */
d8a888d
-struct arpt_counters_info
d8a888d
-{
d8a888d
-	/* Which table. */
d8a888d
-	char name[ARPT_TABLE_MAXNAMELEN];
d8a888d
-
d8a888d
-	unsigned int num_counters;
d8a888d
-
d8a888d
-	/* The counters (actually `number' of these). */
d8a888d
-	struct arpt_counters counters[0];
d8a888d
-};
d8a888d
-
d8a888d
 /* The argument to ARPT_SO_GET_ENTRIES. */
d8a888d
-struct arpt_get_entries
d8a888d
-{
d8a888d
+struct arpt_get_entries {
d8a888d
 	/* Which table: user fills this in. */
d8a888d
-	char name[ARPT_TABLE_MAXNAMELEN];
d8a888d
+	char name[XT_TABLE_MAXNAMELEN];
d8a888d
 
d8a888d
 	/* User fills this in: total entry size. */
d8a888d
 	unsigned int size;
d8a888d
@@ -236,107 +192,13 @@ struct arpt_get_entries
d8a888d
 	struct arpt_entry entrytable[0];
d8a888d
 };
d8a888d
 
d8a888d
-/* Standard return verdict, or do jump. */
d8a888d
-#define ARPT_STANDARD_TARGET ""
d8a888d
-/* Error verdict. */
d8a888d
-#define ARPT_ERROR_TARGET "ERROR"
d8a888d
-
d8a888d
 /* Helper functions */
d8a888d
-static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e)
d8a888d
+static __inline__ struct xt_entry_target *arpt_get_target(struct arpt_entry *e)
d8a888d
 {
d8a888d
 	return (void *)e + e->target_offset;
d8a888d
 }
d8a888d
 
d8a888d
-/* fn returns 0 to continue iteration */
d8a888d
-#define ARPT_ENTRY_ITERATE(entries, size, fn, args...)		\
d8a888d
-({								\
d8a888d
-	unsigned int __i;					\
d8a888d
-	int __ret = 0;						\
d8a888d
-	struct arpt_entry *__entry;				\
d8a888d
-								\
d8a888d
-	for (__i = 0; __i < (size); __i += __entry->next_offset) { \
d8a888d
-		__entry = (void *)(entries) + __i;		\
d8a888d
-								\
d8a888d
-		__ret = fn(__entry , ## args);			\
d8a888d
-		if (__ret != 0)					\
d8a888d
-			break;					\
d8a888d
-	}							\
d8a888d
-	__ret;							\
d8a888d
-})
d8a888d
-
d8a888d
 /*
d8a888d
  *	Main firewall chains definitions and global var's definitions.
d8a888d
  */
d8a888d
-#ifdef __KERNEL__
d8a888d
-
d8a888d
-/* Registration hooks for targets. */
d8a888d
-struct arpt_target
d8a888d
-{
d8a888d
-	struct list_head list;
d8a888d
-
d8a888d
-	const char name[ARPT_FUNCTION_MAXNAMELEN];
d8a888d
-
d8a888d
-	/* Returns verdict. */
d8a888d
-	unsigned int (*target)(struct sk_buff **pskb,
d8a888d
-			       unsigned int hooknum,
d8a888d
-			       const struct net_device *in,
d8a888d
-			       const struct net_device *out,
d8a888d
-			       const void *targinfo,
d8a888d
-			       void *userdata);
d8a888d
-
d8a888d
-	/* Called when user tries to insert an entry of this type:
d8a888d
-           hook_mask is a bitmask of hooks from which it can be
d8a888d
-           called. */
d8a888d
-	/* Should return true or false. */
d8a888d
-	int (*checkentry)(const char *tablename,
d8a888d
-			  const struct arpt_entry *e,
d8a888d
-			  void *targinfo,
d8a888d
-			  unsigned int targinfosize,
d8a888d
-			  unsigned int hook_mask);
d8a888d
-
d8a888d
-	/* Called when entry of this type deleted. */
d8a888d
-	void (*destroy)(void *targinfo, unsigned int targinfosize);
d8a888d
-
d8a888d
-	/* Set this to THIS_MODULE if you are a module, otherwise NULL */
d8a888d
-	struct module *me;
d8a888d
-};
d8a888d
-
d8a888d
-extern int arpt_register_target(struct arpt_target *target);
d8a888d
-extern void arpt_unregister_target(struct arpt_target *target);
d8a888d
-
d8a888d
-/* Furniture shopping... */
d8a888d
-struct arpt_table
d8a888d
-{
d8a888d
-	struct list_head list;
d8a888d
-
d8a888d
-	/* A unique name... */
d8a888d
-	char name[ARPT_TABLE_MAXNAMELEN];
d8a888d
-
d8a888d
-	/* Seed table: copied in register_table */
d8a888d
-	struct arpt_replace *table;
d8a888d
-
d8a888d
-	/* What hooks you will enter on */
d8a888d
-	unsigned int valid_hooks;
d8a888d
-
d8a888d
-	/* Lock for the curtain */
d8a888d
-	rwlock_t lock;
d8a888d
-
d8a888d
-	/* Man behind the curtain... */
d8a888d
-	struct arpt_table_info *private;
d8a888d
-
d8a888d
-	/* Set this to THIS_MODULE if you are a module, otherwise NULL */
d8a888d
-	struct module *me;
d8a888d
-};
d8a888d
-
d8a888d
-extern int arpt_register_table(struct arpt_table *table);
d8a888d
-extern void arpt_unregister_table(struct arpt_table *table);
d8a888d
-extern unsigned int arpt_do_table(struct sk_buff **pskb,
d8a888d
-				  unsigned int hook,
d8a888d
-				  const struct net_device *in,
d8a888d
-				  const struct net_device *out,
d8a888d
-				  struct arpt_table *table,
d8a888d
-				  void *userdata);
d8a888d
-
d8a888d
-#define ARPT_ALIGN(s) (((s) + (__alignof__(struct arpt_entry)-1)) & ~(__alignof__(struct arpt_entry)-1))
d8a888d
-#endif /*__KERNEL__*/
d8a888d
 #endif /* _ARPTABLES_H */
d8a888d
diff --git a/libarptc/libarptc_incl.c b/libarptc/libarptc_incl.c
d8a888d
index 1d2e8b7b7ac01..a034930600344 100644
d8a888d
--- a/libarptc/libarptc_incl.c
d8a888d
+++ b/libarptc/libarptc_incl.c
d8a888d
@@ -40,13 +40,6 @@ struct counter_map
d8a888d
 	unsigned int mappos;
d8a888d
 };
d8a888d
 
d8a888d
-/* Convenience structures */
d8a888d
-struct arpt_error_target
d8a888d
-{
d8a888d
-	STRUCT_ENTRY_TARGET t;
d8a888d
-	char error[TABLE_MAXNAMELEN];
d8a888d
-};
d8a888d
-
d8a888d
 struct chain_cache
d8a888d
 {
d8a888d
 	char name[TABLE_MAXNAMELEN];
d8a888d
@@ -1342,9 +1335,9 @@ TC_CREATE_CHAIN(const ARPT_CHAINLABEL chain, TC_HANDLE_T *handle)
d8a888d
 	newc.head.next_offset
d8a888d
 		= sizeof(STRUCT_ENTRY)
d8a888d
 		+ ALIGN(sizeof(struct arpt_error_target));
d8a888d
-	strcpy(newc.name.t.u.user.name, ERROR_TARGET);
d8a888d
-	newc.name.t.u.target_size = ALIGN(sizeof(struct arpt_error_target));
d8a888d
-	strcpy(newc.name.error, chain);
d8a888d
+	strcpy(newc.name.target.u.user.name, ERROR_TARGET);
d8a888d
+	newc.name.target.u.target_size = ALIGN(sizeof(struct arpt_error_target));
d8a888d
+	strcpy(newc.name.errorname, chain);
d8a888d
 
d8a888d
 	newc.ret.target_offset = sizeof(STRUCT_ENTRY);
d8a888d
 	newc.ret.next_offset
d8a888d
@@ -1482,8 +1475,8 @@ int TC_RENAME_CHAIN(const ARPT_CHAINLABEL oldname,
d8a888d
 	t = (struct arpt_error_target *)
d8a888d
 		GET_TARGET(get_entry(*handle, labeloff));
d8a888d
 
d8a888d
-	memset(t->error, 0, sizeof(t->error));
d8a888d
-	strcpy(t->error, newname);
d8a888d
+	memset(t->errorname, 0, sizeof(t->errorname));
d8a888d
+	strcpy(t->errorname, newname);
d8a888d
 	set_changed(*handle);
d8a888d
 
d8a888d
 	return 1;
d8a888d
-- 
d8a888d
2.21.0
d8a888d