Forum Discussion
Colin_Walker_12
Apr 08, 2009Historic F5 Account
v.10 Command Interoperability
While performing internal testing on some advanced iRules on the newly released v10 platform, we discovered a couple possible scenarios that users should be aware of. Making use of certain commands: (session, persist , after) inside one of a few specific constructs: (switch, foreach, eval, catch) can result in an error condition, causing serious repercussions to the performance and stability of your device. Because of this, they need to be avoided when upgrading to or installing v10, at least temporarily. It's important to note here that while these temporary workarounds are important for immediate upgrades to v10, our rock-star PD crew is well aware of this and will have a fix out very soon.
These situations in code are thankfully relatively painless to work around, in many cases. To help facilitate this, we've distilled down a couple of simple, possible scenarios that you might run into, in hopes of showing you an alternate method of achieving the same functionality with your code. These examples are straight-forward, but the concepts carry over into more complex iRules. Understand that this is in no way a comprehensive list of examples, just a visual guide to show what we're talking about, in code.
First, here's an example of a session lookup inside of a switch statement. This should work properly in v9.x, and variations on this type of structure are quite possible.
when HTTP_REQUEST {
session add uie 12345 "this is a session" 200
switch [HTTP::path] {
"/foo.html" {
session lookup uie 12345
log local0. "done with all session requests"
}
default {
log local0. "default path, no request made"
}
}
}
Please note that the above code will not function in v10, and it will need to be re-written. A possible solution for how to do so is to make use of if-else, instead of switch, if you're going to be using one of the commands listed above (session, persist , after). The same logic without the switch statement would look something like this in v10.
when HTTP_REQUEST {
session add uie 12345 "this is a session" 200
if { [HTTP::path] eq "/foo.html" } {
session lookup uie 12345
log local0. "done with all session requests"
} else {
log local0. "default path, no request made"
}
}
You'll notice that we're achieving the same goal but without causing the combination of commands that were discovered to be a problem, at least temporarily. This allows your iRules to continue giving you the functionality you need while this issue is resolved.
Next is an example of a persist lookup being executed from within a foreach loop, working in v9.x.
when HTTP_REQUEST {
foreach client $::myIPs {
set val [persist lookup uie "$client any pool"]
if {[string length $val] < 7 } {
persist add uie $client
}
}
}
Again, this combination of commands should be temporarily avoided in v10. Instead, the below example is a possible solution that not only achieves the same functionality, but shows off some of the features of the amazingly powerful new class command. This code isn't the simplest way to produce this result, but I wanted to take the opportunity to showcase the awesome new command and some of the things that it can do.
when HTTP_REQUEST {
set n [class size myIPs]
set id [class startsearch myIPs]
for {set x 0} {$x < $n} {incr x} {
set client [class nextelement -value myIPs $id]
set val [persist lookup uie $client]
if {[string length $val] < 7 } {
persist add uie $client
}
}
class donesearch myIPs $id
}
So there are a couple of examples of what we were seeing. I know that having to modify your code isn't always ideal, hopefully this has helped to clarify a couple of ways around the problem that was uncovered. The good part of this though, is that our amazing PD team is already completely on top of this and are already working towards getting this resolved in the very near future. I don't have an exact date for you, but I can assure you it's a top priority, and that I expect to see something very soon. Until then, hopefully this helps get you pointed in the right direction.
- hoolio
Cirrostratus
Hi Colin, - spark_86682Historic F5 Account
Is there a CR for this issue? (Edit: It looks like it's CR101506)
Are there plans to address this in a hotfix?
- Colin_Walker_12Historic F5 AccountThis has been fixed in v10.0.1.
- Sake_Blok
Nimbostratus
Posted By Colin Walker on 06/04/2009 9:33 AM
when CLIENTSSL_CLIENTCERT { set sslcert [SSL::cert 0] ... log local0. "[IP::client_addr], [X509::subject $sslcert] -> [IP::local_addr]" if { ... } { log local0. "...error..." reject } else { set ssl_cache_timeout [PROFILE::clientssl "cache_timeout"] session add ssl [SSL::sessionid] $sslcert $ssl_cache_timeout } } when HTTP_REQUEST { set sslcert [session lookup ssl [SSL::sessionid]] if { $sslcert ne "" } { HTTP::header remove X-Client-Cert HTTP::header insert X-Client-Cert [X509::whole $sslcert] } else { log local0. "No client certificate in the session table for [IP::client_addr] (SSLid: [SSL::sessionid])" } }
- hoolio
Cirrostratus
Hi Sake, - Rodney_80133
Nimbostratus
If I may barge in (I asked for Sake's help with this particular problem), this is the TCL error: - Rodney_80133
Nimbostratus
I just ran into something else, switching a profile seemed to work fine in 9.4.5 but it no longer seems to work in 10.1.0, llike in this example: - hoolio
Cirrostratus
Hi Rodney, - mrintzler
Nimbostratus
I am running into an iRule compatibility issue between 9.4.5/10.0.1HF3 and 10.1.0. I have an array that I am running through with a foreach loop. I'm trying to set two variables to the array index and element for each array row. However, both variables are being set to the index for the first run through, and then the element on the second iteration, etc. It worked fine under 9.4.5 and 10.0.1. Here's the applicable code from the iRule: - mrintzler
Nimbostratus
Here's the log output of the above iRule when run on the two different versions:
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