Forum Discussion
ichalis_37981
Apr 22, 2010Historic F5 Account
Automatic expiry of subtables
HI, In the example rule below, subtables are used to store information on a per-client basis, and once the TCP::close occurs, the subtable is manually deleted. What happens if the client disappears without closing the connection? In other words do you have to explicitly delete the table, or can you rely on the entries timing out automatically? Is the command: "table delete -subtable $tbl $key" required in every case, or if all the entries in the table expire on their own, does the ENTIRE subtable disappear from memory? I would like to create subtables per client IP and allow the entries to expire on their own, but am worried about memory filling up with hundreds of "empty" tables.. Any help would be much appreciated.. Evan.
when CLIENT_ACCEPTED {
set tbl "connlimit:[IP::client_addr]"
set key "[TCP::client_port]"
if { [table keys -subtable $tbl -count] > 100 } {
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
}
- spark_86682Historic F5 AccountTypically, if the client simply disappears, then the entry in the connection table will timeout, and CLIENT_CLOSED will fire. There are some rare instances where CLIENT_CLOSED will not fire, though. One of the features of the table command was to handle exactly this case. Even if CLIENT_CLOSED does not fire, the timer will get automatically canceled when the connection expires, and so the subtable entry will stop getting updated, and will also expire on its own. So in this case, the code in CLIENT_CLOSED could be viewed as simply an optimization, cleaning up the entry as soon as we know it isn't needed, and not waiting for it to timeout.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects