Forum Discussion
kman_52500
Nimbostratus
May 01, 2009"syntax error" at character '}'
Hello,
I am trying to add an iRule to our f5 and it loads just fine but I get an error when doing a config sync or b verify load.
The iRule works well and loads just fine, but this error is thrown ever time bigip.conf is loaded:
Reading configuration from /config/profile_base.conf.
rule limit_uri {
/config/bigip.conf: "syntax error" at character '}' in line 217
rule limit_uri {
/config/bigip.conf: "syntax error" at character '}' in line 217
Here is the iRule:
when RULE_INIT {
set ::rate 30
set ::window 300
set ::purge_interval 10
set ::last_purge [clock seconds]
array set ::hit_list {}
array unset ::hit_list
array set ::block_state {}
array unset ::block_state
array set ::hit_count {}
array unset ::hit_count
}
when HTTP_REQUEST {
if { [matchclass [string tolower [HTTP::path]] ends_with $::limit_uris] } {
set current_time [clock seconds]
set request_id "[HTTP::host]_[expr { int(1000000 * rand()) }]"
set ::hit_list($request_id) $current_time
set window_start [expr $current_time - $::window]
if { not [info exists ::block_state([HTTP::host])] } {
set ::block_state([HTTP::host]) 0
set ::hit_count([HTTP::host]) 0
}
if { [expr $current_time - $::last_purge] > $::purge_interval } {
set ::last_purge $current_time
set count 0
foreach { request_id request_time } [array get ::hit_list [HTTP::host]*] {
if { $request_time < $window_start } {
unset ::hit_list($request_id)
} else {
incr count
}
}
set ::hit_count([HTTP::host]) $count
}
if { $::hit_count([HTTP::host]) > $::rate } {
HTTP::respond 503 content "Page LimitedThis page is being limited due to excessive use. Please try again later"
if { $::block_state([HTTP::host]) == 0 } {
log local0. "Started blocking [HTTP::host]"
set ::block_state([HTTP::host]) 1
}
} elseif { $::block_state([HTTP::host]) == 1 } {
log local0. "Stopped blocking [HTTP::host]"
set ::block_state([HTTP::host]) 0
}
}
}
- hoolio
Cirrostratus
Does the error occur when you try to save the iRule or when you try to load the configuration? Which LTM version are you running?array set ::hit_list {} array unset ::hit_list array set ::block_state {} array unset ::block_state array set ::hit_count {} array unset ::hit_count
if {[array exists ::hit_list]}{ array unset ::hit_list } if {[array exists ::block_state]}{ array unset ::block_state } if {[array exists ::hit_count]}{ array unset ::hit_count }
- kman_52500
Nimbostratus
Yes, that fixed the problem. - kman_52500
Nimbostratus
That change also seems to have made things a little more unstable. - hoolio
Cirrostratus
The issue wasn't with your rule--it's down to a bug in parsing the iRule. The issue is described in SOL7988 (Click here). I'm not sure why it would matter if you set the array to nothing and then unset it versus just unsetting it. Can you try logging the array size to see if the array isn't getting cleared? You could try replacing the {}s with ""s to avoid the bug from SOL7988 and use your original set/unset. - kman_52500
Nimbostratus
I considered not logging requests that are blocked, but I would still like the accuracy. - hoolio
Cirrostratus
So what did you actually end up using in RULE_INIT? - kman_52500
Nimbostratus
I changed it to: - kman_52500
Nimbostratus
Never mind. I just noticed your "" suggestion.
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