Forum Discussion
hoolio
Cirrostratus
Oct 07, 2009matchclass versus class in v10 for address comparisons?
Is there any advantage to using class match versus matchclass to evaluate an IP address against an address type datagroup?
Here is a simple iRule I used to test class/matchclass for an IP aga...
hoolio
Cirrostratus
Aug 30, 2011Hi Tom,
The minimal change you have to make is to remove the $:: prefix from the datagroup names in the iRules. If you do this you can continue to use findclass and/or matchclass in v10 or v11 as you did in v9.
To gain performance you should ideally change matchclass and findclass to the corresponding class sub-commands. You can also take advantage of the new name=value pairs available in 10.1+ using the class command with the -value option. This last option would require changing your string datagroups from a "key value" space separated format to the new name=value format:
class string_name_value_class {
{
"key1" { "value1" }
"key2" { "value2" }
}
}
class address_name_value_class {
{
host 1.1.1.1 { "value1" }
network 1.1.2.0/24 { "value2" }
}
}
Sample iRule which gets the value for a string datagroup entry and an address datagroup entry
when RULE_INIT {
set value [class match -value "key1" equals string_name_value_class]
log local0. "Looked up key1 and found $value"
set value [class match -value 1.1.2.25 equals address_name_value_class]
log local0. "Looked up 1.1.2.25 and found $value"
}Log output:
Looked up key1 and found value1
Looked up 1.1.2.25 and found value2
Aaron
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
