Forum Discussion

Craig_Jackson_2's avatar
Craig_Jackson_2
Icon for Nimbostratus rankNimbostratus
Nov 11, 2008

Parameters to iRules?

What's the best way to pass parameters to iRules?

 

 

I'm thinking of an iRule which will have a couple of parameters -- integer values which will control behavior. I'd like to figure out the best way to manage these.

 

 

I've seen a lot of iRules set such parameters as global variables in a RULE_INIT handler. However, if this method is used, tuning the parameters requires modifying the program. This doesn't seem like good practice.

 

 

I'm thinking of putting the parameters in a string data group. The iRule would look these up to determine the current policy.

 

 

My questions are:

 

 

- Will this work? Is a data group consulted dynamically, or will the iRule need to be recompiled anyway every time the data group changes?

 

 

- Is this a good way to do this? Will using the data group add an enormous amount of overhead?

 

 

- Has anybody else tried this, or any other method other than hard-coding the values in the iRule?

 

 

Craig

1 Reply

  • Hi Craig,

     

     

    As you suggest, you can either configure a global parameter in RULE_INIT (or in any event of any iRule) or you can use a datagroup (called a class in the bigip.conf). I don't think there is a significant difference between referencing a global parameter compared with referencing a class. You could test this using timing or by looping a few hundred or thousand references and comparing the times.

     

     

    A reference to either object is checked on every attempt--there isn't any caching. Generally, I've suggested our clients use a global variable if it's something the administrator won't need to modify on a regular basis. If it's something an end user would need to view or change regularly a datagroup is probably easier. Modifying a global variable within the iRule requires reloading the entire rule, whereas modifying a datagroup doesn't.

     

     

    Aaron