List Info

Thread: ip_conntrack_ftp: improve performance of update_nl_seq




ip_conntrack_ftp: improve performance of update_nl_seq
country flaguser name
China
2007-05-28 09:48:45
[NETFILTER]: nf_conntrack_ftp: Improve the performance of
update_nl_seq by using
temporary variables and changing the sequence of program.

----
Signed-off-by: xiaosuo <xiaosuogmail.com>
----
 ip_conntrack_ftp.c |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
----
--- linux/net/ipv4/netfilter/ip_conntrack_ftp.c 2007-05-28
21:59:22.000000000
+0800
+++ linux-new/net/ipv4/netfilter/ip_conntrack_ftp.c    
2007-05-28
22:36:07.000000000 +0800
 -264,25
+264,28 
 static void update_nl_seq(u32 nl_seq, struct
ip_ct_ftp_master *info, int dir,
                          struct sk_buff *skb)
 {
-       unsigned int i, oldest = NUM_SEQ_TO_REMEMBER;
+       unsigned int i, oldest;
+       u_int32_t *seq_aft_nl = info->seq_aft_nl[dir];
+       int seq_aft_nl_num = info->seq_aft_nl_num[dir];

-       /* Look for oldest: if we find exact match, we're
done. */
-       for (i = 0; i < info->seq_aft_nl_num[dir];
i++) {
-               if (info->seq_aft_nl[dir][i] == nl_seq)
-                       return;
+       if (seq_aft_nl_num < NUM_SEQ_TO_REMEMBER) {
+               seq_aft_nl[info->seq_aft_nl_num[dir]++] =
nl_seq;
+              
ip_conntrack_event_cache(IPCT_HELPINFO_VOLATILE, skb);
+               return;
+       }

-               if (oldest == info->seq_aft_nl_num[dir]
-                   || before(info->seq_aft_nl[dir][i],
oldest))
+       for (oldest = 0, i = 1; i < seq_aft_nl_num; i ++)
{
+               if (seq_aft_nl[oldest] == nl_seq)
+                       return;
+               if (before(seq_aft_nl[i],
seq_aft_nl[oldest]))
                        oldest = i;
        }

-       if (info->seq_aft_nl_num[dir] <
NUM_SEQ_TO_REMEMBER) {
-              
info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] =
nl_seq;
-              
ip_conntrack_event_cache(IPCT_HELPINFO_VOLATILE, skb);
-       } else if (oldest != NUM_SEQ_TO_REMEMBER) {
-               info->seq_aft_nl[dir][oldest] = nl_seq;
-              
ip_conntrack_event_cache(IPCT_HELPINFO_VOLATILE, skb);
-       }
+       if (nl_seq == seq_aft_nl[oldest] || before(nl_seq,
seq_aft_nl[oldest]))
+               return;
+
+       seq_aft_nl[oldest] = nl_seq;
+       ip_conntrack_event_cache(IPCT_HELPINFO_VOLATILE,
skb);
 }

 static int help(struct sk_buff **pskb,



  
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )