Forum Discussion

Jereme_De_Leo_4's avatar
Jereme_De_Leo_4
Icon for Nimbostratus rankNimbostratus
Sep 11, 2006

TCL Error

Greetings,

 

 

I am receiving the following TCL error in the Local Traffic logs of the Big-IP:

 

 

"TCL error: Rule rate_limit_5 CLIENT_CLOSED - cant read client_ip: no such variable while executing info exists ::active_clients$client_ip"

 

 

The error refers to the "CLIENT_CLOSED" section of the "rate_limit_5" iRule, on the line "info exists ::active_clients$client_ip". The iRule is listed below.

 

 

What I am trying to do is set a rule that limits the amount of bandwidth (kbps) given to a client IP address based on the number of active connections from that client IP. The only exception is when the client IP address matches an IP address in the "monhosts" list, which effectively exempts that IP from the rule.

 

 

The rule has passed the iRule Editor check and appears to be working fine, except for the TCL error being received.

 

 

Any assistance is greatly appreciated.

 

 

---START IRULE RATE_LIMIT_5---

 

priority 700

 

 

when RULE_INIT {

 

array set ::active_clients { }

 

}

 

when CLIENT_ACCEPTED {

 

if { [matchclass [IP::remote_addr] equals $::monhosts] } {

 

return

 

}

 

set client_ip [IP::remote_addr]

 

if { [info exists ::active_clients($client_ip)] } {

 

incr ::active_clients($client_ip)

 

if { $::active_clients($client_ip) > 250 } {

 

drop

 

} elseif { $::active_clients($client_ip) > 150 } {

 

rateclass limit_400kbps

 

} elseif { $::active_clients($client_ip) > 100 } {

 

rateclass limit_800kbps

 

} elseif { $::active_clients($client_ip) > 50 } {

 

rateclass limit_1600kbps

 

}

 

} else {

 

set ::active_clients($client_ip) 1

 

}

 

}

 

when CLIENT_CLOSED {

 

if { [info exists ::active_clients($client_ip)] } {

 

incr ::active_clients($client_ip) -1

 

if { $::active_clients($client_ip) <= 0 } {

 

unset ::active_clients($client_ip)

 

}

 

}

 

}

 

---END IRULE RATE_LIMIT_5---

 

 

Thank you,

 

 

jddevcen

 

 

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    I'd guess that the connections meant to be excluded from the rule are hitting the CLIENT_CLOSED event without having set the variable "client_ip" for those connections.

    The "return" command only stops processing of that event in that rule. To end rule processing altogether for those connections, change the "return" command in CLIENT_ACCEPTED to "event disable all":
    when CLIENT_ACCEPTED {
      if { [matchclass [IP::remote_addr] equals $::monhosts] } {
        event disable all
      }
      set client_ip [IP::remote_addr]
      ...

    I think that will do the trick.

    /deb

  • Hello,

     

    Do you really need this variable ? Isn't it more flexible to use [IP::client_addr] in the CLIENT_CLOSED event ?