From 6f01cf11e7951b6c63b8aa8d8dafff6108a09e23 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 10 Mar 2011 13:50:19 +0000 Subject: [PATCH] =?UTF-8?q?[generic]=C3=82backport=20upstream=20commit=200?= =?UTF-8?q?079c5aee34880bcee7feee9960f0502c73dc5fa=20(xt=5Frecent=20entry?= =?UTF-8?q?=20reaper)=20to=20kernels=202.6.30,=202.6.31,=202.6.32=20and=20?= =?UTF-8?q?2.6.34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.openwrt.org/openwrt/trunk@26007 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- .../120-netfilter_recent_reap.patch | 71 +++++++++++++++++++ .../120-netfilter_recent_reap.patch | 71 +++++++++++++++++++ .../120-netfilter_recent_reap.patch | 71 +++++++++++++++++++ .../120-netfilter_recent_reap.patch | 71 +++++++++++++++++++ 4 files changed, 284 insertions(+) create mode 100644 target/linux/generic/patches-2.6.30/120-netfilter_recent_reap.patch create mode 100644 target/linux/generic/patches-2.6.31/120-netfilter_recent_reap.patch create mode 100644 target/linux/generic/patches-2.6.32/120-netfilter_recent_reap.patch create mode 100644 target/linux/generic/patches-2.6.34/120-netfilter_recent_reap.patch diff --git a/target/linux/generic/patches-2.6.30/120-netfilter_recent_reap.patch b/target/linux/generic/patches-2.6.30/120-netfilter_recent_reap.patch new file mode 100644 index 0000000000..8ac3954470 --- /dev/null +++ b/target/linux/generic/patches-2.6.30/120-netfilter_recent_reap.patch @@ -0,0 +1,71 @@ +--- a/include/linux/netfilter/xt_recent.h ++++ b/include/linux/netfilter/xt_recent.h +@@ -9,6 +9,7 @@ enum { + XT_RECENT_UPDATE = 1 << 2, + XT_RECENT_REMOVE = 1 << 3, + XT_RECENT_TTL = 1 << 4, ++ XT_RECENT_REAP = 1 << 5, + + XT_RECENT_SOURCE = 0, + XT_RECENT_DEST = 1, +@@ -16,6 +17,9 @@ enum { + XT_RECENT_NAME_LEN = 200, + }; + ++/* Only allowed with --rcheck and --update */ ++#define XT_RECENT_MODIFIERS (XT_RECENT_TTL|XT_RECENT_REAP) ++ + struct xt_recent_mtinfo { + __u32 seconds; + __u32 hit_count; +--- a/net/netfilter/xt_recent.c ++++ b/net/netfilter/xt_recent.c +@@ -142,6 +142,25 @@ static void recent_entry_remove(struct r + t->entries--; + } + ++/* ++ * Drop entries with timestamps older then 'time'. ++ */ ++static void recent_entry_reap(struct recent_table *t, unsigned long time) ++{ ++ struct recent_entry *e; ++ ++ /* ++ * The head of the LRU list is always the oldest entry. ++ */ ++ e = list_entry(t->lru_list.next, struct recent_entry, lru_list); ++ ++ /* ++ * The last time stamp is the most recent. ++ */ ++ if (time_after(time, e->stamps[e->index-1])) ++ recent_entry_remove(t, e); ++} ++ + static struct recent_entry * + recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr, + u_int16_t family, u_int8_t ttl) +@@ -265,6 +284,10 @@ recent_mt(const struct sk_buff *skb, con + break; + } + } ++ ++ /* info->seconds must be non-zero */ ++ if (info->check_set & XT_RECENT_REAP) ++ recent_entry_reap(t, time); + } + + if (info->check_set & XT_RECENT_SET || +@@ -292,7 +315,10 @@ static bool recent_mt_check(const struct + XT_RECENT_CHECK | XT_RECENT_UPDATE)) != 1) + return false; + if ((info->check_set & (XT_RECENT_SET | XT_RECENT_REMOVE)) && +- (info->seconds || info->hit_count)) ++ (info->seconds || info->hit_count || ++ (info->check_set & XT_RECENT_MODIFIERS))) ++ return false; ++ if ((info->check_set & XT_RECENT_REAP) && !info->seconds) + return false; + if (info->hit_count > ip_pkt_list_tot) + return false; diff --git a/target/linux/generic/patches-2.6.31/120-netfilter_recent_reap.patch b/target/linux/generic/patches-2.6.31/120-netfilter_recent_reap.patch new file mode 100644 index 0000000000..8ac3954470 --- /dev/null +++ b/target/linux/generic/patches-2.6.31/120-netfilter_recent_reap.patch @@ -0,0 +1,71 @@ +--- a/include/linux/netfilter/xt_recent.h ++++ b/include/linux/netfilter/xt_recent.h +@@ -9,6 +9,7 @@ enum { + XT_RECENT_UPDATE = 1 << 2, + XT_RECENT_REMOVE = 1 << 3, + XT_RECENT_TTL = 1 << 4, ++ XT_RECENT_REAP = 1 << 5, + + XT_RECENT_SOURCE = 0, + XT_RECENT_DEST = 1, +@@ -16,6 +17,9 @@ enum { + XT_RECENT_NAME_LEN = 200, + }; + ++/* Only allowed with --rcheck and --update */ ++#define XT_RECENT_MODIFIERS (XT_RECENT_TTL|XT_RECENT_REAP) ++ + struct xt_recent_mtinfo { + __u32 seconds; + __u32 hit_count; +--- a/net/netfilter/xt_recent.c ++++ b/net/netfilter/xt_recent.c +@@ -142,6 +142,25 @@ static void recent_entry_remove(struct r + t->entries--; + } + ++/* ++ * Drop entries with timestamps older then 'time'. ++ */ ++static void recent_entry_reap(struct recent_table *t, unsigned long time) ++{ ++ struct recent_entry *e; ++ ++ /* ++ * The head of the LRU list is always the oldest entry. ++ */ ++ e = list_entry(t->lru_list.next, struct recent_entry, lru_list); ++ ++ /* ++ * The last time stamp is the most recent. ++ */ ++ if (time_after(time, e->stamps[e->index-1])) ++ recent_entry_remove(t, e); ++} ++ + static struct recent_entry * + recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr, + u_int16_t family, u_int8_t ttl) +@@ -265,6 +284,10 @@ recent_mt(const struct sk_buff *skb, con + break; + } + } ++ ++ /* info->seconds must be non-zero */ ++ if (info->check_set & XT_RECENT_REAP) ++ recent_entry_reap(t, time); + } + + if (info->check_set & XT_RECENT_SET || +@@ -292,7 +315,10 @@ static bool recent_mt_check(const struct + XT_RECENT_CHECK | XT_RECENT_UPDATE)) != 1) + return false; + if ((info->check_set & (XT_RECENT_SET | XT_RECENT_REMOVE)) && +- (info->seconds || info->hit_count)) ++ (info->seconds || info->hit_count || ++ (info->check_set & XT_RECENT_MODIFIERS))) ++ return false; ++ if ((info->check_set & XT_RECENT_REAP) && !info->seconds) + return false; + if (info->hit_count > ip_pkt_list_tot) + return false; diff --git a/target/linux/generic/patches-2.6.32/120-netfilter_recent_reap.patch b/target/linux/generic/patches-2.6.32/120-netfilter_recent_reap.patch new file mode 100644 index 0000000000..8ac3954470 --- /dev/null +++ b/target/linux/generic/patches-2.6.32/120-netfilter_recent_reap.patch @@ -0,0 +1,71 @@ +--- a/include/linux/netfilter/xt_recent.h ++++ b/include/linux/netfilter/xt_recent.h +@@ -9,6 +9,7 @@ enum { + XT_RECENT_UPDATE = 1 << 2, + XT_RECENT_REMOVE = 1 << 3, + XT_RECENT_TTL = 1 << 4, ++ XT_RECENT_REAP = 1 << 5, + + XT_RECENT_SOURCE = 0, + XT_RECENT_DEST = 1, +@@ -16,6 +17,9 @@ enum { + XT_RECENT_NAME_LEN = 200, + }; + ++/* Only allowed with --rcheck and --update */ ++#define XT_RECENT_MODIFIERS (XT_RECENT_TTL|XT_RECENT_REAP) ++ + struct xt_recent_mtinfo { + __u32 seconds; + __u32 hit_count; +--- a/net/netfilter/xt_recent.c ++++ b/net/netfilter/xt_recent.c +@@ -142,6 +142,25 @@ static void recent_entry_remove(struct r + t->entries--; + } + ++/* ++ * Drop entries with timestamps older then 'time'. ++ */ ++static void recent_entry_reap(struct recent_table *t, unsigned long time) ++{ ++ struct recent_entry *e; ++ ++ /* ++ * The head of the LRU list is always the oldest entry. ++ */ ++ e = list_entry(t->lru_list.next, struct recent_entry, lru_list); ++ ++ /* ++ * The last time stamp is the most recent. ++ */ ++ if (time_after(time, e->stamps[e->index-1])) ++ recent_entry_remove(t, e); ++} ++ + static struct recent_entry * + recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr, + u_int16_t family, u_int8_t ttl) +@@ -265,6 +284,10 @@ recent_mt(const struct sk_buff *skb, con + break; + } + } ++ ++ /* info->seconds must be non-zero */ ++ if (info->check_set & XT_RECENT_REAP) ++ recent_entry_reap(t, time); + } + + if (info->check_set & XT_RECENT_SET || +@@ -292,7 +315,10 @@ static bool recent_mt_check(const struct + XT_RECENT_CHECK | XT_RECENT_UPDATE)) != 1) + return false; + if ((info->check_set & (XT_RECENT_SET | XT_RECENT_REMOVE)) && +- (info->seconds || info->hit_count)) ++ (info->seconds || info->hit_count || ++ (info->check_set & XT_RECENT_MODIFIERS))) ++ return false; ++ if ((info->check_set & XT_RECENT_REAP) && !info->seconds) + return false; + if (info->hit_count > ip_pkt_list_tot) + return false; diff --git a/target/linux/generic/patches-2.6.34/120-netfilter_recent_reap.patch b/target/linux/generic/patches-2.6.34/120-netfilter_recent_reap.patch new file mode 100644 index 0000000000..f7fd9ed935 --- /dev/null +++ b/target/linux/generic/patches-2.6.34/120-netfilter_recent_reap.patch @@ -0,0 +1,71 @@ +--- a/include/linux/netfilter/xt_recent.h ++++ b/include/linux/netfilter/xt_recent.h +@@ -9,6 +9,7 @@ enum { + XT_RECENT_UPDATE = 1 << 2, + XT_RECENT_REMOVE = 1 << 3, + XT_RECENT_TTL = 1 << 4, ++ XT_RECENT_REAP = 1 << 5, + + XT_RECENT_SOURCE = 0, + XT_RECENT_DEST = 1, +@@ -16,6 +17,9 @@ enum { + XT_RECENT_NAME_LEN = 200, + }; + ++/* Only allowed with --rcheck and --update */ ++#define XT_RECENT_MODIFIERS (XT_RECENT_TTL|XT_RECENT_REAP) ++ + struct xt_recent_mtinfo { + __u32 seconds; + __u32 hit_count; +--- a/net/netfilter/xt_recent.c ++++ b/net/netfilter/xt_recent.c +@@ -147,6 +147,25 @@ static void recent_entry_remove(struct r + t->entries--; + } + ++/* ++ * Drop entries with timestamps older then 'time'. ++ */ ++static void recent_entry_reap(struct recent_table *t, unsigned long time) ++{ ++ struct recent_entry *e; ++ ++ /* ++ * The head of the LRU list is always the oldest entry. ++ */ ++ e = list_entry(t->lru_list.next, struct recent_entry, lru_list); ++ ++ /* ++ * The last time stamp is the most recent. ++ */ ++ if (time_after(time, e->stamps[e->index-1])) ++ recent_entry_remove(t, e); ++} ++ + static struct recent_entry * + recent_entry_init(struct recent_table *t, const union nf_inet_addr *addr, + u_int16_t family, u_int8_t ttl) +@@ -273,6 +292,10 @@ recent_mt(const struct sk_buff *skb, con + break; + } + } ++ ++ /* info->seconds must be non-zero */ ++ if (info->check_set & XT_RECENT_REAP) ++ recent_entry_reap(t, time); + } + + if (info->check_set & XT_RECENT_SET || +@@ -305,7 +328,10 @@ static bool recent_mt_check(const struct + XT_RECENT_CHECK | XT_RECENT_UPDATE)) != 1) + return false; + if ((info->check_set & (XT_RECENT_SET | XT_RECENT_REMOVE)) && +- (info->seconds || info->hit_count)) ++ (info->seconds || info->hit_count || ++ (info->check_set & XT_RECENT_MODIFIERS))) ++ return false; ++ if ((info->check_set & XT_RECENT_REAP) && !info->seconds) + return false; + if (info->hit_count > ip_pkt_list_tot) { + pr_info(KBUILD_MODNAME ": hitcount (%u) is larger than "