Commit 5c33448c405adfe1562df76215f24ef0a7947872
Committed by
Pablo Neira Ayuso
1 parent
8746ddcf12
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
netfilter: xt_NFQUEUE: coalesce IPv4 and IPv6 hashing
Because rev1 and rev3 of the target share the same hashing generalize it by introduing nfqueue_hash(). Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Showing 1 changed file with 22 additions and 20 deletions Side-by-side Diff
net/netfilter/xt_NFQUEUE.c
... | ... | @@ -76,22 +76,31 @@ |
76 | 76 | } |
77 | 77 | #endif |
78 | 78 | |
79 | -static unsigned int | |
80 | -nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par) | |
79 | +static u32 | |
80 | +nfqueue_hash(const struct sk_buff *skb, const struct xt_action_param *par) | |
81 | 81 | { |
82 | 82 | const struct xt_NFQ_info_v1 *info = par->targinfo; |
83 | 83 | u32 queue = info->queuenum; |
84 | 84 | |
85 | - if (info->queues_total > 1) { | |
86 | - if (par->family == NFPROTO_IPV4) | |
87 | - queue = (((u64) hash_v4(skb) * info->queues_total) >> | |
88 | - 32) + queue; | |
85 | + if (par->family == NFPROTO_IPV4) | |
86 | + queue += ((u64) hash_v4(skb) * info->queues_total) >> 32; | |
89 | 87 | #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) |
90 | - else if (par->family == NFPROTO_IPV6) | |
91 | - queue = (((u64) hash_v6(skb) * info->queues_total) >> | |
92 | - 32) + queue; | |
88 | + else if (par->family == NFPROTO_IPV6) | |
89 | + queue += ((u64) hash_v6(skb) * info->queues_total) >> 32; | |
93 | 90 | #endif |
94 | - } | |
91 | + | |
92 | + return queue; | |
93 | +} | |
94 | + | |
95 | +static unsigned int | |
96 | +nfqueue_tg_v1(struct sk_buff *skb, const struct xt_action_param *par) | |
97 | +{ | |
98 | + const struct xt_NFQ_info_v1 *info = par->targinfo; | |
99 | + u32 queue = info->queuenum; | |
100 | + | |
101 | + if (info->queues_total > 1) | |
102 | + queue = nfqueue_hash(skb, par); | |
103 | + | |
95 | 104 | return NF_QUEUE_NR(queue); |
96 | 105 | } |
97 | 106 | |
98 | 107 | |
... | ... | @@ -144,17 +153,10 @@ |
144 | 153 | int cpu = smp_processor_id(); |
145 | 154 | |
146 | 155 | queue = info->queuenum + cpu % info->queues_total; |
147 | - } else { | |
148 | - if (par->family == NFPROTO_IPV4) | |
149 | - queue = (((u64) hash_v4(skb) * info->queues_total) >> | |
150 | - 32) + queue; | |
151 | -#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES) | |
152 | - else if (par->family == NFPROTO_IPV6) | |
153 | - queue = (((u64) hash_v6(skb) * info->queues_total) >> | |
154 | - 32) + queue; | |
155 | -#endif | |
156 | - } | |
156 | + } else | |
157 | + queue = nfqueue_hash(skb, par); | |
157 | 158 | } |
159 | + | |
158 | 160 | return NF_QUEUE_NR(queue); |
159 | 161 | } |
160 | 162 |