All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Amin Azez <azez@ufomechanic.net>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: ipt_recent fix
Date: Sat, 04 Mar 2006 11:10:31 +0100	[thread overview]
Message-ID: <44096797.7060203@trash.net> (raw)
In-Reply-To: <dt51lh$b63$1@sea.gmane.org>

Amin Azez wrote:
> Here is a fix for ipt_recent.
> 
> The problem is that curr_table[x].hash_entry=0 (for all x)
> 
> So all pristine (never used) curr_table entries claim to have hash pos 0.
> 
> So when we add new items to the hash and do:
>  hash_table[r_list[location].hash_entry] = -1;
> to use the oldest (used or unused) location - if it is unused we trash
> anything that really has hash pos 0 already allocated.
> 
> This can be reproduced with this:
> 
> # iptables -A FORWARD -d 1.1.1.1 -m recent --name TEST1 --set
> # G=1 ; while test $G -lt 17 ; do echo $G ; echo 1.1.1.$G> \
>  /proc/net/ipt_recent/TEST1 ; G=$(($G+1)) ; dmesg -c ; cat \
>  /proc/net/ipt_recent/TEST1  | head ; done > x
> 
> the 13th item has hash of 0 and gets trashed when the 14th item is added
> without this patch.
> 
> We should only trash it then if we _know_ it has been used before and
> therefore is REALLY at the position it claims...
> 
> This patch makes sure that items claiming to have a hash entry really do
> have that hash entry before destroying that hash entry.
> 
> This patch also adds counting of the number of hash entries in
> preparation for conditions based on the number of entries in the recent
> table rule; patch for that to follow next week.
> 
> Any comments on this?
> 
> Sam
> 
> 
> ------------------------------------------------------------------------
> 
> --- ./net/ipv4/netfilter/ipt_recent.c.nolimit	2006-02-15 16:34:20.000000000 +0000
> +++ ./net/ipv4/netfilter/ipt_recent.c	2006-02-17 17:23:00.000000000 +0000
> @@ -70,7 +70,11 @@
>  /* Structure of our linked list of tables of recent lists. */
>  struct recent_ip_tables {
>  	char name[IPT_RECENT_NAME_LEN];
> +	/* number of entries in list *table */
> +	int entry_count;
> +	/* number of reference to this structure from iptables rules */
>  	int count;
> +	/* an index increased with each operation which maps time_info[x].position to a position in table */
>  	int time_pos;
>  	struct recent_ip_list *table;
>  	struct recent_ip_tables *next;
> @@ -139,6 +143,7 @@
>  	curr_table = (struct recent_ip_tables*) data;
>  
>  	spin_lock_bh(&curr_table->list_lock);
> +	len += sprintf(buffer+len,"count=%d\n",curr_table->entry_count);
>  	for(count = 0; count < ip_list_tot; count++) {
>  		if(!curr_table->table[count].addr) continue;
>  		last_len = len;

This changes the proc output format, which we shouldn't do without a
good reason to avoid breaking scripts parsing it. Can you seperate
the fix from the patch please and send that? If you think there is
a good reason to change the output format feel free to send a seperate
patch for that.

      parent reply	other threads:[~2006-03-04 10:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-17 17:37 ipt_recent fix Amin Azez
2006-02-20 16:12 ` [patch] ipt_recent Amin Azez
2006-03-04 10:00   ` Patrick McHardy
2006-03-07 15:48     ` Amin Azez
2006-03-08 12:16       ` Patrick McHardy
2006-03-13 17:47         ` ipt_recent patch Amin Azez
2006-03-22 14:26           ` Stephen Frost
2006-05-03  9:32             ` Amin Azez
2006-05-03 11:41               ` Amin Azez
2006-03-22 12:04         ` [patch] ipt_recent Amin Azez
2006-02-21 11:16 ` BUG: More ipt_recent queries Amin Azez
2006-02-21 16:28   ` Amin Azez
2006-03-04 10:13   ` Patrick McHardy
2006-03-06  3:04     ` Stephen Frost
2006-03-07 15:46       ` Amin Azez
2006-03-04 10:10 ` Patrick McHardy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44096797.7060203@trash.net \
    --to=kaber@trash.net \
    --cc=azez@ufomechanic.net \
    --cc=netfilter-devel@lists.netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.