Forum Discussion

Simon_Knox_1115's avatar
Simon_Knox_1115
Icon for Nimbostratus rankNimbostratus
Dec 14, 2005

Any one see why this doesn't work?

when CLIENT_ACCEPTED {
   set TEST [findclass [IP::remote_addr] $::DBConnections " "]
   set SOURCE [IP::remote_addr]
   if { [matchclass [IP::remote_addr] eq $::DBConnections] } {
     set CHECK "YES" }
}
when HTTP_REQUEST {
      HTTP::header insert "CONN" $CHECK
      pool WIP-4
}

The data group is cotains string values formatted:

IP_Addresses Value

using the space to deliminate between the two fields. If I comment out the following lines

   if { [matchclass [IP::remote_addr] eq $::DBConnections] } {
     set CHECK "YES" }

And change the CONN to insert one either the value of TEST or SOURCE it works fine. But with these lines in the rule just hangs the connection.

It ought to be simple but its giving me a headache.

Cheers

Simon
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The matchclass command is designed to match the entire string in the data group. If the string contains two parts seperated by a space as you described, then your matchclass is probably returning false.

    Try something like this instead:

    
    [matchclass $::DBConnections starts_with [IP::remote_addr]]

    This would say "If any of the elements in the class start with the IP address..." instead of "If the IP address starts with any of the elements in the array...". This is a subtle difference, I know...but a difference nonetheless.

    HTH,

    -Colin
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    I'll add that your probably aborting the connection because CHECK is not getting defined as a variable and then when you try to insert the CONN header, it runs into a Tcl error. You should check your /var/log/ltm file for any rule errors - I'll bet you'll find some.

    You may want to add this to your if matchclass:
    else {
       set CHECK "NO"
    }

  • Ha, that fixed it. Thank you for your help. Obvious really when you look at it.

     

     

    Cheers

     

    Simon