Commit 0cac7232 authored by Rusty Russell's avatar Rusty Russell Committed by David S. Miller

[NETFILTER]: Make expectations timeouts compulsory

This patch simplifies the code by always having expectation timeouts.
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2a526ac9
...@@ -176,7 +176,7 @@ find_expectation(const struct ip_conntrack_tuple *tuple) ...@@ -176,7 +176,7 @@ find_expectation(const struct ip_conntrack_tuple *tuple)
and weird things would happen to future packets). */ and weird things would happen to future packets). */
if (ip_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask) if (ip_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask)
&& is_confirmed(i->master) && is_confirmed(i->master)
&& (!i->timeout.function || del_timer(&i->timeout))) { && del_timer(&i->timeout)) {
unlink_expect(i); unlink_expect(i);
return i; return i;
} }
...@@ -194,8 +194,7 @@ static void remove_expectations(struct ip_conntrack *ct) ...@@ -194,8 +194,7 @@ static void remove_expectations(struct ip_conntrack *ct)
return; return;
list_for_each_entry_safe(i, tmp, &ip_conntrack_expect_list, list) { list_for_each_entry_safe(i, tmp, &ip_conntrack_expect_list, list) {
if (i->master == ct if (i->master == ct && del_timer(&i->timeout)) {
&& (!i->timeout.function || del_timer(&i->timeout))) {
unlink_expect(i); unlink_expect(i);
destroy_expect(i); destroy_expect(i);
} }
...@@ -722,8 +721,7 @@ void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp) ...@@ -722,8 +721,7 @@ void ip_conntrack_unexpect_related(struct ip_conntrack_expect *exp)
WRITE_LOCK(&ip_conntrack_lock); WRITE_LOCK(&ip_conntrack_lock);
/* choose the the oldest expectation to evict */ /* choose the the oldest expectation to evict */
list_for_each_entry_reverse(i, &ip_conntrack_expect_list, list) { list_for_each_entry_reverse(i, &ip_conntrack_expect_list, list) {
if (expect_matches(i, exp) if (expect_matches(i, exp) && del_timer(&i->timeout)) {
&& (!i->timeout.function || del_timer(&i->timeout))) {
unlink_expect(i); unlink_expect(i);
WRITE_UNLOCK(&ip_conntrack_lock); WRITE_UNLOCK(&ip_conntrack_lock);
destroy_expect(i); destroy_expect(i);
...@@ -777,7 +775,7 @@ static void evict_oldest_expect(struct ip_conntrack *master) ...@@ -777,7 +775,7 @@ static void evict_oldest_expect(struct ip_conntrack *master)
list_for_each_entry_reverse(i, &ip_conntrack_expect_list, list) { list_for_each_entry_reverse(i, &ip_conntrack_expect_list, list) {
if (i->master == master) { if (i->master == master) {
if (!i->timeout.function || del_timer(&i->timeout)) { if (del_timer(&i->timeout)) {
unlink_expect(i); unlink_expect(i);
destroy_expect(i); destroy_expect(i);
} }
...@@ -788,9 +786,6 @@ static void evict_oldest_expect(struct ip_conntrack *master) ...@@ -788,9 +786,6 @@ static void evict_oldest_expect(struct ip_conntrack *master)
static inline int refresh_timer(struct ip_conntrack_expect *i) static inline int refresh_timer(struct ip_conntrack_expect *i)
{ {
if (!i->timeout.function)
return 1;
if (!del_timer(&i->timeout)) if (!del_timer(&i->timeout))
return 0; return 0;
...@@ -856,6 +851,7 @@ void ip_conntrack_alter_reply(struct ip_conntrack *conntrack, ...@@ -856,6 +851,7 @@ void ip_conntrack_alter_reply(struct ip_conntrack *conntrack,
int ip_conntrack_helper_register(struct ip_conntrack_helper *me) int ip_conntrack_helper_register(struct ip_conntrack_helper *me)
{ {
BUG_ON(me->timeout == 0);
WRITE_LOCK(&ip_conntrack_lock); WRITE_LOCK(&ip_conntrack_lock);
list_prepend(&helpers, me); list_prepend(&helpers, me);
WRITE_UNLOCK(&ip_conntrack_lock); WRITE_UNLOCK(&ip_conntrack_lock);
...@@ -882,14 +878,11 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me) ...@@ -882,14 +878,11 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me)
/* Get rid of expectations */ /* Get rid of expectations */
list_for_each_entry_safe(exp, tmp, &ip_conntrack_expect_list, list) { list_for_each_entry_safe(exp, tmp, &ip_conntrack_expect_list, list) {
if (exp->master->helper == me) { if (exp->master->helper == me && del_timer(&exp->timeout)) {
if (!exp->timeout.function
|| del_timer(&exp->timeout)) {
unlink_expect(exp); unlink_expect(exp);
destroy_expect(exp); destroy_expect(exp);
} }
} }
}
/* Get rid of expecteds, set helpers to NULL. */ /* Get rid of expecteds, set helpers to NULL. */
LIST_FIND_W(&unconfirmed, unhelp, struct ip_conntrack_tuple_hash*, me); LIST_FIND_W(&unconfirmed, unhelp, struct ip_conntrack_tuple_hash*, me);
for (i = 0; i < ip_conntrack_htable_size; i++) for (i = 0; i < ip_conntrack_htable_size; i++)
......
...@@ -476,7 +476,7 @@ static int __init init(void) ...@@ -476,7 +476,7 @@ static int __init init(void)
ftp[i].mask.src.u.tcp.port = 0xFFFF; ftp[i].mask.src.u.tcp.port = 0xFFFF;
ftp[i].mask.dst.protonum = 0xFFFF; ftp[i].mask.dst.protonum = 0xFFFF;
ftp[i].max_expected = 1; ftp[i].max_expected = 1;
ftp[i].timeout = 0; ftp[i].timeout = 5 * 60; /* 5 minutes */
ftp[i].me = ip_conntrack_ftp; ftp[i].me = ip_conntrack_ftp;
ftp[i].help = help; ftp[i].help = help;
......
...@@ -131,7 +131,7 @@ static int __init init(void) ...@@ -131,7 +131,7 @@ static int __init init(void)
tftp[i].mask.dst.protonum = 0xFFFF; tftp[i].mask.dst.protonum = 0xFFFF;
tftp[i].mask.src.u.udp.port = 0xFFFF; tftp[i].mask.src.u.udp.port = 0xFFFF;
tftp[i].max_expected = 1; tftp[i].max_expected = 1;
tftp[i].timeout = 0; tftp[i].timeout = 5 * 60; /* 5 minutes */
tftp[i].me = THIS_MODULE; tftp[i].me = THIS_MODULE;
tftp[i].help = tftp_help; tftp[i].help = tftp_help;
......
...@@ -34,8 +34,6 @@ MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>"); ...@@ -34,8 +34,6 @@ MODULE_AUTHOR("Harald Welte <laforge@gnumonks.org>");
MODULE_DESCRIPTION("IRC (DCC) NAT helper"); MODULE_DESCRIPTION("IRC (DCC) NAT helper");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
/* FIXME: Time out? --RR */
static unsigned int help(struct sk_buff **pskb, static unsigned int help(struct sk_buff **pskb,
enum ip_conntrack_info ctinfo, enum ip_conntrack_info ctinfo,
unsigned int matchoff, unsigned int matchoff,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment