Forum Discussion

chris_connell_1's avatar
chris_connell_1
Icon for Nimbostratus rankNimbostratus
Apr 21, 2009

Quickest way to do this

 

I want to do this in my virtual server irule.

 

 

Could someone confirm if for my irule below

 

 

only 1 condition is met and i will get this behaviour:

 

 

i,e

 

 

if the destination address is in the blocked list, its rejected.

 

OR

 

if the source matches clients and active mebers are more than 48 forward to ingress pool

 

OR

 

if the source is in the testrange then forward to test pool

 

OR everythign else

 

forward

 

 

Is it better to use a switch/case for this? but there are a few variables here.

 

 

 

when CLIENT_ACCEPTED {

 

if { [matchclass [IP::local_addr] equals $::blocked]} {

 

reject

 

} elseif { [matchclass [IP::remote_addr] equals $::clients] and [active_members Ingress] >= 48 } {

 

pool Ingress

 

} elseif { [matchclass [IP::remote_addr] equals $::testpool] } {

 

pool Ingress-test

 

} else {

 

forward

 

}

 

}

3 Replies

  • Hi,

     

     

    Looks good to me. Switch statements are generally considered to be faster than if - elseif's but I doubt the difference would be measurable here unless you're expecting a very large amount of traffic.

     

     

    Although I'm not sure what's going to happen if you just forward a packet that was destined for the vip in the first place?

     

     

    Denny
  •  

    Thanks, my understanding was switch statments are good if u are comparing one variable. but if you are looking for mulitple conditions as above, then its difficult and complicated.
  • You're correct, you can't use a switch to check the condition of multiple variables.

     

     

    Aaron