conntrackd: consolidate more code to use resync_send()
PATCH 1/2 conntrackd: consolidate more code to use resync_send()
These digest_msg() functions can use resync_send() as well.
While at it, bring back a call to kernel_resync() in notrack_local() which was lost in a previous commit.
--- src/sync-ftfw.c | 5 +---- src/sync-notrack.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 12 deletions(-)
src/sync-ftfw.c +1 -4
@@ -313,10 +313,7 @@ static int digest_msg(const struct nethdr *net) }else if (IS_RESYNC (net)) {dlog (LOG_NOTICE ,"resync requested by other node" ); -cache_iterate (STATE (mode)->internal->ct.data,NULL , - do_cache_to_tx); -cache_iterate (STATE (mode)->internal->exp.data,NULL , - do_cache_to_tx); +resync_send (do_cache_to_tx);return MSG_CTL ; }else if (IS_ALIVE (net))
src/sync-notrack.c +7 -8
@@ -107,7 +107,10 @@ static int notrack_local(int fd, int type, void *data)resync_req ();break ;case SEND_BULK : -resync_send (do_cache_to_tx); +if (CONFIG (sync).internal_cache_disable) +kernel_resync (); +else +resync_send (do_cache_to_tx);break ;default : ret =0 ;
@@ -124,14 +127,10 @@ static int digest_msg(const struct nethdr *net)if (IS_RESYNC (net)) {dlog (LOG_NOTICE ,"resync requested by other node" ); -if (CONFIG (sync).internal_cache_disable) { +if (CONFIG (sync).internal_cache_disable)kernel_resync (); - }else { -cache_iterate (STATE (mode)->internal->ct.data, -NULL , do_cache_to_tx); -cache_iterate (STATE (mode)->internal->exp.data, -NULL , do_cache_to_tx); - } +else +resync_send (do_cache_to_tx);return MSG_CTL ; }
PATCH 2/2 conntrackd: request resync at startup
If a node goes to live, ask the other for resync at startup. This has to be done usually by hand, but I guess is an operation common enough to add some bits to ease people life here.
--- conntrackd.conf.5 | 25 +++++++++++++++++++++---- include/conntrackd.h | 1 + include/resync.h | 1 + src/main.c | 2 ++ src/read_config_lex.l | 1 + src/read_config_yy.y | 14 +++++++++++++- src/resync.c | 8 ++++++++ 7 files changed, 47 insertions(+), 5 deletions(-)
conntrackd.conf.5 +21 -4
@@ -22,7 +22,7 @@ .\" <http://www.gnu.org/licenses/>. .\" %%%LICENSE_END .\" -.TH CONNTRACKD.CONF 5 "Oct 18, 2016" +.TH CONNTRACKD.CONF 5 "May 09, 2017" .SH NAME conntrackd.conf \- configuration file for conntrackd daemon
@@ -78,8 +78,8 @@ This mode is based on a reliable protocol that performs message tracking. Thus, the protocol can recover from message loss, re-ordering and corruption. In this synchronization mode you may configure \fBResendQueueSize\fP, -\fBCommitTimeout\fP, \fBPurgeTimeout\fP, \fBACKWindowSize\fP and -\fBDisableExternalCache\fP. +\fBCommitTimeout\fP, \fBPurgeTimeout\fP, \fBACKWindowSize\fP , +\fBDisableExternalCache\fP and \fBStartupResync\fP. .TP .BI "ResendQueueSize <value>"
@@ -146,6 +146,18 @@ enabling this option! By default, this clause is set off. +.TP +.BI "StartupResync <on|off>" +Order conntrackd to request a complete conntrack table resync against the other +node at startup. A single request will be made. + +This is useful to get in sync with another node which has been running while we +were down. + +Example: StartupResync on + +By default, this clause is set off. + .SS Mode ALARM This mode is spamming. It is based on a alarm-based protocol that periodically
@@ -185,7 +197,8 @@ ie. unreliable protocol. This protocol sends and receives the state information without performing any specific checking. In this synchronization mode you may configure \fBDisableInternalCache\fP, -\fBDisableExternalCache\fP, \fBCommitTimeout\fP and \fBPurgeTimeout\fP. +\fBDisableExternalCache\fP, \fBCommitTimeout\fP, \fBPurgeTimeout\fP and +\fBStartupResync\fP. .TP .BI "DisableInternalCache <on|off>"
@@ -206,6 +219,10 @@ Same as in \fBFTFW\fP mode. .BI "PurgeTimeout <seconds>" Same as in \fBFTFW\fP mode. +.TP +.BI "StartupResync <on|off>" +Same as in \fBFTFW\fP mode. + .SS MULTICAST This section indicates to \fBconntrackd(8)\fP to use multicast as transport
include/conntrackd.h +1 -0
@@ -111,6 +111,7 @@ struct ct_conf {int event_iterations_limit;int systemd;int running_mode; +int startup_resync;struct {int error_queue_length; } channelc;
include/resync.h +1 -0
@@ -3,5 +3,6 @@void resync_req (void );void resync_send (int (*do_cache_to_tx)(void *data1,void *data2)); +void resync_at_startup (void );#endif /*_RESYNC_H_ */
src/main.c +2 -0
@@ -21,6 +21,7 @@#include "log.h" #include "helper.h" #include "systemd.h" +#include "resync.h" #include <sys/types.h> #include <sys/stat.h>
@@ -431,6 +432,7 @@ int main(int argc, char *argv[])dlog (LOG_NOTICE ,"-- starting in console mode --" );sd_ct_init (); +resync_at_startup ();/* * run main process
src/read_config_lex.l +1 -0
@@ -136,6 +136,7 @@ notrack [N|n][O|o][T|t][R|r][A|a][C|c][K|k] "ExpectMax" { return T_HELPER_EXPECT_MAX; } "ExpectTimeout" { return T_HELPER_EXPECT_TIMEOUT; } "Systemd" { return T_SYSTEMD; } +"StartupResync" { return T_STARTUP_RESYNC; } {is_on} { return T_ON; } {is_off} { return T_OFF; }
src/read_config_yy.y +13 -1
@@ -81,7 +81,7 @@ enum { %token T_OPTIONS T_TCP_WINDOW_TRACKING T_EXPECT_SYNC %token T_HELPER T_HELPER_QUEUE_NUM T_HELPER_QUEUE_LEN T_HELPER_POLICY %token T_HELPER_EXPECT_TIMEOUT T_HELPER_EXPECT_MAX -%token T_SYSTEMD +%token T_SYSTEMD T_STARTUP_RESYNC %token <string> T_IP T_PATH_VAL %token <val> T_NUMBER
@@ -768,6 +768,7 @@ sync_mode_ftfw_line: resend_queue_size | purge | window_size | disable_external_cache + | startup_resync ; sync_mode_notrack_list:
@@ -777,6 +778,7 @@ sync_mode_notrack_line: timeout | purge | disable_internal_cache | disable_external_cache + | startup_resync ; disable_internal_cache: T_DISABLE_INTERNAL_CACHE T_ON
@@ -804,6 +806,16 @@ resend_queue_size: T_RESEND_QUEUE_SIZE T_NUMBER conf.resend_queue_size = $2; }; +startup_resync: T_STARTUP_RESYNC T_ON +{ + conf.startup_resync = 1; +}; + +startup_resync: T_STARTUP_RESYNC T_OFF +{ + conf.startup_resync = 0; +}; + window_size: T_WINDOWSIZE T_NUMBER { conf.window_size = $2;
src/resync.c +8 -0
@@ -38,3 +38,11 @@ void resync_send(int (*do_cache_to_tx)(void *data1, void *data2))cache_iterate (STATE (mode)->internal->exp.data,NULL , do_cache_to_tx); } + +void resync_at_startup (void ) +{ +if (CONFIG (startup_resync) ==0 ) +return ; + +resync_req (); +}
Pablo Neira Ayuso
maintainerRe: [conntrack-tools PATCH 2/2] conntrackd: request resync at startup
Quoted 3 lines · Arturo Borrero Gonzalez
If a node goes to live, ask the other for resync at startup. This has to be done usually by hand, but I guess is an operation common enough to add some bits to ease people life here.
Also applied, thanks.
Quoted 4 lines · Arturo Borrero Gonzalez
These
digest_msg()functions can useresync_send()as well.While at it, bring back a call to
kernel_resync()innotrack_local()which was lost in a previous commit.
Applied, thanks.