forked from mirrors/linux
		
	netfilter: conntrack: avoid same-timeout update
No need to dirty a cache line if timeout is unchanged. Also, WARN() is useless here: we crash on 'skb->len' access if skb is NULL. Last, ct->timeout is u32, not 'unsigned long' so adapt the function prototype accordingly. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
		
							parent
							
								
									d2c5c103b1
								
							
						
					
					
						commit
						cc16921351
					
				
					 2 changed files with 9 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -190,23 +190,23 @@ bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff,
 | 
			
		|||
 | 
			
		||||
void __nf_ct_refresh_acct(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
 | 
			
		||||
			  const struct sk_buff *skb,
 | 
			
		||||
			  unsigned long extra_jiffies, int do_acct);
 | 
			
		||||
			  u32 extra_jiffies, bool do_acct);
 | 
			
		||||
 | 
			
		||||
/* Refresh conntrack for this many jiffies and do accounting */
 | 
			
		||||
static inline void nf_ct_refresh_acct(struct nf_conn *ct,
 | 
			
		||||
				      enum ip_conntrack_info ctinfo,
 | 
			
		||||
				      const struct sk_buff *skb,
 | 
			
		||||
				      unsigned long extra_jiffies)
 | 
			
		||||
				      u32 extra_jiffies)
 | 
			
		||||
{
 | 
			
		||||
	__nf_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies, 1);
 | 
			
		||||
	__nf_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies, true);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Refresh conntrack for this many jiffies */
 | 
			
		||||
static inline void nf_ct_refresh(struct nf_conn *ct,
 | 
			
		||||
				 const struct sk_buff *skb,
 | 
			
		||||
				 unsigned long extra_jiffies)
 | 
			
		||||
				 u32 extra_jiffies)
 | 
			
		||||
{
 | 
			
		||||
	__nf_ct_refresh_acct(ct, 0, skb, extra_jiffies, 0);
 | 
			
		||||
	__nf_ct_refresh_acct(ct, 0, skb, extra_jiffies, false);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* kill conntrack and do accounting */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1751,11 +1751,9 @@ EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
 | 
			
		|||
void __nf_ct_refresh_acct(struct nf_conn *ct,
 | 
			
		||||
			  enum ip_conntrack_info ctinfo,
 | 
			
		||||
			  const struct sk_buff *skb,
 | 
			
		||||
			  unsigned long extra_jiffies,
 | 
			
		||||
			  int do_acct)
 | 
			
		||||
			  u32 extra_jiffies,
 | 
			
		||||
			  bool do_acct)
 | 
			
		||||
{
 | 
			
		||||
	WARN_ON(!skb);
 | 
			
		||||
 | 
			
		||||
	/* Only update if this is not a fixed timeout */
 | 
			
		||||
	if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status))
 | 
			
		||||
		goto acct;
 | 
			
		||||
| 
						 | 
				
			
			@ -1764,6 +1762,7 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
 | 
			
		|||
	if (nf_ct_is_confirmed(ct))
 | 
			
		||||
		extra_jiffies += nfct_time_stamp;
 | 
			
		||||
 | 
			
		||||
	if (ct->timeout != extra_jiffies)
 | 
			
		||||
		ct->timeout = extra_jiffies;
 | 
			
		||||
acct:
 | 
			
		||||
	if (do_acct)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue