From: Christopher Faulet Date: Thu, 25 Apr 2024 07:43:16 +0000 (+0200) Subject: DEV: flags/peers: Decode PEER and PEERS flags X-Git-Tag: v3.0-dev9~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5df54f4796b2e2e69bc294c12b05756107a5d498;p=thirdparty%2Fhaproxy.git DEV: flags/peers: Decode PEER and PEERS flags Decode peer and peers flags via peer_show_flags() and peers_show_flags() functions. --- diff --git a/dev/flags/flags.c b/dev/flags/flags.c index 65af2379b0..8da485b430 100644 --- a/dev/flags/flags.c +++ b/dev/flags/flags.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -36,10 +37,13 @@ #define SHOW_AS_H1S 0x00010000 #define SHOW_AS_FCONN 0x00020000 #define SHOW_AS_FSTRM 0x00040000 +#define SHOW_AS_PEERS 0x00080000 +#define SHOW_AS_PEER 0x00100000 // command line names, must be in exact same order as the SHOW_AS_* flags above // so that show_as_words[i] matches flag 1U<flags = %s\n", (h1s_show_flags (buf, bsz, " | ", flags), buf)); if (show_as & SHOW_AS_FCONN) printf("fconn->flags = %s\n",(fconn_show_flags (buf, bsz, " | ", flags), buf)); if (show_as & SHOW_AS_FSTRM) printf("fstrm->flags = %s\n",(fstrm_show_flags (buf, bsz, " | ", flags), buf)); + if (show_as & SHOW_AS_PEERS) printf("peers->flags = %s\n",(peers_show_flags (buf, bsz, " | ", flags), buf)); + if (show_as & SHOW_AS_PEER) printf("peer->flags = %s\n", (peer_show_flags (buf, bsz, " | ", flags), buf)); } return 0; } diff --git a/include/haproxy/peers-t.h b/include/haproxy/peers-t.h index b11c6ac2ad..7ee339047a 100644 --- a/include/haproxy/peers-t.h +++ b/include/haproxy/peers-t.h @@ -74,6 +74,27 @@ enum peer_learn_state { #define PEERS_RESYNC_STATEMASK (PEERS_F_RESYNC_LOCAL_FINISHED|PEERS_F_RESYNC_REMOTE_FINISHED) #define PEERS_RESYNC_FINISHED (PEERS_F_RESYNC_LOCAL_FINISHED|PEERS_F_RESYNC_REMOTE_FINISHED) +/* This function is used to report flags in debugging tools. Please reflect + * below any single-bit flag addition above in the same order via the + * __APPEND_FLAG macro. The new end of the buffer is returned. + */ +static forceinline char *peers_show_flags(char *buf, size_t len, const char *delim, uint flg) +{ +#define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__) + /* prologue */ + _(0); + /* flags */ + _(PEERS_F_RESYNC_LOCAL_FINISHED, _(PEERS_F_RESYNC_REMOTE_FINISHED, _(PEERS_F_RESYNC_ASSIGN, _(PEERS_F_DONOTSTOP, + _(PEERS_F_DBG_RESYNC_LOCALTIMEOUT, _(PEERS_F_DBG_RESYNC_REMOTETIMEOUT, + _(PEERS_F_DBG_RESYNC_LOCALABORT, _(PEERS_F_DBG_RESYNC_REMOTEABORT, + _(PEERS_F_DBG_RESYNC_LOCALFINISHED, _(PEERS_F_DBG_RESYNC_REMOTEFINISHED, + _(PEERS_F_DBG_RESYNC_LOCALPARTIAL, _(PEERS_F_DBG_RESYNC_REMOTEPARTIAL, + _(PEERS_F_DBG_RESYNC_LOCALASSIGN, _(PEERS_F_DBG_RESYNC_REMOTEABORT)))))))))))))); + /* epilogue */ + _(~0U); + return buf; +#undef _ +} /******************************/ /* Peer flags */ @@ -91,6 +112,26 @@ enum peer_learn_state { #define PEER_TEACH_FLAGS (PEER_F_TEACH_PROCESS|PEER_F_TEACH_FINISHED) +/* This function is used to report flags in debugging tools. Please reflect + * below any single-bit flag addition above in the same order via the + * __APPEND_FLAG macro. The new end of the buffer is returned. + */ +static forceinline char *peer_show_flags(char *buf, size_t len, const char *delim, uint flg) +{ +#define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__) + /* prologue */ + _(0); + /* flags */ + _(PEER_F_TEACH_PROCESS, _(PEER_F_TEACH_FINISHED, _(PEER_F_LOCAL_TEACH_COMPLETE, + _(PEER_F_LEARN_NOTUP2DATE, _(PEER_F_WAIT_SYNCTASK_ACK, + _(PEER_F_ALIVE, _(PEER_F_HEARTBEAT, _(PEER_F_DWNGRD, + _(PEER_F_DBG_RESYNC_REQUESTED))))))))); + /* epilogue */ + _(~0U); + return buf; +#undef _ +} + struct shared_table { struct stktable *table; /* stick table to sync */ int local_id;