Skip to content

Commit

Permalink
[clusterer] Added enable_rerouting parameter
Browse files Browse the repository at this point in the history
 When "enable_rerouting" is set to 0, packet will never be rerouted via other nodes.
 This is useful for situations where network issues are unlikely (LAN) or when only
 two nodes are present.
  • Loading branch information
svanstone-resilient authored and bogdan-iancu committed Apr 18, 2024
1 parent fa61e9b commit 1e9d124
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
5 changes: 5 additions & 0 deletions modules/clusterer/clusterer.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern int node_timeout;
extern int ping_timeout;
extern int seed_fb_interval;
extern int sync_timeout;
extern int clusterer_enable_rerouting;

int dispatch_jobs = 1;

Expand Down Expand Up @@ -1076,6 +1077,10 @@ void bin_rcv_cl_extra_packets(bin_packet_t *packet, int packet_type,
lock_release(node->lock);

if (dest_id != current_id) {
if (clusterer_enable_rerouting == 0) {
LM_WARN("Received message for destination id [%d] but rerouting disabled\n", dest_id);
goto exit;
}
/* route the message */
bin_push_int(packet, cluster_id);
bin_push_int(packet, source_id);
Expand Down
2 changes: 2 additions & 0 deletions modules/clusterer/clusterer_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ int seed_fb_interval = DEFAULT_SEED_FB_INTERVAL;
int sync_timeout = DEFAULT_SYNC_TIMEOUT;
int current_id = -1;
int db_mode = 1;
int clusterer_enable_rerouting = 1;

str clusterer_db_url = {NULL, 0};
str db_table = str_init("clusterer");
Expand Down Expand Up @@ -171,6 +172,7 @@ static const param_export_t params[] = {
(void*)&shtag_modparam_func},
{"sync_packet_size", INT_PARAM, &sync_packet_size },
{"dispatch_jobs", INT_PARAM, &dispatch_jobs },
{"enable_rerouting", INT_PARAM, &clusterer_enable_rerouting },
{0, 0, 0}
};

Expand Down
23 changes: 23 additions & 0 deletions modules/clusterer/doc/clusterer_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,29 @@ modparam("clusterer", "description_col", "description")
<programlisting format="linespecific">
...
modparam("clusterer", "enable_stats", 0)
...
</programlisting>
</example>
</section>

<section id="param_enable_rerouting" xreflabel="enable_rerouting">
<title><varname>enable_rerouting</varname> (integer)</title>
<para>
If packets should be rerouted via another node if a direct route
to destination is unavailible. Disabling may improve stability in
two-node topologies.
Set it to zero to disable or to non-zero to enable it.
</para>
<para>
<emphasis>
Default value is <quote>1 (enabled)</quote>.
</emphasis>
</para>
<example>
<title>Set <varname>enable_rerouting</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("clusterer", "enable_rerouting", 0)
...
</programlisting>
</example>
Expand Down
21 changes: 16 additions & 5 deletions modules/clusterer/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
extern int ping_interval;
extern int node_timeout;
extern int ping_timeout;
extern int clusterer_enable_rerouting;

#define PING_REPLY_INTERVAL(_node) \
((_node)->last_pong.tv_sec*1000000 + (_node)->last_pong.tv_usec \
Expand Down Expand Up @@ -313,12 +314,16 @@ node_info_t *get_next_hop_2(node_info_t *dest)
{
node_info_t *n, *next_hop;
struct node_search_info *queue_front;
struct node_search_info *root, *curr;
struct neighbour *neigh;
struct node_search_info *root, *curr;
struct neighbour *neigh;

if (clusterer_enable_rerouting == 0) {
return NULL;
}

lock_get(dest->cluster->lock);
lock_get(dest->cluster->lock);

/* run BFS */
/* run BFS */
if (dest->cluster->top_version != dest->sp_top_version) {
lock_get(dest->lock);
dest->next_hop = NULL;
Expand Down Expand Up @@ -398,6 +403,10 @@ int get_next_hop(node_info_t *dest)
{
node_info_t *nhop;

if (clusterer_enable_rerouting == 0) {
return 0;
}

lock_get(dest->lock);

if (dest->link_state == LS_UP) {
Expand Down Expand Up @@ -909,7 +918,9 @@ int set_link_w_neigh(clusterer_link_state new_ls, node_info_t *neigh)
check_node_events(neigh, CLUSTER_NODE_UP);
lock_get(neigh->lock);
}
neigh->next_hop = neigh;
if (clusterer_enable_rerouting) {
neigh->next_hop = neigh;
}

}

Expand Down

0 comments on commit 1e9d124

Please sign in to comment.