Skip to contentSkip to conversation

add mark target

PATCH Superseded Zhang Chunyu 2 participants 7 messages Mar 26, 2015 – Mar 30, 2015 netfilter

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover add mark target

v1:
add mark target for arptables

v2:
add --and-mark
add --or-mark
add revision for common api

v3:
fold 2/4, 3/4 and 4/4 patch into one single patch use C99 initialization
change some format

Zhang Chunyu (2):
Add MARK target for arptables

 arptables.8                              |  17 ++++
 arptables.c                              |   2 +
 extensions/Makefile                      |   2 +-
 extensions/arpt_CLASSIFY.c               |   1 +
 extensions/arpt_MARK.c                   | 151 +++++++++++++++++++++++++++++++
 extensions/arpt_mangle.c                 |   1 +
 extensions/arpt_standard.c               |   1 +
 include/arptables.h                      |   6 ++
 include/linux/netfilter_arp/arp_tables.h |   3 +-
 9 files changed, 182 insertions(+), 2 deletions(-)
 create mode 100644 extensions/arpt_MARK.c
Signature · 1 line
1.7.12.4
#1 lore raw

PATCH v3 1/2 Add revision field for xt_entry_target

From: zhangcy <[email protected]>

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.

---
 arptables.c                              | 2 ++
 extensions/arpt_CLASSIFY.c               | 1 +
 extensions/arpt_mangle.c                 | 1 +
 extensions/arpt_standard.c               | 1 +
 include/arptables.h                      | 6 ++++++
 include/linux/netfilter_arp/arp_tables.h | 3 ++-
 6 files changed, 13 insertions(+), 1 deletion(-)
arptables.c +2 -0
index 845e226..3f24ef1 100644
@@ -2067,6 +2067,7 @@ int do_command(int argc, char *argv[], char **table, arptc_handle_t *handle)
 				target->t->u.target_size = size;
 				strncpy(target->t->u.user.name, jumpto, sizeof(target->t->u.user.name));
 				target->t->u.user.name[sizeof(target->t->u.user.name)-1] = '\0';
+				target->t->u.user.revision = target->revision;
 /*
 				target->init(target->t, &fw.nfcache);
 */
@@ -2391,6 +2392,7 @@ int do_command(int argc, char *argv[], char **table, arptc_handle_t *handle)
 			target->t = fw_calloc(1, size);
 			target->t->u.target_size = size;
 			strcpy(target->t->u.user.name, jumpto);
+			target->t->u.user.revision = target->revision;
 			target->init(target->t);
 		}
 
extensions/arpt_CLASSIFY.c +1 -0
index cb5770b..7893aed 100644
@@ -105,6 +105,7 @@ struct arptables_target classify
 	ARPTABLES_VERSION,
 	ARPT_ALIGN(sizeof(struct xt_classify_target_info)),
 	ARPT_ALIGN(sizeof(struct xt_classify_target_info)),
+	0,
 	&help,
 	&init,
 	&parse,
extensions/arpt_mangle.c +1 -0
index c38fc16..502fc2b 100644
@@ -199,6 +199,7 @@ struct arptables_target change
     ARPTABLES_VERSION,
     ARPT_ALIGN(sizeof(struct arpt_mangle)),
     ARPT_ALIGN(sizeof(struct arpt_mangle)),
+	0,
     &help,
     &init,
     &parse,
extensions/arpt_standard.c +1 -0
index cb3891d..c647316 100644
@@ -54,6 +54,7 @@ struct arptables_target standard
     ARPTABLES_VERSION,
     ARPT_ALIGN(sizeof(int)),
     ARPT_ALIGN(sizeof(int)),
+	0,
     &help,
     &init,
     &parse,
include/arptables.h +6 -0
index 820b664..82e6e9a 100644
@@ -32,6 +32,9 @@ struct arptables_match
 	/* Size of match data relevent for userspace comparison purposes */
 	size_t userspacesize;
 
+	/* Revision of target (0 by default). */
+	u_int8_t revision;
+
 	/* Function which prints out usage message. */
 	void (*help)(void);
 
@@ -81,6 +84,9 @@ struct arptables_target
 	/* Size of target data relevent for userspace comparison purposes */
 	size_t userspacesize;
 
+	/* Revision of target (0 by default). */
+	u_int8_t revision;
+
 	/* Function which prints out usage message. */
 	void (*help)(void);
 
include/linux/netfilter_arp/arp_tables.h +2 -1
index 0acda66..0bf2457 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,7 @@ 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
1.7.12.4
#2 lore raw

Re: [PATCH V3 1/2] Add revision field for xt_entry_target

Quoted 9 lines · Zhang Chunyu
---
 arptables.c                              | 2 ++
 extensions/arpt_CLASSIFY.c               | 1 +
 extensions/arpt_mangle.c                 | 1 +
 extensions/arpt_standard.c               | 1 +
 include/arptables.h                      | 6 ++++++
 include/linux/netfilter_arp/arp_tables.h | 3 ++-
 6 files changed, 13 insertions(+), 1 deletion(-)

[...]

Quoted 14 lines
include/linux/netfilter_arp/arp_tables.h +1 -1
index 0acda66..0bf2457 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 75

Quoted 7 lines
include/linux/netfilter_arp/arp_tables.h +1 -0
@@ -69,6 +69,7 @@ struct arpt_entry_target
 
 			/* Used by userspace */
 			char name[ARPT_FUNCTION_MAXNAMELEN];
+			u_int8_t revision;
 		} user;
 		struct {
 			u_int16_t target_size;

Could you also resubmit the kernel patch to adds this? Please, no need to resend the full userspace series, just send the kernel patch as a follow up.

#3 lore raw

Re: Re: [PATCH V3 1/2] Add revision field for xt_entry_target

hi pablo

Quoted 31 lines

From: Pablo Neira Ayuso
Date: 2015-03-26
To: Zhang, Chunyu/章 春宇
Subject: Re: [PATCH V3 1/2] Add revision field for xt_entry_target

Quoted 9 lines · Zhang Chunyu
---
 arptables.c                              | 2 ++
 extensions/arpt_CLASSIFY.c               | 1 +
 extensions/arpt_mangle.c                 | 1 +
 extensions/arpt_standard.c               | 1 +
 include/arptables.h                      | 6 ++++++
 include/linux/netfilter_arp/arp_tables.h | 3 ++-
 6 files changed, 13 insertions(+), 1 deletion(-)

[...]

Quoted 15 lines
include/linux/netfilter_arp/arp_tables.h +1 -1
index 0acda66..0bf2457 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,7 @@ struct arpt_entry_target
 
Quoted 10 lines

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

Quoted 6 lines
include/linux/netfilter_arp/arp_tables.h +1 -0
                      /* Used by userspace */
                      char name[ARPT_FUNCTION_MAXNAMELEN];
+                     u_int8_t revision;
              } user;
              struct {
                      u_int16_t target_size;

Could you also resubmit the kernel patch to adds this? Please, no need to resend the full userspace series, just send the kernel patch as a follow up.

do you mean:

include/linux/netfilter_arp/arp_tables.h

Quoted 3 lines
include/linux/netfilter_arp/arp_tables.h +1 -1
-#define ARPT_FUNCTION_MAXNAMELEN 30
 
+#define ARPT_FUNCTION_MAXNAMELEN 29

do this in another patch , like this ?

patch1:  change ARPT_FUNCTION_MAXNAMELEN
patch2:  add revision
patch3:  add arp mark
#4 lore raw

Re: Re: [PATCH V3 1/2] Add revision field for xt_entry_target

Quoted 9 lines · Chunyu
Quoted 8 lines

From: Pablo Neira Ayuso
Date: 2015-03-26
To: Zhang, Chunyu/章 春宇
Subject: Re: [PATCH V3 1/2] Add revision field for xt_entry_target

Could you also resubmit the kernel patch to adds this? Please, no need to resend the full userspace series, just send the kernel patch as a follow up.

Quoted 5 lines

do you mean:

include/linux/netfilter_arp/arp_tables.h

Quoted 3 lines
include/linux/netfilter_arp/arp_tables.h +1 -1
-#define ARPT_FUNCTION_MAXNAMELEN 30
 
+#define ARPT_FUNCTION_MAXNAMELEN 29

do this in another patch , like this ?

I mean this:

http://patchwork.ozlabs.org/patch/437065/

but never mind, I'll take that original patch. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: Re: [PATCH V3 1/2] Add revision field for xt_entry_target

Quoted 18 lines

From: netfilter-devel-owner
Date: 2015-03-27
To: Zhang, Chunyu/章 春宇
Subject: Re: Re: [PATCH V3 1/2] Add revision field for xt_entry_target

Quoted 10 lines · Chunyu
Quoted 8 lines

From: Pablo Neira Ayuso
Date: 2015-03-26
To: Zhang, Chunyu/章 春宇
Subject: Re: [PATCH V3 1/2] Add revision field for xt_entry_target

Could you also resubmit the kernel patch to adds this? Please, no need to resend the full userspace series, just send the kernel patch as a follow up.

do you mean:

Quoted 8 lines
Quoted 4 lines

include/linux/netfilter_arp/arp_tables.h

Quoted 3 lines
include/linux/netfilter_arp/arp_tables.h +1 -1
-#define ARPT_FUNCTION_MAXNAMELEN 30
 
+#define ARPT_FUNCTION_MAXNAMELEN 29

do this in another patch , like this ?

I mean this:

http://patchwork.ozlabs.org/patch/437065/

ok. get it.
will do

Quoted 6 lines

but never mind, I'll take that original patch. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

PATCH v3 2/2 Add MARK target for arptables

In reply to Zhang Chunyu

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

---
 arptables.8            |  17 ++++++
 extensions/Makefile    |   2 +-
 extensions/arpt_MARK.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 169 insertions(+), 1 deletion(-)
 create mode 100644 extensions/arpt_MARK.c
arptables.8 +17 -0
index 78b2c60..676b884 100644
@@ -315,6 +315,23 @@ 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
+
+.TP
+.BR "--and-mark mark"
+Binary AND the mark with bits.
+
+.TP
+.BR "--or-mark mark"
+Binary OR the mark with bits.
+
 .SH MAILINGLISTS
 .BR "" "See " http://netfilter.org/mailinglists.html
 .SH SEE ALSO
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 +151 -0

151 lines not on this page · raw message

Signature · 1 line
1.7.12.4