Forum Discussion
engtmk
Nimbostratus
Dec 27, 2007bigip1 panic: unable to alloc 4194304 bytes
I found this error in my LTM log, when I asked the support he said:
that TCL was trying to resize the ::users array (internal hash table) with an index of "time,200.35.63.129", and it crossed the 4MB boundary
so I need to know if there is a way to prevent this variable from exceeding the 4MB memory limit
below you will find the iRule that caused the error:
when RULE_INIT {
set ::maxconnect 80
set ::blocktime 120
array set ::users { }
array set ::spammers { }
}
when CLIENT_ACCEPTED {
set clientip [IP::remote_addr]
log local0. "the client ip is $clientip"
if { [matchclass [IP::remote_addr] equals $::smtp_whitelist ] } {
Accept unlimited connections from the whitelist users
return
}
set clientip [IP::remote_addr]
set now [clock second]
if { [ info exists ::spammers($clientip) ] } {
if { $::blocktime > [expr { $now - $::spammers($clientip) }] } {
the user tries to connect in the blocktime period
set ::spammers($clientip) $now
TCP::respond "550 Message Rejected - Too Much spam/r/n"
log local0. "The user tries to send while in the block period - $clientip"
drop
return
}
else {
the timeout has expired free the user from the list
unset ::spammers($clientip)
log local0. "The user has been removed from the list - $clientip"
}
}
if { [ info exists ::users(nb,$clientip)] } {
if { [expr { $now - $::users(time,$clientip) }] > $::blocktime } {
the last connection was before the timeout period
set ::users(nb,$clientip) 1
set ::users(time,$clientip) $now
return
}
else {
the connection was in the timeout
incr ::users(nb,$clientip)
set t $::users(nb,$clientip)
log local0. "the user - $clientip - has been connected $t times"
set ::users(time,$clientip) $now
if { $::users(nb,$clientip) > $::maxconnect } {
the user has exceeded the max no of connections
add him to the spam list
set ::spammers($clientip) $now
set ::users(nb,$clientip) 1
set ::users(time,$clientip) $now
TCP::respond "550 Message Rejected - Too much spam\r\n"
log local0. "this user has started spamming us $clientip "
drop
return
}
}
} else {
new client
set ::users(nb,$clientip) 1
set ::users(time,$clientip) $now
log local0. "this is user has just connected - $clientip"
}
}
Thanks for the help
- hoolio
Cirrostratus
You're using two array entries for each client IP: "$::users(nb,IP)" and "$::users(time,IP)". I think you could combine these to $::users(IP) = "count:timer" to save some memory. - engtmk
Nimbostratus
we are testing the iRule now after the modification - hoolio
Cirrostratus
Hi, - engtmk
Nimbostratus
The irule is not working - hoolio
Cirrostratus
Sorry the suggestions haven't worked so far. Can you try logging the value of the array after you try to add new entries to see if they're being added correctly? You can use a foreach loop with array get to write the keys and values out:foreach {key value} [array get ::users { log local0. "$key = $value" }
- engtmk
Nimbostratus
well I loged the array - hoolio
Cirrostratus
Sorry if this caused a TMM restart. I didn't realize you were testing this on a live system. I'd suggest using a test unit or testing during a maintenance window. - engtmk
Nimbostratus
ernel: - hoolio
Cirrostratus
So you wouldn't be affected by the clock issue. Are you able to try testing either on a non-production unit or on a production unit during a maintenance window? - engtmk
Nimbostratus
I am afraid not, we only got the Acive/standby single pair
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects