Forum Discussion
zhanghr_101384
Nimbostratus
Oct 22, 2009Global variables shared across virtual servers and irle scripts?
It seems that all global variables defined in RULE_INIT event are shared across different irule scripts, even if they are deployed on different virtual servers.
I have created one irule...
hoolio
Cirrostratus
Oct 22, 2009This is expected. From a past post:
http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=25222&ptarget=25227
Any variable declared in RULE_INIT is global. If you declare a variable using the global command or with two colons in front (set ::my_global_var 1), it will also be global. Global variables are accessible across all connections on any VIP. Local variables are accessible only on the current TCP connection pair (client - VIP and LTM - pool member).
If you reference a global variable in two different rules on the same or different VIPs, the variable is shared between the two connections and can be trampled. The second link below has details on one option for variable names.
Variable Scope & Lifetime
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=18430
Multiple irules using same local variable name
http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&postid=23503&ptarget=23582
Besides making global variable names fully qualified, can someone recommend any other ways to avoid such conflicts?
You'll need to come up with some scheme to ensure that your iRule's global variables are unique. Maybe you can come up with a naming convention within your company that does this. There isn't a simple technical solution for this.
Aaron
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
