For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Heisenberg_1452's avatar
Heisenberg_1452
Historic F5 Account
Mar 03, 2014

libraries and procs

Hello All,

 

I am new to iRules and have been doing a lot of reading on DevCentral. I see a couple of excellent examples of using libraries and procedures (proc). However, I am struggling to use them as I receiving errors when trying to save the iRule. Simple code in its own iRule -- not in an event:

 

rule library {
        proc foo { someInputVar } {
                Do some stuff here and then return a value
                return $bar
        }
}

Then I would call that from another iRule as such:

 

when CLIENT_ACCEPTED {
        set fooBar [call library::foo "bar"]
}

Seems simple and straight forward. However, I am experiencing a few issues: - When I am typing out the word "proc" in the iRules editor, the word disappears until I hit return, then is shows up in red highlight. I am taking that as a bad thing. - When I go to save, I am receiving an error:

 

Exception caught in LocalLB::urn:iControl:LocalLB/Rule::create() Exception: Common::OperationFailed primary_error_code : 17236305 (0x01070151) secondary_error_code : 0 error_string : 01070151:3: Rule [/Common/iRuleLibrary] error: /Common/iRuleLibrary:1: error: [undefined procedure: rule][rule library { proc isDst {foo} { return 1 } }]

 

This is patterned after an example I saw in DevCentral. Could be I need to set up something ahead of time. This is 11.4.1.

 

Any ideas?

 

Cheers in advance!

 

2 Replies

  • Two things:

    1. The red and disappearing "proc" in the iRule editor is an anomalous behavior. I imagine it's a relic of the iRule editor thinking Proc isn't supported.

    2. Your iRule shouldn't start with "rule library". That's how it's described in the config and is created when you create the iRule.

    An iRule named "library":

    proc foo { someInputVar } {
        return $someInputVar
    }
    

    Test iRule:

    when RULE_INIT {
        set foobar [call library::foo "test1234"]
        log local0. $foobar
    }
    
  • Heisenberg_1452's avatar
    Heisenberg_1452
    Historic F5 Account

    Feel somewhat dumb, but if I recall the example, it had {} after "rule library" so I thought it was required syntax.

     

    Anyway, cheers, really appreciate it.