netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* removing black listed ip
@ 2010-04-10 17:03 ratheesh k
  2010-04-10 17:12 ` Jan Engelhardt
  0 siblings, 1 reply; 9+ messages in thread
From: ratheesh k @ 2010-04-10 17:03 UTC (permalink / raw)
  To: netfilter

Hi ,

 I need to remove black listed ip if   last seen packet is  x time
ago  . I have changed code , but here it is comparing with first seen
packet time . i need to compare last seen packet .

**************************************************************************************************

--- xt_recent.c.old	2010-04-11 03:51:10.000000000 +0530
+++ xt_recent.c	2010-04-11 03:50:06.000000000 +0530
@@ -113,12 +113,13 @@
 	       (ip_list_hash_size - 1);
 }

+static void recent_entry_remove(struct recent_table *, struct recent_entry *);
 static struct recent_entry *
 recent_entry_lookup(const struct recent_table *table,
 		    const union nf_inet_addr *addrp, u_int16_t family,
 		    u_int8_t ttl)
 {
-	struct recent_entry *e;
+	struct recent_entry *e ,*next;
 	unsigned int h;

 	if (family == NFPROTO_IPV4)
@@ -126,7 +127,17 @@
 	else
 		h = recent_entry_hash6(addrp);

-	list_for_each_entry(e, &table->iphash[h], list)
+	
+          list_for_each_entry_safe(e,next , &table->iphash[h], list) {
+          if (e->family == family && (jiffies - e->stamps[0] > 10000 )  ) {
+                       printk("\n Removing one entry  %lu  %lu \n" ,
e->stamps[0] ,jiffies);
+                       printk(KERN_INFO "\nRemoving  ip entry:
%d.%d.%d.%d\n", NIPQUAD(e->addr));
+                      recent_entry_remove(table, e);
+                      }
+
+          }
+
+        list_for_each_entry(e, &table->iphash[h], list)
 		if (e->family == family &&
 		    memcmp(&e->addr, addrp, sizeof(e->addr)) == 0 &&
 		    (ttl == e->ttl || ttl == 0 || e->ttl == 0))
@@ -178,6 +189,10 @@
 		e->nstamps = e->index;
 	e->index %= ip_pkt_list_tot;
 	list_move_tail(&e->lru_list, &t->lru_list);
+
+
+
+
 }

 static struct recent_table *recent_table_lookup(const char *name)


***************************************************************************************

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-04-20 11:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-10 17:03 removing black listed ip ratheesh k
2010-04-10 17:12 ` Jan Engelhardt
2010-04-10 17:20   ` ratheesh k
2010-04-10 17:42     ` Jan Engelhardt
2010-04-12  6:24       ` ratheesh k
2010-04-12 12:30         ` Jan Engelhardt
2010-04-20  2:46           ` ratheesh k
2010-04-20  8:06             ` Jan Engelhardt
2010-04-20 11:21               ` ratheesh k

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).