diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2009-02-27 21:23:57 -0500 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-03-17 10:48:36 -0400 |
commit | 28b949885f80efb87d7cebdcf879c99db12c37bd (patch) | |
tree | f6c0acd5646a899c7eebb91fee856eebd8cbca83 /net | |
parent | 44c5873199a90a45e9d64a86a1f54b1ccab21ec8 (diff) |
netfilter: xtables: merge xt_MARK into xt_mark
Two arguments for combining the two:
- xt_mark is pretty useless without xt_MARK
- the actual code is so small anyway that the kmod metadata and the module
in its loaded state totally outweighs the combined actual code size.
i586-before:
-rw-r--r-- 1 jengelh users 3821 Feb 10 01:01 xt_MARK.ko
-rw-r--r-- 1 jengelh users 2592 Feb 10 00:04 xt_MARK.o
-rw-r--r-- 1 jengelh users 3274 Feb 10 01:01 xt_mark.ko
-rw-r--r-- 1 jengelh users 2108 Feb 10 00:05 xt_mark.o
text data bss dec hex filename
354 264 0 618 26a xt_MARK.o
223 176 0 399 18f xt_mark.o
And the runtime size is like 14 KB.
i586-after:
-rw-r--r-- 1 jengelh users 3264 Feb 18 17:28 xt_mark.o
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/Kconfig | 46 | ||||
-rw-r--r-- | net/netfilter/Makefile | 5 | ||||
-rw-r--r-- | net/netfilter/xt_MARK.c | 56 | ||||
-rw-r--r-- | net/netfilter/xt_mark.c | 35 |
4 files changed, 65 insertions, 77 deletions
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index abf4ce6d1834..236aa20ce5cc 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig | |||
@@ -314,6 +314,23 @@ config NETFILTER_XTABLES | |||
314 | 314 | ||
315 | if NETFILTER_XTABLES | 315 | if NETFILTER_XTABLES |
316 | 316 | ||
317 | comment "Xtables combined modules" | ||
318 | |||
319 | config NETFILTER_XT_MARK | ||
320 | tristate 'nfmark target and match support' | ||
321 | default m if NETFILTER_ADVANCED=n | ||
322 | ---help--- | ||
323 | This option adds the "MARK" target and "mark" match. | ||
324 | |||
325 | Netfilter mark matching allows you to match packets based on the | ||
326 | "nfmark" value in the packet. | ||
327 | The target allows you to create rules in the "mangle" table which alter | ||
328 | the netfilter mark (nfmark) field associated with the packet. | ||
329 | |||
330 | Prior to routing, the nfmark can influence the routing method (see | ||
331 | "Use netfilter MARK value as routing key") and can also be used by | ||
332 | other subsystems to change their behavior. | ||
333 | |||
317 | # alphabetically ordered list of targets | 334 | # alphabetically ordered list of targets |
318 | 335 | ||
319 | comment "Xtables targets" | 336 | comment "Xtables targets" |
@@ -425,16 +442,12 @@ config NETFILTER_XT_TARGET_LED | |||
425 | 442 | ||
426 | config NETFILTER_XT_TARGET_MARK | 443 | config NETFILTER_XT_TARGET_MARK |
427 | tristate '"MARK" target support' | 444 | tristate '"MARK" target support' |
428 | default m if NETFILTER_ADVANCED=n | 445 | depends on NETFILTER_ADVANCED |
429 | help | 446 | select NETFILTER_XT_MARK |
430 | This option adds a `MARK' target, which allows you to create rules | 447 | ---help--- |
431 | in the `mangle' table which alter the netfilter mark (nfmark) field | 448 | This is a backwards-compat option for the user's convenience |
432 | associated with the packet prior to routing. This can change | 449 | (e.g. when running oldconfig). It selects |
433 | the routing method (see `Use netfilter MARK value as routing | 450 | CONFIG_NETFILTER_XT_MARK (combined mark/MARK module). |
434 | key') and can also be used by other subsystems to change their | ||
435 | behavior. | ||
436 | |||
437 | To compile it as a module, choose M here. If unsure, say N. | ||
438 | 451 | ||
439 | config NETFILTER_XT_TARGET_NFLOG | 452 | config NETFILTER_XT_TARGET_NFLOG |
440 | tristate '"NFLOG" target support' | 453 | tristate '"NFLOG" target support' |
@@ -739,13 +752,12 @@ config NETFILTER_XT_MATCH_MAC | |||
739 | 752 | ||
740 | config NETFILTER_XT_MATCH_MARK | 753 | config NETFILTER_XT_MATCH_MARK |
741 | tristate '"mark" match support' | 754 | tristate '"mark" match support' |
742 | default m if NETFILTER_ADVANCED=n | 755 | depends on NETFILTER_ADVANCED |
743 | help | 756 | select NETFILTER_XT_MARK |
744 | Netfilter mark matching allows you to match packets based on the | 757 | ---help--- |
745 | `nfmark' value in the packet. This can be set by the MARK target | 758 | This is a backwards-compat option for the user's convenience |
746 | (see below). | 759 | (e.g. when running oldconfig). It selects |
747 | 760 | CONFIG_NETFILTER_XT_MARK (combined mark/MARK module). | |
748 | To compile it as a module, choose M here. If unsure, say N. | ||
749 | 761 | ||
750 | config NETFILTER_XT_MATCH_MULTIPORT | 762 | config NETFILTER_XT_MATCH_MULTIPORT |
751 | tristate '"multiport" Multiple port match support' | 763 | tristate '"multiport" Multiple port match support' |
diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile index f873644f02f6..19775cc30fe5 100644 --- a/net/netfilter/Makefile +++ b/net/netfilter/Makefile | |||
@@ -40,6 +40,9 @@ obj-$(CONFIG_NETFILTER_TPROXY) += nf_tproxy_core.o | |||
40 | # generic X tables | 40 | # generic X tables |
41 | obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o | 41 | obj-$(CONFIG_NETFILTER_XTABLES) += x_tables.o xt_tcpudp.o |
42 | 42 | ||
43 | # combos | ||
44 | obj-$(CONFIG_NETFILTER_XT_MARK) += xt_mark.o | ||
45 | |||
43 | # targets | 46 | # targets |
44 | obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o | 47 | obj-$(CONFIG_NETFILTER_XT_TARGET_CLASSIFY) += xt_CLASSIFY.o |
45 | obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o | 48 | obj-$(CONFIG_NETFILTER_XT_TARGET_CONNMARK) += xt_CONNMARK.o |
@@ -48,7 +51,6 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_CT) += xt_CT.o | |||
48 | obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o | 51 | obj-$(CONFIG_NETFILTER_XT_TARGET_DSCP) += xt_DSCP.o |
49 | obj-$(CONFIG_NETFILTER_XT_TARGET_HL) += xt_HL.o | 52 | obj-$(CONFIG_NETFILTER_XT_TARGET_HL) += xt_HL.o |
50 | obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o | 53 | obj-$(CONFIG_NETFILTER_XT_TARGET_LED) += xt_LED.o |
51 | obj-$(CONFIG_NETFILTER_XT_TARGET_MARK) += xt_MARK.o | ||
52 | obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o | 54 | obj-$(CONFIG_NETFILTER_XT_TARGET_NFLOG) += xt_NFLOG.o |
53 | obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o | 55 | obj-$(CONFIG_NETFILTER_XT_TARGET_NFQUEUE) += xt_NFQUEUE.o |
54 | obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o | 56 | obj-$(CONFIG_NETFILTER_XT_TARGET_NOTRACK) += xt_NOTRACK.o |
@@ -76,7 +78,6 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_IPRANGE) += xt_iprange.o | |||
76 | obj-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += xt_length.o | 78 | obj-$(CONFIG_NETFILTER_XT_MATCH_LENGTH) += xt_length.o |
77 | obj-$(CONFIG_NETFILTER_XT_MATCH_LIMIT) += xt_limit.o | 79 | obj-$(CONFIG_NETFILTER_XT_MATCH_LIMIT) += xt_limit.o |
78 | obj-$(CONFIG_NETFILTER_XT_MATCH_MAC) += xt_mac.o | 80 | obj-$(CONFIG_NETFILTER_XT_MATCH_MAC) += xt_mac.o |
79 | obj-$(CONFIG_NETFILTER_XT_MATCH_MARK) += xt_mark.o | ||
80 | obj-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += xt_multiport.o | 81 | obj-$(CONFIG_NETFILTER_XT_MATCH_MULTIPORT) += xt_multiport.o |
81 | obj-$(CONFIG_NETFILTER_XT_MATCH_OSF) += xt_osf.o | 82 | obj-$(CONFIG_NETFILTER_XT_MATCH_OSF) += xt_osf.o |
82 | obj-$(CONFIG_NETFILTER_XT_MATCH_OWNER) += xt_owner.o | 83 | obj-$(CONFIG_NETFILTER_XT_MATCH_OWNER) += xt_owner.o |
diff --git a/net/netfilter/xt_MARK.c b/net/netfilter/xt_MARK.c deleted file mode 100644 index 225f8d11e173..000000000000 --- a/net/netfilter/xt_MARK.c +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | /* | ||
2 | * xt_MARK - Netfilter module to modify the NFMARK field of an skb | ||
3 | * | ||
4 | * (C) 1999-2001 Marc Boucher <marc@mbsi.ca> | ||
5 | * Copyright © CC Computer Consultants GmbH, 2007 - 2008 | ||
6 | * Jan Engelhardt <jengelh@computergmbh.de> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/skbuff.h> | ||
15 | #include <linux/ip.h> | ||
16 | #include <net/checksum.h> | ||
17 | |||
18 | #include <linux/netfilter/x_tables.h> | ||
19 | #include <linux/netfilter/xt_MARK.h> | ||
20 | |||
21 | MODULE_LICENSE("GPL"); | ||
22 | MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); | ||
23 | MODULE_DESCRIPTION("Xtables: packet mark modification"); | ||
24 | MODULE_ALIAS("ipt_MARK"); | ||
25 | MODULE_ALIAS("ip6t_MARK"); | ||
26 | |||
27 | static unsigned int | ||
28 | mark_tg(struct sk_buff *skb, const struct xt_target_param *par) | ||
29 | { | ||
30 | const struct xt_mark_tginfo2 *info = par->targinfo; | ||
31 | |||
32 | skb->mark = (skb->mark & ~info->mask) ^ info->mark; | ||
33 | return XT_CONTINUE; | ||
34 | } | ||
35 | |||
36 | static struct xt_target mark_tg_reg __read_mostly = { | ||
37 | .name = "MARK", | ||
38 | .revision = 2, | ||
39 | .family = NFPROTO_UNSPEC, | ||
40 | .target = mark_tg, | ||
41 | .targetsize = sizeof(struct xt_mark_tginfo2), | ||
42 | .me = THIS_MODULE, | ||
43 | }; | ||
44 | |||
45 | static int __init mark_tg_init(void) | ||
46 | { | ||
47 | return xt_register_target(&mark_tg_reg); | ||
48 | } | ||
49 | |||
50 | static void __exit mark_tg_exit(void) | ||
51 | { | ||
52 | xt_unregister_target(&mark_tg_reg); | ||
53 | } | ||
54 | |||
55 | module_init(mark_tg_init); | ||
56 | module_exit(mark_tg_exit); | ||
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c index 1db07d8125f8..035c468a0040 100644 --- a/net/netfilter/xt_mark.c +++ b/net/netfilter/xt_mark.c | |||
@@ -18,9 +18,20 @@ | |||
18 | 18 | ||
19 | MODULE_LICENSE("GPL"); | 19 | MODULE_LICENSE("GPL"); |
20 | MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); | 20 | MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); |
21 | MODULE_DESCRIPTION("Xtables: packet mark match"); | 21 | MODULE_DESCRIPTION("Xtables: packet mark operations"); |
22 | MODULE_ALIAS("ipt_mark"); | 22 | MODULE_ALIAS("ipt_mark"); |
23 | MODULE_ALIAS("ip6t_mark"); | 23 | MODULE_ALIAS("ip6t_mark"); |
24 | MODULE_ALIAS("ipt_MARK"); | ||
25 | MODULE_ALIAS("ip6t_MARK"); | ||
26 | |||
27 | static unsigned int | ||
28 | mark_tg(struct sk_buff *skb, const struct xt_target_param *par) | ||
29 | { | ||
30 | const struct xt_mark_tginfo2 *info = par->targinfo; | ||
31 | |||
32 | skb->mark = (skb->mark & ~info->mask) ^ info->mark; | ||
33 | return XT_CONTINUE; | ||
34 | } | ||
24 | 35 | ||
25 | static bool | 36 | static bool |
26 | mark_mt(const struct sk_buff *skb, const struct xt_match_param *par) | 37 | mark_mt(const struct sk_buff *skb, const struct xt_match_param *par) |
@@ -30,6 +41,15 @@ mark_mt(const struct sk_buff *skb, const struct xt_match_param *par) | |||
30 | return ((skb->mark & info->mask) == info->mark) ^ info->invert; | 41 | return ((skb->mark & info->mask) == info->mark) ^ info->invert; |
31 | } | 42 | } |
32 | 43 | ||
44 | static struct xt_target mark_tg_reg __read_mostly = { | ||
45 | .name = "MARK", | ||
46 | .revision = 2, | ||
47 | .family = NFPROTO_UNSPEC, | ||
48 | .target = mark_tg, | ||
49 | .targetsize = sizeof(struct xt_mark_tginfo2), | ||
50 | .me = THIS_MODULE, | ||
51 | }; | ||
52 | |||
33 | static struct xt_match mark_mt_reg __read_mostly = { | 53 | static struct xt_match mark_mt_reg __read_mostly = { |
34 | .name = "mark", | 54 | .name = "mark", |
35 | .revision = 1, | 55 | .revision = 1, |
@@ -41,12 +61,23 @@ static struct xt_match mark_mt_reg __read_mostly = { | |||
41 | 61 | ||
42 | static int __init mark_mt_init(void) | 62 | static int __init mark_mt_init(void) |
43 | { | 63 | { |
44 | return xt_register_match(&mark_mt_reg); | 64 | int ret; |
65 | |||
66 | ret = xt_register_target(&mark_tg_reg); | ||
67 | if (ret < 0) | ||
68 | return ret; | ||
69 | ret = xt_register_match(&mark_mt_reg); | ||
70 | if (ret < 0) { | ||
71 | xt_unregister_target(&mark_tg_reg); | ||
72 | return ret; | ||
73 | } | ||
74 | return 0; | ||
45 | } | 75 | } |
46 | 76 | ||
47 | static void __exit mark_mt_exit(void) | 77 | static void __exit mark_mt_exit(void) |
48 | { | 78 | { |
49 | xt_unregister_match(&mark_mt_reg); | 79 | xt_unregister_match(&mark_mt_reg); |
80 | xt_unregister_target(&mark_tg_reg); | ||
50 | } | 81 | } |
51 | 82 | ||
52 | module_init(mark_mt_init); | 83 | module_init(mark_mt_init); |