-
Notifications
You must be signed in to change notification settings - Fork 83
Session timer enhancement #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
bc6f421
75df0d1
73bc6ae
e9ca0ee
19ff3e4
3c7ab57
8c4e5b3
4685e69
9ffc57a
1bbb13a
6fdca2c
12ccf87
9e214c6
fb8369c
330d689
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #ifndef _JOOL_MOD_GLOBAL_TIMER_H | ||
| #define _JOOL_MOD_GLOBAL_TIMER_H | ||
|
|
||
| /** | ||
| * @file | ||
| * Timer used to trigger some of Jool's events. Always runs, as long as Jool | ||
| * is modprobed. At time of writing, this induces fragment expiration. | ||
| */ | ||
|
|
||
| int global_timer_init(void); | ||
| void global_timer_destroy(void); | ||
|
|
||
| #endif /* _JOOL_MOD_GLOBAL_TIMER_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #ifndef _JOOL_MOD_SESSION_TIMER_H | ||
| #define _JOOL_MOD_SESSION_TIMER_H | ||
|
|
||
| /** | ||
| * @file | ||
| * Timer used to trigger some of Jool's events. Always runs, as long as Jool | ||
| * is modprobed. At time of writing, this induces session expiration. | ||
| */ | ||
|
|
||
| int session_timer_init(void); | ||
| void session_timer_destroy(void); | ||
|
|
||
| #endif /* _JOOL_MOD_SESSION_TIMER_H */ |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #include "nat64/mod/stateful/session_timer.h" | ||
|
|
||
| #include "nat64/mod/common/xlator.h" | ||
| #include "nat64/mod/stateful/bib/db.h" | ||
|
|
||
| #define INITIAL_TIMER_PERIOD msecs_to_jiffies(2000) | ||
| #define MAX_SESSIONS_RM 1024 | ||
|
|
||
| static struct timer_list timer; | ||
|
|
||
| struct clean_params { | ||
| bool pend_rm; | ||
| u64 max_session_rm; | ||
| }; | ||
|
|
||
| static struct clean_params sess_params; | ||
|
|
||
| static int clean_state(struct xlator *jool, void *args) | ||
| { | ||
| struct clean_params *params = args; | ||
| bib_clean(jool->nat64.bib, jool->ns, ¶ms->max_session_rm, | ||
| ¶ms->pend_rm); | ||
| return 0; | ||
| } | ||
|
|
||
| static void update_params(unsigned long arg) | ||
| { | ||
| if (sess_params.pend_rm) { | ||
| timer.data = msecs_to_jiffies(jiffies_to_msecs(arg) / 2); | ||
| sess_params.max_session_rm <<= 1; | ||
| log_debug("+ Session timer NEW msecs and max_sess_rm: %u - %llu", | ||
| (jiffies_to_msecs(arg) / 2), sess_params.max_session_rm); | ||
| } else { | ||
| timer.data = INITIAL_TIMER_PERIOD; | ||
| sess_params.max_session_rm = MAX_SESSIONS_RM; | ||
| log_debug("+ Session timer RESET msecs and max_sess_rm: %u - %llu", | ||
| jiffies_to_msecs(INITIAL_TIMER_PERIOD), | ||
| sess_params.max_session_rm); | ||
| } | ||
| sess_params.pend_rm = 0; | ||
| } | ||
|
|
||
| static void timer_function(unsigned long arg) | ||
| { | ||
| xlator_foreach(clean_state, &sess_params); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice: This is the line that causes the timer (which is global) to be run on each translator instance.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has been removed. |
||
| update_params(arg); | ||
| mod_timer(&timer, jiffies + timer.data); | ||
| } | ||
|
|
||
| /** | ||
| * This function should be always called *after* other init()s. | ||
| */ | ||
| int session_timer_init(void) | ||
| { | ||
| init_timer(&timer); | ||
| timer.function = timer_function; | ||
| timer.expires = 0; | ||
| timer.data = 0; | ||
| sess_params.pend_rm = 0; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really a bug by any means, but notice that the kernel API declares boolean identifiers which Jool can access from anywhere, so you can make
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, now the boolean labels are used. |
||
| sess_params.max_session_rm = MAX_SESSIONS_RM; | ||
| mod_timer(&timer, jiffies + INITIAL_TIMER_PERIOD); | ||
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * This function should be always called *before* other destroy()s. | ||
| */ | ||
| void session_timer_destroy(void) | ||
| { | ||
| del_timer_sync(&timer); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something that you might have understandably missed while reading the documentation is that a kernel can have multiple Jool instances, each of them will have a distinct BIB/session database, and each of these databases will have a separate spinlock.
If
sess_paramsis a global variable, then all the instances will share the same "session parameters", and that means that, if one translator faces stress, it will affect the session removal limit of the other translators as well. This is not what we want, because a laggy spinlock only affects its own translator.I believe that the session parameters should belong to the
bib_tablestructure.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the parameters and the timers belong to the
bib_tablestructure.