Skip to contentSkip to conversation

cthelper: Set up userspace helpers when daemon starts

PATCH New Pablo Neira Ayuso 1 participant 1 message May 27, 2021 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 cthelper: Set up userspace helpers when daemon starts

Add a new setting to allow conntrackd to autoconfigure the userspace helpers at startup.

---
 doc/helper/conntrackd.conf |  9 +++++--
 include/conntrackd.h       |  1 +
 src/cthelper.c             | 55 ++++++++++++++++++++++++++++++++++++++
 src/read_config_lex.l      |  1 +
 src/read_config_yy.y       | 13 ++++++++-
 5 files changed, 76 insertions(+), 3 deletions(-)
doc/helper/conntrackd.conf +7 -2
index 6ffe00863c88..0255c2c42a95 100644
@@ -3,11 +3,16 @@
 #
 
 Helper {
-	# Before this, you have to make sure you have registered the `ftp'
-	# user-space helper stub via:
+	#
+	# Set up the userspace helpers when the daemon is started. If unset,
+	# you have manually set up the user-space helper stub, e.g.
 	#
 	# nfct add helper ftp inet tcp
 	#
+	# Default: no (for backward compatibility reasons)
+	#
+	Setup yes
+
 	Type ftp inet tcp {
 		#
 		# Set NFQUEUE number you want to use to receive traffic from
include/conntrackd.h +1 -0
index fe9ec1854a7d..3e0d09585b26 100644
@@ -138,6 +138,7 @@ struct ct_conf {
 	} stats;
 	struct {
 		struct list_head list;
+		bool setup;
 	} cthelper;
 };
 
src/cthelper.c +55 -0

69 lines not on this page · raw message

src/read_config_lex.l +1 -0
index f1f4fe3f5b5d..7dc400a3a9b5 100644
@@ -141,6 +141,7 @@ notrack		[N|n][O|o][T|t][R|r][A|a][C|c][K|k]
 "ExpectTimeout"			{ return T_HELPER_EXPECT_TIMEOUT; }
 "Systemd"			{ return T_SYSTEMD; }
 "StartupResync"			{ return T_STARTUP_RESYNC; }
+"Setup"				{ return T_SETUP; }
 
 {is_true}		{ return T_ON; }
 {is_false}		{ return T_OFF; }
src/read_config_yy.y +12 -1
index b215a729b716..95845a19e768 100644
@@ -63,7 +63,7 @@ enum {
 
 %token T_IPV4_ADDR T_IPV4_IFACE T_PORT T_HASHSIZE T_HASHLIMIT T_MULTICAST
 %token T_PATH T_UNIX T_REFRESH T_IPV6_ADDR T_IPV6_IFACE
-%token T_BACKLOG T_GROUP T_IGNORE
+%token T_BACKLOG T_GROUP T_IGNORE T_SETUP
 %token T_LOG T_UDP T_ICMP T_IGMP T_VRRP T_TCP
 %token T_LOCK T_BUFFER_SIZE_MAX_GROWN T_EXPIRE T_TIMEOUT
 %token T_GENERAL T_SYNC T_STATS T_BUFFER_SIZE
@@ -1454,6 +1454,7 @@ helper_list:
 	    ;
 
 helper_line: helper_type
+	    | helper_setup
 	    ;
 
 helper_type: T_TYPE T_STRING T_STRING T_STRING '{' helper_type_list  '}'
@@ -1562,6 +1563,16 @@ helper_type: T_TYPE T_STRING T_STRING T_STRING '{' helper_type_list  '}'
 	list_add(&helper_inst->head, &CONFIG(cthelper).list);
 };
 
+helper_setup : T_SETUP T_ON
+{
+	CONFIG(cthelper).setup = true;
+};
+
+helper_setup : T_SETUP T_OFF
+{
+	CONFIG(cthelper).setup = false;
+};
+
 helper_type_list:
 		| helper_type_list helper_type_line
 		;
Signature · 1 line
2.30.2