For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

BaltoStar_12467's avatar
Feb 12, 2015

BIG-IP : disable further processing for event -- except for diagnostics

F5 BIG-IP Virtual Edition v11.4.1 (Build 635.0) LTM on ESXi

My virtual-server has a stack of irules :

 

irule-01
irule-02
irule-03
irule-diagnostic

 

These irules examine requests and make decisions about pool to route to, for example

irule-01.conf

 

when HTTP_REQUEST {
   some conditional logic ...
  pool pool-01
   some more conditional logic ...
  pool pool-02
}

 

irule-02.conf

 

when HTTP_REQUEST {
   some conditional logic ...
  pool pool-03
   some more conditional logic ...
  pool pool-04
}    

 

NOTE : irule-diagnostic is at the bottom of the stack ( lowest priority ) because i need to log not only request fields but also response fields.

My understanding is that irules execute all event-handlers in order of irule priority and can override decisions made by higher-priority irules -- so if irule-01 decides to route to pool-01 but irule-03 then decides to route to pool-04 , the request will be routed to pool-04

I need to add a new i-rule at the top of the stack where pool routing decisions are final -- so I was thinking of using event HTTP_REQUEST disable

irule-00.conf

 

when HTTP_REQUEST {
   some conditional logic ...
  pool pool-01
   some more conditional logic ...
  pool pool-04
  event HTTP_REQUEST disable
} 

 

However, this would mean that HTTP_REQUEST event would never fire in irule-diagnostic

What is a workaround or alternate solution ?

5 Replies

  • Greg_Chew_31149's avatar
    Greg_Chew_31149
    Historic F5 Account

    return will only exit the current event in the current rule. If you want to prevent all subsequent iRule events from any iRule on the virtual server from running, you can use 'event disable all'. Or if you want to do it just for select code in this or another rule on the same virtual server, you could set a variable in CLIENT_ACCEPTED and then check the value in subsequent code before running it.

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/return

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/event

     

  • Refer also to the syntax possibilities of the when clause.

     

    https://devcentral.f5.com/wiki/iRules.when.ashx

     

    You can define a priority for each event. I recommend this as a best practice, so that if multiple iRules get assigned on the virtual, you know the sequence in which they will fire.

     

    You could use the priority to setup flags and only exit out from your last event processing iRule.

     

    Best.

     

  • In your case, would it be doable by just making sure the diagnostics iRule is processed before others? For the majority of use-cases, the event disable command is not needed in a diagnostics iRule.

    Add a line of code priority 100 at the top of the diagnostics iRule. You may replace 100 with any number from 1-499. If the priority is not set, it will default to 500.

    • i need diagnostics to log not just request fields but also response fields - so i need diagnostics irule to process at bottom of stack
    • Hannes_Rapp's avatar
      Hannes_Rapp
      Icon for Nimbostratus rankNimbostratus
      Your HTTP_RESPONSE event for the "top of the stack" iRule will be processed regardless. It's not a technical show-stopper, unless your other iRules call the 'event disable all' or 'event HTTP_RESPONSE disable' commands. Also note that a position "top of the stack" does not mean the iRule is completely processed, before the execution of other iRules begins. All iRules attached to a VS are always processed concurrently, on a per-event basis. - Would you mind sharing your diagnostics iRule? Perhaps we could offer a solution to your problem more efficiently.