From dfb88dae65fbdc37d72483ddff23171ef4070dae Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Tue, 14 Apr 2009 10:43:16 +0200 Subject: conntrackd: change scheduler and priority via configuration file With this patch, you can change the scheduler policy and priority for conntrackd. Using a RT scheduler policy reduces the chances to hit ENOBUFS in Netlink. Signed-off-by: Pablo Neira Ayuso --- src/main.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 62ae599..7507ae5 100644 --- a/src/main.c +++ b/src/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #include struct ct_general_state st; @@ -295,6 +296,23 @@ int main(int argc, char *argv[]) } close(ret); + /* + * Setting process priority and scheduler + */ + nice(CONFIG(nice)); + + if (CONFIG(sched).type != SCHED_OTHER) { + struct sched_param schedparam = { + .sched_priority = CONFIG(sched).prio, + }; + + ret = sched_setscheduler(0, CONFIG(sched).type, &schedparam); + if (ret == -1) { + perror("sched"); + exit(EXIT_FAILURE); + } + } + /* * initialization process */ @@ -309,7 +327,6 @@ int main(int argc, char *argv[]) chdir("/"); close(STDIN_FILENO); - nice(CONFIG(nice)); /* Daemonize conntrackd */ if (type == DAEMON) { -- cgit v1.2.3