summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-04-14 10:43:16 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2009-04-14 10:43:16 +0200
commitdfb88dae65fbdc37d72483ddff23171ef4070dae (patch)
tree387294ba81c2847a2f713be54750da20fb5bade2 /src/main.c
parent549d78e74c1140b1a4dcd35e44e64d51a3c613e6 (diff)
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 <pablo@netfilter.org>
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 18 insertions, 1 deletions
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 <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sched.h>
#include <limits.h>
struct ct_general_state st;
@@ -296,6 +297,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) {