Forum Discussion

smp_86112's avatar
smp_86112
Icon for Cirrostratus rankCirrostratus
Apr 28, 2010

v9 matchclass and v10 class match iRule commands

I've got a v9 irule that takes action based on whether or not the client IP address is in a data class. The v9 iRule looks like this:

 

 

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

 

 

if I read the v10 doc:

 

For v10 users: Classes (data groups) used to be accessible as a global TCL list. Starting in v10, accessing a data group as a global variable ($::class_name) simply returns the name of the data group and is no longer a TCL list. You must now use the "class" command for all data group access.

 

 

, my interpretation is that this match class statement should be replaced with "class match", like this:

 

 

if { [class match [IP::remote_addr] equals $::allowed_clients] } {

 

 

However both statements return the same value which I've validated by logging it - they both return the index number of the class which holds the matching record. Based on the doc I expected the "$::allowed_clients" statement to return the name of the class "allowed_clients", which [IP::remote_addr] obviously will never match. However the matchclass statement seems to be working the same way in v10 as it did in v9. Am I just not understanding the doc properly?

 

11 Replies

  • My upgrade retained the class definitions properly. However I think you are going to need iRule code changes. I tested the rule as you wrote it, it only returns the URI in v10.2.0. One of the things I took away from this thread is that I needed to remove the "$::" string from class references during my move from 9.3.1 to 10.1.0, which I did with no negative impact. My understanding was that keeping the $:: reference in v10 demotes the VS with the offending iRule to a single processor, effectively disabling CMP on the VS.

     

     

    I don't really understand these class statements very well at all, but I did quickly reproduce the behavior your desired in v10.2.0 with the following iRule. This was generated based on an example in the "class" command description in the iRule wiki:

     

     

    
    when HTTP_REQUEST {
      set myURI [string tolower [URI::decode [HTTP::uri]]]
      set target [class match -value $myURI starts_with class_table]
      log local0. "$target"
    }

     

     

    However you may want to wait for some more feedback on whether this is better than the findclass statement, because it is not clear to me which is better and why, and I could not get it to work in v10.2.0. My thinking was that the findclass syntax should not be used in v10 since it's examples still use the "$::" class reference syntax, but obviously that's not very conclusive.