Forum Discussion

adirz's avatar
adirz
Icon for Nimbostratus rankNimbostratus
Nov 27, 2019

Class match with starts_with - Data group matching order

Hello DevCentral,

I need your help today with very basic question which for some reason doesn't really makes senese for me.

I trying searched for such previously asked questions in the boards but couldn't find any.

 

I use a match class with starts_with operator to check the website url mathch against around 100 records of string based data groups key records - in order to determine the appropriate redirect to apply for this HTTP Requst - the value found inside the data group value.

 

Becasue of the starts_with operator I have a lot of situations where there are multiple keys inside the Datagroup that match the starts_with condition for the requsted URL.

 

For example I browse to: www.cnn.com/sports

 

inside my Datagroup I have both this records:

www.cnn.com -------> www.cnn.com/short

www.cnn.com/sports ------> www.cnn.com/long

 

in this case beacsue of the starts_with operator both these records match the requested HTTP URI.

I assume the F5 will chose in this case the first record showed inside the data group , this one:

"www.cnn.com -------> www.cnn.com/short"

 

But in practise after testing I see this is one who gets chosen is the most specfic one

"www.cnn.com/sports ------> www.cnn.com/long"

 

Meaning I get redirected to this final URL:

"www.cnn.com/long"

 

I'm not sure if I'm doing something wrong with my tests or if this is the accpted behavior , I couldn't find a clear answer for that.

I will appreciate your kind help with that,

Thanks in advance !

 

Kind regards,

 

Adir Z.

Bezeq International

 

  • It's "longest match". See https://clouddocs.f5.com/api/irules/class.html

    ---

    Note: When using the equals operator on IP classes, or when using the starts_with or ends_with operators, if multiple possible matches are found in the class, then the longest match is always chosen. This is not true when using the contains operator. See the example below for more details.

    ---

  • It's "longest match". See https://clouddocs.f5.com/api/irules/class.html

    ---

    Note: When using the equals operator on IP classes, or when using the starts_with or ends_with operators, if multiple possible matches are found in the class, then the longest match is always chosen. This is not true when using the contains operator. See the example below for more details.

    ---

  • adirz's avatar
    adirz
    Icon for Nimbostratus rankNimbostratus

    Hi Vijay_E,

    I can use "equals" instead , but the thing I trying to understand is the expected behavior with "starts_with" and multiple keys inside Data groups that all match.

    Does the Class match iterate througth all the keys inside the Datagroup and choose the longest / more exact match or does it just pick the first one it matches on?

     

    Of course I can't really change the order of Datagroups entries , F5 just orangize these according to ABC order, not matter which one I entered first.

     

     

  • Unfortunately, I am not sure how the DataGroup is parsed. This behavior may change over different code versions. I think the datagroup is re-arranged internally before it is parsed. When working with DataGroup, I think you should expect the ordering to change and try to have unique key-value pair.

  • adirz's avatar
    adirz
    Icon for Nimbostratus rankNimbostratus

    Hello Vijay_E,

    Thanks, I actually checked with two different code versions and it looks like it's behaving the , same the most specific match with starts_with , I understand what you're saying regarding the re-arranged internally DG order.

     

    It would very helpfull if there was a way to verify it.

    Those are unique key-value pair but some are most specific and some are more general.

     

    Using "equals" doesn't solve our issue entirely becasue we don't want to insert inside the Datagroup exact URLs - starts_with takes into account the begining of the URL , so if we have Long URLS like this

    "www.cnn.com/sports/liverpool/sundaygame/score"

    there are also being taked care of and treated with the same Datagroup record!

     

    If someone on F5 or anybody else has definite answer on that it would really help me understand.

    Thanks again,

    Adir

    Bezeq Int.

     

  • If you really want to find an answer, you can try and open up a case with F5.