diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-05-08 03:28:19 -0400 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2012-05-08 13:40:49 -0400 |
commit | 6b324dbfc3dc13f0a7e236d3529c31d6bc4edbfe (patch) | |
tree | 4432b7ddd2b70666b4a91195f888b2e27f73f822 /net/netfilter | |
parent | f73181c8288fc38747ec4f0f3e8a9052ab785cd5 (diff) |
ipvs: optimize the use of flags in ip_vs_bind_dest
cp->flags is marked volatile but ip_vs_bind_dest
can safely modify the flags, so save some CPU cycles by
using temp variable.
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/ipvs/ip_vs_conn.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index c7edf2022c3e..1548df9a7524 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c | |||
@@ -548,6 +548,7 @@ static inline void | |||
548 | ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) | 548 | ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) |
549 | { | 549 | { |
550 | unsigned int conn_flags; | 550 | unsigned int conn_flags; |
551 | __u32 flags; | ||
551 | 552 | ||
552 | /* if dest is NULL, then return directly */ | 553 | /* if dest is NULL, then return directly */ |
553 | if (!dest) | 554 | if (!dest) |
@@ -559,17 +560,19 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) | |||
559 | conn_flags = atomic_read(&dest->conn_flags); | 560 | conn_flags = atomic_read(&dest->conn_flags); |
560 | if (cp->protocol != IPPROTO_UDP) | 561 | if (cp->protocol != IPPROTO_UDP) |
561 | conn_flags &= ~IP_VS_CONN_F_ONE_PACKET; | 562 | conn_flags &= ~IP_VS_CONN_F_ONE_PACKET; |
563 | flags = cp->flags; | ||
562 | /* Bind with the destination and its corresponding transmitter */ | 564 | /* Bind with the destination and its corresponding transmitter */ |
563 | if (cp->flags & IP_VS_CONN_F_SYNC) { | 565 | if (flags & IP_VS_CONN_F_SYNC) { |
564 | /* if the connection is not template and is created | 566 | /* if the connection is not template and is created |
565 | * by sync, preserve the activity flag. | 567 | * by sync, preserve the activity flag. |
566 | */ | 568 | */ |
567 | if (!(cp->flags & IP_VS_CONN_F_TEMPLATE)) | 569 | if (!(flags & IP_VS_CONN_F_TEMPLATE)) |
568 | conn_flags &= ~IP_VS_CONN_F_INACTIVE; | 570 | conn_flags &= ~IP_VS_CONN_F_INACTIVE; |
569 | /* connections inherit forwarding method from dest */ | 571 | /* connections inherit forwarding method from dest */ |
570 | cp->flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT); | 572 | flags &= ~(IP_VS_CONN_F_FWD_MASK | IP_VS_CONN_F_NOOUTPUT); |
571 | } | 573 | } |
572 | cp->flags |= conn_flags; | 574 | flags |= conn_flags; |
575 | cp->flags = flags; | ||
573 | cp->dest = dest; | 576 | cp->dest = dest; |
574 | 577 | ||
575 | IP_VS_DBG_BUF(7, "Bind-dest %s c:%s:%d v:%s:%d " | 578 | IP_VS_DBG_BUF(7, "Bind-dest %s c:%s:%d v:%s:%d " |
@@ -584,12 +587,12 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest) | |||
584 | atomic_read(&dest->refcnt)); | 587 | atomic_read(&dest->refcnt)); |
585 | 588 | ||
586 | /* Update the connection counters */ | 589 | /* Update the connection counters */ |
587 | if (!(cp->flags & IP_VS_CONN_F_TEMPLATE)) { | 590 | if (!(flags & IP_VS_CONN_F_TEMPLATE)) { |
588 | /* It is a normal connection, so modify the counters | 591 | /* It is a normal connection, so modify the counters |
589 | * according to the flags, later the protocol can | 592 | * according to the flags, later the protocol can |
590 | * update them on state change | 593 | * update them on state change |
591 | */ | 594 | */ |
592 | if (!(cp->flags & IP_VS_CONN_F_INACTIVE)) | 595 | if (!(flags & IP_VS_CONN_F_INACTIVE)) |
593 | atomic_inc(&dest->activeconns); | 596 | atomic_inc(&dest->activeconns); |
594 | else | 597 | else |
595 | atomic_inc(&dest->inactconns); | 598 | atomic_inc(&dest->inactconns); |