Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

irule subtable learning problem

hello,everyone: I am learning irule,Found this statement is not very clear, please help me explain it, thank you

when CLIENT_ACCEPTED {
    set tbl "connlimit:[IP::client_addr]"
    set key "[TCP::client_port]"

    if { [table keys -subtable $tbl -count] > 1000 } {
        event CLIENT_CLOSED disable
        reject
    } else {
        table set -subtable $tbl $key "ignored" 180
        set timer [after 60000 -periodic { table lookup -subtable $tbl $key }]
        //????
    }
}
when CLIENT_CLOSED {
    after cancel $timer
    //???
    table delete -subtable $tbl $key
}
0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hello Wang,

I'll try to break down each of the parts of the code that you have question marks next to.

        set timer [after 60000 -periodic { table lookup -subtable $tbl $key }]
        //????

This creates a timer for a command, telling it to repeat every 60000 milliseconds. The command that will be repeated every 60000 milliseconds is:

table lookup -subtable $tbl $key

This command checks the $tbl subtable (a subtable created at the beginning of the Irule that equals the source IP address). The value will be "ignore." Since it is being referenced every 60 seconds, and the default timeout for a table entry is 180 seconds, the cache is prevented from deleting the table value. This line is being used to create a pseudo keep-alive for that entry in the subtable by referencing it every 60000 milliseconds.

when CLIENT_CLOSED {
    after cancel $timer
    //???
    table delete -subtable $tbl $key

This event happens when the client closes a connection. "after cancel" is a command that stops a timer from running, in this case the timer

[after 60000 -periodic { table lookup -subtable $tbl $key }]

is stopped. The entry in the subtable is then deleted when the timer runs out.

Feel free to ask if you have any follow-up questions,

Austin

1