2
* (C) 2006-2007 by Pablo Neira Ayuso <pablo@netfilter.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
#include "conntrackd.h"
22
#include "us-conntrack.h"
30
static void refresher(struct alarm_block *a, void *data)
34
struct us_conntrack *u = data;
36
debug_ct(u->ct, "persistence update");
39
random() % CONFIG(refresh) + 1,
40
((random() % 5 + 1) * 200000) - 1);
42
net = BUILD_NETMSG(u->ct, NFCT_Q_UPDATE);
43
len = prepare_send_netmsg(STATE_SYNC(mcast_client), net);
44
mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len);
47
static void cache_alarm_add(struct us_conntrack *u, void *data)
49
struct alarm_block *alarm = data;
51
init_alarm(alarm, u, refresher);
53
random() % CONFIG(refresh) + 1,
54
((random() % 5 + 1) * 200000) - 1);
57
static void cache_alarm_update(struct us_conntrack *u, void *data)
59
struct alarm_block *alarm = data;
61
random() % CONFIG(refresh) + 1,
62
((random() % 5 + 1) * 200000) - 1);
65
static void cache_alarm_destroy(struct us_conntrack *u, void *data)
67
struct alarm_block *alarm = data;
71
static struct cache_extra cache_alarm_extra = {
72
.size = sizeof(struct alarm_block),
73
.add = cache_alarm_add,
74
.update = cache_alarm_update,
75
.destroy = cache_alarm_destroy
78
static int alarm_recv(const struct nethdr *net)
83
* Ignore error messages: Although this message type is not ever
84
* generated in alarm mode, we don't want to crash the daemon
85
* if someone nuts mixes ftfw and alarm.
91
* Multicast sequence tracking: we keep track of multicast messages
92
* although we don't do any explicit message recovery. So, why do
93
* we do sequence tracking? Just to let know the sysadmin.
95
* Let t be 1 < t < RefreshTime. To ensure consistency, conntrackd
96
* retransmit every t seconds a message with the state of a certain
97
* entry even if such entry did not change. This mechanism also
98
* provides passive resynchronization, in other words, there is
99
* no facility to request a full synchronization from new nodes that
100
* just joined the cluster, instead they just get resynchronized in
101
* RefreshTime seconds at worst case.
103
mcast_track_seq(net->seq, &exp_seq);
108
struct sync_mode sync_alarm = {
109
.internal_cache_flags = LIFETIME,
110
.external_cache_flags = TIMER | LIFETIME,
111
.internal_cache_extra = &cache_alarm_extra,