Matt_Breedlove_
Apr 25, 2009Nimbostratus
Using Switch vs If/Elsif
Hi All,
The below irule is active on a middle tier which forces connections coming from the front end VIP/Pool to be mapped to the correlating partner server in the middle tier pool. So web1 talks to middle1, and web2 talks to middle2 first if the node is up, otherwise it re-selects the pool with least connection. No persistance is used
Would be interested in optimizing this rule to use Switch instead. Is it possible with the need to check the status before sending as as the client_addr or would switch make it unwieldy?
Suggestions?
when CLIENT_ACCEPTED {
if { [IP::addr [IP::client_addr] equals 10.128.1.1] } {
if { [LB::status pool middlepool_80 member 10.128.2.1 80] eq “up” } {
pool middlepool_80 member 10.128.2.1 80
}
}
elseif { [IP::addr [IP::client_addr] equals 10.128.1.2] } {
if { [LB::status pool middlepool_80 member 10.128.2.2 80] eq “up” } {
pool middlepool_80 member 10.128.2.2 80
}
}
elseif { [IP::addr [IP::client_addr] equals 10.128.1.3] } {
if { [LB::status pool middlepool_80 member 10.128.2.3 80] eq “up” } {
pool middlepool_80 member 10.128.2.3 80
}
}
elseif { [IP::addr [IP::client_addr] equals 10.128.1.4] } {
if { [LB::status pool middlepool_80 member 10.128.2.4 80] eq “up” } {
pool middlepool_80 member 10.128.2.4 80
}
}
else {
LB::mode lc
LB::reselect pool middlepool_80
}
}