Skip to contentSkip to conversation

rfc: add classify target

arptables In review Frederic Leroy 4 participants 22 messages Nov 7, 2010 – Nov 15, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

I ran into an old problem with Linux [1]. I need to touch the skb->priority field for arp packet in order to map it to vlan cos.

I wrote a new classify target. Patches for both current linux-stable and arptables cvs are joined.

For example, if you wan't to put arp packets on vlan 100 with priority, you can do it like this :

vconfig set_egressmap eth0.100 7 7
arptables -A OUTPUT -o eth0.100 -j classify --set-class 0:7

[1] http://lists.openwall.net/netdev/2007/06/04/71

Signature · 1 line
Frédéric Leroy
arptables.8 +4 -0
diff -r e7c5081f9739 arptables.8
@@ -297,6 +297,10 @@
 .BR "--mangle-target target "
 Target of ARP mangle operation
 .BR "" ( DROP ", " CONTINUE " or " ACCEPT " -- default is " ACCEPT ).
+.SS classify
+.TP
+.BR "--set-class-mac major:minor"
+Classifies arp packet
 
 .SH MAILINGLISTS
 .BR "" "See " http://netfilter.org/mailinglists.html
extensions/Makefile +1 -1
diff -r e7c5081f9739 extensions/Makefile
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=standard mangle
+EXT_FUNC+=standard mangle classify
 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_classify.c new file +112 -0

112 lines not on this page · raw message

include/linux/netfilter_arp/arpt_classify.h new file +9 -0
diff -r e7c5081f9739 include/linux/netfilter_arp/arpt_classify.h
@@ -0,0 +1,9 @@
+#ifndef _ARPT_CLASSIFY_H
+#define _ARPT_CLASSIFY_H
+
+struct arpt_classify
+{
+	__u32 priority;
+};
+
+#endif /* _ARPT_CLASSIFY */
include/linux/netfilter_arp/arpt_classify.h new file +9 -0
new file mode 100644
index 0000000..1bbc6d0
@@ -0,0 +1,9 @@
+#ifndef _ARPT_CLASSIFY_H
+#define _ARPT_CLASSIFY_H
+
+struct arpt_classify
+{
+	__u32 priority;
+};
+
+#endif /* _ARPT_CLASSIFY */
net/ipv4/netfilter/Kconfig +11 -0
index babd1a2..4f10dbf 100644
@@ -386,6 +386,17 @@ config IP_NF_ARP_MANGLE
 	  Allows altering the ARP packet payload: source and destination
 	  hardware and network addresses.
 
+config IP_NF_ARP_CLASSIFY
+	tristate "ARP packet classification target"
+	help
+	  This option adds a `classify' target, which enables the user to set
+	  the priority of an arp packet. Some qdiscs can use this value for
+	  classification, among these are:
+
+  	  atm, cbq, dsmark, pfifo_fast, htb, prio
+
+	  To compile it as a module, choose M here.  If unsure, say N.
+
 endif # IP_NF_ARPTABLES
 
 endmenu
net/ipv4/netfilter/Makefile +1 -0
index 4811159..a5387dc 100644
@@ -65,6 +65,7 @@ obj-$(CONFIG_IP_NF_TARGET_ULOG) += ipt_ULOG.o
 # generic ARP tables
 obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o
 obj-$(CONFIG_IP_NF_ARP_MANGLE) += arpt_mangle.o
+obj-$(CONFIG_IP_NF_ARP_CLASSIFY) += arpt_classify.o
 
 # just filtering instance of ARP tables for now
 obj-$(CONFIG_IP_NF_ARPFILTER) += arptable_filter.o
net/ipv4/netfilter/arpt_classify.c new file +41 -0

41 lines not on this page · raw message

#1 lore raw
Quoted 15 lines · Frederic Leroy

I wrote a new classify target. Patches for both current linux-stable and arptables cvs are joined.

+++ b/net/ipv4/netfilter/arpt_classify.c

net/ipv4/netfilter/arpt_classify.c new file +9 -0
@@ -0,0 +1,41 @@
+/* module that allows classification of arp packet */
+#include <linux/module.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter_arp/arpt_classify.h>
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Frederic Leroy <[email protected]>");
+MODULE_DESCRIPTION("arptables arp classify target");

net/ipv4/netfilter/arpt_classify.c line 19

Quoted 10 lines
net/ipv4/netfilter/arpt_classify.c new file +10 -0
+
+static unsigned int
+target(struct sk_buff *skb, const struct xt_action_param *par)
+{
+	const struct arpt_classify *classify = par->targinfo;
+
+	skb->priority=classify->priority;
+
+	return XT_CONTINUE;
+}

Why did you not update xt_CLASSIFY instead?

#2 lore raw

Am 07.11.2010 16:18, schrieb Jan Engelhardt:

Quoted 20 lines · Frederic Leroy
Quoted 19 lines

I wrote a new classify target. Patches for both current linux-stable and arptables cvs are joined.

+++ b/net/ipv4/netfilter/arpt_classify.c

net/ipv4/netfilter/arpt_classify.c new file +13 -0
@@ -0,0 +1,41 @@
+/* module that allows classification of arp packet */
+#include <linux/module.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter/x_tables.h>
+#include <linux/netfilter_arp/arpt_classify.h>
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Frederic Leroy <[email protected]>");
+MODULE_DESCRIPTION("arptables arp classify target");
+
+static unsigned int
+target(struct sk_buff *skb, const struct xt_action_param *par)
+{
Quoted 8 lines

net/ipv4/netfilter/arpt_classify.c line 19

Quoted 6 lines
net/ipv4/netfilter/arpt_classify.c new file +6 -0
+	const struct arpt_classify *classify = par->targinfo;
+
+	skb->priority=classify->priority;
+
+	return XT_CONTINUE;
+}

Why did you not update xt_CLASSIFY instead?

Actually we already register for NFPROTO_UNSPEC, so simply adding a userspace extension should do the job.

#3 lore raw
Quoted 4 lines · Patrick McHardy

Am 07.11.2010 16:18, schrieb Jan Engelhardt:

Quoted 1 line · Frederic Leroy

Actually we already register for NFPROTO_UNSPEC, so simply adding a userspace extension should do the job.

Not really, the mangle table for arp seems to be inexistnet. And hacking and using the filter table I got arptables complaining about chain INPUT missing although the command line with -A OUTPUT.

It seems there need a big work on arptables userspace side.

Signature · 5 lines
Frédéric Leroy
--
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
#4 lore raw

Am 09.11.2010 17:10, schrieb Frederic Leroy:

Quoted 11 lines · Patrick McHardy
Quoted 4 lines

Am 07.11.2010 16:18, schrieb Jan Engelhardt:

Quoted 1 line · Frederic Leroy

Actually we already register for NFPROTO_UNSPEC, so simply adding a userspace extension should do the job.

Not really, the mangle table for arp seems to be inexistnet. And hacking and using the filter table I got arptables complaining about chain INPUT missing although the command line with -A OUTPUT.

It seems there need a big work on arptables userspace side.

Actually there is no technical reason for limiting the CLASSIFY target to the mangle table. You can simply remove this.

#5 lore raw
In reply to Frederic Leroy

Op 9/11/2010 17:10, Frederic Leroy schreef:

Quoted 11 lines · Patrick McHardy
Quoted 4 lines

Am 07.11.2010 16:18, schrieb Jan Engelhardt:

Quoted 1 line · Frederic Leroy

Actually we already register for NFPROTO_UNSPEC, so simply adding a userspace extension should do the job.

Not really, the mangle table for arp seems to be inexistnet. And hacking and using the filter table I got arptables complaining about chain INPUT missing although the command line with -A OUTPUT.

It seems there need a big work on arptables userspace side.

I'm not sure why you think this requires a lot of work on the userspace side. If you get stuck, feel free to post what you already have and I'll have a look at it. As it seems the kernel functionality is already there, I'd be glad to submit your userspace patch.

Best regards,
Bart

Signature · 2 lines
Bart De Schuymer
www.artinalgorithms.be
#6 lore raw

Hello Bart,

Quoted 10 lines · Bart De Schuymer

Op 9/11/2010 17:10, Frederic Leroy schreef:

Quoted 9 lines · Patrick McHardy
Quoted 4 lines

Am 07.11.2010 16:18, schrieb Jan Engelhardt:

Quoted 1 line · Frederic Leroy

Actually we already register for NFPROTO_UNSPEC, so simply adding a userspace extension should do the job.

Not really, the mangle table for arp seems to be inexistnet. And hacking and using the filter table I got arptables complaining about chain INPUT missing although the command line with -A OUTPUT.

Quoted 6 lines
Quoted 2 lines

It seems there need a big work on arptables userspace side.

I'm not sure why you think this requires a lot of work on the userspace side. If you get stuck, feel free to post what you already have and I'll have a look at it. As it seems the kernel functionality is already there, I'd be glad to submit your userspace patch.

It may not requires a lot of work to the userspace side, but it doesn't seem straight for me.
By the way, I joined what I've done for the moment. My free time is sparse, but I wan't to go until the end :)

+#include <linux/netfilter/xt_CLASSIFY.h>

I have a doubt with this include because arptables have copies of the kernel header. Should I copy it in arptables ? (compiles fine without it here)

For the kernel part,I didn't add modalias command because the userspace don't work yet :

# ./arptables -A OUTPUT -o eth0 -j CLASSIFY --set-class 0:7
x_tables: arp_tables: CLASSIFY target: used from hooks INPUT, but only
usable from FORWARD/OUTPUT/POSTROUTING
Signature · 1 line
Frédéric Leroy

commit 01c54593df8a3e975d76b1ab745abdc26b477379

Author: Frédéric Leroy <[email protected]>
Date:   Tue Nov 9 20:54:47 2010 +0100

netfilter: xtables: allow xt_CLASSIFY in all tables

net/netfilter/xt_CLASSIFY.c +0 -1
index c2c0e4a..eb7057a 100644
@@ -39,7 +39,6 @@ static struct xt_target classify_tg_reg __read_mostly = {
 	.name       = "CLASSIFY",
 	.revision   = 0,
 	.family     = NFPROTO_UNSPEC,
-	.table      = "mangle",
 	.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
 		      (1 << NF_INET_POST_ROUTING),
 	.target     = classify_tg,
arptables.8 +4 -0
diff -r e7c5081f9739 arptables.8
@@ -297,6 +297,10 @@
 .BR "--mangle-target target "
 Target of ARP mangle operation
 .BR "" ( DROP ", " CONTINUE " or " ACCEPT " -- default is " ACCEPT ).
+.SS CLASSIFY
+.TP
+.BR "--set-class-mac major:minor"
+Classifies arp packet
 
 .SH MAILINGLISTS
 .BR "" "See " http://netfilter.org/mailinglists.html
extensions/Makefile +1 -1
diff -r e7c5081f9739 extensions/Makefile
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=standard mangle
+EXT_FUNC+=standard mangle CLASSIFY
 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_CLASSIFY.c new file +112 -0

112 lines not on this page · raw message

#7 lore raw
Quoted 7 lines · Frederic Leroy

For the kernel part,I didn't add modalias command because the userspace don't work yet :

# ./arptables -A OUTPUT -o eth0 -j CLASSIFY --set-class 0:7
x_tables: arp_tables: CLASSIFY target: used from hooks INPUT, but only
usable from FORWARD/OUTPUT/POSTROUTING

Here we have a perfect example of the dentrimentality of code duplication. Hooray for NF_ARP_* not matching NF_INET_*.

Alas, when I originally coded NFPROTO_UNSPEC wildcard support, I allowed for same-rev overloading, as in:

static struct xt_target classify_tg_reg[] __read_mostly = {
{
.name = "CLASSIFY",
.revision = 0,
.family = NFPROTO_UNSPEC,
.table = "mangle",
.hooks = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
(1 << NF_INET_POST_ROUTING),
.target = classify_tg,
.targetsize = sizeof(struct xt_classify_target_info),
.me = THIS_MODULE,
},
{
.name = "CLASSIFY",
.revision = 0,
.family = NFPROTO_ARP,
.hooks = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORDWARD),
.target = classify_tg,
.targetsize = sizeof(struct xt_classify_target_info),
.me = THIS_MODULE,
},
};

This should nicely work around the NF_ARP_* hook number deviation for the time being.

#8 lore raw
Quoted 11 lines · Jan Engelhardt
Quoted 7 lines · Frederic Leroy

For the kernel part,I didn't add modalias command because the userspace don't work yet :

# ./arptables -A OUTPUT -o eth0 -j CLASSIFY --set-class 0:7
x_tables: arp_tables: CLASSIFY target: used from hooks INPUT, but
only usable from FORWARD/OUTPUT/POSTROUTING

Here we have a perfect example of the dentrimentality of code duplication. Hooray for NF_ARP_* not matching NF_INET_*.

It was what saying me that it would be a lot of work. Move arptables to match NF_INET_*

Signature · 5 lines
Frédéric Leroy
--
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
#9 lore raw
Quoted 9 lines · Frederic Leroy
Quoted 9 lines · Frederic Leroy
Quoted 7 lines

For the kernel part,I didn't add modalias command because the userspace don't work yet :

# ./arptables -A OUTPUT -o eth0 -j CLASSIFY --set-class 0:7
x_tables: arp_tables: CLASSIFY target: used from hooks INPUT, but
only usable from FORWARD/OUTPUT/POSTROUTING
Quoted 5 lines
Quoted 2 lines

Here we have a perfect example of the dentrimentality of code duplication. Hooray for NF_ARP_* not matching NF_INET_*.

It was what saying me that it would be a lot of work. Move arptables to match NF_INET_*

The actual work is minimal - since you just need to change the values of the NF_ARP_ constants. The problem is that it is shared with userspace.

#10 lore raw
Quoted 14 lines · Jan Engelhardt
Quoted 12 lines · Frederic Leroy
Quoted 11 lines · Frederic Leroy
Quoted 7 lines

For the kernel part,I didn't add modalias command because the userspace don't work yet :

# ./arptables -A OUTPUT -o eth0 -j CLASSIFY --set-class 0:7
x_tables: arp_tables: CLASSIFY target: used from hooks INPUT, but
only usable from FORWARD/OUTPUT/POSTROUTING

Here we have a perfect example of the dentrimentality of code duplication. Hooray for NF_ARP_* not matching NF_INET_*.

Quoted 6 lines
Quoted 2 lines

It was what saying me that it would be a lot of work. Move arptables to match NF_INET_*

The actual work is minimal - since you just need to change the values of the NF_ARP_ constants. The problem is that it is shared with userspace.

If I remember correctly what I've see sunday, there is some arrays of size : number of NF_ARP*
There is some code with ->hook[NF_xxx]=yyy

Moreover, when I turned debug on, it outputs me warnings with overflow on these arrays when I switched to NF_INET.

Signature · 5 lines
Frédéric Leroy
--
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
#11 lore raw
In reply to Jan Engelhardt
Quoted 8 lines · Jan Engelhardt

Alas, when I originally coded NFPROTO_UNSPEC wildcard support, I allowed for same-rev overloading, as in:

static struct xt_target classify_tg_reg[] __read_mostly = {
	{

[...]
};

Here is a patch against my previous patch with your insights. I had time to test it.

Signature · 1 line
Frédéric Leroy

commit fdf76e03e17b7d4cd5a160ee3a5b005859eff2fd

Author: Frédéric Leroy <[email protected]>
Date:   Tue Nov 9 21:46:29 2010 +0100

netfilter: xtables: allow xt_CLASSIFY for arp tables

net/netfilter/xt_CLASSIFY.c +24 -11
index eb7057a..add7435 100644
@@ -19,6 +19,7 @@
 #include <linux/netfilter_ipv6.h>
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter/xt_CLASSIFY.h>
+#include <linux/netfilter_arp.h>
 
 MODULE_AUTHOR("Patrick McHardy <[email protected]>");
 MODULE_LICENSE("GPL");
@@ -35,25 +36,37 @@ classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
 	return XT_CONTINUE;
 }
 
-static struct xt_target classify_tg_reg __read_mostly = {
-	.name       = "CLASSIFY",
-	.revision   = 0,
-	.family     = NFPROTO_UNSPEC,
-	.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
-		      (1 << NF_INET_POST_ROUTING),
-	.target     = classify_tg,
-	.targetsize = sizeof(struct xt_classify_target_info),
-	.me         = THIS_MODULE,
+static struct xt_target classify_tg_reg[] __read_mostly = {
+	{
+		.name       = "CLASSIFY",
+		.revision   = 0,
+		.family     = NFPROTO_UNSPEC,
+		.table      = "mangle",
+		.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
+		              (1 << NF_INET_POST_ROUTING),
+		.target     = classify_tg,
+		.targetsize = sizeof(struct xt_classify_target_info),
+		.me         = THIS_MODULE,
+	},
+	{
+		.name       = "CLASSIFY",
+		.revision   = 0,
+		.family     = NFPROTO_ARP,
+		.hooks      = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
+		.target     = classify_tg,
+		.targetsize = sizeof(struct xt_classify_target_info),
+		.me         = THIS_MODULE,
+	},
 };
 
 static int __init classify_tg_init(void)
 {
-	return xt_register_target(&classify_tg_reg);
+	return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
 }
 
 static void __exit classify_tg_exit(void)
 {
-	xt_unregister_target(&classify_tg_reg);
+	xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
 }
 
 module_init(classify_tg_init);
#12 lore raw
Quoted 6 lines · Frederic Leroy
Quoted 3 lines · Jan Engelhardt

Alas, when I originally coded NFPROTO_UNSPEC wildcard support, I allowed for same-rev overloading, as in:

Quoted 8 lines
Quoted 5 lines
static struct xt_target classify_tg_reg[] __read_mostly = {
	{

[...]
};

Here is a patch against my previous patch with your insights. I had time to test it.

This seems like the best we can do for now. Does it work as intended? --
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

#13 lore raw
Quoted 13 lines · Patrick McHardy
Quoted 12 lines · Frederic Leroy
Quoted 8 lines · Jan Engelhardt

Alas, when I originally coded NFPROTO_UNSPEC wildcard support, I allowed for same-rev overloading, as in:

static struct xt_target classify_tg_reg[] __read_mostly = {
	{

[...]
};

Quoted 4 lines
Quoted 2 lines

Here is a patch against my previous patch with your insights. I had time to test it.

This seems like the best we can do for now. Does it work as intended?

Yes, it works as intended.

Nevertheless, I plan to update kernel and arptables to match NF_INET_*. I should have time to do it for sunday.

Signature · 5 lines
Frédéric Leroy
--
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
#14 lore raw
Quoted 19 lines · Frederic Leroy
Quoted 16 lines · Patrick McHardy
Quoted 14 lines · Frederic Leroy
Quoted 8 lines · Jan Engelhardt

Alas, when I originally coded NFPROTO_UNSPEC wildcard support, I allowed for same-rev overloading, as in:

static struct xt_target classify_tg_reg[] __read_mostly = {
	{

[...]
};

Here is a patch against my previous patch with your insights. I had time to test it.

Quoted 6 lines
Quoted 1 line

This seems like the best we can do for now. Does it work as intended?

Yes, it works as intended.

Nevertheless, I plan to update kernel and arptables to match NF_INET_*. I should have time to do it for sunday.

You can't change the numerical values, that would break compatibility. That basically leaves the option of using NF_INET_PRE_ROUTING instead of NF_ARP_IN etc, which would make things highly confusing :)
--
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

#15 lore raw
Quoted 7 lines · Patrick McHardy
Quoted 2 lines · Frederic Leroy

Le Thu, 11 Nov 2010 11:38:41 +0100,
Patrick McHardy <[email protected]> a écrit :

You can't change the numerical values, that would break compatibility. That basically leaves the option of using NF_INET_PRE_ROUTING instead of NF_ARP_IN etc, which would make things highly confusing :)

There is no much use of NF_ARP_* in the google codesearch world, but I understand the need to not break compatibility.

So I joined my last patches to xt_CLASSIFY and arptables.

I checked that :
- modules are autoloaded
- it works as intended for marking cos on vlan interface.

Signature · 1 line
Frédéric Leroy
arptables.8 +4 -0
diff -r e7c5081f9739 arptables.8
@@ -297,6 +297,10 @@
 .BR "--mangle-target target "
 Target of ARP mangle operation
 .BR "" ( DROP ", " CONTINUE " or " ACCEPT " -- default is " ACCEPT ).
+.SS CLASSIFY
+.TP
+.BR "--set-class-mac major:minor"
+Classifies arp packet
 
 .SH MAILINGLISTS
 .BR "" "See " http://netfilter.org/mailinglists.html
extensions/Makefile +1 -1
diff -r e7c5081f9739 extensions/Makefile
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=standard mangle
+EXT_FUNC+=standard mangle CLASSIFY
 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_CLASSIFY.c new file +112 -0

112 lines not on this page · raw message

commit 80e6be1186004e7f325482c0f151ab9c9fad155f

Author: Frédéric Leroy <[email protected]>
Date:   Sat Nov 13 16:16:43 2010 +0100

netfilter: xtables: add arp support, allow CLASSIFY target on any table

net/netfilter/xt_CLASSIFY.c +24 -12
index c2c0e4a..af9c4da 100644
@@ -19,12 +19,14 @@
 #include <linux/netfilter_ipv6.h>
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter/xt_CLASSIFY.h>
+#include <linux/netfilter_arp.h>
 
 MODULE_AUTHOR("Patrick McHardy <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Xtables: Qdisc classification");
 MODULE_ALIAS("ipt_CLASSIFY");
 MODULE_ALIAS("ip6t_CLASSIFY");
+MODULE_ALIAS("arpt_CLASSIFY");
 
 static unsigned int
 classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
@@ -35,26 +37,36 @@ classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
 	return XT_CONTINUE;
 }
 
-static struct xt_target classify_tg_reg __read_mostly = {
-	.name       = "CLASSIFY",
-	.revision   = 0,
-	.family     = NFPROTO_UNSPEC,
-	.table      = "mangle",
-	.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
-		      (1 << NF_INET_POST_ROUTING),
-	.target     = classify_tg,
-	.targetsize = sizeof(struct xt_classify_target_info),
-	.me         = THIS_MODULE,
+static struct xt_target classify_tg_reg[] __read_mostly = {
+	{
+		.name       = "CLASSIFY",
+		.revision   = 0,
+		.family     = NFPROTO_UNSPEC,
+		.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
+		              (1 << NF_INET_POST_ROUTING),
+		.target     = classify_tg,
+		.targetsize = sizeof(struct xt_classify_target_info),
+		.me         = THIS_MODULE,
+	},
+	{
+		.name       = "CLASSIFY",
+		.revision   = 0,
+		.family     = NFPROTO_ARP,
+		.hooks      = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
+		.target     = classify_tg,
+		.targetsize = sizeof(struct xt_classify_target_info),
+		.me         = THIS_MODULE,
+	},
 };
 
 static int __init classify_tg_init(void)
 {
-	return xt_register_target(&classify_tg_reg);
+	return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
 }
 
 static void __exit classify_tg_exit(void)
 {
-	xt_unregister_target(&classify_tg_reg);
+	xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
 }
 
 module_init(classify_tg_init);
#16 lore raw

Apart from my comments below, the userspace patch looks ok:
- I would line up the help and man page entries between arptables and iptables so noone gets confused. Also, the man page entry refers to set-class-mac.
- In final_check() you should make sure that the priority has been set (similar to what's done in libxt_CLASSIFY.c).

cheers,
Bart

Quoted 18 lines · Frederic Leroy
Quoted 6 lines · Patrick McHardy
Quoted 2 lines · Frederic Leroy

Le Thu, 11 Nov 2010 11:38:41 +0100,
Patrick McHardy <[email protected]> a écrit :

You can't change the numerical values, that would break compatibility. That basically leaves the option of using NF_INET_PRE_ROUTING instead of NF_ARP_IN etc, which would make things highly confusing :)

There is no much use of NF_ARP_* in the google codesearch world, but I understand the need to not break compatibility.

So I joined my last patches to xt_CLASSIFY and arptables.

I checked that :
- modules are autoloaded
- it works as intended for marking cos on vlan interface.

Signature · 7 lines
Bart De Schuymer
www.artinalgorithms.be

--
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
#17 lore raw
Quoted 6 lines · Bart De Schuymer

Apart from my comments below, the userspace patch looks ok:
- I would line up the help and man page entries between arptables and iptables so noone gets confused. Also, the man page entry refers to set-class-mac.
- In final_check() you should make sure that the priority has been set (similar to what's done in libxt_CLASSIFY.c).

Here it is, largely borrowed from iptables.

Cheers,

Signature · 1 line
Frédéric Leroy
arptables.8 +9 -0
diff -r e7c5081f9739 arptables.8
@@ -297,6 +297,15 @@
 .BR "--mangle-target target "
 Target of ARP mangle operation
 .BR "" ( DROP ", " CONTINUE " or " ACCEPT " -- default is " ACCEPT ).
+.SS CLASSIFY
+This  module  allows you to set the skb->priority value (and thus clas-
+sify the packet into a specific CBQ class).
+
+.TP
+.BR "--set-class major:minor"
+
+Set the major and minor  class  value.  The  values  are  always
+interpreted as hexadecimal even if no 0x prefix is given.
 
 .SH MAILINGLISTS
 .BR "" "See " http://netfilter.org/mailinglists.html
extensions/Makefile +1 -1
diff -r e7c5081f9739 extensions/Makefile
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=standard mangle
+EXT_FUNC+=standard mangle CLASSIFY
 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_CLASSIFY.c new file +121 -0

121 lines not on this page · raw message

#18 lore raw

Applied,

Thanks Frederic.

Bart

Quoted 13 lines · Frederic Leroy
Quoted 6 lines · Bart De Schuymer

Apart from my comments below, the userspace patch looks ok:
- I would line up the help and man page entries between arptables and iptables so noone gets confused. Also, the man page entry refers to set-class-mac.
- In final_check() you should make sure that the priority has been set (similar to what's done in libxt_CLASSIFY.c).

Here it is, largely borrowed from iptables.

Cheers,

Signature · 7 lines
Bart De Schuymer
www.artinalgorithms.be

--
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
#19 lore raw
In reply to Frederic Leroy
Quoted 11 lines · Frederic Leroy
Quoted 7 lines · Patrick McHardy
Quoted 2 lines · Frederic Leroy

Le Thu, 11 Nov 2010 11:38:41 +0100,
Patrick McHardy <[email protected]> a écrit :

You can't change the numerical values, that would break compatibility. That basically leaves the option of using NF_INET_PRE_ROUTING instead of NF_ARP_IN etc, which would make things highly confusing :)

Quoted 9 lines

There is no much use of NF_ARP_* in the google codesearch world, but I understand the need to not break compatibility.

So I joined my last patches to xt_CLASSIFY and arptables.

I checked that :
- modules are autoloaded
- it works as intended for marking cos on vlan interface.

Thanks. Please add a Signed-off-by: line to your patch and I'll apply it.
--
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

#20 lore raw

PATCH 1/1 netfilter: xtables: add arp support, allow CLASSIFY target on any table

---
 net/netfilter/xt_CLASSIFY.c |   36 ++++++++++++++++++++++++------------
 1 files changed, 24 insertions(+), 12 deletions(-)
net/netfilter/xt_CLASSIFY.c +24 -12
index c2c0e4a..af9c4da 100644
@@ -19,12 +19,14 @@
 #include <linux/netfilter_ipv6.h>
 #include <linux/netfilter/x_tables.h>
 #include <linux/netfilter/xt_CLASSIFY.h>
+#include <linux/netfilter_arp.h>
 
 MODULE_AUTHOR("Patrick McHardy <[email protected]>");
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Xtables: Qdisc classification");
 MODULE_ALIAS("ipt_CLASSIFY");
 MODULE_ALIAS("ip6t_CLASSIFY");
+MODULE_ALIAS("arpt_CLASSIFY");
 
 static unsigned int
 classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
@@ -35,26 +37,36 @@ classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
 	return XT_CONTINUE;
 }
 
-static struct xt_target classify_tg_reg __read_mostly = {
-	.name       = "CLASSIFY",
-	.revision   = 0,
-	.family     = NFPROTO_UNSPEC,
-	.table      = "mangle",
-	.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
-		      (1 << NF_INET_POST_ROUTING),
-	.target     = classify_tg,
-	.targetsize = sizeof(struct xt_classify_target_info),
-	.me         = THIS_MODULE,
+static struct xt_target classify_tg_reg[] __read_mostly = {
+	{
+		.name       = "CLASSIFY",
+		.revision   = 0,
+		.family     = NFPROTO_UNSPEC,
+		.hooks      = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
+		              (1 << NF_INET_POST_ROUTING),
+		.target     = classify_tg,
+		.targetsize = sizeof(struct xt_classify_target_info),
+		.me         = THIS_MODULE,
+	},
+	{
+		.name       = "CLASSIFY",
+		.revision   = 0,
+		.family     = NFPROTO_ARP,
+		.hooks      = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
+		.target     = classify_tg,
+		.targetsize = sizeof(struct xt_classify_target_info),
+		.me         = THIS_MODULE,
+	},
 };
 
 static int __init classify_tg_init(void)
 {
-	return xt_register_target(&classify_tg_reg);
+	return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
 }
 
 static void __exit classify_tg_exit(void)
 {
-	xt_unregister_target(&classify_tg_reg);
+	xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
 }
 
 module_init(classify_tg_init);
Signature · 6 lines
1.7.2.3

--
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