aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2009-06-05 09:22:15 -0400
committerPatrick McHardy <kaber@trash.net>2010-03-17 10:48:35 -0400
commitf76a47c83247b453f25629618056a6d2c1e39103 (patch)
treee64261ff64e89b4853e7c25519f150e93ff90106
parent076f7839dd30b379f3cd468b13cf513cdcd5cee7 (diff)
netfilter: xt_NFQUEUE: consolidate v4/v6 targets into one
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
-rw-r--r--net/netfilter/xt_NFQUEUE.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c
index 12dcd7007c3e..a37e2166858e 100644
--- a/net/netfilter/xt_NFQUEUE.c
+++ b/net/netfilter/xt_NFQUEUE.c
@@ -49,17 +49,6 @@ static u32 hash_v4(const struct sk_buff *skb)
49 return jhash_2words((__force u32)ipaddr, iph->protocol, jhash_initval); 49 return jhash_2words((__force u32)ipaddr, iph->protocol, jhash_initval);
50} 50}
51 51
52static unsigned int
53nfqueue_tg4_v1(struct sk_buff *skb, const struct xt_target_param *par)
54{
55 const struct xt_NFQ_info_v1 *info = par->targinfo;
56 u32 queue = info->queuenum;
57
58 if (info->queues_total > 1)
59 queue = hash_v4(skb) % info->queues_total + queue;
60 return NF_QUEUE_NR(queue);
61}
62
63#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE) 52#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
64static u32 hash_v6(const struct sk_buff *skb) 53static u32 hash_v6(const struct sk_buff *skb)
65{ 54{
@@ -73,18 +62,24 @@ static u32 hash_v6(const struct sk_buff *skb)
73 62
74 return jhash2((__force u32 *)addr, ARRAY_SIZE(addr), jhash_initval); 63 return jhash2((__force u32 *)addr, ARRAY_SIZE(addr), jhash_initval);
75} 64}
65#endif
76 66
77static unsigned int 67static unsigned int
78nfqueue_tg6_v1(struct sk_buff *skb, const struct xt_target_param *par) 68nfqueue_tg_v1(struct sk_buff *skb, const struct xt_target_param *par)
79{ 69{
80 const struct xt_NFQ_info_v1 *info = par->targinfo; 70 const struct xt_NFQ_info_v1 *info = par->targinfo;
81 u32 queue = info->queuenum; 71 u32 queue = info->queuenum;
82 72
83 if (info->queues_total > 1) 73 if (info->queues_total > 1) {
84 queue = hash_v6(skb) % info->queues_total + queue; 74 if (par->target->family == NFPROTO_IPV4)
75 queue = hash_v4(skb) % info->queues_total + queue;
76#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
77 else if (par->target->family == NFPROTO_IPV6)
78 queue = hash_v6(skb) % info->queues_total + queue;
79#endif
80 }
85 return NF_QUEUE_NR(queue); 81 return NF_QUEUE_NR(queue);
86} 82}
87#endif
88 83
89static bool nfqueue_tg_v1_check(const struct xt_tgchk_param *par) 84static bool nfqueue_tg_v1_check(const struct xt_tgchk_param *par)
90{ 85{
@@ -119,23 +114,12 @@ static struct xt_target nfqueue_tg_reg[] __read_mostly = {
119 { 114 {
120 .name = "NFQUEUE", 115 .name = "NFQUEUE",
121 .revision = 1, 116 .revision = 1,
122 .family = NFPROTO_IPV4, 117 .family = NFPROTO_UNSPEC,
123 .checkentry = nfqueue_tg_v1_check,
124 .target = nfqueue_tg4_v1,
125 .targetsize = sizeof(struct xt_NFQ_info_v1),
126 .me = THIS_MODULE,
127 },
128#if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
129 {
130 .name = "NFQUEUE",
131 .revision = 1,
132 .family = NFPROTO_IPV6,
133 .checkentry = nfqueue_tg_v1_check, 118 .checkentry = nfqueue_tg_v1_check,
134 .target = nfqueue_tg6_v1, 119 .target = nfqueue_tg_v1,
135 .targetsize = sizeof(struct xt_NFQ_info_v1), 120 .targetsize = sizeof(struct xt_NFQ_info_v1),
136 .me = THIS_MODULE, 121 .me = THIS_MODULE,
137 }, 122 },
138#endif
139}; 123};
140 124
141static int __init nfqueue_tg_init(void) 125static int __init nfqueue_tg_init(void)