Forum Discussion

Nicolas_Menant's avatar
Mar 31, 2008

Session command and any virtual ...

Hi,

 

 

i faced an issue when trying to share session data between VS:

 

 

here was my code:

 

 


when HTTP_REQUEST {
if {[session lookup uie {[IP::client_addr] any virtual}]  eq ""} {
log local0. "no session data found"
session add uie {[IP::client_addr] any virtual} "1" 1800 
} else {
log local0. "session data found "
}
}

 

 

Then if i look at my persistence record i can see that my persistence value is [IP::client_addr] -_-'

 

 

 

 

 

I did several manipulation and saw that by doing it through a variable it would work and without the {}

 


when HTTP_REQUEST {
set line "[IP::client_addr] any virtual"
if {[session lookup uie $line]  eq ""} {
log local0. "no session data found"
session add uie $line "1" 1800 
} else {
log local0. "session data found "
}
}

 

 

Is it some kind of issue ?

 

 

Thanks for your help!

 

 

I saw this behavior in v9.4.3 and v9.4.4

 

7 Replies

  • Out of curiosity i tried this iRule:

    
    when HTTP_REQUEST {
    set line "[IP::client_addr] any virtual"
    if {[persist lookup uie {[IP::client_addr] any virtual}]  eq ""} {
    log local0. "no session data found"
    persist add uie {[IP::client_addr] any virtual} 1800 
    } else {
    log local0. "session data found "
    }
    }

    and it works, so here the syntax is fine, it doesn't work only for the session command
  • Hi

     

     

    so should we use command "persist" instead of "session" if we want to store value for sharing between two VS?

     

     

    - rk
  • No mandatory since my workaround works but i think it may be better to wait for an answer from Devcentral.

     

     

    I opened a support case anyway i'll keep you updated.

     

     

  • Hi,

     

     

    it seems to be an expected behavior ...

     

     

    Here is the response coming from support:

     

     

    The session command expects all of the data and associated "any virtual" commands to be a single argument; in other words, a list.

     

     

    The documentation uses the most obvious and straight forward way of creating a list, which is to use curly braces ( {} ). However, Tcl deliberately does not expand variables inside curly braces, so the session command as it is written does not add the IP address as the key.

     

     

    See http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=120 for additional details on TCL and braces..

     

     

    There are two ways to make this work. The first is to use the "list" command to create the list:

     

     

    set slist [list [IP::client_addr] any virtual] session lookup uie $slist

     

     

    The second way is to use a string and let Tcl promote it to a list. This is what you are doing when you set the variable.

     

     

    session lookup uie "[IP::client_addr] any virtual"

     

     

     

    HTH
  • Lee_Orrick_5554's avatar
    Lee_Orrick_5554
    Historic F5 Account
    This also applies to the persist command.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/persist.html

     

     

    In the comments section of that link, fancisfcm calls out the same solution.

     

     

    "francisfcm writes:

     

     

    To allow variable substituition for in = { [any virtual|service|pool] [pool ] }, double quotes should be used instead of braces."