Forum Discussion

Gbps_31870's avatar
Icon for Nimbostratus rankNimbostratus
Aug 14, 2011

using localvar to manage iRules process flow

Hi All,



I really appreciate your efforts in this wouderful forum.



I have a question which might solve the logs generated for TCL error for multiple redirection.



I have two irules, irule1 and irule2, and both are for HTTP redirection. I know that event disable is based on the connection rather than request which might cause subsequent requests bypassing that event, so I'm trying to avoid it.



irule 1





switch [string tolower [HTTP::path]] {


"/xyz" {


HTTP::redirect ""


set stop_processing 1









irule 2






if {($stop_processing != 1)









My goal is to skip irule 2 if and only if irule 1 is processed for that connection, my questions are:



1- if there is no hit for irule 1, will be there any issues that prevent irule 2 from processing the request, as the localvar (stop_processing) has no value?



2- The localvar is per connection, so no need to worry about multiple/parallel connections, but what about subsequent HTTP_REQUEST during the same connection, is it possible to create irule 3 as below and associate it with the same VS to chenge localvar value.





set stop_processing 0













3 Replies

  • Before reading a variable it must be set somewhere or an exception will occur. In the first iRule, add a "set stop_processing 0" before the switch statement so it will always be set to some value. Another approach is to bullet proof the second iRule test with something like
    if {[catch {set stop_processing}] or $stop_processing != 1} { do stuff }}
    which survive if the first iRule is not in the chain of execution.
  • Thanks Hammond, I would like to go with the first option as you mentioned (setting localvar in the first iRule).





  • Colin_Walker_12's avatar
    Historic F5 Account
    You can also use the info exists command, such as:

    if {[info exists $stop_processing]} {

    Rather than a catch. This way setting the value at all would result in a success. Both are valid, just another way to go about it.