Forum Discussion

gdoyle's avatar
gdoyle
Icon for Cirrostratus rankCirrostratus
May 19, 2016

iRules seem to be processing out of order.

I have several iRules setup for a server and I put my most recent iRule at the top; however, they appear to be processing out of order. I can see this because users are being redirected to a page when they should in fact just be stopped and receive a custom error message.

 

Is there a way to set the order in which the iRules are processed? Does the BigIP process ALL iRules listed? Does the BigIP hit the first rule that meets some criteria and then stop processing iRules?

 

...

 

Thanks.

 

3 Replies

  • When you have multiple iRules with the SAME event in them, then they are all merged to form a single event processing cycle. I would not use this as a recommended approach because this requires more coordination of logic between the rules. If you want to use common code, then create a TCL proc and then invoke this proc from an iRule. The other alternative is to set state variables "set i_did_action_1" and then check for this variable in a different irule and re-act accordingly. The downside to this is that it wastes TMM memory.

     

  • Hello,

     

    There is many things to take into accounts : - Events are processed in a specific order (CLIENT_ACCEPTED, HTTP_REQUEST, ...) - When you have several irules with the same event (e.g HTTP_REQUEST), the Event content is processed in the order starting at the top in the irule list - You can change the processing order by adding a priority to each event (e.g when HTTP_REQUEST priority 100 {... )

     

    When you have several condratictory commands in a same event (e.g HTTP::respond, HTTP::redirect, ...), you will trigger a tcl error.

     

    You can use "return" command to stop processing within an event

     

    or even use "event disable" to disable the current event for the active connection

     

    or also "event disable HTTP_REQUEST" to disable the HTTP_REQUEST event