Forum Discussion
William_Benett1
Nimbostratus
Mar 28, 2007TCL capabilities in iRules
So i'm working on an iRule that will require me to do bitwise math in order to determine if the port number is odd or even. I believe I looked up the operator (&) but the iRuler gives me a syntax err...
William_Benett1
Nimbostratus
Mar 30, 2007So i've been working with this and I can't seem to get information out of the persistence table. If I try and do a lookup during CLIENT_ACCEPTED it throws me a "Prerequisite operation not in progress" if I try and do it during LB_SELECTED I get nothing returned on my lookup. I can perform a lookup right after I set the persistence in LB_SELECTED, so i'm not sure why I can't do it again when the odd port connection comes in.
when CLIENT_ACCEPTED {
switch -glob [TCP::local_port] {
49* { if {[TCP::local_port] > 49151 && 49250 > [TCP::local_port]} {
set lport [TCP::local_port]
if { ! [expr {$lport & 1}]} {
pool pool_$lport
} else {
set evenport [ expr $lport -1]
set current [LB::server addr]
set remaddr [IP::client_addr]
set ourpool "pool_$evenport"
set hoohaa [persist lookup source_addr [IP::client_addr]]
log local0. "current: $current evenport: $evenport pers entry: $hoohaa remote_addr: $remaddr"
}
}
}
default { discard }
}
}
when LB_SELECTED {
if {[TCP::local_port] > 49151 && 49250 > [TCP::local_port]} {
set lport [TCP::local_port]
if { ! [expr {$lport &1}]} {
even
set remaddr [IP::client_addr]
persist add source_addr [IP::client_addr] 300
set output [persist lookup source_addr [IP::client_addr] node ]
log local0. "pers lookup: $output remip: [IP::remote_addr]"
} else {
odd
set evenport [ expr $lport - 1 ]
set current [LB::server addr]
set remaddr [IP::client_addr]
set ourpool "pool_$evenport"
log local0. "pool: $ourpool remaddr: $remaddr"
set hoohaa [persist lookup source_addr [IP::client_addr] ]
log local0. "current: $current evenport: $evenport pers entry: $hoohaa remote_addr: $remaddr"
if {[$entry != $current]} {
LB::reselect pool pool_$lport
}
}
}
}
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects