Forum Discussion

cerpika_14370's avatar
cerpika_14370
Icon for Nimbostratus rankNimbostratus
Sep 04, 2009

session add command behavior

Quick question for the iRules gurus. I am considering using the session add command in an iRule, which will help us with a unique requirement in a multihomed BIG-IP deployment. In this iRule the key will be the source IP address of the connection. This iRule will build the session table based upon the source IP and the lasthop MAC address.

 

 

when SERVER_DATA {

 

set session_key [IP::local_addr]

 

session add uie {$session_key any virtual} [LINK::nexthop] 800

 

 

 

In this scenario, users with the same source IP [IP::local_addr] may switch incoming routers and therefor have a new lasthop MAC address [LINK::nexthop]. So how will the table be affected?

 

 

Will the BIG-IP overwrite the old entry in the session table with the new record?

 

 

Thanks!

1 Reply

  • You can test this by running the iRule a few times where the same client IP will have multiple nexthop values and then logging the value of the session lookup command. I expect the existing key will be updated with the new value. Here is a simple iRule which demonstrates this:

     
     when HTTP_REQUEST { 
      
        session add uie key1 value1 
        session add uie key1 value2 
     log local0. "\[session lookup uie key1\]: [session lookup uie key1]" 
     } 
     

    Log output:

    : [session lookup uie key1]: value2

    Also, to allow for variable expansion (of $session_key) or of commands (like IP::client_addr), you should replace the curly braces in the session command with:

    session add uie [list [IP::client_addr] any virtual] [LINK::nexthop] 800

    Aaron