Skip to content

Commit

Permalink
Add a filter option to drop all cluster packets (valkey-io#1252)
Browse files Browse the repository at this point in the history
A minor debugging change that helped in the investigation of
valkey-io#1251. Basically there are
some edge cases where we want to fully isolate a note from receiving
packets, but can't suspend the process because we need it to continue
sending outbound traffic. So, added a filter for that.

Signed-off-by: Madelyn Olson <[email protected]>
  • Loading branch information
madolson authored and proost committed Nov 9, 2024
1 parent 5adef5c commit 46d2448
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,7 @@ int clusterIsValidPacket(clusterLink *link) {
return 0;
}

if (type == server.cluster_drop_packet_filter) {
if (type == server.cluster_drop_packet_filter || server.cluster_drop_packet_filter == -2) {
serverLog(LL_WARNING, "Dropping packet that matches debug drop filter");
return 0;
}
Expand Down Expand Up @@ -3070,7 +3070,8 @@ int clusterProcessPacket(clusterLink *link) {
if (!clusterIsValidPacket(link)) {
clusterMsg *hdr = (clusterMsg *)link->rcvbuf;
uint16_t type = ntohs(hdr->type);
if (server.debug_cluster_close_link_on_packet_drop && type == server.cluster_drop_packet_filter) {
if (server.debug_cluster_close_link_on_packet_drop &&
(type == server.cluster_drop_packet_filter || server.cluster_drop_packet_filter == -2)) {
freeClusterLink(link);
serverLog(LL_WARNING, "Closing link for matching packet type %hu", type);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void debugCommand(client *c) {
" Some fields of the default behavior may be time consuming to fetch,",
" and `fast` can be passed to avoid fetching them.",
"DROP-CLUSTER-PACKET-FILTER <packet-type>",
" Drop all packets that match the filtered type. Set to -1 allow all packets.",
" Drop all packets that match the filtered type. Set to -1 allow all packets or -2 to drop all packets.",
"CLOSE-CLUSTER-LINK-ON-PACKET-DROP <0|1>",
" This is valid only when DROP-CLUSTER-PACKET-FILTER is set to a valid packet type.",
" When set to 1, the cluster link is closed after dropping a packet based on the filter.",
Expand Down

0 comments on commit 46d2448

Please sign in to comment.