diff options
author | Julian Anastasov <ja@ssi.bg> | 2013-03-21 05:58:11 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2013-04-01 18:23:45 -0400 |
commit | 1845ed0bb29fa7864781021e0c8d06af318f358a (patch) | |
tree | 022aa226f2c66912dcd79c61606d21782e759e7f /net/netfilter | |
parent | 088339a57d6042a8a19a3d5794594b558cd7b624 (diff) |
ipvs: reorder keys in connection structure
__ip_vs_conn_in_get and ip_vs_conn_out_get are
hot places. Optimize them, so that ports are matched first.
By moving net and fwmark below, on 32-bit arch we can fit
caddr in 32-byte cache line and all addresses in 64-byte
cache line.
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off by: Hans Schillstrom <hans@schillstrom.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_conn.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index b0cd2be01d75..416015b34c23 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c | |||
@@ -265,8 +265,8 @@ __ip_vs_conn_in_get(const struct ip_vs_conn_param *p) | |||
265 | rcu_read_lock(); | 265 | rcu_read_lock(); |
266 | 266 | ||
267 | hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) { | 267 | hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) { |
268 | if (cp->af == p->af && | 268 | if (p->cport == cp->cport && p->vport == cp->vport && |
269 | p->cport == cp->cport && p->vport == cp->vport && | 269 | cp->af == p->af && |
270 | ip_vs_addr_equal(p->af, p->caddr, &cp->caddr) && | 270 | ip_vs_addr_equal(p->af, p->caddr, &cp->caddr) && |
271 | ip_vs_addr_equal(p->af, p->vaddr, &cp->vaddr) && | 271 | ip_vs_addr_equal(p->af, p->vaddr, &cp->vaddr) && |
272 | ((!p->cport) ^ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) && | 272 | ((!p->cport) ^ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) && |
@@ -350,9 +350,9 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p) | |||
350 | rcu_read_lock(); | 350 | rcu_read_lock(); |
351 | 351 | ||
352 | hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) { | 352 | hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) { |
353 | if (!ip_vs_conn_net_eq(cp, p->net)) | 353 | if (unlikely(p->pe_data && p->pe->ct_match)) { |
354 | continue; | 354 | if (!ip_vs_conn_net_eq(cp, p->net)) |
355 | if (p->pe_data && p->pe->ct_match) { | 355 | continue; |
356 | if (p->pe == cp->pe && p->pe->ct_match(p, cp)) { | 356 | if (p->pe == cp->pe && p->pe->ct_match(p, cp)) { |
357 | if (__ip_vs_conn_get(cp)) | 357 | if (__ip_vs_conn_get(cp)) |
358 | goto out; | 358 | goto out; |
@@ -366,9 +366,10 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p) | |||
366 | * p->vaddr is a fwmark */ | 366 | * p->vaddr is a fwmark */ |
367 | ip_vs_addr_equal(p->protocol == IPPROTO_IP ? AF_UNSPEC : | 367 | ip_vs_addr_equal(p->protocol == IPPROTO_IP ? AF_UNSPEC : |
368 | p->af, p->vaddr, &cp->vaddr) && | 368 | p->af, p->vaddr, &cp->vaddr) && |
369 | p->cport == cp->cport && p->vport == cp->vport && | 369 | p->vport == cp->vport && p->cport == cp->cport && |
370 | cp->flags & IP_VS_CONN_F_TEMPLATE && | 370 | cp->flags & IP_VS_CONN_F_TEMPLATE && |
371 | p->protocol == cp->protocol) { | 371 | p->protocol == cp->protocol && |
372 | ip_vs_conn_net_eq(cp, p->net)) { | ||
372 | if (__ip_vs_conn_get(cp)) | 373 | if (__ip_vs_conn_get(cp)) |
373 | goto out; | 374 | goto out; |
374 | } | 375 | } |
@@ -404,8 +405,8 @@ struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p) | |||
404 | rcu_read_lock(); | 405 | rcu_read_lock(); |
405 | 406 | ||
406 | hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) { | 407 | hlist_for_each_entry_rcu(cp, &ip_vs_conn_tab[hash], c_list) { |
407 | if (cp->af == p->af && | 408 | if (p->vport == cp->cport && p->cport == cp->dport && |
408 | p->vport == cp->cport && p->cport == cp->dport && | 409 | cp->af == p->af && |
409 | ip_vs_addr_equal(p->af, p->vaddr, &cp->caddr) && | 410 | ip_vs_addr_equal(p->af, p->vaddr, &cp->caddr) && |
410 | ip_vs_addr_equal(p->af, p->caddr, &cp->daddr) && | 411 | ip_vs_addr_equal(p->af, p->caddr, &cp->daddr) && |
411 | p->protocol == cp->protocol && | 412 | p->protocol == cp->protocol && |