Skip to content

Commit 1252fd6

Browse files
madolsonenjoy-binbin
authored andcommitted
Add a filter option to drop all cluster packets (valkey-io#1252)
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]>
1 parent 0ef3dc3 commit 1252fd6

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/cluster_legacy.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3016,7 +3016,7 @@ int clusterIsValidPacket(clusterLink *link) {
30163016
return 0;
30173017
}
30183018

3019-
if (type == server.cluster_drop_packet_filter) {
3019+
if (type == server.cluster_drop_packet_filter || server.cluster_drop_packet_filter == -2) {
30203020
serverLog(LL_WARNING, "Dropping packet that matches debug drop filter");
30213021
return 0;
30223022
}
@@ -3105,7 +3105,8 @@ int clusterProcessPacket(clusterLink *link) {
31053105
if (!clusterIsValidPacket(link)) {
31063106
clusterMsg *hdr = (clusterMsg *)link->rcvbuf;
31073107
uint16_t type = ntohs(hdr->type);
3108-
if (server.debug_cluster_close_link_on_packet_drop && type == server.cluster_drop_packet_filter) {
3108+
if (server.debug_cluster_close_link_on_packet_drop &&
3109+
(type == server.cluster_drop_packet_filter || server.cluster_drop_packet_filter == -2)) {
31093110
freeClusterLink(link);
31103111
serverLog(LL_WARNING, "Closing link for matching packet type %hu", type);
31113112
return 0;

src/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ void debugCommand(client *c) {
431431
" Some fields of the default behavior may be time consuming to fetch,",
432432
" and `fast` can be passed to avoid fetching them.",
433433
"DROP-CLUSTER-PACKET-FILTER <packet-type>",
434-
" Drop all packets that match the filtered type. Set to -1 allow all packets.",
434+
" Drop all packets that match the filtered type. Set to -1 allow all packets or -2 to drop all packets.",
435435
"CLOSE-CLUSTER-LINK-ON-PACKET-DROP <0|1>",
436436
" This is valid only when DROP-CLUSTER-PACKET-FILTER is set to a valid packet type.",
437437
" When set to 1, the cluster link is closed after dropping a packet based on the filter.",

0 commit comments

Comments
 (0)