Forum Discussion

bilsch_10068's avatar
bilsch_10068
Icon for Nimbostratus rankNimbostratus
Oct 26, 2010

Fix to http persistence cookie logger irule

Was working with the persistence cookie logger irule, its logging the wrong value for ports.

 

 

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

 

 

Original code

 

set myPortD [string trimleft [expr 0x[substr $myPortH 2 2]][expr 0x[substr $myPortH 0 2]] 0]

 


Should be
    set myPortD [string trimleft [expr 0x[substr $myPortH 2 2][substr $myPortH 0 2]] 0]
Per the docs https://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html , the 2-byte hex values are reversed, so should be re-ordered. However the value should be a single string, not 2 unique hex values.
( not sure if this is the best/right way to post this 😆 )

 

  • Hi Bilsch,

    Thanks for finding, fixing and pointing this out. Your interpretation looks correct to me:

    
    when RULE_INIT {
    
     From http://support.f5.com/kb/en-us/solutions/public/6000/900/sol6917.html
     For example, if the port of the destination server is 8080, the BIG-IP LTM encodes the port as follows:
     8080 = 0x1F90
     Reverse byte order = 0x901F
     0x901F = 36895
    
    set myPortE 36895
    set myPortH [format %x $myPortE]
    log local0. "\$myPortE: $myPortE, \$myPortH, $myPortH"
    
     Old, wrong way
    log local0. "Old: [expr 0x[substr $myPortH 2 2]][expr 0x[substr $myPortH 0 2]]"
    
     Updated, correct way
    log local0. "New: [expr 0x[substr $myPortH 2 2][substr $myPortH 0 2]]"
    
     Log output:
     : $myPortE: 36895, $myPortH, 901f
     : Old: 31144
     : New: 8080
    }
    

    Aaron