Skip to contentSkip to conversation

Add revision field for xt_entry_target

PATCH In review Gao feng 2 participants 6 messages Feb 6, 2015 – Feb 11, 2015 netfilter

lore
Share & tools
lore

Gao feng

author
#0 lore raw

PATCH 1/3 Add revision field for xt_entry_target

This filed is useful if we want to add TARGET which has revision for arptables rules.

Also make sure xt_entry_target is consistent with
the definition in kernel.

---
 include/linux/netfilter_arp/arp_tables.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/netfilter_arp/arp_tables.h +3 -1
index 0acda66..ccf8cd0 100644
@@ -19,7 +19,7 @@
 
 #include <linux/netfilter_arp.h>
 
-#define ARPT_FUNCTION_MAXNAMELEN 30
+#define ARPT_FUNCTION_MAXNAMELEN 29
 #define ARPT_TABLE_MAXNAMELEN 32
 
 #define ARPT_DEV_ADDR_LEN_MAX 16
@@ -69,6 +69,8 @@ struct arpt_entry_target
 
 			/* Used by userspace */
 			char name[ARPT_FUNCTION_MAXNAMELEN];
+
+			u_int8_t revision;
 		} user;
 		struct {
 			u_int16_t target_size;
Signature · 1 line
2.1.0
author
#1 lore raw

PATCH 2/3 Add MARK target for arptables

We can use MARK target to set make value for
arp packet.

---
 extensions/Makefile    |   2 +-
 extensions/arpt_MARK.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 extensions/arpt_MARK.c
extensions/Makefile +1 -1
index 09b244e..0189cc9 100644
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=standard mangle CLASSIFY
+EXT_FUNC+=standard mangle CLASSIFY MARK
 EXT_OBJS+=$(foreach T,$(EXT_FUNC), extensions/arpt_$(T).o)
 
 extensions/ebt_%.o: extensions/arpt_%.c include/arptables.h include/arptables_common.h
extensions/arpt_MARK.c new file +119 -0

119 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

Re: [PATCH 2/3] Add MARK target for arptables

Quoted 58 lines · Gao feng

We can use MARK target to set make value for
arp packet.

---
 extensions/Makefile    |   2 +-
 extensions/arpt_MARK.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 extensions/arpt_MARK.c
extensions/Makefile +1 -1
index 09b244e..0189cc9 100644
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=standard mangle CLASSIFY
+EXT_FUNC+=standard mangle CLASSIFY MARK
 EXT_OBJS+=$(foreach T,$(EXT_FUNC), extensions/arpt_$(T).o)
 
 extensions/ebt_%.o: extensions/arpt_%.c include/arptables.h include/arptables_common.h
extensions/arpt_MARK.c new file +30 -0
new file mode 100644
index 0000000..ce24bdb
@@ -0,0 +1,119 @@
+/*
+ * (C) 2015 by Gao feng <[email protected]>
+ *
+ * arpt_MARK.c -- arptables extension to set mark for arp packet
+ *
+ *	This program is free software; you can redistribute it and/or modify
+ *	it under the terms of the GNU General Public License as published by
+ *	the Free Software Foundation; either version 2 of the License, or
+ *	(at your option) any later version.
+ *
+ *	This program is distributed in the hope that it will be useful,
+ *	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *	GNU General Public License for more details.
+ *
+ *	You should have received a copy of the GNU General Public License
+ *	along with this program; if not, write to the Free Software
+ *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <getopt.h>
+#include <arptables.h>
+#include <linux/netfilter/xt_mark.h>
+#include <linux/netfilter/x_tables.h>
+
+static void
+help(void)
+{
+	printf(

extensions/arpt_MARK.c line 40

Quoted 10 lines
extensions/arpt_MARK.c new file +10 -0
+"MARK target v%s options:\n"
+"--set-mark mark : set the mark value\n",
+	ARPTABLES_VERSION);
+}
+
+#define MARK_OPT 1
+
+static struct option opts[] = {
+	{ "set-mark"   , required_argument, 0, MARK_OPT },
+	{0}

Please, add all options that MARK support according to man iptables-extensions.

author
#3 lore raw

Re: [PATCH 2/3] Add MARK target for arptables

Quoted 64 lines · Pablo Neira Ayuso
Quoted 63 lines · Gao feng

We can use MARK target to set make value for
arp packet.

---
 extensions/Makefile    |   2 +-
 extensions/arpt_MARK.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 extensions/arpt_MARK.c
extensions/Makefile +1 -1
index 09b244e..0189cc9 100644
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=standard mangle CLASSIFY
+EXT_FUNC+=standard mangle CLASSIFY MARK
 EXT_OBJS+=$(foreach T,$(EXT_FUNC), extensions/arpt_$(T).o)
 
 extensions/ebt_%.o: extensions/arpt_%.c include/arptables.h include/arptables_common.h
extensions/arpt_MARK.c new file +35 -0
new file mode 100644
index 0000000..ce24bdb
@@ -0,0 +1,119 @@
+/*
+ * (C) 2015 by Gao feng <[email protected]>
+ *
+ * arpt_MARK.c -- arptables extension to set mark for arp packet
+ *
+ *	This program is free software; you can redistribute it and/or modify
+ *	it under the terms of the GNU General Public License as published by
+ *	the Free Software Foundation; either version 2 of the License, or
+ *	(at your option) any later version.
+ *
+ *	This program is distributed in the hope that it will be useful,
+ *	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *	GNU General Public License for more details.
+ *
+ *	You should have received a copy of the GNU General Public License
+ *	along with this program; if not, write to the Free Software
+ *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <getopt.h>
+#include <arptables.h>
+#include <linux/netfilter/xt_mark.h>
+#include <linux/netfilter/x_tables.h>
+
+static void
+help(void)
+{
+	printf(
+"MARK target v%s options:\n"
+"--set-mark mark : set the mark value\n",
+	ARPTABLES_VERSION);
+}
+
Quoted 8 lines

extensions/arpt_MARK.c line 40

Quoted 5 lines
extensions/arpt_MARK.c new file +5 -0
+#define MARK_OPT 1
+
+static struct option opts[] = {
+	{ "set-mark"   , required_argument, 0, MARK_OPT },
+	{0}

Please, add all options that MARK support according to man iptables-extensions.

Get, will do. thanks!

author
#4 lore raw

PATCH 3/3 Update the manpage for MARK target

In reply to Gao feng
---
 arptables.8 | 10 ++++++++++
 1 file changed, 10 insertions(+)
arptables.8 +10 -0
index 78b2c60..a0ada83 100644
@@ -315,6 +315,16 @@ sify the packet into a specific CBQ class).
 Set the major and minor  class  value.  The  values  are  always
 interpreted as hexadecimal even if no 0x prefix is given.
 
+.SS MARK
+This  module  allows you to set the skb->mark value (and thus classify
+the packet by the mark in u32)
+
+.TP
+.BR "--set-mark mark"
+
+Set the mark value.  The  values  are  always
+interpreted as hexadecimal even if no 0x prefix is given.
+
 .SH MAILINGLISTS
 .BR "" "See " http://netfilter.org/mailinglists.html
 .SH SEE ALSO
Signature · 1 line
2.1.0
#5 lore raw
In reply to Gao feng
Quoted 25 lines · Gao feng

This filed is useful if we want to add TARGET which has revision for arptables rules.

Also make sure xt_entry_target is consistent with
the definition in kernel.

---
 include/linux/netfilter_arp/arp_tables.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/netfilter_arp/arp_tables.h +1 -1
index 0acda66..ccf8cd0 100644
@@ -19,7 +19,7 @@
 
 #include <linux/netfilter_arp.h>
 
-#define ARPT_FUNCTION_MAXNAMELEN 30
+#define ARPT_FUNCTION_MAXNAMELEN 29
 #define ARPT_TABLE_MAXNAMELEN 32
 
 #define ARPT_DEV_ADDR_LEN_MAX 16

include/linux/netfilter_arp/arp_tables.h struct arpt_entry_target · line 73

Quoted 5 lines
include/linux/netfilter_arp/arp_tables.h +2 -0
@@ -69,6 +69,8 @@ struct arpt_entry_target
 
 			/* Used by userspace */
 			char name[ARPT_FUNCTION_MAXNAMELEN];
+
+			u_int8_t revision;

This structure is not exposed to userspace and I don't find any client of it in this code:

include/uapi/linux/netfilter_arp/arp_tables.h:#define arpt_entry_target xt_entry_target

and arp_tables uses xt_entry_target all the time.

I guess you can get rid of this dead code. Then, update the cached copy and also include x_tables.h definition in the arptables tree.

Quoted 6 lines
include/linux/netfilter_arp/arp_tables.h +0 -0
 		} user;
 		struct {
 			u_int16_t target_size;
Signature · 1 line
2.1.0