[conntrack-tools] src: add Nice clause to set the nice value

Pablo Neira netfilter-cvslog-bounces at lists.netfilter.org
Sun Feb 8 21:25:10 CET 2009


Gitweb:		http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=7f902c8419c891ec3ec83d40fb30afccb2a150c6
commit 7f902c8419c891ec3ec83d40fb30afccb2a150c6
Author:     Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Sun Feb 8 20:55:34 2009 +0100
Commit:     Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Sun Feb 8 20:55:34 2009 +0100

    src: add Nice clause to set the nice value
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
       via  7f902c8419c891ec3ec83d40fb30afccb2a150c6 (commit)
      from  d214500c0e5f06587cd2436bf88c93b399df5122 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7f902c8419c891ec3ec83d40fb30afccb2a150c6
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date:   Sun Feb 8 20:55:34 2009 +0100

    src: add Nice clause to set the nice value
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

-----------------------------------------------------------------------

 doc/stats/conntrackd.conf        |    8 ++++++++
 doc/sync/alarm/conntrackd.conf   |    8 ++++++++
 doc/sync/ftfw/conntrackd.conf    |    8 ++++++++
 doc/sync/notrack/conntrackd.conf |    8 ++++++++
 include/conntrackd.h             |    1 +
 src/main.c                       |    1 +
 src/read_config_lex.l            |    3 +++
 src/read_config_yy.y             |   11 +++++++++--
 8 files changed, 46 insertions(+), 2 deletions(-)
Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

diff --git a/doc/stats/conntrackd.conf b/doc/stats/conntrackd.conf
index 889d387..54e2322 100644
--- a/doc/stats/conntrackd.conf
+++ b/doc/stats/conntrackd.conf
@@ -3,6 +3,14 @@
 #
 General {
 	#
+	# Set the nice value of the daemon. This value goes from -20
+	# (most favorable scheduling) to 19 (least favorable). Using a
+	# negative value reduces the chances to lose state-change events.
+	# Default is 0. See man nice(1) for more information.
+	#
+	Nice -1
+
+	#
 	# Number of buckets in the caches: hash table
 	#
 	HashSize 8192
diff --git a/doc/sync/alarm/conntrackd.conf b/doc/sync/alarm/conntrackd.conf
index 5e44d0d..aa87541 100644
--- a/doc/sync/alarm/conntrackd.conf
+++ b/doc/sync/alarm/conntrackd.conf
@@ -135,6 +135,14 @@ Sync {
 #
 General {
 	#
+	# Set the nice value of the daemon, this value goes from -20
+	# (most favorable scheduling) to 19 (least favorable). Using a
+	# negative value reduces the chances to lose state-change events.
+	# Default is 0. See man nice(1) for more information.
+	#
+	Nice -1
+
+	#
 	# Number of buckets in the cache hashtable. The bigger it is,
 	# the closer it gets to O(1) at the cost of consuming more memory.
 	# Read some documents about tuning hashtables for further reference.
diff --git a/doc/sync/ftfw/conntrackd.conf b/doc/sync/ftfw/conntrackd.conf
index 92cd9d1..a3f42a2 100644
--- a/doc/sync/ftfw/conntrackd.conf
+++ b/doc/sync/ftfw/conntrackd.conf
@@ -144,6 +144,14 @@ Sync {
 #
 General {
 	#
+	# Set the nice value of the daemon, this value goes from -20
+	# (most favorable scheduling) to 19 (least favorable). Using a
+	# negative value reduces the chances to lose state-change events.
+	# Default is 0. See man nice(1) for more information.
+	#
+	Nice -1
+
+	#
 	# Number of buckets in the cache hashtable. The bigger it is,
 	# the closer it gets to O(1) at the cost of consuming more memory.
 	# Read some documents about tuning hashtables for further reference.
diff --git a/doc/sync/notrack/conntrackd.conf b/doc/sync/notrack/conntrackd.conf
index c64291b..755b08b 100644
--- a/doc/sync/notrack/conntrackd.conf
+++ b/doc/sync/notrack/conntrackd.conf
@@ -125,6 +125,14 @@ Sync {
 #
 General {
 	#
+	# Set the nice value of the daemon, this value goes from -20
+	# (most favorable scheduling) to 19 (least favorable). Using a
+	# negative value reduces the chances to lose state-change events.
+	# Default is 0. See man nice(1) for more information.
+	#
+	Nice -1
+
+	#
 	# Number of buckets in the cache hashtable. The bigger it is,
 	# the closer it gets to O(1) at the cost of consuming more memory.
 	# Read some documents about tuning hashtables for further reference.
diff --git a/include/conntrackd.h b/include/conntrackd.h
index 4051e94..2aaa6e6 100644
--- a/include/conntrackd.h
+++ b/include/conntrackd.h
@@ -73,6 +73,7 @@ struct ct_conf {
 	int mcast_default_link;
 	struct mcast_conf mcast[MCAST_LINKS_MAX];
 	struct local_conf local;	/* unix socket facilities */
+	int nice;
 	int limit;
 	int refresh;
 	int cache_timeout;		/* cache entries timeout */
diff --git a/src/main.c b/src/main.c
index c3271fe..8f75904 100644
--- a/src/main.c
+++ b/src/main.c
@@ -279,6 +279,7 @@ int main(int argc, char *argv[])
 
 	chdir("/");
 	close(STDIN_FILENO);
+	nice(CONFIG(nice));
 
 	/* Daemonize conntrackd */
 	if (type == DAEMON) {
diff --git a/src/read_config_lex.l b/src/read_config_lex.l
index 26c6124..a1830fd 100644
--- a/src/read_config_lex.l
+++ b/src/read_config_lex.l
@@ -35,6 +35,7 @@ nl		[\n\r]
 is_on		[o|O][n|N]
 is_off		[o|O][f|F][f|F]
 integer		[0-9]+
+signed_integer	[\-\+][0-9]+
 path		\/[^\"\n ]*
 ip4_cidr	\/[0-2]*[0-9]+
 ip4_end		[0-9]*[0-9]+
@@ -122,10 +123,12 @@ notrack		[N|n][O|o][T|t][R|r][A|a][C|c][K|k]
 "Default"			{ return T_DEFAULT; }
 "PollSecs"			{ return T_POLL_SECS; }
 "NetlinkOverrunResync"		{ return T_NETLINK_OVERRUN_RESYNC; }
+"Nice"				{ return T_NICE; }
 
 {is_on}			{ return T_ON; }
 {is_off}		{ return T_OFF; }
 {integer}		{ yylval.val = atoi(yytext); return T_NUMBER; }
+{signed_integer}	{ yylval.val = atoi(yytext); return T_SIGNED_NUMBER; }
 {ip4}			{ yylval.string = strdup(yytext); return T_IP; }
 {ip6}			{ yylval.string = strdup(yytext); return T_IP; }
 {path}			{ yylval.string = strdup(yytext); return T_PATH_VAL; }
diff --git a/src/read_config_yy.y b/src/read_config_yy.y
index 1bea865..b9a37f7 100644
--- a/src/read_config_yy.y
+++ b/src/read_config_yy.y
@@ -61,10 +61,11 @@ static void __max_mcast_dedicated_links_reached(void);
 %token T_MCAST_RCVBUFF T_MCAST_SNDBUFF T_NOTRACK T_POLL_SECS
 %token T_FILTER T_ADDRESS T_PROTOCOL T_STATE T_ACCEPT T_IGNORE
 %token T_FROM T_USERSPACE T_KERNELSPACE T_EVENT_ITER_LIMIT T_DEFAULT
-%token T_NETLINK_OVERRUN_RESYNC
+%token T_NETLINK_OVERRUN_RESYNC T_NICE
 
 %token <string> T_IP T_PATH_VAL
 %token <val> T_NUMBER
+%token <val> T_SIGNED_NUMBER
 %token <string> T_STRING
 
 %%
@@ -727,6 +728,7 @@ general_line: hashsize
 	    | poll_secs
 	    | filter
 	    | netlink_overrun_resync
+	    | nice
 	    ;
 
 netlink_buffer_size: T_BUFFER_SIZE T_NUMBER
@@ -752,7 +754,12 @@ netlink_overrun_resync : T_NETLINK_OVERRUN_RESYNC T_OFF
 netlink_overrun_resync : T_NETLINK_OVERRUN_RESYNC T_NUMBER
 {
 	conf.nl_overrun_resync = $2;
-}
+};
+
+nice : T_NICE T_SIGNED_NUMBER
+{
+	conf.nice = $2;
+};
 
 family : T_FAMILY T_STRING
 {



More information about the netfilter-cvslog mailing list