Forum Discussion

Ganesh_Ramamoor's avatar
Ganesh_Ramamoor
Icon for Nimbostratus rankNimbostratus
Nov 01, 2005

UDP iRule question

If I want to have an iRule for UDP data that will distribute based on a string that is in the first 50 bytes, this simple iRule should do it right?

 

 

when CLIENT_ACCEPTED { UDP::collect 50 }

 

 

when CLIENT_DATA {

 

if { [UDP::payload 50] contains "xyz" } {

 

pool server_1

 

} else {

 

pool server_2

 

}

 

}

 

 

And when does the CLIENT_ACCEPTED get invoked for an UDP iRule? Does the client have to use the UDP connect first before sending data for the CLIENT_ACCEPTED to get invoked?

 

 

Thanks

 

 

 

 

  • Oh, on further search and trying out the iRule, I see that UDP::collect is not defined.

     

     

    So I can either have:

     

     

    when CLIENT_DATA {

     

    if { [UDP::payload 50] contains "XYZ" } {

     

    pool xyz_servers

     

    } else {

     

    pool web_servers

     

    }

     

    }

     

     

    or

     

     

    when CLIENT_ACCEPTED {

     

    if { [UDP::payload 50] contains "XYZ" } {

     

    pool xyz_servers

     

    } else {

     

    pool web_servers

     

    }

     

    }

     

     

    So, the question is when is CLIENT_ACCEPTED triggered for a UDP client? I suppose CLIENT_DATA is triggered whenever DATA is sent.

     

     

    Thanks in advance.

     

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    For UDP (and only UDP), the CLIENT_ACCEPTED event is fired on the first UDP datagram received. The CLIENT_DATA event is automatically fired for each UDP datagram received. You don't need to issue a UDP::collect (and hence it doesn't exist).

     

  • Hi,

     

     

    I'm getting errors when trying to use UDP::payload inside SERVER_CONNECTED.

     

    I've got the following error :

     

    --

     

    Nov 2 12:00:40 tmm tmm[26896]: 01220001:3: TCL error: Rule rad_p2 - More data required (line 1) invoked from within "{UDP::payload}"

     

    --

     

     

    This is the code part where the error happens :

     

     

     

    when SERVER_CONNECTED {

     

    if {[UDP::remote_port] eq 1813} {

     

    log local0. "rulerule sss -- [LB::server addr] ";

     

    set ip1 0; set ip2 0; set ip3 0; set ip4 0;

     

    binary scan [{UDP::payload}] c* str;

     

    ...

     

     

    Does anyone know why this is happening, I noticed already that it is working in CLIENT_ACCEPTED.. but then I don't know to which node the data will go.. And that is also something that I need to know.

     

     

    Thanks,

     

    Jeroen
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    I have two comments.

     

     

    First, UDP::payload doesn't make sense in the SERVER_CONNECTED event. At this point, there is no payload. You need to use UDP::payload either in CLIENT_DATA or SERVER_DATA. If there is data from the UDP payload that you want to use in a later event, like SERVER_CONNECTED, then you will need to parse it into a variable and use the variable in the other event.

     

     

    Second, I'm not sure why you have extra curly braces {} around the UDP::payload command. You should simply use: [UDP::payload] to get the contents.